use of org.kie.workbench.common.stunner.core.diagram.GraphsProvider in project kie-wb-common by kiegroup.
the class SafeDeleteNodeProcessorTest method testRunKeepChildrenAndIsGlobalGraph.
@Test
public void testRunKeepChildrenAndIsGlobalGraph() {
final Graph graph = mock(Graph.class);
final Node node = mock(Node.class);
final GraphsProvider graphsProvider = mock(GraphsProvider.class);
when(graphsProvider.isGlobalGraphSelected()).thenReturn(true);
this.tested = spy(new SafeDeleteNodeProcessor(new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()), graph, node, true, new TreeWalkTraverseProcessorImpl(), graphsProvider));
final ArrayDeque nodes = mock(ArrayDeque.class);
doReturn(nodes).when(tested).createNodesDequeue();
doNothing().when(tested).deleteChildren(callback, nodes);
doNothing().when(tested).processNode(node, callback, true);
doNothing().when(tested).deleteGlobalGraphNodes(callback, nodes);
tested.run(callback);
verify(tested, never()).deleteChildren(callback, nodes);
verify(tested).deleteGlobalGraphNodes(callback, nodes);
}
use of org.kie.workbench.common.stunner.core.diagram.GraphsProvider in project kie-wb-common by kiegroup.
the class DMNCanvasHandlerTest method getElementForTestUpdateDiagramId.
private Element getElementForTestUpdateDiagramId(final String diagramId, final String currentDiagramId, final HasContentDefinitionId hasContentDefinitionId) {
final Element element = mock(Element.class);
final Definition definition = mock(Definition.class);
final GraphsProvider graphsProvider = mock(GraphsProvider.class);
when(graphsProvider.getCurrentDiagramId()).thenReturn(diagramId);
when(definition.getDefinition()).thenReturn(hasContentDefinitionId);
when(element.getContent()).thenReturn(definition);
when(hasContentDefinitionId.getDiagramId()).thenReturn(currentDiagramId);
when(canvasHandler.getGraphsProvider()).thenReturn(graphsProvider);
return element;
}
use of org.kie.workbench.common.stunner.core.diagram.GraphsProvider in project kie-wb-common by kiegroup.
the class ContentDefinitionIdUtilsTest method testEdgeBelongsToCurrentGraph.
@Test
public void testEdgeBelongsToCurrentGraph() {
final String currentDiagramId = "currentDiagramId";
final Node node = createNode(currentDiagramId);
final Edge edge = createEdge(node, null);
final GraphsProvider graphsProvider = createGraphsProvider(currentDiagramId);
assertTrue(belongsToCurrentGraph(edge, graphsProvider));
}
use of org.kie.workbench.common.stunner.core.diagram.GraphsProvider in project kie-wb-common by kiegroup.
the class SafeDeleteNodeProcessorTest method testRunKeepChildren.
@Test
public void testRunKeepChildren() {
final Graph graph = mock(Graph.class);
final Node node = mock(Node.class);
final GraphsProvider graphsProvider = mock(GraphsProvider.class);
when(graphsProvider.isGlobalGraphSelected()).thenReturn(false);
this.tested = spy(new SafeDeleteNodeProcessor(new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()), graph, node, true, new TreeWalkTraverseProcessorImpl(), graphsProvider));
final ArrayDeque nodes = mock(ArrayDeque.class);
doReturn(nodes).when(tested).createNodesDequeue();
doNothing().when(tested).deleteChildren(callback, nodes);
doNothing().when(tested).processNode(node, callback, true);
tested.run(callback);
verify(tested, never()).deleteChildren(callback, nodes);
verify(tested, never()).deleteGlobalGraphNodes(callback, nodes);
}
use of org.kie.workbench.common.stunner.core.diagram.GraphsProvider in project kie-wb-common by kiegroup.
the class SafeDeleteNodeProcessorTest method testDeleteGlobalGraphNodes.
@Test
public void testDeleteGlobalGraphNodes() {
final Node node = mock(Node.class);
final GraphsProvider graphsProvider = mock(GraphsProvider.class);
final Deque nodes = new ArrayDeque();
final TreeWalkTraverseProcessor treeWalk = mock(TreeWalkTraverseProcessor.class);
final List<Graph> graphs = Arrays.asList(graphHolder.graph, graphHolderContainer.graph, graphHolderDocked.graph);
when(graphsProvider.isGlobalGraphSelected()).thenReturn(false);
this.tested = spy(new SafeDeleteNodeProcessor(new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()), graphHolder.graph, node, true, treeWalk, graphsProvider));
when(graphsProvider.getGraphs()).thenReturn(graphs);
doReturn(nodes).when(tested).createNodesDequeue();
doReturn(true).when(tested).processGlobalNodeForDeletion(any(Node.class), eq(nodes));
tested.deleteGlobalGraphNodes(callback, nodes);
verify(treeWalk).traverse(eq(graphHolder.graph), any(AbstractTreeTraverseCallback.class));
verify(treeWalk).traverse(eq(graphHolderContainer.graph), any(AbstractTreeTraverseCallback.class));
verify(treeWalk).traverse(eq(graphHolderDocked.graph), any(AbstractTreeTraverseCallback.class));
}
Aggregations