Search in sources :

Example 6 with GraphsProvider

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);
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Node(org.kie.workbench.common.stunner.core.graph.Node) ChildrenTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl) GraphsProvider(org.kie.workbench.common.stunner.core.diagram.GraphsProvider) TreeWalkTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl) ArrayDeque(java.util.ArrayDeque) Test(org.junit.Test)

Example 7 with GraphsProvider

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;
}
Also used : Element(org.kie.workbench.common.stunner.core.graph.Element) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) GraphsProvider(org.kie.workbench.common.stunner.core.diagram.GraphsProvider)

Example 8 with GraphsProvider

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));
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Edge(org.kie.workbench.common.stunner.core.graph.Edge) GraphsProvider(org.kie.workbench.common.stunner.core.diagram.GraphsProvider) Test(org.junit.Test)

Example 9 with 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);
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Node(org.kie.workbench.common.stunner.core.graph.Node) ChildrenTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl) GraphsProvider(org.kie.workbench.common.stunner.core.diagram.GraphsProvider) TreeWalkTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl) ArrayDeque(java.util.ArrayDeque) Test(org.junit.Test)

Example 10 with GraphsProvider

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));
}
Also used : TreeWalkTraverseProcessor(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessor) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Node(org.kie.workbench.common.stunner.core.graph.Node) AbstractTreeTraverseCallback(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.AbstractTreeTraverseCallback) ChildrenTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl) GraphsProvider(org.kie.workbench.common.stunner.core.diagram.GraphsProvider) Deque(java.util.Deque) ArrayDeque(java.util.ArrayDeque) ArrayDeque(java.util.ArrayDeque) TreeWalkTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl) Test(org.junit.Test)

Aggregations

GraphsProvider (org.kie.workbench.common.stunner.core.diagram.GraphsProvider)11 Test (org.junit.Test)8 Node (org.kie.workbench.common.stunner.core.graph.Node)7 ArrayDeque (java.util.ArrayDeque)3 Graph (org.kie.workbench.common.stunner.core.graph.Graph)3 ChildrenTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl)3 TreeWalkTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl)3 Annotation (java.lang.annotation.Annotation)2 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)2 Edge (org.kie.workbench.common.stunner.core.graph.Edge)2 Deque (java.util.Deque)1 PostConstruct (javax.annotation.PostConstruct)1 ClientSession (org.kie.workbench.common.stunner.core.client.session.ClientSession)1 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)1 Element (org.kie.workbench.common.stunner.core.graph.Element)1 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)1 AbstractTreeTraverseCallback (org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.AbstractTreeTraverseCallback)1 TreeWalkTraverseProcessor (org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessor)1