use of org.kie.workbench.common.stunner.core.graph.Edge in project kie-wb-common by kiegroup.
the class CanvasLayoutUtilsTest method getNextFromRootWithParent.
@Test
@SuppressWarnings("unchecked")
public void getNextFromRootWithParent() {
this.graphTestHandlerParent = new TestingGraphMockHandler();
graphInstanceParent = TestingGraphInstanceBuilder.newGraph2(graphTestHandlerParent);
Node node = mock(Node.class);
Bounds boundsNode = new BoundsImpl(new BoundImpl(100d, 100d), new BoundImpl(300d, 200d));
View viewNode = mock(View.class);
when(node.getContent()).thenReturn(viewNode);
when(viewNode.getBounds()).thenReturn(boundsNode);
when(canvasHandler.getDiagram().getGraph()).thenReturn(graphInstanceParent.graph);
Point2D next = canvasLayoutUtils.getNext(canvasHandler, graphInstanceParent.startNode, node);
Node<View<?>, Edge> start = (Node<View<?>, Edge>) graphInstanceParent.startNode;
double[] size = GraphUtils.getNodeSize(start.getContent());
assertTrue(next.getX() == CanvasLayoutUtils.getPaddingX());
assertTrue(next.getY() > size[1]);
}
use of org.kie.workbench.common.stunner.core.graph.Edge in project kie-wb-common by kiegroup.
the class CanvasLayoutUtilsTest method getNextNewTaskWithNonEmptyPosition.
// TODO (AlessioP & Roger):
@Test
@Ignore
@SuppressWarnings("unchecked")
public void getNextNewTaskWithNonEmptyPosition() {
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 newNode = mock(Node.class);
Bounds boundsNewNode = new BoundsImpl(new BoundImpl(200d, 300d), new BoundImpl(300d, 400d));
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, 100.0, 100.0, null)).thenReturn(graphInstance.intermNode);
graphInstance.startNode.getOutEdges().clear();
Point2D next = canvasLayoutUtils.getNext(canvasHandler, graphInstance.startNode, newNode);
Node<View<?>, Edge> startNode = (Node<View<?>, Edge>) graphInstance.startNode;
double[] sizeStartNode = GraphUtils.getNodeSize(startNode.getContent());
Node<View<?>, Edge> intermNode = (Node<View<?>, Edge>) graphInstance.intermNode;
double[] sizeIntermNode = GraphUtils.getNodeSize(intermNode.getContent());
assertTrue(next.getX() == sizeStartNode[0] + CanvasLayoutUtils.getPaddingX());
assertTrue(next.getY() > sizeIntermNode[1]);
}
use of org.kie.workbench.common.stunner.core.graph.Edge in project kie-wb-common by kiegroup.
the class AbstractGraphCommandTest method mockEdge.
public static Edge mockEdge(String uuid) {
Edge edge = mock(Edge.class);
when(edge.getUUID()).thenReturn(uuid);
when(edge.asEdge()).thenReturn(edge);
return edge;
}
use of org.kie.workbench.common.stunner.core.graph.Edge in project kie-wb-common by kiegroup.
the class DeleteConnectorCommandTest method testExecute.
@Test
@SuppressWarnings("unchecked")
public void testExecute() {
final List sourceOutEdges = mock(List.class);
final List targetInEdges = mock(List.class);
when(source.getOutEdges()).thenReturn(sourceOutEdges);
when(target.getInEdges()).thenReturn(targetInEdges);
CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext);
assertEquals(CommandResult.Type.INFO, result.getType());
verify(sourceOutEdges, times(1)).remove(eq(edge));
verify(targetInEdges, times(1)).remove(eq(edge));
verify(graphIndex, times(1)).removeEdge(eq(edge));
verify(graphIndex, times(0)).addEdge(any(Edge.class));
verify(graphIndex, times(0)).addNode(any(Node.class));
verify(graphIndex, times(0)).removeNode(any(Node.class));
}
use of org.kie.workbench.common.stunner.core.graph.Edge in project kie-wb-common by kiegroup.
the class DockNodeCommandTest method testExecute.
@Test
@SuppressWarnings("unchecked")
public void testExecute() {
CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext);
assertEquals(CommandResult.Type.INFO, result.getType());
assertFalse(parent.getOutEdges().isEmpty());
assertFalse(candidate.getInEdges().isEmpty());
Edge edge = (Edge) parent.getOutEdges().get(0);
assertTrue(edge.getContent() instanceof Dock);
assertEquals(parent, edge.getSourceNode());
assertEquals(candidate, edge.getTargetNode());
verify(graphIndex, times(1)).addEdge(eq(edge));
verify(graphIndex, times(0)).addNode(any(Node.class));
}
Aggregations