use of org.kie.workbench.common.dmn.client.widgets.codecompletion.feel.Variable in project kie-wb-common by kiegroup.
the class MonacoFEELSuggestionsTest method getSuggestions.
@Test
public void getSuggestions() {
final String expectedNodeName1 = "Decision-1";
final String expectedNodeName2 = "Decision-2";
final String expectedNodeName3 = "Decision-3";
final String expectedNodeName4 = "Decision-4";
final String expectedNodeName5 = "Decision-5";
final String expectedNodeName6 = "Decision-6";
final String expression = "1 +";
final Position position = new Position(1, 1);
final List<Candidate> expectedCandidates = new ArrayList<>();
final Stream<Node> nodeStream = Stream.of(makeDecisionNode(expectedNodeName1, BuiltInType.NUMBER), makeDecisionNode(expectedNodeName2, BuiltInType.STRING), makeDecisionNode(expectedNodeName3, BuiltInType.DATE), makeDecisionNode(expectedNodeName4, BuiltInType.BOOLEAN), makeDecisionNode(expectedNodeName5, BuiltInType.CONTEXT), makeDecisionNode(expectedNodeName6, null));
when(dmnGraphUtils.getNodeStream()).thenReturn(nodeStream);
when(feelLanguageService.getCandidates(any(), any(), any())).thenReturn(expectedCandidates);
final List<Candidate> actualSuggestions = monacoFEELSuggestions.getCandidates(expression, position);
verify(feelLanguageService).getCandidates(eq(expression), variablesArgumentCaptor.capture(), eq(position));
final List<Variable> actualVariables = variablesArgumentCaptor.getValue();
assertSame(expectedCandidates, actualSuggestions);
assertEquals(6, actualVariables.size());
assertEquals(expectedNodeName1, actualVariables.get(0).getName());
assertEquals(expectedNodeName2, actualVariables.get(1).getName());
assertEquals(expectedNodeName3, actualVariables.get(2).getName());
assertEquals(expectedNodeName4, actualVariables.get(3).getName());
assertEquals(expectedNodeName5, actualVariables.get(4).getName());
assertEquals(expectedNodeName6, actualVariables.get(5).getName());
assertEquals(org.kie.dmn.feel.lang.types.BuiltInType.NUMBER, actualVariables.get(0).getType());
assertEquals(org.kie.dmn.feel.lang.types.BuiltInType.STRING, actualVariables.get(1).getType());
assertEquals(org.kie.dmn.feel.lang.types.BuiltInType.DATE, actualVariables.get(2).getType());
assertEquals(org.kie.dmn.feel.lang.types.BuiltInType.BOOLEAN, actualVariables.get(3).getType());
assertEquals(org.kie.dmn.feel.lang.types.BuiltInType.CONTEXT, actualVariables.get(4).getType());
assertEquals(org.kie.dmn.feel.lang.types.BuiltInType.UNKNOWN, actualVariables.get(5).getType());
}
Aggregations