Search in sources :

Example 21 with BPMNShape

use of org.eclipse.bpmn2.di.BPMNShape in project kie-wb-common by kiegroup.

the class AssociationPropertyWriterTest method testSetConnection.

@Test
public void testSetConnection() {
    BPMNShape sourceShape = mockShape(SOURCE_SHAPE_ID, 1, 1, 4, 4);
    BPMNShape targetShape = mockShape(TARGET_SHAPE_ID, 10, 10, 4, 4);
    when(sourceWriter.getShape()).thenReturn(sourceShape);
    when(targetWriter.getShape()).thenReturn(targetShape);
    ControlPoint[] controlPoints = new ControlPoint[] { new ControlPoint(Point2D.create(3, 3)), new ControlPoint(Point2D.create(4, 4)), new ControlPoint(Point2D.create(5, 5)) };
    ViewConnector<? extends BPMNViewDefinition> connector = mockConnector(1, 1, 10, 10, controlPoints);
    associationWriter.setSource(sourceWriter);
    associationWriter.setTarget(targetWriter);
    associationWriter.setConnection(connector);
    assertNotNull(associationWriter.getEdge());
    assertEquals(association, associationWriter.getEdge().getBpmnElement());
    assertEquals("edge_SOURCE_SHAPE_ID_to_TARGET_SHAPE_ID", associationWriter.getEdge().getId());
    assertWaypoint(2, 2, 0, associationWriter.getEdge().getWaypoint());
    assertWaypoint(3, 3, 1, associationWriter.getEdge().getWaypoint());
    assertWaypoint(4, 4, 2, associationWriter.getEdge().getWaypoint());
    assertWaypoint(5, 5, 3, associationWriter.getEdge().getWaypoint());
    assertWaypoint(20, 20, 4, associationWriter.getEdge().getWaypoint());
}
Also used : ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) Test(org.junit.Test)

Example 22 with BPMNShape

use of org.eclipse.bpmn2.di.BPMNShape in project kie-wb-common by kiegroup.

the class AbstractBasePropertyWriterTest method testSetBounds.

@Test
public void testSetBounds() {
    org.kie.workbench.common.stunner.core.graph.content.Bounds bounds = org.kie.workbench.common.stunner.core.graph.content.Bounds.create(X1, Y1, X2, Y2);
    propertyWriter.setBounds(bounds);
    BPMNShape shape = propertyWriter.getShape();
    assertNotNull(shape);
    assertEquals("shape_" + ID, shape.getId());
    assertEquals(element, shape.getBpmnElement());
    Bounds shapeBounds = shape.getBounds();
    assertEquals(X1.floatValue(), shapeBounds.getX(), 0);
    assertEquals(Y1.floatValue(), shapeBounds.getY(), 0);
    assertEquals(X2.floatValue() - X1.floatValue(), shapeBounds.getWidth(), 0);
    assertEquals(Y2.floatValue() - Y1.floatValue(), shapeBounds.getHeight(), 0);
}
Also used : Bounds(org.eclipse.dd.dc.Bounds) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) Test(org.junit.Test)

Example 23 with BPMNShape

use of org.eclipse.bpmn2.di.BPMNShape in project kie-wb-common by kiegroup.

the class ProcessConverterDelegateTest method mockTaskNode.

private BpmnNode.Simple mockTaskNode(Task task) {
    BPMNShape shape = mock(BPMNShape.class);
    when(shape.getBounds()).thenReturn(mock(Bounds.class));
    plane.getPlaneElement().add(shape);
    when(shape.getBpmnElement()).thenReturn(task);
    return new BpmnNode.Simple(new NodeImpl<>(task.getId()), basePropertyReader);
}
Also used : Bounds(org.eclipse.dd.dc.Bounds) BPMNShape(org.eclipse.bpmn2.di.BPMNShape)

Example 24 with BPMNShape

use of org.eclipse.bpmn2.di.BPMNShape in project kie-wb-common by kiegroup.

the class PropertyWriterUtilsTest method testCreateBPMNEdge.

@Test
public void testCreateBPMNEdge() {
    BPMNShape sourceShape = mockShape(SOURCE_SHAPE_ID, 1, 1, 4, 4);
    BPMNShape targetShape = mockShape(TARGET_SHAPE_ID, 10, 10, 4, 4);
    when(sourceWriter.getShape()).thenReturn(sourceShape);
    when(targetWriter.getShape()).thenReturn(targetShape);
    Connection sourceConnection = mockConnection(1, 1);
    Connection targetConnection = mockConnection(10, 10);
    ControlPoint[] controlPoints = new ControlPoint[] { new ControlPoint(Point2D.create(3, 3)), new ControlPoint(Point2D.create(4, 4)), new ControlPoint(Point2D.create(5, 5)) };
    BPMNEdge edge = PropertyWriterUtils.createBPMNEdge(sourceWriter, targetWriter, sourceConnection, controlPoints, targetConnection);
    assertEquals("edge_SOURCE_SHAPE_ID_to_TARGET_SHAPE_ID", edge.getId());
    assertWaypoint(2, 2, 0, edge.getWaypoint());
    assertWaypoint(3, 3, 1, edge.getWaypoint());
    assertWaypoint(4, 4, 2, edge.getWaypoint());
    assertWaypoint(5, 5, 3, edge.getWaypoint());
    assertWaypoint(20, 20, 4, edge.getWaypoint());
}
Also used : Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) BPMNEdge(org.eclipse.bpmn2.di.BPMNEdge) Test(org.junit.Test)

Example 25 with BPMNShape

use of org.eclipse.bpmn2.di.BPMNShape in project kie-wb-common by kiegroup.

the class PropertyWriterUtilsTest method mockShape.

public static BPMNShape mockShape(String id, float x, float y, float width, float height) {
    BPMNShape shape = mock(BPMNShape.class);
    when(shape.getId()).thenReturn(id);
    Bounds bounds = mock(Bounds.class);
    when(bounds.getX()).thenReturn(x);
    when(bounds.getY()).thenReturn(y);
    when(shape.getBounds()).thenReturn(bounds);
    return shape;
}
Also used : Bounds(org.eclipse.dd.dc.Bounds) BPMNShape(org.eclipse.bpmn2.di.BPMNShape)

Aggregations

BPMNShape (org.eclipse.bpmn2.di.BPMNShape)26 Bounds (org.eclipse.dd.dc.Bounds)12 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)7 DataObject (org.eclipse.bpmn2.DataObject)7 BPMNEdge (org.eclipse.bpmn2.di.BPMNEdge)7 LinkedHashMap (java.util.LinkedHashMap)6 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)6 SubProcess (org.eclipse.bpmn2.SubProcess)6 Point (org.eclipse.dd.dc.Point)6 DiagramElement (org.eclipse.dd.di.DiagramElement)6 Process (org.eclipse.bpmn2.Process)5 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)5 Entry (java.util.Map.Entry)4 List (java.util.List)3 BaseElement (org.eclipse.bpmn2.BaseElement)3 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)3 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)3 Artifact (org.eclipse.bpmn2.Artifact)2 BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)2