Search in sources :

Example 91 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class DecisionComponentsTest method makeDecisionComponent.

private DecisionComponent makeDecisionComponent(final String name, final String drgElementId, final String fileName, final boolean imported) {
    final Decision decision = new Decision();
    decision.setName(new Name(name));
    decision.setId(new Id(drgElementId));
    return new DecisionComponent(fileName, decision, imported);
}
Also used : Id(org.kie.workbench.common.dmn.api.property.dmn.Id) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 92 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class BoxedExpressionHelperTest method testGetHasExpression.

@Test
public void testGetHasExpression() {
    final View content = mock(View.class);
    final Decision expected = mock(Decision.class);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(expected);
    final HasExpression actual = helper.getHasExpression(node);
    assertEquals(expected, actual);
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 93 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class BoxedExpressionHelperTest method testGetOptionalHasExpressionWhenNodeIsDecision.

@Test
public void testGetOptionalHasExpressionWhenNodeIsDecision() {
    final View content = mock(View.class);
    final Decision expectedHasExpression = mock(Decision.class);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(expectedHasExpression);
    final Optional<HasExpression> actualHasExpression = helper.getOptionalHasExpression(node);
    assertTrue(actualHasExpression.isPresent());
    assertEquals(expectedHasExpression, actualHasExpression.get());
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 94 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class BoxedExpressionHelperTest method testGetOptionalExpressionWhenIsNotPresent.

@Test
public void testGetOptionalExpressionWhenIsNotPresent() {
    final View content = mock(View.class);
    final Decision decision = mock(Decision.class);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(decision);
    when(decision.getExpression()).thenReturn(null);
    final Optional<Expression> optionalExpression = helper.getOptionalExpression(node);
    assertFalse(optionalExpression.isPresent());
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 95 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class DecisionNavigatorItemsProviderTest method testGetItems.

@Test
public void testGetItems() {
    final Diagram stunnerDiagram1 = mock(Diagram.class);
    final Diagram stunnerDiagram2 = mock(Diagram.class);
    final DMNDiagramElement dmnDiagramElement1 = mock(DMNDiagramElement.class);
    final DMNDiagramElement dmnDiagramElement2 = mock(DMNDiagramElement.class);
    final DMNDiagramTuple dmnDiagramTuple1 = new DMNDiagramTuple(stunnerDiagram1, dmnDiagramElement1);
    final DMNDiagramTuple dmnDiagramTuple2 = new DMNDiagramTuple(stunnerDiagram2, dmnDiagramElement2);
    final DecisionNavigatorItem decisionNavigatorItem1 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem2 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem3 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem4 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem5 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem6 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem7 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem8 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem9 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem10 = mock(DecisionNavigatorItem.class);
    final List<DMNDiagramTuple> diagramTuples = asList(dmnDiagramTuple1, dmnDiagramTuple2);
    final Node node1 = mockNode(new Decision());
    final Node node2 = mockNode(new InputData());
    final Node node3 = mockNode(new TextAnnotation());
    final Node node4 = mockNode(new BusinessKnowledgeModel());
    final Node node5 = mockNode(new KnowledgeSource());
    final Node node6 = mockNode(new TextAnnotation());
    final Stream<Node> stunnerNodes1 = Stream.of(node1, node2, node3);
    final Stream<Node> stunnerNodes2 = Stream.of(node4, node5, node6);
    when(dmnDiagramElement1.getName()).thenReturn(new Name("DRD"));
    when(dmnDiagramElement2.getName()).thenReturn(new Name("DRG"));
    when(dmnDiagramsSession.getDMNDiagrams()).thenReturn(diagramTuples);
    when(itemFactory.makeRoot(dmnDiagramTuple1)).thenReturn(decisionNavigatorItem1);
    when(itemFactory.makeRoot(dmnDiagramTuple2)).thenReturn(decisionNavigatorItem2);
    when(itemFactory.makeItem(node1)).thenReturn(decisionNavigatorItem5);
    when(itemFactory.makeItem(node2)).thenReturn(decisionNavigatorItem6);
    when(itemFactory.makeItem(node3)).thenReturn(decisionNavigatorItem7);
    when(itemFactory.makeItem(node4)).thenReturn(decisionNavigatorItem8);
    when(itemFactory.makeItem(node5)).thenReturn(decisionNavigatorItem9);
    when(itemFactory.makeItem(node6)).thenReturn(decisionNavigatorItem10);
    when(itemFactory.makeSeparator(DRG)).thenReturn(decisionNavigatorItem3);
    when(itemFactory.makeSeparator(DRDs)).thenReturn(decisionNavigatorItem4);
    when(dmnDiagramUtils.getNodeStream(stunnerDiagram1)).thenReturn(stunnerNodes1);
    when(dmnDiagramUtils.getNodeStream(stunnerDiagram2)).thenReturn(stunnerNodes2);
    final List<DecisionNavigatorItem> actualItems = itemsProvider.getItems();
    final List<DecisionNavigatorItem> expectedItems = asList(decisionNavigatorItem3, decisionNavigatorItem2, decisionNavigatorItem4, decisionNavigatorItem1);
    assertEquals(expectedItems, actualItems);
    verify(decisionNavigatorItem1).addChild(decisionNavigatorItem5);
    verify(decisionNavigatorItem1).addChild(decisionNavigatorItem6);
    verify(decisionNavigatorItem1).addChild(decisionNavigatorItem7);
    verify(decisionNavigatorItem2).addChild(decisionNavigatorItem8);
    verify(decisionNavigatorItem2).addChild(decisionNavigatorItem9);
    verify(decisionNavigatorItem2).addChild(decisionNavigatorItem10);
}
Also used : DMNDiagramTuple(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple) Node(org.kie.workbench.common.stunner.core.graph.Node) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) Test(org.junit.Test)

Aggregations

Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)121 Test (org.junit.Test)79 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)39 View (org.kie.workbench.common.stunner.core.graph.content.view.View)38 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)37 Node (org.kie.workbench.common.stunner.core.graph.Node)28 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)23 Edge (org.kie.workbench.common.stunner.core.graph.Edge)23 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)22 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)21 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)21 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)20 List (java.util.List)16 TDecision (org.kie.dmn.model.v1_2.TDecision)16 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)16 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)16 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)16 ArrayList (java.util.ArrayList)15 Optional (java.util.Optional)15 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)15