use of org.activiti.api.task.model.Task 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.task.model.Task in project Activiti by Activiti.
the class ProcessRuntimeCallActivityMappingIT method getTask.
private Task getTask(ProcessInstance subProcessInstance) {
List<Task> taskList = taskRuntime.tasks(Pageable.of(0, 50), TaskPayloadBuilder.tasks().withProcessInstanceId(subProcessInstance.getId()).build()).getContent();
assertThat(taskList).isNotEmpty();
Task task = taskList.get(0);
assertThat(task.getAssignee()).isNull();
assertThat(task.getStatus()).isEqualTo(Task.TaskStatus.CREATED);
return task;
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class ProcessRuntimeCallActivityMappingIT method completeTask.
public void completeTask(String taskId, Map<String, Object> variables) {
Task completeTask = taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskId).withVariables(variables).build());
assertThat(completeTask).isNotNull();
assertThat(completeTask.getStatus()).isEqualTo(Task.TaskStatus.COMPLETED);
}
use of org.activiti.api.task.model.Task 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();
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class ProcessRuntimeIT method should_startAnAlreadyCreatedProcess_when_startCreatedProcessIsCalled.
@Test
public void should_startAnAlreadyCreatedProcess_when_startCreatedProcessIsCalled() {
securityUtil.logInAs("garth");
ProcessInstance singleTaskProcessCreated = processRuntime.create(ProcessPayloadBuilder.create().withProcessDefinitionKey(SINGLE_TASK_PROCESS).build());
assertThat(singleTaskProcessCreated.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.CREATED);
Page<Task> tasks = taskRuntime.tasks(PAGEABLE, TaskPayloadBuilder.tasks().withProcessInstanceId(singleTaskProcessCreated.getId()).build());
assertThat(tasks.getTotalItems()).isEqualTo(0);
ProcessInstance singleTaskProcessStarted = processRuntime.startCreatedProcess(singleTaskProcessCreated.getId(), ProcessPayloadBuilder.start().build());
tasks = taskRuntime.tasks(PAGEABLE, TaskPayloadBuilder.tasks().withProcessInstanceId(singleTaskProcessCreated.getId()).build());
assertThat(tasks.getTotalItems()).isEqualTo(1);
assertThat(tasks.getContent().get(0).getName()).isEqualTo("my-task");
assertThat(RuntimeTestConfiguration.createdTasks).contains(tasks.getContent().get(0).getId());
assertThat(singleTaskProcessStarted).isNotNull();
assertThat(singleTaskProcessStarted.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.RUNNING);
}
Aggregations