@Test public void testGetNode() { final DRGElement drgElement = mock(DRGElement.class); final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class); final Diagram diagram = mock(Diagram.class); final Graph graph = mock(Graph.class); final Node node1 = mock(Node.class); final Node node2 = mock(Node.class); final Node node3 = mock(Node.class); final Definition definition1 = mock(Definition.class); final Definition definition2 = mock(Definition.class); final Definition definition3 = mock(Definition.class); when(definition1.getDefinition()).thenReturn(new Object()); when(definition2.getDefinition()).thenReturn(drgElement); when(definition3.getDefinition()).thenReturn(new Object()); when(node1.getContent()).thenReturn(definition1); when(node2.getContent()).thenReturn(definition2); when(node3.getContent()).thenReturn(definition3); when(canvasHandler.getDiagram()).thenReturn(diagram); when(diagram.getGraph()).thenReturn(graph); when(graph.nodes()).thenReturn(asList(node1, node2, node3)); when(dmnGraphUtils.getCanvasHandler()).thenReturn(canvasHandler); final Node actualNode = handler.getNode(drgElement); assertEquals(node2, actualNode); }
Node getNode(final Object definition) { final Graph<?, Node> graph = getCanvasHandler().getDiagram().getGraph(); return StreamSupport .stream(graph.nodes().spliterator(), false) .filter((Node node) -> node.getContent() instanceof Definition) .filter(node -> Objects.equals(definition, ((Definition) node.getContent()).getDefinition())) .findFirst() .orElse(null); }
DMNIncludedModelHandler implements DRGElementHandler { Node getNode(final Object definition) { final Graph<?, Node> graph = getCanvasHandler().getDiagram().getGraph(); return StreamSupport .stream(graph.nodes().spliterator(), false) .filter((Node node) -> node.getContent() instanceof Definition) .filter(node -> Objects.equals(definition, ((Definition) node.getContent()).getDefinition())) .findFirst() .orElse(null); } }
DMNIncludedModelHandler implements DRGElementHandler { Node getNode(final Object definition) { final Graph<?, Node> graph = getCanvasHandler().getDiagram().getGraph(); return StreamSupport .stream(graph.nodes().spliterator(), false) .filter((Node node) -> node.getContent() instanceof Definition) .filter(node -> Objects.equals(definition, ((Definition) node.getContent()).getDefinition())) .findFirst() .orElse(null); } @Inject  DMNIncludedModelHandler(final DMNGraphUtils dmnGraphUtils,
                                   final @DMNEditor DefaultCanvasCommandFactory canvasCommandFactory,
                                   final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                                   final DefinitionUtils definitionUtils); }
DMNIncludedModelHandler implements DRGElementHandler { Node getNode(final Object definition) { final Graph<?, Node> graph = getCanvasHandler().getDiagram().getGraph(); return StreamSupport .stream(graph.nodes().spliterator(), false) .filter((Node node) -> node.getContent() instanceof Definition) .filter(node -> Objects.equals(definition, ((Definition) node.getContent()).getDefinition())) .findFirst() .orElse(null); } @Inject  DMNIncludedModelHandler(final DMNGraphUtils dmnGraphUtils,
                                   final @DMNEditor DefaultCanvasCommandFactory canvasCommandFactory,
                                   final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                                   final DefinitionUtils definitionUtils); @Override void update(final String oldModelName,
                       final String newModelName); @Override void destroy(final String oldModelName); }
DMNIncludedModelHandler implements DRGElementHandler { Node getNode(final Object definition) { final Graph<?, Node> graph = getCanvasHandler().getDiagram().getGraph(); return StreamSupport .stream(graph.nodes().spliterator(), false) .filter((Node node) -> node.getContent() instanceof Definition) .filter(node -> Objects.equals(definition, ((Definition) node.getContent()).getDefinition())) .findFirst() .orElse(null); } @Inject  DMNIncludedModelHandler(final DMNGraphUtils dmnGraphUtils,
                                   final @DMNEditor DefaultCanvasCommandFactory canvasCommandFactory,
                                   final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                                   final DefinitionUtils definitionUtils); @Override void update(final String oldModelName,
                       final String newModelName); @Override void destroy(final String oldModelName);  }