Search in sources :

Example 1 with LocalClipboardControl

use of org.kie.workbench.common.stunner.core.client.canvas.controls.clipboard.LocalClipboardControl 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 2 with LocalClipboardControl

use of org.kie.workbench.common.stunner.core.client.canvas.controls.clipboard.LocalClipboardControl 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

Before (org.junit.Before)2 TestingGraphMockHandler (org.kie.workbench.common.stunner.core.TestingGraphMockHandler)2 LocalClipboardControl (org.kie.workbench.common.stunner.core.client.canvas.controls.clipboard.LocalClipboardControl)2 HashMap (java.util.HashMap)1 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)1 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)1