use of org.kie.workbench.common.stunner.core.TestingGraphMockHandler in project kie-wb-common by kiegroup.
the class CloneCanvasNodeCommandTest method setUp.
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
super.setUp();
graphInstance = TestingGraphInstanceBuilder.newGraph2(new TestingGraphMockHandler());
graph = graphInstance.graph;
candidate = graphInstance.parentNode;
when(graphIndex.getGraph()).thenReturn(graphInstance.graph);
when(canvas.getShape(graphInstance.edge1.getUUID())).thenReturn(edgeShape);
when(canvas.getShape(graphInstance.edge2.getUUID())).thenReturn(edgeShape);
when(edgeShape.getShapeView()).thenReturn(shapeView);
when(childrenTraverseProcessorManagedInstance.get()).thenReturn(new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()));
this.cloneCanvasNodeCommand = new CloneCanvasNodeCommand(parent, candidate, SHAPE_SET_ID, childrenTraverseProcessorManagedInstance);
}
use of org.kie.workbench.common.stunner.core.TestingGraphMockHandler in project kie-wb-common by kiegroup.
the class DeleteElementsCommandTest method setup.
@Before
public void setup() throws Exception {
TestingGraphMockHandler graphHandler = new TestingGraphMockHandler();
this.graphHolder = TestingGraphInstanceBuilder.newGraph2(graphHandler);
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(canvasHandler.getCanvas()).thenReturn(canvas);
when(canvasHandler.getGraphIndex()).thenReturn(graphHandler.graphIndex);
when(canvasHandler.getGraphExecutionContext()).thenReturn(graphHandler.graphCommandExecutionContext);
when(diagram.getMetadata()).thenReturn(metadata);
when(diagram.getGraph()).thenReturn(graphHandler.graph);
when(metadata.getDefinitionSetId()).thenReturn(TestingGraphMockHandler.DEF_SET_ID);
when(metadata.getShapeSetId()).thenReturn(SHAPE_SET_ID);
when(metadata.getCanvasRootUUID()).thenReturn(graphHolder.parentNode.getUUID());
this.tested = new DeleteElementsCommand(Arrays.asList(graphHolder.startNode, graphHolder.intermNode, graphHolder.endNode));
}
use of org.kie.workbench.common.stunner.core.TestingGraphMockHandler in project kie-wb-common by kiegroup.
the class UpdateChildNodeCommandTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
TestingGraphMockHandler graphHandler = new TestingGraphMockHandler();
this.graphHolder = TestingGraphInstanceBuilder.newGraph2(graphHandler);
this.laneNode = graphHandler.newViewNode(LANE_UUID, Optional.empty(), 50, 59, 500, 500);
graphHandler.setChild(graphHolder.parentNode, laneNode);
this.dockNode = graphHandler.newViewNode(DOCK_UUID, Optional.empty(), 0, 0, 15, 15);
graphHandler.setChild(graphHolder.parentNode, dockNode);
graphHandler.dockTo(graphHolder.endNode, dockNode);
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(canvasHandler.getCanvas()).thenReturn(canvas);
when(canvasHandler.getGraphIndex()).thenReturn(graphHandler.graphIndex);
when(diagram.getMetadata()).thenReturn(metadata);
when(diagram.getGraph()).thenReturn(graphHandler.graph);
when(metadata.getDefinitionSetId()).thenReturn(TestingGraphMockHandler.DEF_SET_ID);
when(metadata.getShapeSetId()).thenReturn(SHAPE_SET_ID);
when(metadata.getCanvasRootUUID()).thenReturn(graphHolder.parentNode.getUUID());
this.tested = new UpdateChildNodeCommand(laneNode, graphHolder.endNode);
}
use of org.kie.workbench.common.stunner.core.TestingGraphMockHandler in project kie-wb-common by kiegroup.
the class EdgeFactoryImplTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
this.testingkHelper = new TestingGraphMockHandler();
when(testingkHelper.definitionAdapter.getId(eq(definition))).thenReturn(ID);
when(testingkHelper.definitionAdapter.getLabels(eq(definition))).thenReturn(LABELS);
this.tested = new EdgeFactoryImpl(testingkHelper.definitionManager);
}
use of org.kie.workbench.common.stunner.core.TestingGraphMockHandler in project kie-wb-common by kiegroup.
the class CanvasLayoutUtilsTest method getNextFromNewTaskWithNonEmptyPositionWithParent.
// TODO (AlessioP & Roger):
@Test
@Ignore
@SuppressWarnings("unchecked")
public void getNextFromNewTaskWithNonEmptyPositionWithParent() {
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(false);
this.graphTestHandlerParent = new TestingGraphMockHandler();
graphInstanceParent = TestingGraphInstanceBuilder.newGraph2(graphTestHandlerParent);
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(graphInstanceParent.graph);
when(graphBoundsIndexer.getAt(280.0, 100.0, 100.0, 100.0, graphInstanceParent.parentNode)).thenReturn(graphInstanceParent.intermNode);
graphInstanceParent.startNode.getOutEdges().clear();
Point2D next = canvasLayoutUtils.getNext(canvasHandler, graphInstanceParent.startNode, newNode);
Node<View<?>, Edge> intermNode = (Node<View<?>, Edge>) graphInstanceParent.intermNode;
double[] size = GraphUtils.getNodeSize(intermNode.getContent());
assertTrue(next.getX() == CanvasLayoutUtils.getPaddingX());
assertTrue(next.getY() > size[1]);
}
Aggregations