use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeBPMNErrorReceivedIT method should_StartSubProcess_When_ErrorEndEvenThrown.
@Test
public void should_StartSubProcess_When_ErrorEndEvenThrown() {
securityUtil.logInAs("user");
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(ERROR_START_EVENT_SUBPROCESS).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(), "subStart1", null, null, "errorId", "123"));
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class HistoryConfigurationTest method shouldRecordHistory.
@Test
public void shouldRecordHistory() {
securityUtil.logInAs("user");
// when
ProcessInstance categorizeProcess = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(CATEGORIZE_PROCESS).withVariable("expectedKey", true).build());
assertThat(RuntimeTestConfiguration.completedProcesses).contains(categorizeProcess.getId());
assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(categorizeProcess.getId()).count()).isEqualTo(1);
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeVariableMappingTest method should_resolveExpression_when_expressionIsInOutputMappingValueOrInMappedProperty.
@Test
public void should_resolveExpression_when_expressionIsInOutputMappingValueOrInMappedProperty() {
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(OUTPUT_MAPPING_EXPRESSION_VALUE_PROCESS);
List<VariableInstance> variables = processBaseRuntime.getProcessVariablesByProcessId(processInstance.getId());
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("name", "John"), tuple("outVar", "Resolved expression: value-set-in-connector"), tuple("outVarFromJsonExpression", "Tower of London"));
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class SignalThrowCatchTest method testProcessWithThrowSignal.
@Test
public void testProcessWithThrowSignal() {
securityUtil.logInAs("user1");
ProcessInstance processInstance = startThrowSignalProcess();
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);
assertThat(RuntimeTestConfiguration.collectedEvents).filteredOn(event -> event.getEventType().equals(BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED)).filteredOn(event -> ((BPMNActivity) event.getEntity()).getActivityType().equals("throwEvent")).extracting(event -> ((BPMNActivity) event.getEntity()).getActivityType(), event -> ((BPMNActivity) event.getEntity()).getProcessInstanceId()).contains(tuple("throwEvent", processInstance.getId()));
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class SignalThrowCatchTest method testProcessWithBoundaryEventSignal.
@Test
public void testProcessWithBoundaryEventSignal() {
securityUtil.logInAs("user1");
ProcessInstance processInstance = startBoundaryEventSignalProcess();
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);
BPMNActivityImpl signalCatchEvent = (BPMNActivityImpl) RuntimeTestConfiguration.collectedEvents.get(5).getEntity();
assertThat(signalCatchEvent.getActivityType()).isEqualTo("userTask");
assertThat(signalCatchEvent.getActivityName()).isEqualTo("Boundary container");
clearEvents();
SignalPayload signalPayload = ProcessPayloadBuilder.signal().withName("Test").withVariable("signal_variable", "test").build();
processRuntime.signal(signalPayload);
assertThat(RuntimeTestConfiguration.collectedEvents).extracting(RuntimeEvent::getEventType).containsExactlyInAnyOrder(BPMNSignalEvent.SignalEvents.SIGNAL_RECEIVED, VariableEvent.VariableEvents.VARIABLE_CREATED, TaskRuntimeEvent.TaskEvents.TASK_CANCELLED, BPMNActivityEvent.ActivityEvents.ACTIVITY_CANCELLED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, BPMNSequenceFlowTakenEvent.SequenceFlowEvents.SEQUENCE_FLOW_TAKEN, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, VariableEvent.VariableEvents.VARIABLE_CREATED, TaskRuntimeEvent.TaskEvents.TASK_CREATED);
BPMNSignalReceivedEvent event = (BPMNSignalReceivedEvent) RuntimeTestConfiguration.collectedEvents.get(0);
assertThat(event.getEntity()).isNotNull();
assertThat(event.getProcessInstanceId()).isEqualTo(processInstance.getId());
assertThat(event.getEntity().getSignalPayload()).isNotNull();
assertThat(event.getEntity().getSignalPayload().getName()).isEqualTo(signalPayload.getName());
assertThat(event.getEntity().getSignalPayload().getVariables()).hasSize(signalPayload.getVariables().size());
assertThat(event.getEntity().getSignalPayload().getVariables().get("signal_variable")).isEqualTo("test");
clearEvents();
}
Aggregations