use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeEventsIT method shouldGetSameProcessInstanceIfForAllVariableCreatedEvents.
@Test
public void shouldGetSameProcessInstanceIfForAllVariableCreatedEvents() {
// when
ProcessInstance categorizeProcess = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(SINGLE_TASK_PROCESS).withVariable("name", "peter").build());
// then
assertThat(RuntimeTestConfiguration.variableCreatedEventsFromProcessInstance).extracting(event -> event.getProcessInstanceId()).contains(categorizeProcess.getId());
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeEventsIT method shouldGetSameProcessInstanceIfForAllSequenceFlowTakenEvents.
@Test
public void shouldGetSameProcessInstanceIfForAllSequenceFlowTakenEvents() {
// when
ProcessInstance categorizeProcess = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(SINGLE_TASK_PROCESS).withVariable("name", "peter").build());
// then
assertThat(RuntimeTestConfiguration.sequenceFlowTakenEvents).extracting(event -> event.getProcessInstanceId()).contains(categorizeProcess.getId());
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessInstanceOperationsTest method shouldBeAbleToStartSuspendAndResumeProcessInstance.
/*
*/
@Test
public void shouldBeAbleToStartSuspendAndResumeProcessInstance() {
securityUtil.logInAs("user1");
// when
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(processKey).withBusinessKey("my-business-key").withName("my-process-instance-name").build());
// then
assertThat(processInstance).isNotNull();
assertThat(processInstance.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.RUNNING);
assertThat(processInstance.getBusinessKey()).isEqualTo("my-business-key");
assertThat(processInstance.getName()).isEqualTo("my-process-instance-name");
assertThat(RuntimeTestConfiguration.collectedEvents).extracting(RuntimeEvent::getEventType).containsExactly(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED, ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, BPMNSequenceFlowTakenEvent.SequenceFlowEvents.SEQUENCE_FLOW_TAKEN, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, TaskRuntimeEvent.TaskEvents.TASK_CREATED);
clearEvents();
ProcessInstance suspendedProcessInstance = processRuntime.suspend(ProcessPayloadBuilder.suspend(processInstance.getId()));
assertThat(suspendedProcessInstance.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.SUSPENDED);
assertThat(RuntimeTestConfiguration.collectedEvents).extracting(RuntimeEvent::getEventType).containsExactly(ProcessRuntimeEvent.ProcessEvents.PROCESS_SUSPENDED, TaskRuntimeEvent.TaskEvents.TASK_SUSPENDED);
clearEvents();
ProcessInstance resumedProcessInstance = processRuntime.resume(ProcessPayloadBuilder.resume(suspendedProcessInstance.getId()));
assertThat(resumedProcessInstance.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.RUNNING);
assertThat(RuntimeTestConfiguration.collectedEvents).extracting(RuntimeEvent::getEventType).containsExactly(ProcessRuntimeEvent.ProcessEvents.PROCESS_RESUMED);
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ConformanceServiceTaskTest method shouldBeAbleToStartProcess.
/*
* This test covers the ServiceTask with Implementation.bpmn20.xml process
* This execution should generate 11 events:
* - PROCESS_CREATED
* - PROCESS_STARTED,
* - ACTIVITY_STARTED,
* - ACTIVITY_COMPLETED,
* - SEQUENCE_FLOW_TAKEN,
* - ACTIVITY_STARTED,
* - ACTIVITY_COMPLETED,
* - SEQUENCE_FLOW_TAKEN,
* - ACTIVITY_STARTED,
* - ACTIVITY_COMPLETED,
* - PROCESS_COMPLETED
* And the Process Instance Status should be Completed
* Connectors are executed in a Sync fashion, so the logic will be exexuted and the BPMN Activity completed automatically.
* IntegrationContext attributes shall capture and contain valid execution context of the underlying process instance.
* No further operation can be executed on the process due the fact that it start and finish in the same transaction
*/
@Test
public void shouldBeAbleToStartProcess() {
securityUtil.logInAs("user1");
// when
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(processKey).withBusinessKey(MY_BUSINESS_KEY).withName("my-process-instance-name").build());
// then
assertThat(processInstance).isNotNull();
assertThat(processInstance.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.COMPLETED);
assertThat(processInstance.getBusinessKey()).isEqualTo(MY_BUSINESS_KEY);
assertThat(processInstance.getName()).isEqualTo("my-process-instance-name");
// No Process Instance should be found
Throwable throwable = catchThrowable(() -> processRuntime.processInstance(processInstance.getId()));
assertThat(throwable).isInstanceOf(NotFoundException.class);
// No Variable Instance should be found
throwable = catchThrowable(() -> processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstanceId(processInstance.getId()).build()));
assertThat(throwable).isInstanceOf(NotFoundException.class);
assertThat(Set1RuntimeTestConfiguration.isConnector1Executed()).isTrue();
// and then
IntegrationContext integrationContext = Set1RuntimeTestConfiguration.getResultIntegrationContext();
assertThat(integrationContext).isNotNull();
assertThat(integrationContext.getBusinessKey()).isEqualTo(processInstance.getBusinessKey());
assertThat(integrationContext.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
assertThat(integrationContext.getProcessInstanceId()).isEqualTo(processInstance.getId());
assertThat(integrationContext.getProcessDefinitionKey()).isEqualTo(processInstance.getProcessDefinitionKey());
assertThat(integrationContext.getProcessDefinitionVersion()).isEqualTo(1);
assertThat(integrationContext.getParentProcessInstanceId()).isNull();
assertThat(integrationContext.getClientId()).isNotNull();
assertThat(integrationContext.getClientName()).isEqualTo("My Service Task");
assertThat(integrationContext.getClientType()).isEqualTo(ServiceTask.class.getSimpleName());
// and then
assertThat(RuntimeTestConfiguration.collectedEvents).extracting(RuntimeEvent::getEventType).containsExactly(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED, ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, BPMNSequenceFlowTakenEvent.SequenceFlowEvents.SEQUENCE_FLOW_TAKEN, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, BPMNSequenceFlowTakenEvent.SequenceFlowEvents.SEQUENCE_FLOW_TAKEN, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED);
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class UserTaskAssigneeDeleteRuntimeTest method shouldFailOnDeleteTask.
@Test
public void shouldFailOnDeleteTask() {
securityUtil.logInAs("user1");
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(processKey).withBusinessKey("my-business-key").withName("my-process-instance-name").build());
// then
assertThat(processInstance).isNotNull();
assertThat(processInstance.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.RUNNING);
assertThat(processInstance.getBusinessKey()).isEqualTo("my-business-key");
assertThat(processInstance.getName()).isEqualTo("my-process-instance-name");
// I should be able to get the process instance from the Runtime because it is still running
ProcessInstance processInstanceById = processRuntime.processInstance(processInstance.getId());
assertThat(processInstanceById).isEqualTo(processInstance);
// I should get a task for User1
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 50));
assertThat(tasks.getTotalItems()).isEqualTo(1);
Task task = tasks.getContent().get(0);
Task taskById = taskRuntime.task(task.getId());
assertThat(taskById.getStatus()).isEqualTo(Task.TaskStatus.ASSIGNED);
assertThat(task).isEqualTo(taskById);
assertThat(task.getAssignee()).isEqualTo("user1");
assertThat(RuntimeTestConfiguration.collectedEvents).extracting(RuntimeEvent::getEventType).containsExactly(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED, ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, BPMNSequenceFlowTakenEvent.SequenceFlowEvents.SEQUENCE_FLOW_TAKEN, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, TaskRuntimeEvent.TaskEvents.TASK_CREATED, TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED);
clearEvents();
Throwable throwable = catchThrowable(() -> taskRuntime.delete(TaskPayloadBuilder.delete().withTaskId(task.getId()).withReason("I don't want this task anymore").build()));
assertThat(throwable).isInstanceOf(ActivitiException.class).hasMessage("The task cannot be deleted because is part of a running process");
}
Aggregations