Skip to content

Commit

Permalink
chore(engine): replace CMMN with BPMN call activity in invoice example
Browse files Browse the repository at this point in the history
related to CAM-10682
  • Loading branch information
mboskamp authored and tasso94 committed Dec 17, 2019
1 parent 5a32336 commit fb615a9
Show file tree
Hide file tree
Showing 7 changed files with 292 additions and 232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void createDeployment(String processArchiveName, DeploymentBuilder deploy
repositoryService.createDeployment(this.getReference())
.addInputStream("invoice.v1.bpmn", classLoader.getResourceAsStream("invoice.v1.bpmn"))
.addInputStream("invoiceBusinessDecisions.dmn", classLoader.getResourceAsStream("invoiceBusinessDecisions.dmn"))
.addInputStream("review-invoice.cmmn", classLoader.getResourceAsStream("review-invoice.cmmn"))
.addInputStream("reviewInvoice.bpmn", classLoader.getResourceAsStream("reviewInvoice.bpmn"))
.deploy();
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/invoice/src/main/resources/META-INF/processes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<process-engine>default</process-engine>
<resource>invoice.v2.bpmn</resource>
<resource>invoiceBusinessDecisions.dmn</resource>
<resource>review-invoice.cmmn</resource>
<resource>reviewInvoice.bpmn</resource>
<properties>
<property name="isDeleteUponUndeploy">false</property>
<property name="isScanForProcessDefinitions">false</property>
Expand Down
192 changes: 98 additions & 94 deletions examples/invoice/src/main/resources/invoice.v1.bpmn

Large diffs are not rendered by default.

180 changes: 92 additions & 88 deletions examples/invoice/src/main/resources/invoice.v2.bpmn

Large diffs are not rendered by default.

47 changes: 0 additions & 47 deletions examples/invoice/src/main/resources/review-invoice.cmmn

This file was deleted.

50 changes: 50 additions & 0 deletions examples/invoice/src/main/resources/reviewInvoice.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1k1vca8" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
<bpmn:process id="ReviewInvoice" name="Review Invoice" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1ggutts</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_1ggutts" sourceRef="StartEvent_1" targetRef="assignReviewer" />
<bpmn:sequenceFlow id="SequenceFlow_144f11w" sourceRef="assignReviewer" targetRef="reviewInvoice" />
<bpmn:endEvent id="EndEvent_1og1zom">
<bpmn:incoming>SequenceFlow_0vvoxt0</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_0vvoxt0" sourceRef="reviewInvoice" targetRef="EndEvent_1og1zom" />
<bpmn:userTask id="assignReviewer" name="Assign Reviewer" camunda:formKey="embedded:app:forms/assign-reviewer.html" camunda:assignee="demo">
<bpmn:incoming>SequenceFlow_1ggutts</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_144f11w</bpmn:outgoing>
</bpmn:userTask>
<bpmn:userTask id="reviewInvoice" name="Review Invoice" camunda:formKey="embedded:app:forms/review-invoice.html" camunda:assignee="${reviewer}" camunda:dueDate="${dateTime().plusDays(2).toDate()}">
<bpmn:incoming>SequenceFlow_144f11w</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0vvoxt0</bpmn:outgoing>
</bpmn:userTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ReviewInvoice">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="79" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1ggutts_di" bpmnElement="SequenceFlow_1ggutts">
<di:waypoint x="215" y="97" />
<di:waypoint x="270" y="97" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_144f11w_di" bpmnElement="SequenceFlow_144f11w">
<di:waypoint x="370" y="97" />
<di:waypoint x="430" y="97" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_1og1zom_di" bpmnElement="EndEvent_1og1zom">
<dc:Bounds x="592" y="79" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0vvoxt0_di" bpmnElement="SequenceFlow_0vvoxt0">
<di:waypoint x="530" y="97" />
<di:waypoint x="592" y="97" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="UserTask_01n44zw_di" bpmnElement="assignReviewer">
<dc:Bounds x="270" y="57" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="UserTask_055nly4_di" bpmnElement="reviewInvoice">
<dc:Bounds x="430" y="57" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void testApproveInvoiceAssignment() {
.startBeforeActivity("approveInvoice")
.execute();

// givent that the process instance is waiting at task "approveInvoice"
// given that the process instance is waiting at task "approveInvoice"
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("approveInvoice", task.getTaskDefinitionKey());

Expand All @@ -163,7 +163,56 @@ public void testApproveInvoiceAssignment() {

// then the variable "approver" exists and is set to mary
assertEquals("mary", taskService.getVariable(task.getId(), "approver"));
}

@Deployment(resources= {"invoice.v2.bpmn", "reviewInvoice.bpmn", "invoiceBusinessDecisions.dmn"})
public void testNonSuccessfulPath() {
InputStream invoiceInputStream = InvoiceProcessApplication.class.getClassLoader().getResourceAsStream("invoice.pdf");
VariableMap variables = Variables.createVariables()
.putValue("creditor", "Great Pizza for Everyone Inc.")
.putValue("amount", 300.0d)
.putValue("invoiceCategory", "Travel Expenses")
.putValue("invoiceNumber", "GPFE-23232323")
.putValue("invoiceDocument", fileValue("invoice.pdf")
.file(invoiceInputStream)
.mimeType("application/pdf")
.create());

ProcessInstance pi = runtimeService.startProcessInstanceByKey("invoice", variables);

Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("approveInvoice", task.getTaskDefinitionKey());

List<IdentityLink> links = taskService.getIdentityLinksForTask(task.getId());
Set<String> approverGroups = new HashSet<String>();
for (IdentityLink link : links) {
approverGroups.add(link.getGroupId());
}
assertEquals(2, approverGroups.size());
assertTrue(approverGroups.contains("accounting"));
assertTrue(approverGroups.contains("sales"));

variables.clear();
variables.put("approved", Boolean.FALSE);
taskService.complete(task.getId(), variables);

task = taskService.createTaskQuery().singleResult();

assertEquals("assignReviewer", task.getTaskDefinitionKey());
variables.clear();
variables.put("reviewer", "peter");
taskService.complete(task.getId(), variables);

task = taskService.createTaskQuery().singleResult();

assertEquals("reviewInvoice", task.getTaskDefinitionKey());
variables.clear();
variables.put("clarified", Boolean.FALSE);
taskService.complete(task.getId(), variables);

assertProcessEnded(task.getProcessInstanceId());
assertProcessEnded(pi.getId());
}


}

0 comments on commit fb615a9

Please sign in to comment.