use of org.activiti.api.process.model.events.BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED in project activiti-cloud by Activiti.
the class ExclusiveGatewayAuditProducerIT method testProcessExecutionWithExclusiveGateway.
@Test
public void testProcessExecutionWithExclusiveGateway() {
// when
streamHandler.getAllReceivedEvents().clear();
ResponseEntity<CloudProcessInstance> processInstance = processInstanceRestTemplate.startProcess(new StartProcessPayloadBuilder().withProcessDefinitionKey(EXCLUSIVE_GATEWAY_PROCESS).withProcessDefinitionId(processDefinitionIds.get(EXCLUSIVE_GATEWAY_PROCESS)).withVariable("input", 0).build());
String processInstanceId = processInstance.getBody().getId();
String processDefinitionKey = processInstance.getBody().getProcessDefinitionKey();
// then
Collection<CloudVariableInstance> variableCollection = processInstanceRestTemplate.getVariables(processInstance).getBody().getContent();
assertThat(variableCollection).isNotEmpty().extracting(CloudVariableInstance::getName, CloudVariableInstance::getValue).contains(tuple("input", 0));
// then
CloudTask task = processInstanceRestTemplate.getTasks(processInstance).getBody().iterator().next();
String taskId = task.getId();
await().untilAsserted(() -> {
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getAllReceivedEvents();
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
assertThat(receivedEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getEntityId).containsExactly(tuple(PROCESS_CREATED, processInstanceId, processInstanceId), tuple(VARIABLE_CREATED, processInstanceId, "input"), tuple(PROCESS_UPDATED, processInstanceId, processInstanceId), tuple(PROCESS_STARTED, processInstanceId, processInstanceId), tuple(ACTIVITY_STARTED, processInstanceId, "theStart"), tuple(ACTIVITY_COMPLETED, processInstanceId, "theStart"), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, "flow1"), tuple(ACTIVITY_STARTED, processInstanceId, "task1"), tuple(VARIABLE_CREATED, processInstanceId, "input"), tuple(TASK_CANDIDATE_USER_ADDED, null, "hruser"), tuple(TASK_CREATED, processInstanceId, taskId));
});
streamHandler.getAllReceivedEvents().clear();
// when
ResponseEntity<CloudTask> claimTask = taskRestTemplate.claim(task);
assertThat(claimTask).isNotNull();
assertThat(claimTask.getBody().getStatus()).isEqualTo(TaskStatus.ASSIGNED);
// then
await().untilAsserted(() -> {
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getAllReceivedEvents();
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
assertThat(receivedEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getEntityId).contains(tuple(TASK_ASSIGNED, processInstanceId, taskId), tuple(TASK_UPDATED, processInstanceId, taskId));
});
streamHandler.getAllReceivedEvents().clear();
// when
CompleteTaskPayload completeTaskPayload = TaskPayloadBuilder.complete().withTaskId(task.getId()).withVariables(Collections.singletonMap("input", 1)).build();
ResponseEntity<CloudTask> completeTask = taskRestTemplate.complete(task, completeTaskPayload);
// then
assertThat(completeTask).isNotNull();
assertThat(completeTask.getBody().getStatus()).isEqualTo(TaskStatus.COMPLETED);
variableCollection = processInstanceRestTemplate.getVariables(processInstance).getBody().getContent();
assertThat(variableCollection).isNotEmpty().extracting(CloudVariableInstance::getName, CloudVariableInstance::getValue).contains(tuple("input", 1));
task = processInstanceRestTemplate.getTasks(processInstance).getBody().iterator().next();
String newTaskId = task.getId();
await().untilAsserted(() -> {
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getAllReceivedEvents();
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
assertThat(receivedEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getEntityId).contains(tuple(VARIABLE_UPDATED, processInstanceId, "input"), tuple(VARIABLE_UPDATED, processInstanceId, "input"), tuple(TASK_COMPLETED, processInstanceId, taskId), tuple(ACTIVITY_COMPLETED, processInstanceId, "task1"), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, "flow2"), tuple(ACTIVITY_STARTED, processInstanceId, "exclusiveGateway"), tuple(ACTIVITY_COMPLETED, processInstanceId, "exclusiveGateway"), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, "flow3"), tuple(ACTIVITY_STARTED, processInstanceId, "task2"), tuple(VARIABLE_CREATED, processInstanceId, "input"), tuple(TASK_CANDIDATE_USER_ADDED, null, "hruser"), tuple(TASK_CREATED, processInstanceId, newTaskId));
assertThat(receivedEvents).filteredOn(event -> (event.getEventType().equals(ACTIVITY_STARTED) || event.getEventType().equals(ACTIVITY_COMPLETED)) && ((BPMNActivity) event.getEntity()).getActivityType().equals("exclusiveGateway")).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessDefinitionKey, event -> ((BPMNActivity) event.getEntity()).getActivityType(), event -> ((BPMNActivity) event.getEntity()).getProcessInstanceId()).contains(tuple(ACTIVITY_STARTED, processDefinitionKey, "exclusiveGateway", processInstanceId), tuple(ACTIVITY_COMPLETED, processDefinitionKey, "exclusiveGateway", processInstanceId));
});
streamHandler.getAllReceivedEvents().clear();
// when
claimTask = taskRestTemplate.claim(task);
// then
assertThat(claimTask).isNotNull();
assertThat(claimTask.getBody().getStatus()).isEqualTo(TaskStatus.ASSIGNED);
completeTaskPayload = TaskPayloadBuilder.complete().withTaskId(task.getId()).withVariables(Collections.singletonMap("input", 2)).build();
completeTask = taskRestTemplate.complete(task, completeTaskPayload);
// then
assertThat(completeTask).isNotNull();
assertThat(completeTask.getBody().getStatus()).isEqualTo(TaskStatus.COMPLETED);
// then
await().untilAsserted(() -> {
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getAllReceivedEvents();
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
assertThat(receivedEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getEntityId).contains(tuple(TASK_ASSIGNED, processInstanceId, newTaskId), tuple(TASK_UPDATED, processInstanceId, newTaskId), tuple(VARIABLE_UPDATED, processInstanceId, "input"), tuple(VARIABLE_UPDATED, processInstanceId, "input"), tuple(TASK_COMPLETED, processInstanceId, newTaskId), tuple(ACTIVITY_COMPLETED, processInstanceId, "task2"), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, "flow4"), tuple(ACTIVITY_STARTED, processInstanceId, "theEnd1"), tuple(ACTIVITY_COMPLETED, processInstanceId, "theEnd1"), tuple(PROCESS_COMPLETED, processInstanceId, processInstanceId));
assertThat(receivedEvents).filteredOn(event -> event.getEventType().equals(VARIABLE_UPDATED)).extracting(CloudRuntimeEvent::getProcessDefinitionKey, event -> ((VariableInstance) event.getEntity()).getProcessInstanceId(), event -> ((VariableInstance) event.getEntity()).isTaskVariable(), event -> ((VariableInstance) event.getEntity()).getName(), event -> ((VariableInstance) event.getEntity()).getValue()).contains(tuple(processDefinitionKey, processInstanceId, true, "input", 2), tuple(processDefinitionKey, processInstanceId, false, "input", 2));
});
}
use of org.activiti.api.process.model.events.BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED in project activiti-cloud by Activiti.
the class SignalAuditProducerIT method testProcessExecutionWithThrowSignal.
@Test
public void testProcessExecutionWithThrowSignal() {
// when
streamHandler.getAllReceivedEvents().clear();
ResponseEntity<CloudProcessInstance> processInstance = processInstanceRestTemplate.startProcess(new StartProcessPayloadBuilder().withProcessDefinitionKey("broadcastSignalEventProcess").withBusinessKey("businessKey").build());
String processInstanceId = processInstance.getBody().getId();
// then
await("Broadcast Signals").untilAsserted(() -> {
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getAllReceivedEvents();
String startedBySignalProcessInstanceId = receivedEvents.stream().filter(it -> PROCESS_CREATED.equals(it.getEventType()) && "processWithSignalStart1".equals(it.getProcessDefinitionKey())).map(CloudRuntimeEvent::getProcessInstanceId).findFirst().orElseThrow(() -> new NoSuchElementException("processWithSignalStart1"));
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
assertThat(receivedEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessDefinitionKey, CloudRuntimeEvent::getBusinessKey, CloudRuntimeEvent::getEntityId).contains(tuple(PROCESS_CREATED, "broadcastSignalEventProcess", "businessKey", processInstanceId), tuple(PROCESS_STARTED, "broadcastSignalEventProcess", "businessKey", processInstanceId), tuple(ACTIVITY_STARTED, "broadcastSignalEventProcess", "businessKey", "startevent1"), tuple(ACTIVITY_COMPLETED, "broadcastSignalEventProcess", "businessKey", "startevent1"), tuple(SEQUENCE_FLOW_TAKEN, "broadcastSignalEventProcess", "businessKey", "flow5"), tuple(ACTIVITY_STARTED, "broadcastSignalEventProcess", "businessKey", "signalintermediatethrowevent1"), tuple(ACTIVITY_COMPLETED, "broadcastSignalEventProcess", "businessKey", "signalintermediatethrowevent1"), tuple(SEQUENCE_FLOW_TAKEN, "broadcastSignalEventProcess", "businessKey", "flow4"), tuple(ACTIVITY_STARTED, "broadcastSignalEventProcess", "businessKey", "endevent1"), tuple(ACTIVITY_COMPLETED, "broadcastSignalEventProcess", "businessKey", "endevent1"), tuple(PROCESS_COMPLETED, "broadcastSignalEventProcess", "businessKey", processInstanceId), tuple(PROCESS_CREATED, "processWithSignalStart1", null, startedBySignalProcessInstanceId), tuple(SIGNAL_RECEIVED, "processWithSignalStart1", null, "theStart"), tuple(PROCESS_STARTED, "processWithSignalStart1", null, startedBySignalProcessInstanceId), tuple(ACTIVITY_COMPLETED, "processWithSignalStart1", null, "theStart"), tuple(SEQUENCE_FLOW_TAKEN, "processWithSignalStart1", null, "flow1"), tuple(ACTIVITY_STARTED, "processWithSignalStart1", null, "theTask"));
runtimeService.deleteProcessInstance(startedBySignalProcessInstanceId, "clean up");
});
}
use of org.activiti.api.process.model.events.BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED in project activiti-cloud by Activiti.
the class ParallelGatewayAuditProducerIT method testProcessExecutionWithParallelGateway.
@Test
public void testProcessExecutionWithParallelGateway() {
// when
streamHandler.getAllReceivedEvents().clear();
ResponseEntity<CloudProcessInstance> processInstance = processInstanceRestTemplate.startProcess(new StartProcessPayloadBuilder().withProcessDefinitionKey(PARALLEL_GATEWAY_PROCESS).build());
String processInstanceId = processInstance.getBody().getId();
// then
await().untilAsserted(() -> {
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getAllReceivedEvents();
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
assertThat(receivedEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getEntityId).contains(tuple(PROCESS_CREATED, processInstanceId, processInstanceId), tuple(PROCESS_STARTED, processInstanceId, processInstanceId), tuple(ACTIVITY_STARTED, processInstanceId, "theStart"), tuple(ACTIVITY_COMPLETED, processInstanceId, "theStart"), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, "flow1"), tuple(ACTIVITY_STARTED, processInstanceId, "task1"), tuple(ACTIVITY_COMPLETED, processInstanceId, "task1"), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, "flow2"), tuple(ACTIVITY_STARTED, processInstanceId, "parallelGateway"), tuple(ACTIVITY_COMPLETED, processInstanceId, "parallelGateway"), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, "flow3"), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, "flow5"), tuple(ACTIVITY_STARTED, processInstanceId, "task2"), tuple(ACTIVITY_STARTED, processInstanceId, "task3"), tuple(ACTIVITY_COMPLETED, processInstanceId, "task2"), tuple(ACTIVITY_COMPLETED, processInstanceId, "task3"), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, "flow4"), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, "flow6"), tuple(ACTIVITY_STARTED, processInstanceId, "theEnd1"), tuple(ACTIVITY_STARTED, processInstanceId, "theEnd2"), tuple(ACTIVITY_COMPLETED, processInstanceId, "theEnd1"), tuple(ACTIVITY_COMPLETED, processInstanceId, "theEnd2"), tuple(PROCESS_COMPLETED, processInstanceId, processInstanceId));
assertThat(receivedEvents).filteredOn(event -> (event.getEventType().equals(ACTIVITY_STARTED) || event.getEventType().equals(ACTIVITY_COMPLETED)) && ((BPMNActivity) event.getEntity()).getActivityType().equals("parallelGateway")).extracting(CloudRuntimeEvent::getEventType, event -> ((BPMNActivity) event.getEntity()).getActivityType(), event -> ((BPMNActivity) event.getEntity()).getProcessInstanceId()).contains(tuple(ACTIVITY_STARTED, "parallelGateway", processInstanceId), tuple(ACTIVITY_COMPLETED, "parallelGateway", processInstanceId));
});
}
use of org.activiti.api.process.model.events.BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED in project activiti-cloud by Activiti.
the class EmbeddedSubProcessAuditIT method shouldExecuteProcessWithEmbeddedSubProcess.
@Test
public void shouldExecuteProcessWithEmbeddedSubProcess() {
// given
ResponseEntity<CloudProcessInstance> processInstance = processInstanceRestTemplate.startProcess(buildStartProcessPayload(SIMPLE_EMBEDDED_SUB_PROCESS));
String processInstanceId = processInstance.getBody().getId();
await().untilAsserted(() -> {
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getLatestReceivedEvents();
assertThat(receivedEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getParentProcessInstanceId, CloudRuntimeEvent::getProcessDefinitionKey).containsExactly(tuple(PROCESS_CREATED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(PROCESS_UPDATED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(PROCESS_STARTED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(ACTIVITY_STARTED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(ACTIVITY_COMPLETED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(ACTIVITY_STARTED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(ACTIVITY_STARTED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(ACTIVITY_COMPLETED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(ACTIVITY_STARTED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(TASK_CANDIDATE_GROUP_ADDED, null, null, null), tuple(TASK_CREATED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS));
assertThat(receivedEvents).filteredOn(event -> TASK_CREATED.equals(event.getEventType())).extracting(CloudRuntimeEvent::getProcessInstanceId, event -> ((CloudTaskCreatedEvent) event).getEntity().getProcessInstanceId()).containsExactly(tuple(processInstanceId, processInstanceId));
List<CloudRuntimeEvent<?, ?>> activitiStartedEvents = receivedEvents.stream().filter(event -> ACTIVITY_STARTED.equals(event.getEventType())).collect(Collectors.toList());
assertThat(activitiStartedEvents).filteredOn(event -> ACTIVITY_STARTED.equals(event.getEventType())).extracting(event -> ((CloudBPMNActivityStartedEvent) event).getEntity().getActivityType(), event -> ((CloudBPMNActivityStartedEvent) event).getEntity().getActivityName()).containsExactly(tuple("startEvent", null), tuple("subProcess", "subProcess"), tuple("startEvent", null), tuple("userTask", "Task in subprocess"));
});
ResponseEntity<PagedResources<CloudTask>> tasks = processInstanceRestTemplate.getTasks(processInstance);
Task task = tasks.getBody().iterator().next();
// when
taskRestTemplate.claim(task);
await().untilAsserted(() -> {
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getLatestReceivedEvents();
assertThat(receivedEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getParentProcessInstanceId, CloudRuntimeEvent::getProcessDefinitionKey).containsExactly(tuple(TASK_ASSIGNED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(TASK_UPDATED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS));
String entityProcessInstanceId = ((CloudTaskAssignedEvent) receivedEvents.get(0)).getEntity().getProcessInstanceId();
assertThat(entityProcessInstanceId).isNotNull();
assertThat(entityProcessInstanceId).isEqualTo(processInstanceId);
});
// when
taskRestTemplate.complete(task);
// then
await().untilAsserted(() -> {
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getLatestReceivedEvents();
assertThat(receivedEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getProcessDefinitionKey).containsExactly(tuple(TASK_COMPLETED, processInstanceId, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(TASK_CANDIDATE_GROUP_REMOVED, null, null), tuple(ACTIVITY_COMPLETED, processInstanceId, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(ACTIVITY_STARTED, processInstanceId, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(ACTIVITY_COMPLETED, processInstanceId, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(ACTIVITY_COMPLETED, processInstanceId, SIMPLE_EMBEDDED_SUB_PROCESS), /*subProcess*/
tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(ACTIVITY_STARTED, processInstanceId, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(ACTIVITY_COMPLETED, processInstanceId, SIMPLE_EMBEDDED_SUB_PROCESS), tuple(PROCESS_COMPLETED, processInstanceId, SIMPLE_EMBEDDED_SUB_PROCESS));
CloudBPMNActivityCompletedEvent subprocessCompletedEvent = (CloudBPMNActivityCompletedEvent) receivedEvents.stream().filter(event -> ACTIVITY_COMPLETED.equals(event.getEventType()) && "subProcess".equals(((CloudBPMNActivityCompletedEvent) event).getEntity().getActivityType())).collect(Collectors.toList()).get(0);
assertThat(subprocessCompletedEvent).isNotNull();
assertThat(subprocessCompletedEvent.getProcessInstanceId()).isEqualTo(processInstanceId);
});
}
use of org.activiti.api.process.model.events.BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED in project activiti-cloud by Activiti.
the class EmbeddedSubProcessAuditIT method shouldExecuteProcessWithEmbeddedSubProcessContainingCallActivity.
@Test
public void shouldExecuteProcessWithEmbeddedSubProcessContainingCallActivity() {
// given
ResponseEntity<CloudProcessInstance> processInstance = processInstanceRestTemplate.startProcess(buildStartProcessPayload(SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY));
String processInstanceId = processInstance.getBody().getId();
await().untilAsserted(() -> {
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getLatestReceivedEvents();
assertThat(receivedEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getParentProcessInstanceId, CloudRuntimeEvent::getProcessDefinitionKey).containsExactly(tuple(PROCESS_CREATED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(PROCESS_UPDATED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(PROCESS_STARTED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(ACTIVITY_STARTED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(ACTIVITY_COMPLETED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(ACTIVITY_STARTED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(ACTIVITY_STARTED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(ACTIVITY_COMPLETED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(ACTIVITY_STARTED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(TASK_CANDIDATE_GROUP_ADDED, null, null, null), tuple(TASK_CREATED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY));
assertThat(receivedEvents).filteredOn(event -> ACTIVITY_STARTED.equals(event.getEventType())).extracting(event -> ((CloudBPMNActivityStartedEvent) event).getEntity().getActivityType(), event -> ((CloudBPMNActivityStartedEvent) event).getEntity().getActivityName()).containsExactly(tuple("startEvent", null), tuple("subProcess", "subProcess"), tuple("startEvent", null), tuple("userTask", "Task in subprocess"));
});
ResponseEntity<PagedResources<CloudTask>> tasks = processInstanceRestTemplate.getTasks(processInstance);
Task task = tasks.getBody().iterator().next();
String subProcessInstanceId = task.getProcessInstanceId();
assertThat(subProcessInstanceId).isNotNull();
assertThat(subProcessInstanceId).isEqualTo(processInstanceId);
// when
taskRestTemplate.claim(task);
await().untilAsserted(() -> {
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getLatestReceivedEvents();
assertThat(receivedEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getParentProcessInstanceId, CloudRuntimeEvent::getProcessDefinitionKey).containsExactly(tuple(TASK_ASSIGNED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(TASK_UPDATED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY));
});
// when
taskRestTemplate.complete(task);
// Check we have two processes and one of them is callActivity process
// when
ResponseEntity<PagedResources<ProcessInstance>> processes = processInstanceRestTemplate.getSubprocesses(processInstanceId);
assertThat(processes.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(processes.getBody()).isNotNull();
assertThat(processes.getBody().getContent().size()).isEqualTo(1);
assertThat(processes.getBody().getContent().iterator().next().getProcessDefinitionKey()).isEqualTo(SIMPLE_SUB_PROCESS1);
String callActivityProcessId = processes.getBody().getContent().iterator().next().getId();
await().untilAsserted(() -> {
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getLatestReceivedEvents();
assertThat(receivedEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getParentProcessInstanceId, CloudRuntimeEvent::getProcessDefinitionKey).containsExactly(tuple(TASK_COMPLETED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(TASK_CANDIDATE_GROUP_REMOVED, null, null, null), tuple(ACTIVITY_COMPLETED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(SEQUENCE_FLOW_TAKEN, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(ACTIVITY_STARTED, processInstanceId, null, SIMPLE_EMBEDDED_SUB_PROCESS_WITH_CALLACTIVITY), tuple(PROCESS_CREATED, callActivityProcessId, processInstanceId, SIMPLE_SUB_PROCESS1), tuple(PROCESS_STARTED, callActivityProcessId, processInstanceId, SIMPLE_SUB_PROCESS1), tuple(ACTIVITY_STARTED, callActivityProcessId, processInstanceId, SIMPLE_SUB_PROCESS1), tuple(ACTIVITY_COMPLETED, callActivityProcessId, processInstanceId, SIMPLE_SUB_PROCESS1), tuple(SEQUENCE_FLOW_TAKEN, callActivityProcessId, processInstanceId, SIMPLE_SUB_PROCESS1), tuple(ACTIVITY_STARTED, callActivityProcessId, processInstanceId, SIMPLE_SUB_PROCESS1), tuple(TASK_CREATED, callActivityProcessId, processInstanceId, SIMPLE_SUB_PROCESS1));
});
// Clean up
runtimeService.deleteProcessInstance(callActivityProcessId, "Clean up");
runtimeService.deleteProcessInstance(processInstanceId, "Clean up");
}
Aggregations