Skip to content

Commit

Permalink
Fixed #152 AQL: Incorrect query validation when a service is used as …
Browse files Browse the repository at this point in the history
…a collector and then normally.
  • Loading branch information
ylussaud committed Apr 11, 2024
1 parent c84f0c6 commit 0b59c70
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public Set<IType> getType(IReadOnlyQueryEnvironment queryEnvironment) {
returnTypes = computeType(queryEnvironment);
}

return returnTypes;
return new LinkedHashSet<>(returnTypes);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2389,6 +2389,25 @@ public void allInstancesSetTest() {
assertEquals(0, validationResult.getMessages(((Call)ast).getArguments().get(0)).size());
}

@Test
public void bug152() {
final IValidationResult validationResult = engine.validate(
"Sequence{'1','2'}.toInteger()->first() > '1'.toInteger()", variableTypes);
final Expression ast = validationResult.getAstResult().getAst();
final Set<IType> possibleTypes = validationResult.getPossibleTypes(ast);

assertEquals(1, possibleTypes.size());
final Iterator<IType> it = possibleTypes.iterator();
IType possibleType = it.next();
assertTrue(possibleType instanceof ClassType);
assertEquals(Boolean.class, possibleType.getType());

assertEquals(0, validationResult.getMessages().size());

assertEquals(0, validationResult.getMessages(ast).size());
assertEquals(0, validationResult.getMessages(((Call)ast).getArguments().get(0)).size());
}

/**
* Asserts the given {@link IValidationMessage} against expected values.
*
Expand Down

0 comments on commit 0b59c70

Please sign in to comment.