use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DMNDiagramsSessionTest method createNodeWithContentDefinitionId.
private Node createNodeWithContentDefinitionId(final String contentDefinitionId) {
final Node node = mock(Node.class);
final Definition definition = mock(Definition.class);
final DRGElement drgElement = mock(DRGElement.class);
when(drgElement.getContentDefinitionId()).thenReturn(contentDefinitionId);
when(definition.getDefinition()).thenReturn(drgElement);
when(node.getContent()).thenReturn(definition);
return node;
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DecisionServiceParametersListWidgetTest method testGetTargetDRGElement_WhenTargetIsNotDRGElement.
@Test
public void testGetTargetDRGElement_WhenTargetIsNotDRGElement() {
final Edge edge = mock(Edge.class);
final Node targetNode = mock(Node.class);
final View targetNodeView = mock(View.class);
final Object obj = mock(Object.class);
when(edge.getTargetNode()).thenReturn(targetNode);
when(targetNode.getContent()).thenReturn(targetNodeView);
when(targetNodeView.getDefinition()).thenReturn(obj);
final Optional<DRGElement> actual = widget.getTargetDRGElement(edge);
assertFalse(actual.isPresent());
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement 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();
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DecisionServiceParametersListWidgetTest method testGetSourceNodeInputData_WhenDoesNotHaveInputData.
@Test
public void testGetSourceNodeInputData_WhenDoesNotHaveInputData() {
final Edge edge = mock(Edge.class);
final Node sourceNode = mock(Node.class);
final View view = mock(View.class);
final DRGElement anotherDrgElement = mock(DRGElement.class);
when(view.getDefinition()).thenReturn(anotherDrgElement);
when(sourceNode.getContent()).thenReturn(view);
when(edge.getSourceNode()).thenReturn(sourceNode);
final Optional<InputData> actualInputData = widget.getSourceNodeInputData(edge);
assertFalse(actualInputData.isPresent());
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DMNIncludedNodeFactoryTest method testCreateName.
@Test
public void testCreateName() {
final DMNIncludedNodeFactory factory = new DMNIncludedNodeFactory();
final DRGElement drgElement = mock(DRGElement.class);
final String theName = "the name";
final Name name = new Name(theName);
final String modelName = "modelName";
when(drgElement.getName()).thenReturn(name);
final Name createdName = factory.createName(drgElement, modelName);
assertEquals(modelName + "." + theName, createdName.getValue());
}
Aggregations