Search in sources :

Example 1 with TestingGraphMockHandler

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);
}
Also used : ChildrenTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl) TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) TreeWalkTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl) Before(org.junit.Before)

Example 2 with TestingGraphMockHandler

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));
}
Also used : TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) Before(org.junit.Before)

Example 3 with TestingGraphMockHandler

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);
}
Also used : TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) Before(org.junit.Before)

Example 4 with TestingGraphMockHandler

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);
}
Also used : TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) Before(org.junit.Before)

Example 5 with TestingGraphMockHandler

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]);
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) Node(org.kie.workbench.common.stunner.core.graph.Node) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) RuleEvaluationContext(org.kie.workbench.common.stunner.core.rule.RuleEvaluationContext) TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

TestingGraphMockHandler (org.kie.workbench.common.stunner.core.TestingGraphMockHandler)26 Before (org.junit.Before)21 Node (org.kie.workbench.common.stunner.core.graph.Node)6 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)6 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)6 Test (org.junit.Test)5 Edge (org.kie.workbench.common.stunner.core.graph.Edge)5 TreeWalkTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl)5 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)4 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)4 View (org.kie.workbench.common.stunner.core.graph.content.view.View)4 Ignore (org.junit.Ignore)3 ChildrenTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl)3 RuleEvaluationContext (org.kie.workbench.common.stunner.core.rule.RuleEvaluationContext)3 LocalClipboardControl (org.kie.workbench.common.stunner.core.client.canvas.controls.clipboard.LocalClipboardControl)2 HashMap (java.util.HashMap)1 Optional (java.util.Optional)1 RunWith (org.junit.runner.RunWith)1 TestingGraphInstanceBuilder (org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder)1 ControlPointImpl (org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl)1