use of org.kie.workbench.common.stunner.core.TestingGraphMockHandler 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.TestingGraphMockHandler 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.TestingGraphMockHandler 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.TestingGraphMockHandler in project kie-wb-common by kiegroup.
the class SafeDeleteNodeCommandTest method setup.
@Before
public void setup() throws Exception {
this.graphTestHandler = new TestingGraphMockHandler();
this.graphHolder = TestingGraphInstanceBuilder.newGraph2(graphTestHandler);
}
use of org.kie.workbench.common.stunner.core.TestingGraphMockHandler in project kie-wb-common by kiegroup.
the class GraphUtilsTest method setup.
@Before
public void setup() {
this.graphTestHandler = new TestingGraphMockHandler();
graphInstance = TestingGraphInstanceBuilder.newGraph2(graphTestHandler);
}
Aggregations