Search in sources :

Example 71 with Decision

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

the class PointUtilsTest method testConvertToRelativeBoundsWhenChild.

@Test
public void testConvertToRelativeBoundsWhenChild() {
    final Node<View, Edge> parent = new NodeImpl<>(UUID.uuid());
    final View parentView = new ViewImpl<>(new Decision(), Bounds.create(100, 200, 1000, 2000));
    parent.setContent(parentView);
    final Node<View, Edge> child = new NodeImpl<>(UUID.uuid());
    final View childView = new ViewImpl<>(new Decision(), Bounds.create(110, 220, 150, 260));
    child.setContent(childView);
    final Edge<Child, Node> edge = new EdgeImpl<>(UUID.uuid());
    edge.setContent(new Child());
    edge.setSourceNode(parent);
    edge.setTargetNode(child);
    parent.getOutEdges().add(edge);
    child.getInEdges().add(edge);
    PointUtils.convertToRelativeBounds(child);
    final Bound ulBound = child.getContent().getBounds().getUpperLeft();
    final Bound lrBound = child.getContent().getBounds().getLowerRight();
    assertThat(ulBound.getX()).isEqualTo(10);
    assertThat(ulBound.getY()).isEqualTo(20);
    assertThat(lrBound.getX()).isEqualTo(50);
    assertThat(lrBound.getY()).isEqualTo(60);
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Node(org.kie.workbench.common.stunner.core.graph.Node) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 72 with Decision

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

the class DMNIncludedNodeFactoryTest method makeDecision.

private Decision makeDecision(final String id, final String name, final String type) {
    final Decision decision = new Decision();
    decision.setId(new Id(id));
    decision.setName(new Name(name));
    decision.setVariable(makeInformationItemPrimary(type));
    return decision;
}
Also used : Id(org.kie.workbench.common.dmn.api.property.dmn.Id) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 73 with Decision

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

the class DecisionConverterTest method testWBFromDMN.

@Test
@SuppressWarnings("unchecked")
public void testWBFromDMN() {
    final Node<View<Decision>, ?> factoryNode = new NodeImpl<>(UUID.uuid());
    final View<Decision> view = new ViewImpl<>(new Decision(), Bounds.create());
    factoryNode.setContent(view);
    when(factoryManager.newElement(Mockito.<String>any(), eq(getDefinitionId(Decision.class)))).thenReturn(element);
    when(element.asNode()).thenReturn(factoryNode);
    final org.kie.dmn.model.api.Decision dmn = new TDecision();
    final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
    final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
    literalExpression.setId(EXPRESSION_UUID);
    dmn.setId(DECISION_UUID);
    dmn.setName(DECISION_NAME);
    dmn.setDescription(DECISION_DESCRIPTION);
    dmn.setVariable(informationItem);
    dmn.setExpression(literalExpression);
    final Node<View<Decision>, ?> node = converter.nodeFromDMN(dmn, hasComponentWidthsConsumer);
    final Decision wb = (Decision) DefinitionUtils.getElementDefinition(node);
    assertThat(wb).isNotNull();
    assertThat(wb.getId()).isNotNull();
    assertThat(wb.getId().getValue()).isEqualTo(DECISION_UUID);
    assertThat(wb.getName()).isNotNull();
    assertThat(wb.getName().getValue()).isEqualTo(DECISION_NAME);
    assertThat(wb.getDescription()).isNotNull();
    assertThat(wb.getDescription().getValue()).isEqualTo(DECISION_DESCRIPTION);
    assertThat(wb.getVariable()).isNotNull();
    assertThat(wb.getVariable().getName().getValue()).isEqualTo(DECISION_NAME);
    assertThat(wb.getExpression()).isNotNull();
    assertThat(wb.getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
    verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
    final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
    assertThat(hasComponentWidths).isNotNull();
    assertThat(hasComponentWidths).isEqualTo(wb.getExpression());
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) TDecision(org.kie.dmn.model.v1_2.TDecision) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) TDecision(org.kie.dmn.model.v1_2.TDecision) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) Test(org.junit.Test)

Example 74 with Decision

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

the class DMNIncludedNodesFilterTest method testGetNodesFromImports.

@Test
public void testGetNodesFromImports() {
    final Path path = mock(Path.class);
    final DMNIncludedModel includedModel1 = mock(DMNIncludedModel.class);
    final DMNIncludedModel includedModel2 = mock(DMNIncludedModel.class);
    final DMNIncludedModel includedModel3 = mock(DMNIncludedModel.class);
    final List<DMNIncludedModel> imports = asList(includedModel1, includedModel2, includedModel3);
    final DMNIncludedNode dmnNode1 = mock(DMNIncludedNode.class);
    final DMNIncludedNode dmnNode2 = mock(DMNIncludedNode.class);
    final Decision node1 = new Decision();
    final InputData node2 = new InputData();
    final List<DRGElement> diagramNodes = asList(node1, node2);
    when(includedModel1.getNamespace()).thenReturn("://namespace1");
    when(includedModel2.getNamespace()).thenReturn("://namespace2");
    when(includedModel3.getNamespace()).thenReturn("://namespace3");
    when(diagramHelper.getDiagramByPath(path)).thenReturn(diagram);
    when(diagramHelper.getNodes(diagram)).thenReturn(diagramNodes);
    when(diagramHelper.getNamespace(diagram)).thenReturn("://namespace1");
    when(factory.makeDMNIncludeModel(path, includedModel1, node1)).thenReturn(dmnNode1);
    when(factory.makeDMNIncludeModel(path, includedModel1, node2)).thenReturn(dmnNode2);
    final List<DMNIncludedNode> actualNodes = filter.getNodesFromImports(path, imports);
    final List<DMNIncludedNode> expectedNodes = asList(dmnNode1, dmnNode2);
    assertEquals(expectedNodes, actualNodes);
}
Also used : Path(org.uberfire.backend.vfs.Path) DMNIncludedNode(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedNode) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DMNIncludedModel(org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 75 with Decision

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

the class DMNDiagramUtilsTest method testGetDefinitionsWithMultipleRootNodes.

@Test
public void testGetDefinitionsWithMultipleRootNodes() {
    final Decision definition1 = new Decision();
    final DMNDiagram definition2 = new DMNDiagram();
    graph.addNode(newNode(definition1));
    graph.addNode(newNode(definition2));
    final Definitions definitions = utils.getDefinitions(diagram);
    assertNotNull(definitions);
    assertEquals(definition2.getDefinitions(), definitions);
}
Also used : DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) 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