Search in sources :

Example 31 with DMNDiagramElement

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

the class DMNDiagramsSessionTest method testAddAndRemove.

@Test
public void testAddAndRemove() {
    final DMNDiagramElement dmnDiagram = mock(DMNDiagramElement.class);
    final Diagram stunnerDiagram = mock(Diagram.class);
    final String diagramId = "0000";
    when(dmnDiagram.getId()).thenReturn(new Id(diagramId));
    dmnDiagramsSession.add(dmnDiagram, stunnerDiagram);
    assertEquals(dmnDiagram, dmnDiagramsSession.getDMNDiagramElement(diagramId));
    assertEquals(stunnerDiagram, dmnDiagramsSession.getDiagram(diagramId));
    assertEquals(dmnDiagram, dmnDiagramsSession.getDiagramTuple(diagramId).getDMNDiagram());
    assertEquals(stunnerDiagram, dmnDiagramsSession.getDiagramTuple(diagramId).getStunnerDiagram());
    dmnDiagramsSession.remove(dmnDiagram);
    assertNull(dmnDiagramsSession.getDMNDiagramElement(diagramId));
    assertNull(dmnDiagramsSession.getDiagram(diagramId));
    assertNull(dmnDiagramsSession.getDiagramTuple(diagramId).getDMNDiagram());
    assertNull(dmnDiagramsSession.getDiagramTuple(diagramId).getStunnerDiagram());
}
Also used : 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) Test(org.junit.Test)

Example 32 with DMNDiagramElement

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

the class DMNDiagramsSessionTest method testGetCurrentDMNDiagramElement.

@Test
public void testGetCurrentDMNDiagramElement() {
    final DMNDiagramElement diagramElement = new DMNDiagramElement();
    final Diagram stunnerDiagram = mock(Diagram.class);
    final DMNDiagramSelected selectedDiagram = new DMNDiagramSelected(diagramElement);
    dmnDiagramsSession.add(diagramElement, stunnerDiagram);
    dmnDiagramsSession.onDMNDiagramSelected(selectedDiagram);
    final Optional<DMNDiagramElement> currentDMNDiagramElement = dmnDiagramsSession.getCurrentDMNDiagramElement();
    assertTrue(currentDMNDiagramElement.isPresent());
    assertEquals(diagramElement, currentDMNDiagramElement.get());
}
Also used : DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 33 with DMNDiagramElement

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

the class DMNDiagramsSessionTest method testIsGlobalGraphWhenItReturnsTrue.

@Test
public void testIsGlobalGraphWhenItReturnsTrue() {
    final DMNDiagramElement diagramElement = new DMNDiagramElement(new Id(), new Name("DRG"));
    final Diagram stunnerDiagram = mock(Diagram.class);
    dmnDiagramsSession.add(diagramElement, stunnerDiagram);
    dmnDiagramsSession.onDMNDiagramSelected(new DMNDiagramSelected(diagramElement));
    assertTrue(dmnDiagramsSession.isGlobalGraphSelected());
}
Also used : Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 34 with DMNDiagramElement

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

the class DecisionNavigatorBaseItemFactoryTest method testMakeOnClickCommandWhenNodeBelongsToCurrentDiagram.

@Test
public void testMakeOnClickCommandWhenNodeBelongsToCurrentDiagram() {
    final String nodeUUID = "nodeUUID";
    final String nodeDiagramUUID = "diagramUUID";
    final String diagramUUID = "diagramUUID";
    final View content = mock(View.class);
    final HasContentDefinitionId hasContentDefinitionId = mock(HasContentDefinitionId.class);
    final DMNDiagramElement dmnDiagramElement = mock(DMNDiagramElement.class);
    when(node.getUUID()).thenReturn(nodeUUID);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(hasContentDefinitionId);
    when(hasContentDefinitionId.getDiagramId()).thenReturn(nodeDiagramUUID);
    when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(dmnDiagramElement));
    when(dmnDiagramElement.getId()).thenReturn(new Id(diagramUUID));
    factory.makeOnClickCommand(node).execute();
    verify(canvasFocusUtils).focus(nodeUUID);
    verify(lazyCanvasFocusUtils, never()).lazyFocus(Mockito.<String>any());
    verify(selectedEvent, never()).fire(any());
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 35 with DMNDiagramElement

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

the class DecisionNavigatorBaseItemFactoryTest method testMakeOnClickCommandWhenNodeDoesNotBelongToCurrentDiagram.

@Test
public void testMakeOnClickCommandWhenNodeDoesNotBelongToCurrentDiagram() {
    final String nodeUUID = "nodeUUID";
    final String nodeDiagramUUID = "otherDiagramUUID";
    final String diagramUUID = "diagramUUID";
    final View content = mock(View.class);
    final HasContentDefinitionId hasContentDefinitionId = mock(HasContentDefinitionId.class);
    final DMNDiagramElement dmnDiagramElement = mock(DMNDiagramElement.class);
    final DMNDiagramElement otherDiagramElement = mock(DMNDiagramElement.class);
    when(node.getUUID()).thenReturn(nodeUUID);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(hasContentDefinitionId);
    when(hasContentDefinitionId.getDiagramId()).thenReturn(nodeDiagramUUID);
    when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(dmnDiagramElement));
    when(dmnDiagramsSession.getDMNDiagramElement(nodeDiagramUUID)).thenReturn(otherDiagramElement);
    when(dmnDiagramElement.getId()).thenReturn(new Id(diagramUUID));
    factory.makeOnClickCommand(node).execute();
    verify(canvasFocusUtils, never()).focus(Mockito.<String>any());
    verify(lazyCanvasFocusUtils).lazyFocus(nodeUUID);
    verify(selectedEvent).fire(diagramSelectedArgumentCaptor.capture());
    assertEquals(otherDiagramElement, diagramSelectedArgumentCaptor.getValue().getDiagramElement());
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) View(org.kie.workbench.common.stunner.core.graph.content.view.View) 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