Search in sources :

Example 26 with DMNDiagramElement

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

the class DecisionNavigatorItemFactoryTest method testGetOnRemove.

@Test
public void testGetOnRemove() {
    final DMNDiagramElement drgDiagramElement = new DMNDiagramElement();
    final DMNDiagramElement drd1DiagramElement = new DMNDiagramElement();
    final DMNDiagramElement drd2DiagramElement = new DMNDiagramElement();
    final DMNDiagramElement drgElement = mock(DMNDiagramElement.class);
    final Graph drgGraph = mock(Graph.class);
    final Diagram drgDiagram = mock(Diagram.class);
    final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
    final Node node = mock(Node.class);
    final Definition definition = mock(Definition.class);
    final DMNDiagram dmnDiagram = mock(DMNDiagram.class);
    final Definitions dmnDefinitions = mock(Definitions.class);
    final List<DMNDiagramElement> diagramElements = new ArrayList<>(asList(drgDiagramElement, drd1DiagramElement, drd2DiagramElement));
    final Iterable nodes = singletonList(node);
    when(dmnDiagramsSession.getDRGDiagramElement()).thenReturn(drgElement);
    when(dmnDiagramsSession.getDRGDiagram()).thenReturn(drgDiagram);
    when(drgDiagram.getGraph()).thenReturn(drgGraph);
    when(drgGraph.nodes()).thenReturn(nodes);
    when(node.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(dmnDiagram);
    when(dmnDiagram.getDefinitions()).thenReturn(dmnDefinitions);
    when(dmnDefinitions.getDiagramElements()).thenReturn(diagramElements);
    factory.getOnRemove(drd1DiagramElement).accept(item);
    verify(dmnDiagramsSession).remove(drd1DiagramElement);
    verify(selectedEvent).fire(diagramSelectedArgumentCaptor.capture());
    assertEquals(drgElement, diagramSelectedArgumentCaptor.getValue().getDiagramElement());
    assertEquals(2, diagramElements.size());
    assertTrue(diagramElements.contains(drgDiagramElement));
    assertFalse(diagramElements.contains(drd1DiagramElement));
    assertTrue(diagramElements.contains(drd2DiagramElement));
}
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) Node(org.kie.workbench.common.stunner.core.graph.Node) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) ArrayList(java.util.ArrayList) 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) Test(org.junit.Test)

Example 27 with DMNDiagramElement

use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement 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)

Example 28 with DMNDiagramElement

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

the class DecisionNavigatorItemFactoryTest method testGetOnClickAction.

@Test
public void testGetOnClickAction() {
    final DMNDiagramElement dmnDiagramElement = mock(DMNDiagramElement.class);
    factory.getOnClickAction(dmnDiagramElement).execute();
    verify(selectedEvent).fire(diagramSelectedArgumentCaptor.capture());
    assertEquals(dmnDiagramElement, diagramSelectedArgumentCaptor.getValue().getDiagramElement());
}
Also used : DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Test(org.junit.Test)

Example 29 with DMNDiagramElement

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

the class DMNDiagramsSessionTest method testOnDMNDiagramSelected_WhenBelongsToCurrentSessionState.

@Test
public void testOnDMNDiagramSelected_WhenBelongsToCurrentSessionState() {
    final DMNDiagramElement selectedDiagramElement = mock(DMNDiagramElement.class);
    final DMNDiagramSelected dmnDiagramSelected = new DMNDiagramSelected(selectedDiagramElement);
    doNothing().when(dmnDiagramsSession).storeCurrentRegistryHistory();
    doReturn(true).when(dmnDiagramsSession).belongsToCurrentSessionState(selectedDiagramElement);
    dmnDiagramsSession.onDMNDiagramSelected(dmnDiagramSelected);
    verify(dmnDiagramsSessionState).setCurrentDMNDiagramElement(selectedDiagramElement);
    verify(dmnDiagramsSession).storeCurrentRegistryHistory();
}
Also used : DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Test(org.junit.Test)

Example 30 with DMNDiagramElement

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

the class DMNDiagramsSessionTest method testGetDRGDiagramElement.

@Test
public void testGetDRGDiagramElement() {
    final DMNDiagramElement expected = mock(DMNDiagramElement.class);
    doReturn(expected).when(dmnDiagramsSessionState).getDRGDiagramElement();
    final DMNDiagramElement actual = dmnDiagramsSession.getDRGDiagramElement();
    assertEquals(expected, actual);
}
Also used : DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Test(org.junit.Test)

Aggregations

DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)35 Test (org.junit.Test)23 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)21 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)13 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)10 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)8 Node (org.kie.workbench.common.stunner.core.graph.Node)7 View (org.kie.workbench.common.stunner.core.graph.content.view.View)6 DMNDiagramTuple (org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple)5 Graph (org.kie.workbench.common.stunner.core.graph.Graph)5 DecisionNavigatorItem (org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem)4 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)3 HasContentDefinitionId (org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId)3 JSONString (com.google.gwt.json.client.JSONString)2 QName (javax.xml.namespace.QName)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)2 DMNElement (org.kie.workbench.common.dmn.api.definition.model.DMNElement)2