@Test public void testRemoveFromCurrentDRD() { final String nodeUUID = "UUID"; final Node node = mock(Node.class); final Diagram diagram = mock(Diagram.class); final DMNDiagramElement dmnDiagram = mock(DMNDiagramElement.class); when(node.getUUID()).thenReturn(nodeUUID); when(dmnDiagramsSession.getCurrentDiagram()).thenReturn(Optional.of(diagram)); when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(dmnDiagram)); when(diagram.getGraph()).thenReturn(graph); drdContextMenuService.removeFromCurrentDRD(singleton(node)); verify(graph, times(1)).removeNode(nodeUUID); verify(selectedEvent, times(1)).fire(any(DMNDiagramSelected.class)); }
public void removeFromCurrentDRD(final Collection<Node<? extends Definition<?>, Edge>> selectedNodes) { final Diagram diagram = dmnDiagramsSession .getCurrentDiagram() .orElse(dmnDiagramsSession.getDRGDiagram()); selectedNodes.forEach(node -> diagram.getGraph().removeNode(node.getUUID())); dmnDiagramsSession .getCurrentDMNDiagramElement() .ifPresent(dmnDiagramElement -> selectedEvent.fire(new DMNDiagramSelected(dmnDiagramElement))); }
DRDContextMenuService { public void removeFromCurrentDRD(final Collection<Node<? extends Definition<?>, Edge>> selectedNodes) { final Diagram diagram = dmnDiagramsSession .getCurrentDiagram() .orElse(dmnDiagramsSession.getDRGDiagram()); selectedNodes.forEach(node -> diagram.getGraph().removeNode(node.getUUID())); dmnDiagramsSession .getCurrentDMNDiagramElement() .ifPresent(dmnDiagramElement -> selectedEvent.fire(new DMNDiagramSelected(dmnDiagramElement))); } }
DRDContextMenuService { public void removeFromCurrentDRD(final Collection<Node<? extends Definition<?>, Edge>> selectedNodes) { final Diagram diagram = dmnDiagramsSession .getCurrentDiagram() .orElse(dmnDiagramsSession.getDRGDiagram()); selectedNodes.forEach(node -> diagram.getGraph().removeNode(node.getUUID())); dmnDiagramsSession .getCurrentDMNDiagramElement() .ifPresent(dmnDiagramElement -> selectedEvent.fire(new DMNDiagramSelected(dmnDiagramElement))); } @Inject  DRDContextMenuService(final DMNDiagramsSession dmnDiagramsSession,
                                 final FactoryManager factoryManager,
                                 final Event<DMNDiagramSelected> selectedEvent,
                                 final DMNDiagramUtils dmnDiagramUtils,
                                 final DMNDeepCloneProcess dmnDeepCloneProcess,
                                 final DMNUnmarshaller dmnUnmarshaller); }
DRDContextMenuService { public void removeFromCurrentDRD(final Collection<Node<? extends Definition<?>, Edge>> selectedNodes) { final Diagram diagram = dmnDiagramsSession .getCurrentDiagram() .orElse(dmnDiagramsSession.getDRGDiagram()); selectedNodes.forEach(node -> diagram.getGraph().removeNode(node.getUUID())); dmnDiagramsSession .getCurrentDMNDiagramElement() .ifPresent(dmnDiagramElement -> selectedEvent.fire(new DMNDiagramSelected(dmnDiagramElement))); } @Inject  DRDContextMenuService(final DMNDiagramsSession dmnDiagramsSession,
                                 final FactoryManager factoryManager,
                                 final Event<DMNDiagramSelected> selectedEvent,
                                 final DMNDiagramUtils dmnDiagramUtils,
                                 final DMNDeepCloneProcess dmnDeepCloneProcess,
                                 final DMNUnmarshaller dmnUnmarshaller); List<DMNDiagramTuple> getDiagrams(); void addToNewDRD(final Collection<Node<? extends Definition<?>, Edge>> selectedNodes); void addToExistingDRD(final DMNDiagramTuple dmnDiagram,
                                 final Collection<Node<? extends Definition<?>, Edge>> selectedNodes); void removeFromCurrentDRD(final Collection<Node<? extends Definition<?>, Edge>> selectedNodes); }
DRDContextMenuService { public void removeFromCurrentDRD(final Collection<Node<? extends Definition<?>, Edge>> selectedNodes) { final Diagram diagram = dmnDiagramsSession .getCurrentDiagram() .orElse(dmnDiagramsSession.getDRGDiagram()); selectedNodes.forEach(node -> diagram.getGraph().removeNode(node.getUUID())); dmnDiagramsSession .getCurrentDMNDiagramElement() .ifPresent(dmnDiagramElement -> selectedEvent.fire(new DMNDiagramSelected(dmnDiagramElement))); } @Inject  DRDContextMenuService(final DMNDiagramsSession dmnDiagramsSession,
                                 final FactoryManager factoryManager,
                                 final Event<DMNDiagramSelected> selectedEvent,
                                 final DMNDiagramUtils dmnDiagramUtils,
                                 final DMNDeepCloneProcess dmnDeepCloneProcess,
                                 final DMNUnmarshaller dmnUnmarshaller); List<DMNDiagramTuple> getDiagrams(); void addToNewDRD(final Collection<Node<? extends Definition<?>, Edge>> selectedNodes); void addToExistingDRD(final DMNDiagramTuple dmnDiagram,
                                 final Collection<Node<? extends Definition<?>, Edge>> selectedNodes); void removeFromCurrentDRD(final Collection<Node<? extends Definition<?>, Edge>> selectedNodes);  }