Search in sources :

Example 1 with UpdateDockNodeCommand

use of org.kie.workbench.common.stunner.core.client.canvas.command.UpdateDockNodeCommand in project kie-wb-common by kiegroup.

the class DockingAcceptorControlImplTest method setup.

@Before
public void setup() {
    when(canvas.getWiresManager()).thenReturn(wiresManager);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(canvasHandler.getCanvas()).thenReturn(canvas);
    when(canvasHandler.getAbstractCanvas()).thenReturn(canvas);
    doAnswer(invocationOnMock -> {
        final Node parent1 = (Node) invocationOnMock.getArguments()[0];
        final Node candidate1 = (Node) invocationOnMock.getArguments()[1];
        updateDockNodeCommand = new UpdateDockNodeCommand(parent1, candidate1);
        return updateDockNodeCommand;
    }).when(canvasCommandFactory).updateDockNode(any(Node.class), any(Node.class));
    when(commandManager.allow(eq(canvasHandler), eq(updateDockNodeCommand))).thenReturn(result);
    when(commandManager.execute(eq(canvasHandler), eq(updateDockNodeCommand))).thenReturn(result);
    this.tested = new DockingAcceptorControlImpl(canvasCommandFactory);
    this.tested.setCommandManagerProvider(() -> commandManager);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) UpdateDockNodeCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateDockNodeCommand) Before(org.junit.Before)

Example 2 with UpdateDockNodeCommand

use of org.kie.workbench.common.stunner.core.client.canvas.command.UpdateDockNodeCommand in project kie-wb-common by kiegroup.

the class ElementBuilderControlImplTest method getElementCommandsDocked.

@Test
public void getElementCommandsDocked() {
    ParentAssignment parentAssignment = ParentAssignment.DOCKING;
    elementBuilderControl.getElementCommands(node, parent, parentAssignment, X, Y, callback);
    verify(callback).onComplete(any(), commandsCapture.capture());
    List<Command<AbstractCanvasHandler, CanvasViolation>> commands = commandsCapture.getValue();
    assertTrue(commands.get(0) instanceof AddChildNodeCommand);
    assertTrue(commands.get(1) instanceof UpdateElementPositionCommand);
    assertTrue(commands.get(2) instanceof UpdateDockNodeCommand);
    verify(canvasCommandFactory).addChildNode(grandParent, node, SHAPE_SET_ID);
    ArgumentCaptor<Point2D> positionCaptor = ArgumentCaptor.forClass(Point2D.class);
    verify(canvasCommandFactory).updatePosition(eq(node), positionCaptor.capture());
    assertEquals(positionCaptor.getValue(), new Point2D(X, Y));
    verify(canvasCommandFactory).addChildNode(grandParent, node, SHAPE_SET_ID);
}
Also used : AddNodeCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AddNodeCommand) UpdateElementPositionCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand) UpdateDockNodeCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateDockNodeCommand) AddChildNodeCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AddChildNodeCommand) Command(org.kie.workbench.common.stunner.core.command.Command) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) ParentAssignment(org.kie.workbench.common.stunner.core.client.canvas.controls.builder.impl.AbstractElementBuilderControl.ParentAssignment) AddChildNodeCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AddChildNodeCommand) UpdateDockNodeCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateDockNodeCommand) UpdateElementPositionCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand) Test(org.junit.Test)

Aggregations

UpdateDockNodeCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateDockNodeCommand)2 Before (org.junit.Before)1 Test (org.junit.Test)1 AddChildNodeCommand (org.kie.workbench.common.stunner.core.client.canvas.command.AddChildNodeCommand)1 AddNodeCommand (org.kie.workbench.common.stunner.core.client.canvas.command.AddNodeCommand)1 UpdateElementPositionCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand)1 ParentAssignment (org.kie.workbench.common.stunner.core.client.canvas.controls.builder.impl.AbstractElementBuilderControl.ParentAssignment)1 Command (org.kie.workbench.common.stunner.core.command.Command)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)1