Search in sources :

Example 6 with DMNDiagramTuple

use of org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple in project kie-wb-common by kiegroup.

the class DecisionNavigatorItemFactoryTest method testMakeRootWhenDMNDiagramElementIsNotDRG.

@Test
public void testMakeRootWhenDMNDiagramElementIsNotDRG() {
    final Diagram stunnerDiagram = mock(Diagram.class);
    final Graph graph = mock(Graph.class);
    final Node node = mock(Node.class);
    final Definition definition = mock(Definition.class);
    final String drdName = "DRD 1";
    final String dmnDiagramId = "0000";
    final DMNDiagramElement dmnDiagramElement = new DMNDiagramElement(new Id(dmnDiagramId), new Name(drdName));
    final DMNDiagramTuple diagramTuple = new DMNDiagramTuple(stunnerDiagram, dmnDiagramElement);
    when(stunnerDiagram.getGraph()).thenReturn(graph);
    when(graph.nodes()).thenReturn(singletonList(node));
    when(node.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(new DMNDiagram());
    when(baseItemFactory.getLabel(node)).thenReturn("diagram-name");
    final DecisionNavigatorItem decisionNavigatorItem = factory.makeRoot(diagramTuple);
    assertEquals(drdName, decisionNavigatorItem.getLabel());
    assertEquals(dmnDiagramId, decisionNavigatorItem.getUUID());
    assertEquals(ROOT, decisionNavigatorItem.getType());
    assertNull(decisionNavigatorItem.getParentUUID());
}
Also used : DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) Graph(org.kie.workbench.common.stunner.core.graph.Graph) DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) DMNDiagramTuple(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple) Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 7 with DMNDiagramTuple

use of org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple in project kie-wb-common by kiegroup.

the class DecisionNavigatorItemFactoryTest method testMakeRootWhenDMNDiagramElementIsDRG.

@Test
public void testMakeRootWhenDMNDiagramElementIsDRG() {
    final Diagram stunnerDiagram = mock(Diagram.class);
    final Graph graph = mock(Graph.class);
    final Node node = mock(Node.class);
    final Definition definition = mock(Definition.class);
    final String dmnDiagramId = "0000";
    final String dmnModelName = "diagram-name";
    final DMNDiagramElement dmnDiagramElement = new DMNDiagramElement(new Id(dmnDiagramId), new Name("DRG"));
    final DMNDiagramTuple diagramTuple = new DMNDiagramTuple(stunnerDiagram, dmnDiagramElement);
    when(stunnerDiagram.getGraph()).thenReturn(graph);
    when(graph.nodes()).thenReturn(singletonList(node));
    when(node.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(new DMNDiagram());
    when(baseItemFactory.getLabel(node)).thenReturn(dmnModelName);
    final DecisionNavigatorItem decisionNavigatorItem = factory.makeRoot(diagramTuple);
    assertEquals(dmnModelName, decisionNavigatorItem.getLabel());
    assertEquals(dmnDiagramId, decisionNavigatorItem.getUUID());
    assertEquals(ROOT, decisionNavigatorItem.getType());
    assertNull(decisionNavigatorItem.getParentUUID());
}
Also used : DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) Graph(org.kie.workbench.common.stunner.core.graph.Graph) DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) DMNDiagramTuple(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple) Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Aggregations

DMNDiagramTuple (org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple)7 Test (org.junit.Test)6 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)6 DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)5 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)4 Node (org.kie.workbench.common.stunner.core.graph.Node)4 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)3 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)3 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)3 DecisionNavigatorItem (org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem)2 Graph (org.kie.workbench.common.stunner.core.graph.Graph)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)1 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)1 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)1 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)1 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)1 View (org.kie.workbench.common.stunner.core.graph.content.view.View)1