use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeIT method should_handleBigDecimalAndDoubleVariables.
@Test
public void should_handleBigDecimalAndDoubleVariables() {
// given
BigDecimal bigDecimalValue = BigDecimal.valueOf(100000, 3);
double doubleValue = 2.0;
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(CATEGORIZE_HUMAN_PROCESS).withVariable("bigDecimalVar", bigDecimalValue).withVariable("doubleVar", doubleValue).build());
// when
List<VariableInstance> variables = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstance(processInstance).build());
// then
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).contains(tuple("bigDecimalVar", bigDecimalValue), tuple("doubleVar", doubleValue));
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeTerminatedEndEventIT method should_CancelledProcessesByTerminateEndEventsHaveCancellationReasonSet.
@Test
public void should_CancelledProcessesByTerminateEndEventsHaveCancellationReasonSet() {
// given
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(PROCESS_TERMINATE_EVENT).withName("to be terminated").withBusinessKey("My business key").build());
List<Task> tasks = taskBaseRuntime.getTasks(processInstance);
assertThat(tasks).hasSize(2);
Task task2 = tasks.get(1);
// when
taskBaseRuntime.completeTask(task2.getId());
// then
List<Task> tasksAfterCompletion = taskBaseRuntime.getTasks(processInstance);
assertThat(tasksAfterCompletion).hasSize(0);
List<ProcessCancelledEvent> processCancelledEvents = localEventSource.getEvents(ProcessCancelledEvent.class);
assertThat(processCancelledEvents).hasSize(1);
ProcessCancelledEvent processCancelledEvent = processCancelledEvents.get(0);
assertThat(processCancelledEvent.getCause()).contains("Terminated by end event");
assertThat(processCancelledEvent.getEntity().getId()).isEqualTo(processInstance.getId());
assertThat(processCancelledEvent.getEntity().getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
assertThat(processCancelledEvent.getEntity().getName()).isEqualTo(processInstance.getName());
assertThat(processCancelledEvent.getEntity().getBusinessKey()).isEqualTo(processInstance.getBusinessKey());
assertThat(processCancelledEvent.getEntity().getStartDate()).isEqualTo(processInstance.getStartDate());
assertThat(processCancelledEvent.getEntity().getInitiator()).isEqualTo(LOGGED_USER);
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessExtensionsIT method processInstanceHasInitialVariables.
@Test
public void processInstanceHasInitialVariables() {
ProcessRuntimeConfiguration configuration = processRuntime.configuration();
assertThat(configuration).isNotNull();
// start a process with vars then check default and specified vars exist
ProcessInstance initialVarsProcess = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(INITIAL_VARS_PROCESS).withVariable("extraVar", true).withVariable("age", 10).withBusinessKey("my business key").build());
assertThat(initialVarsProcess).isNotNull();
assertThat(initialVarsProcess.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.RUNNING);
List<VariableInstance> variableInstances = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstance(initialVarsProcess).build());
assertThat(variableInstances).isNotNull();
assertThat(variableInstances).hasSize(4);
assertThat(variableInstances).extracting("name").contains("extraVar", "name", "age", "birth").doesNotContain("subscribe");
// cleanup
processRuntime.delete(ProcessPayloadBuilder.delete(initialVarsProcess));
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessExtensionsIT method should_mapProcessVariables_when_startEventMappingExists.
@Test
public void should_mapProcessVariables_when_startEventMappingExists() {
// given
ProcessInstance process = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey("process-b42a166d-605b-4eec-8b96-82b1253666bf").withVariable("Text0xfems", "name_value").withVariable("Text0rvs0o", "email_value").withBusinessKey("my business key").build());
// when
List<VariableInstance> variableInstances = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstance(process).build());
// then
assertThat(variableInstances).isNotNull().hasSize(2).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("name", "name_value"), tuple("email", "email_value"));
// when
List<VariableInstance> taskVariables = retrieveVariablesForFirstTaskOfProcess(process);
// then
assertThat(taskVariables).isNotNull().hasSize(2).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("nameInTask", "name_value"), tuple("emailInTask", "email_value"));
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeBPMNErrorReceivedIT method should_CatchCallActivityBoundaryErrorEvent_When_ErrorEndEvenThrown.
@Test
public void should_CatchCallActivityBoundaryErrorEvent_When_ErrorEndEvenThrown() {
securityUtil.logInAs("user");
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(ERROR_BOUNDARY_EVENT_CALLACTIVITY).build());
assertThat(processInstance).isNotNull();
checkProcessAndTask(processInstance.getId(), "Task");
assertThat(listener.getErrorReceivedEvents()).isNotEmpty().extracting(BPMNErrorReceivedEvent::getEventType, BPMNErrorReceivedEvent::getProcessDefinitionId, BPMNErrorReceivedEvent::getProcessInstanceId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId(), event -> event.getEntity().getActivityName(), event -> event.getEntity().getActivityType(), event -> event.getEntity().getErrorId(), event -> event.getEntity().getErrorCode()).contains(Tuple.tuple(BPMNErrorReceivedEvent.ErrorEvents.ERROR_RECEIVED, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "catchError", null, null, "errorId", "123"));
}
Aggregations