Search in sources :

Example 1 with MoveDividerControlHandle

use of org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle in project kie-wb-common by kiegroup.

the class DecisionServiceSVGShapeViewTest method testDragConstraintHandler.

@Test
@SuppressWarnings("unchecked")
public void testDragConstraintHandler() {
    final MoveDividerControlHandle moveDividerControlHandle = getMoveDividerControlHandle();
    final IPrimitive control = moveDividerControlHandle.getControl();
    when(dragContext.getNode()).thenReturn(control);
    final MoveDividerDragHandler dragConstraints = (MoveDividerDragHandler) getMoveDividerControlHandle().getControl().getDragConstraints();
    dragConstraints.startDrag(dragContext);
    final DragBounds dragBounds = control.getDragBounds();
    assertThat(dragBounds.getX1()).isEqualTo(0.0);
    assertThat(dragBounds.getY1()).isEqualTo(GeneralRectangleDimensionsSet.DEFAULT_HEIGHT);
    assertThat(dragBounds.getX2()).isEqualTo(WIDTH);
    assertThat(dragBounds.getY2()).isEqualTo(HEIGHT - GeneralRectangleDimensionsSet.DEFAULT_HEIGHT);
}
Also used : IPrimitive(com.ait.lienzo.client.core.shape.IPrimitive) DragBounds(com.ait.lienzo.client.core.types.DragBounds) MoveDividerDragHandler(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerDragHandler) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) Test(org.junit.Test)

Example 2 with MoveDividerControlHandle

use of org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle in project kie-wb-common by kiegroup.

the class DecisionServiceSVGShapeViewTest method testShapeControlResizeHandles.

@Test
public void testShapeControlResizeHandles() {
    final IControlHandleFactory controlHandleFactory = view.getPath().getControlHandleFactory();
    final IControlHandleList controlHandles = controlHandleFactory.getControlHandles(Collections.singletonList(RESIZE)).get(RESIZE);
    assertThat(controlHandles.size()).isGreaterThan(0);
    assertThat(controlHandles).areExactly(1, new Condition<>(ch -> ch instanceof MoveDividerControlHandle, "Is a MoveDividerControlHandle"));
}
Also used : NodeDragStartEvent(com.ait.lienzo.client.core.event.NodeDragStartEvent) WiresResizeStepEvent(com.ait.lienzo.client.core.shape.wires.event.WiresResizeStepEvent) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) NodeDragEndEvent(com.ait.lienzo.client.core.event.NodeDragEndEvent) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) Shape(com.ait.lienzo.client.core.shape.Shape) Attribute(com.ait.lienzo.client.core.Attribute) DragEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.DragEvent) DragBounds(com.ait.lienzo.client.core.types.DragBounds) SVGPrimitiveShape(org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitiveShape) Attributes(com.ait.lienzo.client.core.shape.Attributes) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) NodeDragMoveEvent(com.ait.lienzo.client.core.event.NodeDragMoveEvent) DragHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.DragHandler) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList) HandlerManager(com.google.gwt.event.shared.HandlerManager) StreamSupport(java.util.stream.StreamSupport) RESIZE(com.ait.lienzo.client.core.shape.wires.IControlHandle.ControlHandleStandardType.RESIZE) Node(com.ait.lienzo.client.core.shape.Node) Before(org.junit.Before) MoveDividerDragHandler(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerDragHandler) IControlHandleFactory(com.ait.lienzo.client.core.shape.wires.IControlHandleFactory) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) DragContext(com.ait.lienzo.client.widget.DragContext) IPrimitive(com.ait.lienzo.client.core.shape.IPrimitive) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) Condition(org.assertj.core.api.Condition) Collections(java.util.Collections) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList) IControlHandleFactory(com.ait.lienzo.client.core.shape.wires.IControlHandleFactory) Test(org.junit.Test)

Example 3 with MoveDividerControlHandle

use of org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle in project kie-wb-common by kiegroup.

the class DecisionServiceSVGShapeViewTest method testShapeControlResizeHandlersWithList.

@Test
public void testShapeControlResizeHandlersWithList() {
    final IControlHandleFactory controlHandleFactory = view.getPath().getControlHandleFactory();
    final IControlHandleList controlHandles = controlHandleFactory.getControlHandles(RESIZE).get(RESIZE);
    assertThat(controlHandles.size()).isGreaterThan(0);
    assertThat(controlHandles).areExactly(1, new Condition<>(ch -> ch instanceof MoveDividerControlHandle, "Is a MoveDividerControlHandle"));
}
Also used : NodeDragStartEvent(com.ait.lienzo.client.core.event.NodeDragStartEvent) WiresResizeStepEvent(com.ait.lienzo.client.core.shape.wires.event.WiresResizeStepEvent) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) NodeDragEndEvent(com.ait.lienzo.client.core.event.NodeDragEndEvent) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) Shape(com.ait.lienzo.client.core.shape.Shape) Attribute(com.ait.lienzo.client.core.Attribute) DragEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.DragEvent) DragBounds(com.ait.lienzo.client.core.types.DragBounds) SVGPrimitiveShape(org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitiveShape) Attributes(com.ait.lienzo.client.core.shape.Attributes) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) NodeDragMoveEvent(com.ait.lienzo.client.core.event.NodeDragMoveEvent) DragHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.DragHandler) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList) HandlerManager(com.google.gwt.event.shared.HandlerManager) StreamSupport(java.util.stream.StreamSupport) RESIZE(com.ait.lienzo.client.core.shape.wires.IControlHandle.ControlHandleStandardType.RESIZE) Node(com.ait.lienzo.client.core.shape.Node) Before(org.junit.Before) MoveDividerDragHandler(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerDragHandler) IControlHandleFactory(com.ait.lienzo.client.core.shape.wires.IControlHandleFactory) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) DragContext(com.ait.lienzo.client.widget.DragContext) IPrimitive(com.ait.lienzo.client.core.shape.IPrimitive) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) Condition(org.assertj.core.api.Condition) Collections(java.util.Collections) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList) IControlHandleFactory(com.ait.lienzo.client.core.shape.wires.IControlHandleFactory) Test(org.junit.Test)

Example 4 with MoveDividerControlHandle

use of org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle in project kie-wb-common by kiegroup.

the class DecisionServiceSVGShapeViewTest method getMoveDividerControlHandle.

private MoveDividerControlHandle getMoveDividerControlHandle() {
    final IControlHandleFactory controlHandleFactory = view.getPath().getControlHandleFactory();
    final IControlHandleList controlHandles = controlHandleFactory.getControlHandles(RESIZE).get(RESIZE);
    return StreamSupport.stream(controlHandles.spliterator(), false).filter(ch -> ch instanceof MoveDividerControlHandle).map(ch -> (MoveDividerControlHandle) ch).findFirst().get();
}
Also used : NodeDragStartEvent(com.ait.lienzo.client.core.event.NodeDragStartEvent) WiresResizeStepEvent(com.ait.lienzo.client.core.shape.wires.event.WiresResizeStepEvent) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) NodeDragEndEvent(com.ait.lienzo.client.core.event.NodeDragEndEvent) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) Shape(com.ait.lienzo.client.core.shape.Shape) Attribute(com.ait.lienzo.client.core.Attribute) DragEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.DragEvent) DragBounds(com.ait.lienzo.client.core.types.DragBounds) SVGPrimitiveShape(org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitiveShape) Attributes(com.ait.lienzo.client.core.shape.Attributes) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) NodeDragMoveEvent(com.ait.lienzo.client.core.event.NodeDragMoveEvent) DragHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.DragHandler) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList) HandlerManager(com.google.gwt.event.shared.HandlerManager) StreamSupport(java.util.stream.StreamSupport) RESIZE(com.ait.lienzo.client.core.shape.wires.IControlHandle.ControlHandleStandardType.RESIZE) Node(com.ait.lienzo.client.core.shape.Node) Before(org.junit.Before) MoveDividerDragHandler(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerDragHandler) IControlHandleFactory(com.ait.lienzo.client.core.shape.wires.IControlHandleFactory) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) DragContext(com.ait.lienzo.client.widget.DragContext) IPrimitive(com.ait.lienzo.client.core.shape.IPrimitive) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) Condition(org.assertj.core.api.Condition) Collections(java.util.Collections) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList) IControlHandleFactory(com.ait.lienzo.client.core.shape.wires.IControlHandleFactory)

Example 5 with MoveDividerControlHandle

use of org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle in project kie-wb-common by kiegroup.

the class DecisionServiceSVGShapeViewTest method testShapeControlResizeHandlerMoveDividerEvents.

@Test
public void testShapeControlResizeHandlerMoveDividerEvents() {
    final MoveDividerControlHandle moveDividerControlHandle = getMoveDividerControlHandle();
    view.addDividerDragHandler(dragHandler);
    moveDividerControlHandle.getControl().fireEvent(nodeDragStartEvent);
    verify(dragHandler).start(any(DragEvent.class));
    moveDividerControlHandle.getControl().fireEvent(nodeDragMoveEvent);
    verify(dragHandler).handle(any(DragEvent.class));
    moveDividerControlHandle.getControl().fireEvent(nodeDragEndEvent);
    verify(dragHandler).end(any(DragEvent.class));
}
Also used : DragEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.DragEvent) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 MoveDividerControlHandle (org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle)5 IPrimitive (com.ait.lienzo.client.core.shape.IPrimitive)4 DragBounds (com.ait.lienzo.client.core.types.DragBounds)4 MoveDividerDragHandler (org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerDragHandler)4 DragEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.DragEvent)4 Attribute (com.ait.lienzo.client.core.Attribute)3 NodeDragEndEvent (com.ait.lienzo.client.core.event.NodeDragEndEvent)3 NodeDragMoveEvent (com.ait.lienzo.client.core.event.NodeDragMoveEvent)3 NodeDragStartEvent (com.ait.lienzo.client.core.event.NodeDragStartEvent)3 Attributes (com.ait.lienzo.client.core.shape.Attributes)3 Node (com.ait.lienzo.client.core.shape.Node)3 Shape (com.ait.lienzo.client.core.shape.Shape)3 RESIZE (com.ait.lienzo.client.core.shape.wires.IControlHandle.ControlHandleStandardType.RESIZE)3 IControlHandleFactory (com.ait.lienzo.client.core.shape.wires.IControlHandleFactory)3 IControlHandleList (com.ait.lienzo.client.core.shape.wires.IControlHandleList)3 WiresResizeStepEvent (com.ait.lienzo.client.core.shape.wires.event.WiresResizeStepEvent)3 DragContext (com.ait.lienzo.client.widget.DragContext)3 LienzoMockitoTestRunner (com.ait.lienzo.test.LienzoMockitoTestRunner)3 HandlerManager (com.google.gwt.event.shared.HandlerManager)3