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()));
}
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));
}
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;
}
Aggregations