Search in sources :

Example 11 with TestingGraphMockHandler

use of org.kie.workbench.common.stunner.core.TestingGraphMockHandler in project kie-wb-common by kiegroup.

the class SafeDeleteNodeProcessorTest method setup.

@Before
public void setup() throws Exception {
    this.graphTestHandler = new TestingGraphMockHandler();
    this.graphTestHandlerContainer = new TestingGraphMockHandler();
    this.graphHolder = TestingGraphInstanceBuilder.newGraph2(graphTestHandler);
    this.graphHolderContainer = TestingGraphInstanceBuilder.newGraph3(graphTestHandlerContainer);
}
Also used : TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) Before(org.junit.Before)

Example 12 with TestingGraphMockHandler

use of org.kie.workbench.common.stunner.core.TestingGraphMockHandler in project kie-wb-common by kiegroup.

the class BPMNProcessVariableDeleteHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    assignmentsInfoString = PROPERTY_ID_INPUT + "," + PROPERTY_ID_OUTPUT;
    bpmnProcessVariableDeleteHandler = new BPMNProcessVariableDeleteHandler();
    this.graphTestHandler = new TestingGraphMockHandler();
    graphInstance = TestingGraphInstanceBuilder.newGraph2(graphTestHandler);
    when(userTask.getExecutionSet()).thenReturn(userTaskExecutionSet);
    when(userTask.getExecutionSet().getAssignmentsinfo()).thenReturn(assignmentsInfo);
    when(userTask.getExecutionSet().getAssignmentsinfo().getValue()).thenReturn(assignmentsInfoString);
    when(businessRuleTask.getDataIOSet()).thenReturn(businessRuleDataIOSet);
    when(businessRuleTask.getDataIOSet().getAssignmentsinfo()).thenReturn(assignmentsInfo);
    when(businessRuleTask.getDataIOSet().getAssignmentsinfo().getValue()).thenReturn(assignmentsInfoString);
    graphInstance.intermNode.setContent(definition);
}
Also used : TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) Before(org.junit.Before)

Example 13 with TestingGraphMockHandler

use of org.kie.workbench.common.stunner.core.TestingGraphMockHandler 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());
}
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)

Example 14 with TestingGraphMockHandler

use of org.kie.workbench.common.stunner.core.TestingGraphMockHandler in project kie-wb-common by kiegroup.

the class CopySelectionSessionCommandTest method setUp.

@Before
public void setUp() throws Exception {
    eventArgumentCaptor = ArgumentCaptor.forClass(CopySelectionSessionCommandExecutedEvent.class);
    clipboardControl = spy(new LocalClipboardControl());
    super.setup();
    TestingGraphMockHandler graphMockHandler = new TestingGraphMockHandler();
    this.graphInstance = TestingGraphInstanceBuilder.newGraph2(graphMockHandler);
    this.copySelectionSessionCommand = getCommand();
    node = graphInstance.startNode;
    when(session.getSelectionControl()).thenReturn(selectionControl);
    when(selectionControl.getSelectedItems()).thenReturn(Arrays.asList(node.getUUID()));
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(canvasHandler.getGraphIndex()).thenReturn(graphMockHandler.graphIndex);
    when(session.getClipboardControl()).thenReturn(clipboardControl);
}
Also used : TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) LocalClipboardControl(org.kie.workbench.common.stunner.core.client.canvas.controls.clipboard.LocalClipboardControl) Before(org.junit.Before)

Example 15 with TestingGraphMockHandler

use of org.kie.workbench.common.stunner.core.TestingGraphMockHandler 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();
}
Also used : HashMap(java.util.HashMap) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) LocalClipboardControl(org.kie.workbench.common.stunner.core.client.canvas.controls.clipboard.LocalClipboardControl) Before(org.junit.Before)

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