Search in sources :

Example 26 with Waypoint

use of org.camunda.bpm.model.bpmn.instance.di.Waypoint in project camunda-bpmn-model by camunda.

the class BpmnDiTest method shouldCreateValidBpmnDi.

@Test
public void shouldCreateValidBpmnDi() {
    modelInstance = Bpmn.createProcess("process").startEvent("start").sequenceFlowId("flow").endEvent("end").done();
    process = modelInstance.getModelElementById("process");
    startEvent = modelInstance.getModelElementById("start");
    sequenceFlow = modelInstance.getModelElementById("flow");
    endEvent = modelInstance.getModelElementById("end");
    // create bpmn diagram
    BpmnDiagram bpmnDiagram = modelInstance.newInstance(BpmnDiagram.class);
    bpmnDiagram.setId("diagram");
    bpmnDiagram.setName("diagram");
    bpmnDiagram.setDocumentation("bpmn diagram element");
    bpmnDiagram.setResolution(120.0);
    modelInstance.getDefinitions().addChildElement(bpmnDiagram);
    // create plane for process
    BpmnPlane processPlane = modelInstance.newInstance(BpmnPlane.class);
    processPlane.setId("plane");
    processPlane.setBpmnElement(process);
    bpmnDiagram.setBpmnPlane(processPlane);
    // create shape for start event
    BpmnShape startEventShape = modelInstance.newInstance(BpmnShape.class);
    startEventShape.setId("startShape");
    startEventShape.setBpmnElement(startEvent);
    processPlane.getDiagramElements().add(startEventShape);
    // create bounds for start event shape
    Bounds startEventBounds = modelInstance.newInstance(Bounds.class);
    startEventBounds.setHeight(36.0);
    startEventBounds.setWidth(36.0);
    startEventBounds.setX(632.0);
    startEventBounds.setY(312.0);
    startEventShape.setBounds(startEventBounds);
    // create shape for end event
    BpmnShape endEventShape = modelInstance.newInstance(BpmnShape.class);
    endEventShape.setId("endShape");
    endEventShape.setBpmnElement(endEvent);
    processPlane.getDiagramElements().add(endEventShape);
    // create bounds for end event shape
    Bounds endEventBounds = modelInstance.newInstance(Bounds.class);
    endEventBounds.setHeight(36.0);
    endEventBounds.setWidth(36.0);
    endEventBounds.setX(718.0);
    endEventBounds.setY(312.0);
    endEventShape.setBounds(endEventBounds);
    // create edge for sequence flow
    BpmnEdge flowEdge = modelInstance.newInstance(BpmnEdge.class);
    flowEdge.setId("flowEdge");
    flowEdge.setBpmnElement(sequenceFlow);
    flowEdge.setSourceElement(startEventShape);
    flowEdge.setTargetElement(endEventShape);
    processPlane.getDiagramElements().add(flowEdge);
    // create waypoints for sequence flow edge
    Waypoint startWaypoint = modelInstance.newInstance(Waypoint.class);
    startWaypoint.setX(668.0);
    startWaypoint.setY(330.0);
    flowEdge.getWaypoints().add(startWaypoint);
    Waypoint endWaypoint = modelInstance.newInstance(Waypoint.class);
    endWaypoint.setX(718.0);
    endWaypoint.setY(330.0);
    flowEdge.getWaypoints().add(endWaypoint);
}
Also used : Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) Waypoint(org.camunda.bpm.model.bpmn.instance.di.Waypoint) Test(org.junit.Test)

Example 27 with Waypoint

use of org.camunda.bpm.model.bpmn.instance.di.Waypoint in project camunda-bpmn-model by camunda.

the class CoordinatesGenerationTest method shouldPlaceBusinessRuleTask.

@Test
public void shouldPlaceBusinessRuleTask() {
    ProcessBuilder builder = Bpmn.createExecutableProcess();
    instance = builder.startEvent(START_EVENT_ID).sequenceFlowId(SEQUENCE_FLOW_ID).businessRuleTask(TASK_ID).done();
    Bounds businessRuleTaskBounds = findBpmnShape(TASK_ID).getBounds();
    assertShapeCoordinates(businessRuleTaskBounds, 186, 78);
    Collection<Waypoint> sequenceFlowWaypoints = findBpmnEdge(SEQUENCE_FLOW_ID).getWaypoints();
    Iterator<Waypoint> iterator = sequenceFlowWaypoints.iterator();
    Waypoint waypoint = iterator.next();
    assertWaypointCoordinates(waypoint, 136, 118);
    while (iterator.hasNext()) {
        waypoint = iterator.next();
    }
    assertWaypointCoordinates(waypoint, 186, 118);
}
Also used : ProcessBuilder(org.camunda.bpm.model.bpmn.builder.ProcessBuilder) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) Waypoint(org.camunda.bpm.model.bpmn.instance.di.Waypoint) Test(org.junit.Test)

Example 28 with Waypoint

use of org.camunda.bpm.model.bpmn.instance.di.Waypoint in project camunda-bpmn-model by camunda.

the class CoordinatesGenerationTest method shouldPlaceInclusiveGateway.

@Test
public void shouldPlaceInclusiveGateway() {
    ProcessBuilder builder = Bpmn.createExecutableProcess();
    instance = builder.startEvent(START_EVENT_ID).sequenceFlowId(SEQUENCE_FLOW_ID).inclusiveGateway("id").done();
    Bounds gatewayBounds = findBpmnShape("id").getBounds();
    assertShapeCoordinates(gatewayBounds, 186, 93);
    Collection<Waypoint> sequenceFlowWaypoints = findBpmnEdge(SEQUENCE_FLOW_ID).getWaypoints();
    Iterator<Waypoint> iterator = sequenceFlowWaypoints.iterator();
    Waypoint waypoint = iterator.next();
    assertWaypointCoordinates(waypoint, 136, 118);
    while (iterator.hasNext()) {
        waypoint = iterator.next();
    }
    assertWaypointCoordinates(waypoint, 186, 118);
}
Also used : ProcessBuilder(org.camunda.bpm.model.bpmn.builder.ProcessBuilder) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) Waypoint(org.camunda.bpm.model.bpmn.instance.di.Waypoint) Test(org.junit.Test)

Example 29 with Waypoint

use of org.camunda.bpm.model.bpmn.instance.di.Waypoint in project camunda-bpmn-model by camunda.

the class CoordinatesGenerationTest method shouldPlaceThreeBranchesForParallelGateway.

@Test
public void shouldPlaceThreeBranchesForParallelGateway() {
    ProcessBuilder builder = Bpmn.createExecutableProcess();
    instance = builder.startEvent(START_EVENT_ID).parallelGateway("id").userTask(USER_TASK_ID).moveToNode("id").endEvent(END_EVENT_ID).moveToNode("id").sequenceFlowId("s1").serviceTask(SERVICE_TASK_ID).done();
    Bounds userTaskBounds = findBpmnShape(USER_TASK_ID).getBounds();
    assertShapeCoordinates(userTaskBounds, 286, 78);
    Bounds endEventBounds = findBpmnShape(END_EVENT_ID).getBounds();
    assertShapeCoordinates(endEventBounds, 286, 208);
    Bounds serviceTaskBounds = findBpmnShape(SERVICE_TASK_ID).getBounds();
    assertShapeCoordinates(serviceTaskBounds, 286, 294);
    Collection<Waypoint> sequenceFlowWaypoints = findBpmnEdge("s1").getWaypoints();
    Iterator<Waypoint> iterator = sequenceFlowWaypoints.iterator();
    Waypoint waypoint = iterator.next();
    assertWaypointCoordinates(waypoint, 211, 143);
    while (iterator.hasNext()) {
        waypoint = iterator.next();
    }
    assertWaypointCoordinates(waypoint, 286, 334);
}
Also used : ProcessBuilder(org.camunda.bpm.model.bpmn.builder.ProcessBuilder) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) Waypoint(org.camunda.bpm.model.bpmn.instance.di.Waypoint) Test(org.junit.Test)

Example 30 with Waypoint

use of org.camunda.bpm.model.bpmn.instance.di.Waypoint in project camunda-bpmn-model by camunda.

the class CoordinatesGenerationTest method shouldPlaceServiceTask.

@Test
public void shouldPlaceServiceTask() {
    ProcessBuilder builder = Bpmn.createExecutableProcess();
    instance = builder.startEvent(START_EVENT_ID).sequenceFlowId(SEQUENCE_FLOW_ID).serviceTask(SERVICE_TASK_ID).done();
    Bounds serviceTaskBounds = findBpmnShape(SERVICE_TASK_ID).getBounds();
    assertShapeCoordinates(serviceTaskBounds, 186, 78);
    Collection<Waypoint> sequenceFlowWaypoints = findBpmnEdge(SEQUENCE_FLOW_ID).getWaypoints();
    Iterator<Waypoint> iterator = sequenceFlowWaypoints.iterator();
    Waypoint waypoint = iterator.next();
    assertWaypointCoordinates(waypoint, 136, 118);
    while (iterator.hasNext()) {
        waypoint = iterator.next();
    }
    assertWaypointCoordinates(waypoint, 186, 118);
}
Also used : ProcessBuilder(org.camunda.bpm.model.bpmn.builder.ProcessBuilder) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) Waypoint(org.camunda.bpm.model.bpmn.instance.di.Waypoint) Test(org.junit.Test)

Aggregations

Waypoint (org.camunda.bpm.model.bpmn.instance.di.Waypoint)34 Bounds (org.camunda.bpm.model.bpmn.instance.dc.Bounds)33 Test (org.junit.Test)31 ProcessBuilder (org.camunda.bpm.model.bpmn.builder.ProcessBuilder)30 BpmnShape (org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape)2 Point (org.camunda.bpm.model.bpmn.instance.dc.Point)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1