use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeBPMNTimerIT method shouldGetTimerCanceledEventByProcessDelete.
@Test
public void shouldGetTimerCanceledEventByProcessDelete() {
// GIVEN
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(PROCESS_TIMER_CANCELLED_EVENT);
// WHEN
processBaseRuntime.delete(processInstance.getId());
// THEN
List<BPMNTimerCancelledEvent> eventsCancelled = listenerCancelled.getEvents();
assertThat(eventsCancelled).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_CANCELLED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeBPMNTimerIT method shouldGetTimerCanceledEventOnBoundaryEvent.
@Test
public void shouldGetTimerCanceledEventOnBoundaryEvent() {
// given
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(PROCESS_TIMER_CANCELLED_EVENT);
List<BPMNTimerScheduledEvent> eventsScheduled = listenerScheduled.getEvents();
assertThat(eventsScheduled).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_SCHEDULED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
clear();
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 10), TaskPayloadBuilder.tasks().withProcessInstanceId(processInstance.getId()).build());
assertThat(tasks.getContent()).hasSize(1);
Task task = tasks.getContent().get(0);
taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());
taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(task.getId()).build());
List<BPMNTimerCancelledEvent> eventsCanceled = listenerCancelled.getEvents();
assertThat(eventsCanceled).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_CANCELLED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeBPMNTimerIT method shouldGetTimerFiredScheduledEventsForProcessWithTimer.
@Test
public void shouldGetTimerFiredScheduledEventsForProcessWithTimer() throws Exception {
// given
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(PROCESS_INTERMEDIATE_TIMER_EVENT);
// when
List<BPMNTimerScheduledEvent> eventsScheduled = listenerScheduled.getEvents();
// then
assertThat(eventsScheduled).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_SCHEDULED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
assertThat(listenerFired.getEvents()).isEmpty();
// when
long waitTime = 10 * 60 * 1000;
Date startTime = new Date();
Date dueDate = new Date(startTime.getTime() + waitTime);
// After setting the clock to time '5minutes and 5 seconds', the second timer should fire
processEngineConfiguration.getClock().setCurrentTime(new Date(dueDate.getTime() + 5000));
// then
await().untilAsserted(() -> {
assertThat(listenerFired.getEvents()).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_FIRED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
assertThat(listenerExecuted.getEvents()).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_EXECUTED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
});
// then the execution reaches the task
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 10), TaskPayloadBuilder.tasks().withProcessInstanceId(processInstance.getId()).build());
assertThat(tasks.getContent()).hasSize(1);
assertThat(tasks.getContent().get(0).getName()).isEqualTo("User Task");
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeCallActivityMappingIT method getSubProcess.
private ProcessInstance getSubProcess(ProcessInstance processInstance) {
List<ProcessInstance> subProcessInstanceList = processRuntime.processInstances(Pageable.of(0, 50), ProcessPayloadBuilder.processInstances().withParentProcessInstanceId(processInstance.getId()).build()).getContent();
assertThat(subProcessInstanceList).isNotEmpty();
ProcessInstance subProcessInstance = subProcessInstanceList.get(0);
assertThat(subProcessInstance).isNotNull();
assertThat(subProcessInstance.getParentId()).isEqualTo(processInstance.getId());
return subProcessInstance;
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeCallActivityMappingIT method basicCallActivityMappingTest.
@Test
public void basicCallActivityMappingTest() {
securityUtil.logInAs("user");
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(PARENT_PROCESS_CALL_ACTIVITY).build());
assertThat(processInstance).isNotNull();
ProcessInstance subProcessInstance = getSubProcess(processInstance);
assertThat(subProcessInstance.getProcessDefinitionKey()).isEqualTo(SUB_PROCESS_CALL_ACTIVITY);
Task task = getTask(subProcessInstance);
taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());
List<VariableInstance> subProcVariables = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstanceId(subProcessInstance.getId()).build());
assertThat(subProcVariables).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("subprocess_input_var1", "inName"), tuple("subprocess_input_var2", 20), tuple("subprocess_input_var3", 5), tuple("input_static_value", "a static value"), tuple("subprocess_out_var1", "outValue"), tuple("subprocess_out_var2", 222), tuple("subprocess_static_value", "static some value"), tuple("var_not_exist_in_subprocess_extension_file", 20));
assertThat("my-task-call-activity").isEqualTo(task.getName());
Map<String, Object> variablesForTask = new HashMap<>();
variablesForTask.put("input_variable_name_1", "fromSubprocessName");
variablesForTask.put("input_variable_name_2", 39);
variablesForTask.put("out_variable_name_1", 176);
completeTask(task.getId(), variablesForTask);
List<VariableInstance> parentVariables = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstanceId(processInstance.getId()).build());
assertThat(parentVariables).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("name", "outValue"), tuple("age", 222), tuple("output_unmapped_variable_with_non_matching_connector_output_name", "default"), tuple("input_unmapped_variable_with_non_matching_connector_input_name", "inTest"));
cleanUp();
}
Aggregations