use of org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList in project kie-wb-common by kiegroup.
the class DecisionServiceParametersListWidgetTest method testSetValue.
@Test
public void testSetValue() {
doNothing().when(widget).refresh();
final DecisionServiceParametersList value = mock(DecisionServiceParametersList.class);
widget.setValue(value, false);
verify(widget).refresh();
}
use of org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList in project kie-wb-common by kiegroup.
the class DecisionServiceParametersListWidgetTest method testGetCurrentItems.
@Test
public void testGetCurrentItems() {
final DecisionServiceParametersList value = mock(DecisionServiceParametersList.class);
final DecisionService decisionService = mock(DecisionService.class);
final String id1 = "id1";
final String id2 = "id2";
final String id3 = "id3";
final List<DMNElementReference> list = createListOfDMNElementReferenceWithIds(id1, id2, id3);
final List<InputData> unsortedInputs = Arrays.asList(createInputDataWithId(id2), createInputDataWithId(id3), createInputDataWithId(id1));
doReturn(value).when(widget).getValue();
when(value.getDecisionService()).thenReturn(decisionService);
when(decisionService.getInputData()).thenReturn(list);
final List<InputData> sorted = widget.getCurrentItems(unsortedInputs);
assertThat(sorted).extracting(inputData -> inputData.getId().getValue()).containsExactly(id1, id2, id3);
}
use of org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList in project kie-wb-common by kiegroup.
the class DecisionServiceParametersListWidgetTest method testGetNewItems.
@Test
public void testGetNewItems() {
final DecisionServiceParametersList value = mock(DecisionServiceParametersList.class);
final DecisionService decisionService = mock(DecisionService.class);
final String id1 = "id1";
final String id2 = "id2";
final String id3 = "id3";
final String newItem1 = "aaa";
final String newItem2 = "bbb";
final String newItem3 = "ccc";
final String newItem4 = "ddd";
final List<DMNElementReference> list = createListOfDMNElementReferenceWithIds(id1, id2, id3);
final List<InputData> currentItems = Arrays.asList(createInputDataWithId(id2), createInputDataWithId(id3), createInputDataWithId(id1));
final List<InputData> inputs = Arrays.asList(createInputDataWithId(newItem3), createInputDataWithId(newItem2), createInputDataWithId(newItem4), createInputDataWithId(newItem1));
doReturn(value).when(widget).getValue();
when(value.getDecisionService()).thenReturn(decisionService);
when(decisionService.getInputData()).thenReturn(list);
final List<InputData> result = widget.getNewItems(inputs, currentItems);
assertThat(result).extracting(inputData -> inputData.getId().getValue()).containsExactly(newItem1, newItem2, newItem3, newItem4);
}
use of org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList in project kie-wb-common by kiegroup.
the class DecisionServiceParametersListWidgetTest method testGetSortedInputs.
@Test
public void testGetSortedInputs() {
final DecisionServiceParametersList value = mock(DecisionServiceParametersList.class);
final DecisionService decisionService = mock(DecisionService.class);
final String id1 = "id1";
final String id2 = "id2";
final String id3 = "id3";
final String newId1 = "newId1";
final String newId2 = "newId2";
final List<DMNElementReference> list = createListOfDMNElementReferenceWithIds(id1, id2, id3);
final List<InputData> unsortedInputs = Arrays.asList(createInputDataWithId(id2), createInputDataWithId(id3), createInputDataWithId(newId2), createInputDataWithId(id1), createInputDataWithId(newId1));
doReturn(value).when(widget).getValue();
when(value.getDecisionService()).thenReturn(decisionService);
when(decisionService.getInputData()).thenReturn(list);
final List<InputData> sorted = widget.getSortedInputs(unsortedInputs);
assertThat(sorted).extracting(inputData -> inputData.getId().getValue()).containsExactly(id1, id2, id3, newId1, newId2);
}
use of org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList in project kie-wb-common by kiegroup.
the class DecisionServiceParametersListWidgetTest method testRefresh.
@Test
public void testRefresh() {
final DecisionServiceParametersList value = mock(DecisionServiceParametersList.class);
final DecisionService decisionService = mock(DecisionService.class);
final String contentDefinitionId = "contentId";
final Node node = mock(Node.class);
final Edge edge1 = mock(Edge.class);
final Child child1 = mock(Child.class);
final Node targetNode1 = mock(Node.class);
final Edge edge2 = mock(Edge.class);
final Child child2 = mock(Child.class);
final Node targetNode2 = mock(Node.class);
final Edge edge3 = mock(Edge.class);
final Child child3 = mock(Child.class);
final Node targetNode3 = mock(Node.class);
final Edge edgeNotChild = mock(Edge.class);
final Object notChild = mock(Object.class);
final List<Edge> edges = Arrays.asList(edge1, edge2, edge3, edgeNotChild);
final DRGElement drgElement1 = mock(DRGElement.class);
final DRGElement drgElement2 = mock(DRGElement.class);
final DRGElement drgElement3 = mock(DRGElement.class);
final Optional<DRGElement> targetDrg1 = Optional.of(drgElement1);
final Optional<DRGElement> targetDrg2 = Optional.of(drgElement2);
final Optional<DRGElement> targetDrg3 = Optional.of(drgElement3);
final List<InputData> sortedList = new ArrayList<>();
when(decisionService.getContentDefinitionId()).thenReturn(contentDefinitionId);
when(value.getDecisionService()).thenReturn(decisionService);
when(edge1.getContent()).thenReturn(child1);
when(edge1.getTargetNode()).thenReturn(targetNode1);
when(edge2.getContent()).thenReturn(child2);
when(edge2.getTargetNode()).thenReturn(targetNode2);
when(edge3.getContent()).thenReturn(child3);
when(edge3.getTargetNode()).thenReturn(targetNode3);
when(edgeNotChild.getContent()).thenReturn(notChild);
when(node.getOutEdges()).thenReturn(edges);
doNothing().when(widget).clear();
doNothing().when(widget).loadGroupsElements();
doNothing().when(widget).loadInputsParameters(anyList());
doNothing().when(widget).loadDecisionsFromNode(any(), any());
doNothing().when(widget).loadInputsFromNode(any(), any());
doNothing().when(widget).loadInputsFromOthersDiagrams(anyList(), any(Node.class));
doReturn(value).when(widget).getValue();
doReturn(node).when(widget).getNode(contentDefinitionId);
doReturn(targetDrg1).when(widget).getTargetDRGElement(edge1);
doReturn(targetDrg2).when(widget).getTargetDRGElement(edge2);
doReturn(targetDrg3).when(widget).getTargetDRGElement(edge3);
doReturn(Optional.empty()).when(widget).getTargetDRGElement(edgeNotChild);
doReturn(sortedList).when(widget).getSortedInputs(anyList());
widget.refresh();
verify(widget).loadDecisionsFromNode(node, targetNode1);
verify(widget).loadDecisionsFromNode(node, targetNode2);
verify(widget).loadDecisionsFromNode(node, targetNode3);
verify(widget).loadInputsFromNode(anyList(), eq(targetNode1));
verify(widget).loadInputsFromNode(anyList(), eq(targetNode2));
verify(widget).loadInputsFromNode(anyList(), eq(targetNode3));
verify(widget).loadInputsFromOthersDiagrams(anyList(), eq(targetNode1));
verify(widget).loadInputsFromOthersDiagrams(anyList(), eq(targetNode2));
verify(widget).loadInputsFromOthersDiagrams(anyList(), eq(targetNode3));
verify(widget).getSortedInputs(anyList());
verify(widget).loadInputsParameters(sortedList);
verify(widget).loadGroupsElements();
}
Aggregations