Search in sources :

Example 6 with TreeWalkTraverseProcessorImpl

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()));
}
Also used : ViewConnectorImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnectorImpl) Node(org.kie.workbench.common.stunner.core.graph.Node) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) ChildrenTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl) TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) TreeWalkTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl)

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

Example 8 with 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 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));
}
Also used : InOrder(org.mockito.InOrder) ChildrenTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl) TreeWalkTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl) Test(org.junit.Test)

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

Example 10 with TreeWalkTraverseProcessorImpl

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);
        }
    };
}
Also used : ElementWrapperWidget(org.jboss.errai.common.client.ui.ElementWrapperWidget) IsElement(org.jboss.errai.common.client.api.IsElement) IsElement(org.jboss.errai.common.client.api.IsElement) Element(org.kie.workbench.common.stunner.core.graph.Element) ChildrenTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl) TreeWalkTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl) Before(org.junit.Before)

Aggregations

TreeWalkTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl)18 ChildrenTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl)14 Node (org.kie.workbench.common.stunner.core.graph.Node)9 Before (org.junit.Before)7 Test (org.junit.Test)5 TestingGraphMockHandler (org.kie.workbench.common.stunner.core.TestingGraphMockHandler)5 Edge (org.kie.workbench.common.stunner.core.graph.Edge)5 Graph (org.kie.workbench.common.stunner.core.graph.Graph)4 View (org.kie.workbench.common.stunner.core.graph.content.view.View)4 DefinitionSet (org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Element (org.kie.workbench.common.stunner.core.graph.Element)2 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)2 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)2 ViewTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ViewTraverseProcessorImpl)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Optional (java.util.Optional)1 Set (java.util.Set)1