Search in sources :

Example 1 with ViewConnectorImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ViewConnectorImpl 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 2 with ViewConnectorImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ViewConnectorImpl in project kie-wb-common by kiegroup.

the class ConnectorShapeTest method testApplyConnections.

@Test
@SuppressWarnings("unchecked")
public void testApplyConnections() {
    final Object def = mock(Object.class);
    final Edge<ViewConnector<Object>, Node> edge = new EdgeImpl<>("uuid1");
    final ViewConnectorImpl<Object> content = new ViewConnectorImpl<>(def, new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(15d, 40d)));
    Connection sourceConnection = mock(Connection.class);
    Connection targetConnection = mock(Connection.class);
    content.setSourceConnection(sourceConnection);
    content.setTargetConnection(targetConnection);
    edge.setContent(content);
    final ShapeView<?> source = mock(ShapeView.class);
    final ShapeView<?> target = mock(ShapeView.class);
    tested.applyConnections(edge, source, target, MutationContext.STATIC);
    verify(((IsConnector) shapeView), times(1)).connect(eq(source), eq(sourceConnection), eq(target), eq(targetConnection));
}
Also used : ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) 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) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Test(org.junit.Test)

Example 3 with ViewConnectorImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ViewConnectorImpl in project kie-wb-common by kiegroup.

the class EdgeFactoryImpl method build.

@Override
@SuppressWarnings("unchecked")
public Edge<Definition<Object>, Node> build(final String uuid, final Object definition) {
    final EdgeImpl edge = new EdgeImpl<>(uuid);
    if (null != definition) {
        ViewConnector<Object> content = new ViewConnectorImpl<>(definition, buildBounds());
        edge.setContent(content);
        addLabels(edge.getLabels(), definition);
    }
    return edge;
}
Also used : ViewConnectorImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnectorImpl) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl)

Aggregations

ViewConnectorImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnectorImpl)3 Node (org.kie.workbench.common.stunner.core.graph.Node)2 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)2 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)2 EdgeImpl (org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl)2 Test (org.junit.Test)1 TestingGraphMockHandler (org.kie.workbench.common.stunner.core.TestingGraphMockHandler)1 Connection (org.kie.workbench.common.stunner.core.graph.content.view.Connection)1 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)1 ChildrenTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl)1 TreeWalkTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl)1