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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations