@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)); }
Consumer<DecisionNavigatorItem> getOnRemove(final DMNDiagramElement dmnDiagramElement) { return (item) -> { removeFromModel(dmnDiagramElement); removeFromSession(dmnDiagramElement); selectedEvent.fire(new DMNDiagramSelected(dmnDiagramsSession.getDRGDiagramElement())); }; }
DecisionNavigatorItemFactory { Consumer<DecisionNavigatorItem> getOnRemove(final DMNDiagramElement dmnDiagramElement) { return (item) -> { removeFromModel(dmnDiagramElement); removeFromSession(dmnDiagramElement); selectedEvent.fire(new DMNDiagramSelected(dmnDiagramsSession.getDRGDiagramElement())); }; } }
DecisionNavigatorItemFactory { Consumer<DecisionNavigatorItem> getOnRemove(final DMNDiagramElement dmnDiagramElement) { return (item) -> { removeFromModel(dmnDiagramElement); removeFromSession(dmnDiagramElement); selectedEvent.fire(new DMNDiagramSelected(dmnDiagramsSession.getDRGDiagramElement())); }; } @Inject  DecisionNavigatorItemFactory(final DecisionNavigatorBaseItemFactory baseItemFactory,
                                        final Event<DMNDiagramSelected> selectedEvent,
                                        final DMNDiagramsSession dmnDiagramsSession); }
DecisionNavigatorItemFactory { Consumer<DecisionNavigatorItem> getOnRemove(final DMNDiagramElement dmnDiagramElement) { return (item) -> { removeFromModel(dmnDiagramElement); removeFromSession(dmnDiagramElement); selectedEvent.fire(new DMNDiagramSelected(dmnDiagramsSession.getDRGDiagramElement())); }; } @Inject  DecisionNavigatorItemFactory(final DecisionNavigatorBaseItemFactory baseItemFactory,
                                        final Event<DMNDiagramSelected> selectedEvent,
                                        final DMNDiagramsSession dmnDiagramsSession); DecisionNavigatorItem makeItem(final Node<View, Edge> node); DecisionNavigatorItem makeRoot(final DMNDiagramTuple diagramTuple); DecisionNavigatorItem makeSeparator(final String label); }
DecisionNavigatorItemFactory { Consumer<DecisionNavigatorItem> getOnRemove(final DMNDiagramElement dmnDiagramElement) { return (item) -> { removeFromModel(dmnDiagramElement); removeFromSession(dmnDiagramElement); selectedEvent.fire(new DMNDiagramSelected(dmnDiagramsSession.getDRGDiagramElement())); }; } @Inject  DecisionNavigatorItemFactory(final DecisionNavigatorBaseItemFactory baseItemFactory,
                                        final Event<DMNDiagramSelected> selectedEvent,
                                        final DMNDiagramsSession dmnDiagramsSession); DecisionNavigatorItem makeItem(final Node<View, Edge> node); DecisionNavigatorItem makeRoot(final DMNDiagramTuple diagramTuple); DecisionNavigatorItem makeSeparator(final String label);  }