use of org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl in project kie-wb-common by kiegroup.
the class CaseManagementCanvasHandlerTest method makeNode.
@SuppressWarnings("unchecked")
private Node<View<BPMNViewDefinition>, Edge> makeNode(final String uuid, final AbstractElementShape shape) {
final Node<View<BPMNViewDefinition>, Edge> node = new NodeImpl<>(uuid);
node.setContent(new ViewImpl(shape.getShapeDefinition(), new BoundsImpl(new BoundImpl(0.0, 0.0), new BoundImpl(10.0, 20.0))));
when(canvas.getShape(eq(uuid))).thenReturn(shape);
when(clientDefinitionManager.adapters()).thenReturn(adapterManager);
when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
when(adapterManager.forProperty()).thenReturn(propertyAdapter);
when(definitionAdapter.getMetaProperty(eq(PropertyMetaTypes.NAME), anyObject())).thenReturn(PropertyMetaTypes.NAME);
when(propertyAdapter.getValue(eq(PropertyMetaTypes.NAME))).thenReturn("name");
return node;
}
use of org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl in project kie-wb-common by kiegroup.
the class CanvasLayoutUtilsTest method getNextFromRoot.
// TODO (AlessioP & Roger):
@Test
@Ignore
@SuppressWarnings("unchecked")
public void getNextFromRoot() {
Node node1 = mock(Node.class);
Bounds boundsNode1 = new BoundsImpl(new BoundImpl(100d, 100d), new BoundImpl(300d, 200d));
View viewNode1 = mock(View.class);
when(node1.getContent()).thenReturn(viewNode1);
when(viewNode1.getBounds()).thenReturn(boundsNode1);
Node node2 = mock(Node.class);
Bounds boundsNode2 = new BoundsImpl(new BoundImpl(100d, 100d), new BoundImpl(300d, 200d));
View viewNode2 = mock(View.class);
when(node2.getContent()).thenReturn(viewNode2);
when(viewNode2.getBounds()).thenReturn(boundsNode2);
Node nodeRoot = mock(Node.class);
double rootWidth = 40d;
double rootHeight = 40d;
Bounds rootBounds = new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(rootWidth, rootHeight));
View rootView = mock(View.class);
when(nodeRoot.getContent()).thenReturn(rootView);
when(rootView.getBounds()).thenReturn(rootBounds);
List<Node> nodes = new ArrayList<>();
List<Edge> edges = new ArrayList<>();
Edge edge = mock(Edge.class);
edges.add(edge);
when(nodeRoot.getOutEdges()).thenReturn(edges);
when(edge.getTargetNode()).thenReturn(node1);
when(nodeRoot.getContent()).thenReturn(rootView);
nodes.add(nodeRoot);
when(graph.nodes()).thenReturn(nodes);
when(node2.getInEdges()).thenReturn(edges);
when(nodeRoot.asNode()).thenReturn(nodeRoot);
Point2D next = canvasLayoutUtils.getNext(canvasHandler, nodeRoot, node2);
assertTrue(next.getX() > rootWidth);
assertTrue(next.getY() > NEW_NODE_HEIGHT);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl in project kie-wb-common by kiegroup.
the class CanvasLayoutUtilsTest method getNextOutOfCanvas.
// TODO (AlessioP & Roger):
@Test
@Ignore
@SuppressWarnings("unchecked")
public void getNextOutOfCanvas() {
when(ruleManager.evaluate(eq(ruleSet), any(RuleEvaluationContext.class))).thenReturn(ruleViolations);
when(ruleViolations.violations(Violation.Type.ERROR)).thenReturn(ruleViolationIterable);
when(ruleViolations.violations(Violation.Type.ERROR).iterator()).thenReturn(ruleViolationIterator);
when(ruleViolations.violations(Violation.Type.ERROR).iterator().hasNext()).thenReturn(true);
this.graphTestHandler = new TestingGraphMockHandler();
graphInstance = TestingGraphInstanceBuilder.newGraph1(graphTestHandler);
Node node = mock(Node.class);
Bounds boundsNode = new BoundsImpl(new BoundImpl(100d, 0d), new BoundImpl(300d, 1400d));
View viewNode = mock(View.class);
when(node.getContent()).thenReturn(viewNode);
when(viewNode.getBounds()).thenReturn(boundsNode);
Node newNode = mock(Node.class);
Bounds boundsNewNode = new BoundsImpl(new BoundImpl(100d, 200d), new BoundImpl(300d, 300d));
View viewNewNode = mock(View.class);
when(newNode.getContent()).thenReturn(viewNewNode);
when(viewNewNode.getBounds()).thenReturn(boundsNewNode);
when(canvasHandler.getDiagram().getGraph()).thenReturn(graphInstance.graph);
when(graphBoundsIndexer.getAt(140.0, 0.0, 200.0, 100.0, null)).thenReturn(node);
graphInstance.startNode.getOutEdges().clear();
Point2D next = canvasLayoutUtils.getNext(canvasHandler, graphInstance.startNode, newNode);
Node<View<?>, Edge> intermNode = (Node<View<?>, Edge>) graphInstance.intermNode;
double[] size = GraphUtils.getNodeSize(intermNode.getContent());
assertTrue(next.getX() > size[0]);
assertTrue(next.getY() == CanvasLayoutUtils.getPaddingY());
}
use of org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl in project kie-wb-common by kiegroup.
the class PasteSelectionSessionCommandTest method setUp.
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
clipboardControl = spy(new LocalClipboardControl());
TestingGraphMockHandler graphMockHandler = new TestingGraphMockHandler();
this.graphInstance = TestingGraphInstanceBuilder.newGraph2(graphMockHandler);
node = graphInstance.startNode;
node.setContent(view);
node2 = graphInstance.intermNode;
node2.setContent(view);
when(session.getCanvasHandler()).thenReturn(canvasHandler);
when(canvasHandler.getGraphIndex()).thenReturn(graphMockHandler.graphIndex);
when(view.getBounds()).thenReturn(new BoundsImpl(new BoundImpl(X, Y), new BoundImpl(X + NODE_SIZE, Y + NODE_SIZE)));
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(diagram.getMetadata()).thenReturn(metadata);
when(metadata.getCanvasRootUUID()).thenReturn(CANVAS_UUID);
when(sessionCommandManager.execute(eq(canvasHandler), any())).thenReturn(commandResult);
when(sessionCommandManager.execute(canvasHandler, cloneConnectorCommand)).thenReturn(commandResultConnector);
when(commandResult.getType()).thenReturn(CommandResult.Type.INFO);
when(commandResultConnector.getType()).thenReturn(CommandResult.Type.INFO);
when(clone.getUUID()).thenReturn(CLONE_UUID);
when(clone2.getUUID()).thenReturn(CLONE2_UUID);
when(session.getClipboardControl()).thenReturn(clipboardControl);
when(sessionCommandFactory.newCopySelectionCommand()).thenReturn(copySelectionSessionCommand);
when(sessionCommandManager.getRegistry()).thenReturn(commandRegistry);
cloneMap = new HashMap() {
{
put(node, clone);
put(node2, clone2);
}
};
super.setup();
this.pasteSelectionSessionCommand = getCommand();
}
use of org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl 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));
}
Aggregations