@Test public void testProcessGlobalNodeForDeletion() { final Deque deque = mock(Deque.class); final String nodeId = "id"; final Node node = createNode(nodeId, "diagramId"); this.tested = mock(SafeDeleteNodeProcessor.class); when(tested.getCandidateContentDefinitionId()).thenReturn(nodeId); when(tested.isDuplicatedOnTheCurrentDiagram(eq(node), anyString(), anyString())).thenReturn(false); when(tested.processGlobalNodeForDeletion(node, deque)).thenCallRealMethod(); final boolean shouldDeleteDuplicatedDRGNodes = tested.processGlobalNodeForDeletion(node, deque); verify(deque).add(node); assertTrue(shouldDeleteDuplicatedDRGNodes); }
boolean processGlobalNodeForDeletion(final Node node, final Deque<Node<View, Edge>> nodes) { final String nodeId = getContentDefinitionId(node); final String diagramId = getDiagramId(node); if (isDuplicatedOnTheCurrentDiagram(node, nodeId, diagramId)) { nodes.clear(); return false; } if (Objects.equals(getCandidateContentDefinitionId(), nodeId) && !Objects.equals(node, candidate)) { nodes.add(node); } return true; }
SafeDeleteNodeProcessor { boolean processGlobalNodeForDeletion(final Node node, final Deque<Node<View, Edge>> nodes) { final String nodeId = getContentDefinitionId(node); final String diagramId = getDiagramId(node); if (isDuplicatedOnTheCurrentDiagram(node, nodeId, diagramId)) { nodes.clear(); return false; } if (Objects.equals(getCandidateContentDefinitionId(), nodeId) && !Objects.equals(node, candidate)) { nodes.add(node); } return true; } }
SafeDeleteNodeProcessor { boolean processGlobalNodeForDeletion(final Node node, final Deque<Node<View, Edge>> nodes) { final String nodeId = getContentDefinitionId(node); final String diagramId = getDiagramId(node); if (isDuplicatedOnTheCurrentDiagram(node, nodeId, diagramId)) { nodes.clear(); return false; } if (Objects.equals(getCandidateContentDefinitionId(), nodeId) && !Objects.equals(node, candidate)) { nodes.add(node); } return true; } SafeDeleteNodeProcessor(final ChildrenTraverseProcessor childrenTraverseProcessor,
                                   final Graph graph,
                                   final Node<Definition<?>, Edge> candidate);  SafeDeleteNodeProcessor(final ChildrenTraverseProcessor childrenTraverseProcessor,
                                   final Graph graph,
                                   final Node<Definition<?>, Edge> candidate,
                                   final boolean keepChildren,
                                   final TreeWalkTraverseProcessor treeWalkTraverseProcessor,
                                   final GraphsProvider graphsProvider); }
SafeDeleteNodeProcessor { boolean processGlobalNodeForDeletion(final Node node, final Deque<Node<View, Edge>> nodes) { final String nodeId = getContentDefinitionId(node); final String diagramId = getDiagramId(node); if (isDuplicatedOnTheCurrentDiagram(node, nodeId, diagramId)) { nodes.clear(); return false; } if (Objects.equals(getCandidateContentDefinitionId(), nodeId) && !Objects.equals(node, candidate)) { nodes.add(node); } return true; } SafeDeleteNodeProcessor(final ChildrenTraverseProcessor childrenTraverseProcessor,
                                   final Graph graph,
                                   final Node<Definition<?>, Edge> candidate);  SafeDeleteNodeProcessor(final ChildrenTraverseProcessor childrenTraverseProcessor,
                                   final Graph graph,
                                   final Node<Definition<?>, Edge> candidate,
                                   final boolean keepChildren,
                                   final TreeWalkTraverseProcessor treeWalkTraverseProcessor,
                                   final GraphsProvider graphsProvider); @SuppressWarnings("unchecked") void run(final Callback callback); String getCandidateDiagramId(); String getCandidateContentDefinitionId(); }
SafeDeleteNodeProcessor { boolean processGlobalNodeForDeletion(final Node node, final Deque<Node<View, Edge>> nodes) { final String nodeId = getContentDefinitionId(node); final String diagramId = getDiagramId(node); if (isDuplicatedOnTheCurrentDiagram(node, nodeId, diagramId)) { nodes.clear(); return false; } if (Objects.equals(getCandidateContentDefinitionId(), nodeId) && !Objects.equals(node, candidate)) { nodes.add(node); } return true; } SafeDeleteNodeProcessor(final ChildrenTraverseProcessor childrenTraverseProcessor,
                                   final Graph graph,
                                   final Node<Definition<?>, Edge> candidate);  SafeDeleteNodeProcessor(final ChildrenTraverseProcessor childrenTraverseProcessor,
                                   final Graph graph,
                                   final Node<Definition<?>, Edge> candidate,
                                   final boolean keepChildren,
                                   final TreeWalkTraverseProcessor treeWalkTraverseProcessor,
                                   final GraphsProvider graphsProvider); @SuppressWarnings("unchecked") void run(final Callback callback); String getCandidateDiagramId(); String getCandidateContentDefinitionId();  }