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());
}
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);
}
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);
}
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());
}
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;
}
Aggregations