use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ConformanceBasicProcessInformationTest method shouldBeAbleToStartProcess.
/*
* This test covers the Process Information.bpmn20.xml process which contains a BPMN Start Event, a BPMN SequenceFlow and BPMN End Event
* This execution should generate 8 events:
* - PROCESS_CREATED,
* - PROCESS_STARTED
* - ACTIVITY_STARTED
* - ACTIVITY_COMPLETED
* - SEQUENCE_FLOW_TAKEN
* - ACTIVITY_STARTED
* - ACTIVITY_COMPLETED
* - PROCESS_COMPLETED
* And the Process Instance Status should be Completed
* 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);
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, ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED);
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ConformanceBasicProcessInformationTest method shouldBeAbleToStartProcessWithVariables.
/*
* This test covers the Process Information.bpmn20.xml process which contains a BPMN Start Event, a BPMN SequenceFlow and BPMN End Event
* This test add variables to the process and generates more events
* This execution should generate 9 events:
* - PROCESS_CREATED,
* - VARIABLE_CREATED
* - PROCESS_STARTED
* - ACTIVITY_STARTED
* - ACTIVITI_COMPLETED
* - SEQUENCE_FLOW_TAKEN
* - ACTIVITY_STARTED
* - ACTIVITI_COMPLETED
* - PROCESS_COMPLETED
* And the Process Instance Status should be Completed
* No further operation can be executed on the process due the fact that it start and finish in the same transaction.
*
*/
@Test
public void shouldBeAbleToStartProcessWithVariables() {
securityUtil.logInAs("user1");
// when
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(processKey).withBusinessKey("my-business-key").withName("my-process-instance-name").withVariable("var1", "value1").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(RuntimeTestConfiguration.collectedEvents).extracting(RuntimeEvent::getEventType).containsExactly(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED, VariableEvent.VariableEvents.VARIABLE_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, ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED);
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class BasicExclusiveGatewayErrorTest method cleanup.
@AfterEach
public void cleanup() {
securityUtil.logInAs("admin");
Page<ProcessInstance> processInstancePage = processAdminRuntime.processInstances(Pageable.of(0, 50));
for (ProcessInstance pi : processInstancePage.getContent()) {
processAdminRuntime.delete(ProcessPayloadBuilder.delete(pi.getId()));
}
clearEvents();
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class BasicParallelGatewayTest method cleanup.
@AfterEach
public void cleanup() {
securityUtil.logInAs("admin");
Page<ProcessInstance> processInstancePage = processAdminRuntime.processInstances(Pageable.of(0, 50));
for (ProcessInstance pi : processInstancePage.getContent()) {
processAdminRuntime.delete(ProcessPayloadBuilder.delete(pi.getId()));
}
clearEvents();
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class BasicCallActivityTest method cleanup.
@AfterEach
public void cleanup() {
securityUtil.logInAs("admin");
Page<ProcessInstance> processInstancePage = processAdminRuntime.processInstances(Pageable.of(0, 50));
for (ProcessInstance pi : processInstancePage.getContent()) {
// We want to delete root processes instances because sub processes will be deleted automatically when the root ones are deleted
if (pi.getParentId() == null) {
processAdminRuntime.delete(ProcessPayloadBuilder.delete(pi.getId()));
}
}
clearEvents();
}
Aggregations