Search in sources :

Example 46 with DRGElement

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;
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement)

Example 47 with DRGElement

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());
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Edge(org.kie.workbench.common.stunner.core.graph.Edge) View(org.kie.workbench.common.stunner.core.graph.content.view.View) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 48 with DRGElement

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();
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) DecisionServiceParametersList(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 49 with DRGElement

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());
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Edge(org.kie.workbench.common.stunner.core.graph.Edge) View(org.kie.workbench.common.stunner.core.graph.content.view.View) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 50 with DRGElement

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());
}
Also used : DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Aggregations

DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)72 Test (org.junit.Test)45 Node (org.kie.workbench.common.stunner.core.graph.Node)27 ArrayList (java.util.ArrayList)25 Edge (org.kie.workbench.common.stunner.core.graph.Edge)17 View (org.kie.workbench.common.stunner.core.graph.content.view.View)17 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)16 List (java.util.List)15 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)15 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)15 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)15 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)14 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)13 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)10 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)9 Import (org.kie.workbench.common.dmn.api.definition.model.Import)9 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)8 KnowledgeRequirement (org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement)7 JSITDefinitions (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)7 Optional (java.util.Optional)6