use of org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl in project kie-wb-common by kiegroup.
the class AbstractCloneCommandTest method setUp.
public void setUp() {
super.init(0, 0);
// creating the mock graph for test
TestingGraphMockHandler handler = new TestingGraphMockHandler();
graphInstance = TestingGraphInstanceBuilder.newGraph3(handler);
graph = graphInstance.graph;
graphIndex = handler.graphIndex;
// mocking the clone nodes on the graphIndex
ArgumentCaptor<Node> nodeArgumentCaptor = ArgumentCaptor.forClass(Node.class);
when(handler.graphIndex.addNode(nodeArgumentCaptor.capture())).thenAnswer(t -> {
// Node node = (Node)t.getArguments()[0];
when(graphIndex.getNode(eq(nodeArgumentCaptor.getValue().getUUID()))).thenReturn(nodeArgumentCaptor.getValue());
return graphIndex;
});
// edge mock
connectorContent = new ViewConnectorImpl(connectorDefinition, new BoundsImpl(new BoundImpl(1d, 1d), new BoundImpl(1d, 1d)));
sourceConnection = MagnetConnection.Builder.forElement(graphInstance.startNode);
connectorContent.setSourceConnection(sourceConnection);
targetConnection = MagnetConnection.Builder.forElement(graphInstance.intermNode);
connectorContent.setTargetConnection(targetConnection);
graphInstance.edge1.setContent(connectorContent);
graphInstance.edge2.setContent(connectorContent);
when(definitionManager.cloneManager()).thenReturn(cloneManager);
when(cloneManager.clone(definition, ClonePolicy.ALL)).thenReturn(definition);
when(cloneManager.clone(connectorDefinition, ClonePolicy.ALL)).thenReturn(connectorDefinition);
when(graphCommandExecutionContext.getGraphIndex()).thenReturn(graphIndex);
when(candidateContent.getDefinition()).thenReturn(definition);
when(factoryManager.newElement(anyString(), any(Class.class))).thenReturn(cloneElement);
when(cloneElement.asNode()).thenReturn(clone);
when(cloneElement.asEdge()).thenReturn(cloneEdge);
when(cloneEdge.getContent()).thenReturn(connectorContent);
when(cloneEdge.getUUID()).thenReturn(CLONE_EDGE_UUID);
when(clone.getContent()).thenReturn(cloneContent);
when(clone.getUUID()).thenReturn(CLONE_UUID);
when(cloneElement.getUUID()).thenReturn(CLONE_UUID);
when(cloneContent.getBounds()).thenReturn(bounds);
when(bounds.getUpperLeft()).thenReturn(bound);
when(bounds.getLowerRight()).thenReturn(bound);
when(childrenTraverseProcessorManagedInstance.get()).thenReturn(new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()));
}
use of org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl in project kie-wb-common by kiegroup.
the class SafeDeleteNodeProcessorTest method testDeleteEndNode.
@Test
@SuppressWarnings("unchecked")
public void testDeleteEndNode() {
this.tested = new SafeDeleteNodeProcessor(new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()), graphHolder.graph, graphHolder.endNode);
tested.run(callback);
verify(callback, times(1)).deleteCandidateConnector(eq(graphHolder.edge2));
verify(callback, times(1)).removeChild(eq(graphHolder.parentNode), eq(graphHolder.endNode));
verify(callback, times(1)).deleteCandidateNode(eq(graphHolder.endNode));
verify(callback, never()).removeDock(any(Node.class), any(Node.class));
}
use of org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl in project kie-wb-common by kiegroup.
the class SafeDeleteNodeProcessorTest method testDeleteParentWithNonEmptyContainerInside.
@Test
@SuppressWarnings("unchecked")
public void testDeleteParentWithNonEmptyContainerInside() {
this.tested = new SafeDeleteNodeProcessor(new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()), graphHolderContainer.graph, graphHolderContainer.parentNode);
tested.run(callback);
InOrder inOrder = inOrder(callback);
inOrder.verify(callback, times(1)).deleteConnector(eq(graphHolderContainer.edge2));
inOrder.verify(callback, times(1)).removeChild(eq(graphHolderContainer.containerNode), eq(graphHolderContainer.endNode));
inOrder.verify(callback, times(1)).deleteNode(eq(graphHolderContainer.endNode));
inOrder.verify(callback, times(1)).deleteConnector(eq(graphHolderContainer.edge1));
inOrder.verify(callback, times(1)).removeChild(eq(graphHolderContainer.containerNode), eq(graphHolderContainer.intermNode));
inOrder.verify(callback, times(1)).deleteNode(eq(graphHolderContainer.intermNode));
inOrder.verify(callback, times(1)).removeChild(eq(graphHolderContainer.containerNode), eq(graphHolderContainer.startNode));
inOrder.verify(callback, times(1)).deleteNode(eq(graphHolderContainer.startNode));
inOrder.verify(callback, times(1)).deleteNode(eq(graphHolderContainer.containerNode));
inOrder.verify(callback, times(1)).deleteCandidateNode(eq(graphHolderContainer.parentNode));
}
use of org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl in project kie-wb-common by kiegroup.
the class SafeDeleteNodeProcessorTest method testDeleteStartNode.
@Test
@SuppressWarnings("unchecked")
public void testDeleteStartNode() {
this.tested = new SafeDeleteNodeProcessor(new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()), graphHolder.graph, graphHolder.startNode);
tested.run(callback);
verify(callback, times(1)).deleteCandidateConnector(eq(graphHolder.edge1));
verify(callback, times(1)).removeChild(eq(graphHolder.parentNode), eq(graphHolder.startNode));
verify(callback, times(1)).deleteCandidateNode(eq(graphHolder.startNode));
verify(callback, never()).removeDock(any(Node.class), any(Node.class));
}
use of org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl in project kie-wb-common by kiegroup.
the class TreeExplorerTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(canvasHandler.getDiagram().getGraph()).thenReturn(graph);
when(diagram.getMetadata()).thenReturn(metadata);
when(metadata.getShapeSetId()).thenReturn(SHAPE_SET_ID);
when(textPropertyProviderFactory.getProvider(any(Element.class))).thenReturn(textPropertyProvider);
when(definitionUtils.getDefinitionManager()).thenReturn(definitionManager);
when(definitionManager.adapters()).thenReturn(adapterManager);
when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
when(definitionAdapter.getId(anyObject())).thenReturn("defId");
when(shapeManager.getShapeSet(eq(SHAPE_SET_ID))).thenReturn(shapeSet);
when(shapeSet.getShapeFactory()).thenReturn(shapeFactory);
when(shapeFactory.getGlyph(eq("defId"))).thenReturn(glyph);
when(domGlyphRenderers.render(eq(glyph), anyDouble(), anyDouble())).thenReturn(isElement);
this.childrenTraverseProcessor = spy(new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()));
this.testedTree = new TreeExplorer(childrenTraverseProcessor, textPropertyProviderFactory, elementSelectedEvent, definitionUtils, shapeManager, domGlyphRenderers, view) {
@Override
ElementWrapperWidget<?> wrapIconElement(final IsElement icon) {
return mock(ElementWrapperWidget.class);
}
};
}
Aggregations