Search in sources :

Example 1 with IDrawable

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

the class WiresUtilsTest method shapeUUID.

@Test
public void shapeUUID() {
    final String uuid = "uuid";
    final IDrawable shape = new Rectangle(0, 0);
    WiresUtils.assertShapeUUID(shape, uuid);
    assertTrue(shape.getUserData() instanceof WiresUtils.UserData);
    assertEquals(uuid, WiresUtils.getShapeUUID(shape));
}
Also used : Rectangle(com.ait.lienzo.client.core.shape.Rectangle) IDrawable(com.ait.lienzo.client.core.shape.IDrawable) Test(org.junit.Test)

Example 2 with IDrawable

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

the class WiresUtilsTest method shapeGroup.

@Test
public void shapeGroup() {
    final String group = "group";
    final IDrawable shape = new Rectangle(0, 0);
    WiresUtils.assertShapeGroup(shape, group);
    assertTrue(shape.getUserData() instanceof WiresUtils.UserData);
    assertEquals(group, WiresUtils.getShapeGroup(shape));
}
Also used : Rectangle(com.ait.lienzo.client.core.shape.Rectangle) IDrawable(com.ait.lienzo.client.core.shape.IDrawable) Test(org.junit.Test)

Example 3 with IDrawable

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

the class WiresShapeViewTest method testConsumeChildrenAndConnectors.

@Test
@SuppressWarnings("unchecked")
public void testConsumeChildrenAndConnectors() {
    // Setup children shapes and connectors.
    final Consumer<IDrawable> consumer = mock(Consumer.class);
    final WiresShapeView child1 = newShape();
    final WiresShapeView child2 = newShape();
    tested.add(child1);
    tested.add(child2);
    final WiresConnectorView connector1 = newConnector();
    final WiresConnectorView connector2 = newConnector();
    final MagnetManager.Magnets magnets1 = mock(MagnetManager.Magnets.class);
    final MagnetManager.Magnets magnets2 = mock(MagnetManager.Magnets.class);
    final WiresMagnet magnet1 = mock(WiresMagnet.class);
    final WiresMagnet magnet2 = mock(WiresMagnet.class);
    final WiresConnection connection1 = mock(WiresConnection.class);
    final WiresConnection connection2 = mock(WiresConnection.class);
    final NFastArrayList<WiresConnection> connections1 = new NFastArrayList<WiresConnection>().add(connection1);
    final NFastArrayList<WiresConnection> connections2 = new NFastArrayList<WiresConnection>().add(connection2);
    when(magnets1.size()).thenReturn(1);
    when(magnets1.getMagnet(eq(0))).thenReturn(magnet1);
    when(magnets2.size()).thenReturn(1);
    when(magnets2.getMagnet(eq(0))).thenReturn(magnet2);
    when(magnet1.getConnections()).thenReturn(connections1);
    when(magnet2.getConnections()).thenReturn(connections2);
    when(connection1.getConnector()).thenReturn(connector1);
    when(connection2.getConnector()).thenReturn(connector2);
    child1.setMagnets(magnets1);
    child2.setMagnets(magnets2);
    // Consume.
    tested.consumeChildrenAndConnectors(consumer);
    // Verify.
    verify(consumer, times(1)).accept(eq(tested.getContainer()));
    verify(consumer, times(1)).accept(eq(child1.getContainer()));
    verify(consumer, times(1)).accept(eq(child2.getContainer()));
    verify(consumer, times(1)).accept(eq(connector1.getGroup()));
    verify(consumer, times(1)).accept(eq(connector2.getGroup()));
}
Also used : WiresConnection(com.ait.lienzo.client.core.shape.wires.WiresConnection) MagnetManager(com.ait.lienzo.client.core.shape.wires.MagnetManager) WiresMagnet(com.ait.lienzo.client.core.shape.wires.WiresMagnet) IDrawable(com.ait.lienzo.client.core.shape.IDrawable) Test(org.junit.Test)

Aggregations

IDrawable (com.ait.lienzo.client.core.shape.IDrawable)3 Test (org.junit.Test)3 Rectangle (com.ait.lienzo.client.core.shape.Rectangle)2 MagnetManager (com.ait.lienzo.client.core.shape.wires.MagnetManager)1 WiresConnection (com.ait.lienzo.client.core.shape.wires.WiresConnection)1 WiresMagnet (com.ait.lienzo.client.core.shape.wires.WiresMagnet)1