Search in sources :

Example 1 with ILocationAcceptor

use of com.ait.lienzo.client.core.shape.wires.ILocationAcceptor in project kie-wb-common by kiegroup.

the class LocationControlImplTest method testLocationAcceptor.

@Test
@SuppressWarnings("unchecked")
public void testLocationAcceptor() {
    tested.enable(canvasHandler);
    tested.register(element);
    ArgumentCaptor<ILocationAcceptor> locationAcceptorArgumentCaptor = ArgumentCaptor.forClass(ILocationAcceptor.class);
    verify(wiresManager, times(1)).setLocationAcceptor(locationAcceptorArgumentCaptor.capture());
    final ILocationAcceptor locationAcceptor = locationAcceptorArgumentCaptor.getValue();
    final WiresShapeView wiresContainer = mock(WiresShapeView.class);
    when(wiresContainer.getUUID()).thenReturn(ELEMENT_UUID);
    final com.ait.lienzo.client.core.types.Point2D point = new com.ait.lienzo.client.core.types.Point2D(40d, 50d);
    locationAcceptor.accept(new WiresContainer[] { wiresContainer }, new com.ait.lienzo.client.core.types.Point2D[] { point });
    ArgumentCaptor<CanvasCommand> commandArgumentCaptor = ArgumentCaptor.forClass(CanvasCommand.class);
    verify(commandManager, times(1)).execute(eq(canvasHandler), commandArgumentCaptor.capture());
    final UpdateElementPositionCommand command = (UpdateElementPositionCommand) commandArgumentCaptor.getValue();
    assertEquals(element, command.getElement());
    assertEquals(new Point2D(40d, 50d), command.getLocation());
}
Also used : ILocationAcceptor(com.ait.lienzo.client.core.shape.wires.ILocationAcceptor) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) WiresShapeView(org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresShapeView) UpdateElementPositionCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand) CanvasCommand(org.kie.workbench.common.stunner.core.client.command.CanvasCommand) Test(org.junit.Test)

Aggregations

ILocationAcceptor (com.ait.lienzo.client.core.shape.wires.ILocationAcceptor)1 Test (org.junit.Test)1 WiresShapeView (org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresShapeView)1 UpdateElementPositionCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand)1 CanvasCommand (org.kie.workbench.common.stunner.core.client.command.CanvasCommand)1 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)1