Search in sources :

Example 1 with ControlPointControl

use of org.kie.workbench.common.stunner.core.client.canvas.controls.connection.ControlPointControl in project kie-wb-common by kiegroup.

the class ControlPointControlImplTest method testStunnerControlPointsAcceptorMove.

@Test
public void testStunnerControlPointsAcceptorMove() {
    ControlPointControl control = mock(ControlPointControl.class);
    ControlPointControlImpl.StunnerControlPointsAcceptor acceptor = createStunnerControlPointsAcceptor(control);
    Point2DArray locationArray = new Point2DArray(new com.ait.lienzo.client.core.types.Point2D(0, 0), new com.ait.lienzo.client.core.types.Point2D(5, 5), new com.ait.lienzo.client.core.types.Point2D(10, 10));
    final boolean moveResult = acceptor.move(connector, locationArray);
    assertTrue(moveResult);
    ArgumentCaptor<ControlPoint[]> controlPointsExpected = ArgumentCaptor.forClass(ControlPoint[].class);
    verify(control, times(1)).updateControlPoints(eq(edge), controlPointsExpected.capture());
    ControlPoint[] cps = controlPointsExpected.getValue();
    assertNotNull(cps);
    assertEquals(1, cps.length);
    assertEquals(ControlPoint.build(5, 5), cps[0]);
}
Also used : Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint) ControlPointControl(org.kie.workbench.common.stunner.core.client.canvas.controls.connection.ControlPointControl) Test(org.junit.Test)

Example 2 with ControlPointControl

use of org.kie.workbench.common.stunner.core.client.canvas.controls.connection.ControlPointControl in project kie-wb-common by kiegroup.

the class DiagramEditorTest method testOpen.

@Test
@SuppressWarnings("unchecked")
public void testOpen() {
    tested.open(diagram, callback);
    assertEquals(diagram, tested.getInstance());
    verify(viewer, times(1)).open(eq(diagram), any(DiagramViewer.DiagramViewerCallback.class));
    verify(locationControlInstance, times(1)).init(eq(canvasHandler));
    verify(resizeControlInstance, times(1)).init(eq(canvasHandler));
    verify(builderControlInstance, times(1)).init(eq(canvasHandler));
    verify(nodeBuilderControlInstance, times(1)).init(eq(canvasHandler));
    verify(edgeBuilderControlInstance, times(1)).init(eq(canvasHandler));
    verify(cpControlInstance, times(1)).init(eq(canvasHandler));
    verify(connectionAcceptorControlInstance, times(1)).init(eq(canvasHandler));
    verify(containmentAcceptorControlInstance, times(1)).init(eq(canvasHandler));
    verify(dockingAcceptorControlInstance, times(1)).init(eq(canvasHandler));
    ArgumentCaptor<CanvasElementListener> elementListenerArgumentCaptor = ArgumentCaptor.forClass(CanvasElementListener.class);
    verify(canvasHandler, times(1)).addRegistrationListener(elementListenerArgumentCaptor.capture());
    DefaultCanvasElementListener elementListener = (DefaultCanvasElementListener) elementListenerArgumentCaptor.getValue();
    Iterator<CanvasControl<AbstractCanvasHandler>> canvasHandlerControls1 = elementListener.getCanvasControls().iterator();
    assertTrue(canvasHandlerControls1.next() instanceof LocationControl);
    assertTrue(canvasHandlerControls1.next() instanceof ResizeControl);
    assertTrue(canvasHandlerControls1.next() instanceof ElementBuilderControl);
    assertTrue(canvasHandlerControls1.next() instanceof NodeBuilderControl);
    assertTrue(canvasHandlerControls1.next() instanceof EdgeBuilderControl);
    assertTrue(canvasHandlerControls1.next() instanceof ControlPointControl);
    assertTrue(canvasHandlerControls1.next() instanceof ContainmentAcceptorControl);
    assertTrue(canvasHandlerControls1.next() instanceof ConnectionAcceptorControl);
    assertTrue(canvasHandlerControls1.next() instanceof DockingAcceptorControl);
    assertFalse(canvasHandlerControls1.hasNext());
}
Also used : EdgeBuilderControl(org.kie.workbench.common.stunner.core.client.canvas.controls.builder.EdgeBuilderControl) ResizeControl(org.kie.workbench.common.stunner.core.client.canvas.controls.ResizeControl) CanvasElementListener(org.kie.workbench.common.stunner.core.client.canvas.listener.CanvasElementListener) DefaultCanvasElementListener(org.kie.workbench.common.stunner.core.client.session.impl.DefaultCanvasElementListener) ControlPointControl(org.kie.workbench.common.stunner.core.client.canvas.controls.connection.ControlPointControl) ConnectionAcceptorControl(org.kie.workbench.common.stunner.core.client.canvas.controls.connection.ConnectionAcceptorControl) ContainmentAcceptorControl(org.kie.workbench.common.stunner.core.client.canvas.controls.ContainmentAcceptorControl) LocationControl(org.kie.workbench.common.stunner.core.client.canvas.controls.LocationControl) DefaultCanvasElementListener(org.kie.workbench.common.stunner.core.client.session.impl.DefaultCanvasElementListener) NodeBuilderControl(org.kie.workbench.common.stunner.core.client.canvas.controls.builder.NodeBuilderControl) CanvasControl(org.kie.workbench.common.stunner.core.client.canvas.controls.CanvasControl) ElementBuilderControl(org.kie.workbench.common.stunner.core.client.canvas.controls.builder.ElementBuilderControl) DockingAcceptorControl(org.kie.workbench.common.stunner.core.client.canvas.controls.DockingAcceptorControl) AbstractCanvasHandlerViewerTest(org.kie.workbench.common.stunner.client.widgets.presenters.AbstractCanvasHandlerViewerTest) Test(org.junit.Test)

Example 3 with ControlPointControl

use of org.kie.workbench.common.stunner.core.client.canvas.controls.connection.ControlPointControl in project kie-wb-common by kiegroup.

the class ControlPointControlImplTest method testStunnerControlPointsAcceptorDelete.

@Test
public void testStunnerControlPointsAcceptorDelete() {
    ControlPointControl control = mock(ControlPointControl.class);
    ControlPointControlImpl.StunnerControlPointsAcceptor acceptor = createStunnerControlPointsAcceptor(control);
    final boolean deleteResult = acceptor.delete(connector, 1);
    assertTrue(deleteResult);
    verify(control, times(1)).deleteControlPoint(eq(edge), eq(0));
}
Also used : ControlPointControl(org.kie.workbench.common.stunner.core.client.canvas.controls.connection.ControlPointControl) Test(org.junit.Test)

Example 4 with ControlPointControl

use of org.kie.workbench.common.stunner.core.client.canvas.controls.connection.ControlPointControl in project kie-wb-common by kiegroup.

the class ControlPointControlImplTest method testStunnerControlPointsAcceptorAdd.

@Test
public void testStunnerControlPointsAcceptorAdd() {
    final HandlerRegistration mouseUpHandlerRegistration = mock(HandlerRegistration.class);
    final NodeMouseUpHandler[] mouseUpHandlerCaptured = new NodeMouseUpHandler[1];
    doAnswer(invocationOnMock -> {
        mouseUpHandlerCaptured[0] = (NodeMouseUpHandler) invocationOnMock.getArguments()[0];
        mouseUpHandlerCaptured[0].onNodeMouseUp(mock(NodeMouseUpEvent.class));
        return mouseUpHandlerRegistration;
    }).when(layer).addNodeMouseUpHandler(any(NodeMouseUpHandler.class));
    ControlPointControl control = mock(ControlPointControl.class);
    ControlPointControlImpl.StunnerControlPointsAcceptor acceptor = createStunnerControlPointsAcceptor(control);
    boolean addResult = acceptor.add(connector, 1, new com.ait.lienzo.client.core.types.Point2D(2, 2));
    assertTrue(addResult);
    verify(connector, times(1)).addControlPoint(eq(2d), eq(2d), eq(1));
    verify(control, times(1)).addControlPoint(eq(edge), eq(ControlPoint.build(2, 2)), eq(0));
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) NodeMouseUpEvent(com.ait.lienzo.client.core.event.NodeMouseUpEvent) ControlPointControl(org.kie.workbench.common.stunner.core.client.canvas.controls.connection.ControlPointControl) NodeMouseUpHandler(com.ait.lienzo.client.core.event.NodeMouseUpHandler) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 ControlPointControl (org.kie.workbench.common.stunner.core.client.canvas.controls.connection.ControlPointControl)4 NodeMouseUpEvent (com.ait.lienzo.client.core.event.NodeMouseUpEvent)1 NodeMouseUpHandler (com.ait.lienzo.client.core.event.NodeMouseUpHandler)1 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)1 HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)1 AbstractCanvasHandlerViewerTest (org.kie.workbench.common.stunner.client.widgets.presenters.AbstractCanvasHandlerViewerTest)1 CanvasControl (org.kie.workbench.common.stunner.core.client.canvas.controls.CanvasControl)1 ContainmentAcceptorControl (org.kie.workbench.common.stunner.core.client.canvas.controls.ContainmentAcceptorControl)1 DockingAcceptorControl (org.kie.workbench.common.stunner.core.client.canvas.controls.DockingAcceptorControl)1 LocationControl (org.kie.workbench.common.stunner.core.client.canvas.controls.LocationControl)1 ResizeControl (org.kie.workbench.common.stunner.core.client.canvas.controls.ResizeControl)1 EdgeBuilderControl (org.kie.workbench.common.stunner.core.client.canvas.controls.builder.EdgeBuilderControl)1 ElementBuilderControl (org.kie.workbench.common.stunner.core.client.canvas.controls.builder.ElementBuilderControl)1 NodeBuilderControl (org.kie.workbench.common.stunner.core.client.canvas.controls.builder.NodeBuilderControl)1 ConnectionAcceptorControl (org.kie.workbench.common.stunner.core.client.canvas.controls.connection.ConnectionAcceptorControl)1 CanvasElementListener (org.kie.workbench.common.stunner.core.client.canvas.listener.CanvasElementListener)1 DefaultCanvasElementListener (org.kie.workbench.common.stunner.core.client.session.impl.DefaultCanvasElementListener)1 ControlPoint (org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint)1