Skip to content

Commit

Permalink
Use sequential multi instance in the JPA tests to avoid a potential r…
Browse files Browse the repository at this point in the history
…ace condition
  • Loading branch information
filiphr committed Jul 18, 2023
1 parent d788659 commit 3f5005e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<process id="dogeProcess" name="DogeProcess" isExecutable="true">
<startEvent id="startEvent1"></startEvent>
<subProcess id="sid-1AA38D08-310B-4BFE-A6AD-F32488643000" name="subProcess">
<multiInstanceLoopCharacteristics isSequential="false" flowable:collection="photos" flowable:elementVariable="photo"></multiInstanceLoopCharacteristics>
<multiInstanceLoopCharacteristics isSequential="true" flowable:collection="photos" flowable:elementVariable="photo"></multiInstanceLoopCharacteristics>
<serviceTask id="sid-FCFA0F9D-8796-43E2-ACFD-13AF3465F929" name="Send to photo processing service" flowable:expression="${photoService.processPhoto(photo.id)}"></serviceTask>
<startEvent id="sid-821438D0-CD00-43F1-A847-42112E44BA12"></startEvent>
<receiveTask id="wait" name="Wait for completion"></receiveTask>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ public void photosArePersistedAsJpaEntities() {

ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dogeProcess", variables);

List<Execution> waitingExecutions = runtimeService.createExecutionQuery().activityId("wait").list();
assertThat(waitingExecutions)
.hasSize(2);

Map<String, Object> processInstanceVariables = runtimeService.getVariables(processInstance.getId());
assertThat(processInstanceVariables).containsOnlyKeys("photos");
List<Photo> processPhotos = (List<Photo>) processInstanceVariables.get("photos");
Expand All @@ -107,11 +103,13 @@ public void photosArePersistedAsJpaEntities() {
"two"
);

for (Execution waitingExecution : waitingExecutions) {
Execution waitingExecution = runtimeService.createExecutionQuery().activityId("wait").singleResult();
while (waitingExecution != null) {
Photo executionPhoto = runtimeService.getVariable(waitingExecution.getId(), "photo", Photo.class);
assertThat(executionPhoto).isNotNull();
assertThat(executionPhoto.getLabel()).isIn("one", "two");
runtimeService.trigger(waitingExecution.getId());
waitingExecution = runtimeService.createExecutionQuery().activityId("wait").singleResult();
}

Task reviewTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
Expand Down

0 comments on commit 3f5005e

Please sign in to comment.