use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.
the class LocationControlImplTest method testMove.
@Test
@SuppressWarnings("unchecked")
public void testMove() throws Exception {
final WiresShapeView wiresShape = mock(WiresShapeView.class);
final WiresShapeView childWiresShape = mock(WiresShapeView.class);
final MagnetManager.Magnets magnets = mock(MagnetManager.Magnets.class);
final WiresMagnet magnet = mock(WiresMagnet.class);
final WiresConnection connection = mock(WiresConnection.class);
final NFastArrayList<WiresConnection> connections = new NFastArrayList<>(connection);
final WiresConnector connector = mock(WiresConnector.class);
final String connectorUUID = UUID.uuid();
final NFastArrayList<WiresShape> children = new NFastArrayList<>(childWiresShape);
final Group connectorGroup = mock(Group.class);
final Edge connectorEdge = mock(Edge.class);
final com.ait.lienzo.client.core.types.Point2D controlPointLienzo = new com.ait.lienzo.client.core.types.Point2D(100, 100);
final Point2DArray controlPointsLienzo = new Point2DArray(controlPointLienzo);
final ViewConnector viewConnector = mock(ViewConnector.class);
Group parentGroup = mock(Group.class);
BoundingBox parentBB = new BoundingBox(0, 0, 200, 200);
MultiPath head = mock(MultiPath.class);
MultiPath tail = mock(MultiPath.class);
when(childWiresShape.getMagnets()).thenReturn(magnets);
when(childWiresShape.getParent()).thenReturn(wiresShape);
when(wiresShape.getGroup()).thenReturn(parentGroup);
when(parentGroup.getBoundingBox()).thenReturn(parentBB);
when(wiresShape.getX()).thenReturn(0d);
when(wiresShape.getY()).thenReturn(0d);
when(magnets.size()).thenReturn(1);
when(magnets.getMagnet(0)).thenReturn(magnet);
when(magnet.getConnectionsSize()).thenReturn(connections.size());
when(magnet.getConnections()).thenReturn(connections);
when(connection.getConnector()).thenReturn(connector);
when(connector.getGroup()).thenReturn(connectorGroup);
when(connectorGroup.uuid()).thenReturn(connectorUUID);
when(connector.getControlPoints()).thenReturn(controlPointsLienzo);
when(connector.getHead()).thenReturn(head);
when(connector.getTail()).thenReturn(tail);
when(head.getLocation()).thenReturn(new com.ait.lienzo.client.core.types.Point2D(1, 1));
when(tail.getLocation()).thenReturn(new com.ait.lienzo.client.core.types.Point2D(2, 2));
when(wiresShape.getChildShapes()).thenReturn(children);
when(shape.getShapeView()).thenReturn(wiresShape);
when(graphIndex.getEdge(connectorUUID)).thenReturn(connectorEdge);
when(connectorEdge.getContent()).thenReturn(viewConnector);
when(connectorGroup.getUserData()).thenReturn(new WiresUtils.UserData(connectorUUID, ""));
tested.init(canvasHandler);
tested.register(element);
Point2D location = new Point2D(45d, 65.5d);
tested.move(new Element[] { element }, new Point2D[] { location });
ArgumentCaptor<CanvasCommand> commandArgumentCaptor = forClass(CanvasCommand.class);
verify(commandManager, times(1)).execute(eq(canvasHandler), commandArgumentCaptor.capture());
ArgumentCaptor<ShapeLocationsChangedEvent> shapeLocationsChangedEventCaptor = forClass(ShapeLocationsChangedEvent.class);
verify(shapeLocationsChangedEvent, times(1)).fire(shapeLocationsChangedEventCaptor.capture());
assertTrue(shapeLocationsChangedEventCaptor.getValue() instanceof ShapeLocationsChangedEvent);
// assert parent node move
final CompositeCommand command = (CompositeCommand) commandArgumentCaptor.getValue();
UpdateElementPositionCommand updateElementPositionCommand = (UpdateElementPositionCommand) command.getCommands().get(0);
assertEquals(element, updateElementPositionCommand.getElement());
assertEquals(location, updateElementPositionCommand.getLocation());
}
use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.
the class ShapeGlyphDragHandlerTest method setUp.
@Before
public void setUp() throws Exception {
proxyPanel = spy(new LienzoPanelImpl(DRAG_PROXY_WIDTH, DRAG_PROXY_HEIGHT));
when(proxyPanel.getElement()).thenReturn(proxyElement);
when(proxyElement.getStyle()).thenReturn(proxyStyle);
handlerRegistrations = new ArrayList<>();
glyphGroup = new Group();
when(glyphLienzoGlyphRenderer.render(eq(glyph), anyDouble(), anyDouble())).thenReturn(glyphGroup);
when(glyphDragItem.getHeight()).thenReturn(DRAG_PROXY_WIDTH);
when(glyphDragItem.getWidth()).thenReturn(DRAG_PROXY_HEIGHT);
when(glyphDragItem.getShape()).thenReturn(glyph);
when(rootPanel.addDomHandler(any(MouseMoveHandler.class), eq(MouseMoveEvent.getType()))).thenReturn(moveHandlerReg);
when(rootPanel.addDomHandler(any(MouseUpHandler.class), eq(MouseUpEvent.getType()))).thenReturn(upHandlerReg);
when(rootPanel.addDomHandler(any(KeyDownHandler.class), eq(KeyDownEvent.getType()))).thenReturn(keyHandlerReg);
tested = new ShapeGlyphDragHandler(glyphLienzoGlyphRenderer, handlerRegistrations, () -> rootPanel, item -> proxyPanel, (task, timeout) -> task.execute());
}
use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.
the class WiresUtilsTest method isWiresShapeWhenWiresContainer.
@Test
public void isWiresShapeWhenWiresContainer() {
final WiresContainer wc = new WiresContainer(new Group());
assertFalse(WiresUtils.isWiresShape(wc));
}
use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.
the class WiresLayerTest method setUp.
@Before
public void setUp() throws Exception {
Group shapeGroup = new Group();
when(shape.uuid()).thenReturn(SHAPE_UUID);
when(shape.getGroup()).thenReturn(shapeGroup);
Group connectorGroup = new Group();
when(connector.getGroup()).thenReturn(connectorGroup);
when(wiresManager.getMagnetManager()).thenReturn(magnetManager);
tested = new WiresLayer();
tested.use(wiresManager);
}
use of com.ait.lienzo.client.core.shape.Group in project kie-wb-common by kiegroup.
the class LienzoPictureGlyphRendererTest method testRender.
@Test
@SuppressWarnings("unchecked")
public void testRender() {
final Group glyphView = tested.render(glyph, 100, 100);
assertNotNull(glyphView);
verify(pictureBuilder, times(1)).accept(eq("http://url"), any(Consumer.class));
}
Aggregations