Search in sources :

Example 76 with ProcessInstance

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"));
}
Also used : ProcessInstance(org.activiti.api.process.model.ProcessInstance) BeforeEach(org.junit.jupiter.api.BeforeEach) Pageable(org.activiti.api.runtime.shared.query.Pageable) Tuple(org.assertj.core.groups.Tuple) GetTasksPayloadBuilder(org.activiti.api.task.model.builders.GetTasksPayloadBuilder) Task(org.activiti.api.task.model.Task) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SecurityUtil(org.activiti.spring.boot.security.util.SecurityUtil) Autowired(org.springframework.beans.factory.annotation.Autowired) Import(org.springframework.context.annotation.Import) Page(org.activiti.api.runtime.shared.query.Page) ProcessPayloadBuilder(org.activiti.api.process.model.builders.ProcessPayloadBuilder) GetTasksPayload(org.activiti.api.task.model.payloads.GetTasksPayload) ProcessRuntime(org.activiti.api.process.runtime.ProcessRuntime) Test(org.junit.jupiter.api.Test) AfterEach(org.junit.jupiter.api.AfterEach) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ProcessCleanUpUtil(org.activiti.spring.boot.test.util.ProcessCleanUpUtil) BPMNErrorReceivedEvent(org.activiti.api.process.model.events.BPMNErrorReceivedEvent) DummyBPMNErrorReceivedListener(org.activiti.spring.boot.process.listener.DummyBPMNErrorReceivedListener) TaskRuntime(org.activiti.api.task.runtime.TaskRuntime) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 77 with ProcessInstance

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);
}
Also used : ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 78 with ProcessInstance

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"));
}
Also used : ProcessInstance(org.activiti.api.process.model.ProcessInstance) VariableInstance(org.activiti.api.model.shared.model.VariableInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 79 with ProcessInstance

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()));
}
Also used : VariableEvent(org.activiti.api.model.shared.event.VariableEvent) BPMNSequenceFlowTakenEvent(org.activiti.api.process.model.events.BPMNSequenceFlowTakenEvent) BeforeEach(org.junit.jupiter.api.BeforeEach) Pageable(org.activiti.api.runtime.shared.query.Pageable) ProcessRuntimeEvent(org.activiti.api.process.model.events.ProcessRuntimeEvent) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Autowired(org.springframework.beans.factory.annotation.Autowired) RuntimeTestConfiguration(org.activiti.spring.conformance.util.RuntimeTestConfiguration) ProcessPayloadBuilder(org.activiti.api.process.model.builders.ProcessPayloadBuilder) ProcessRuntime(org.activiti.api.process.runtime.ProcessRuntime) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) SecurityUtil(org.activiti.spring.conformance.util.security.SecurityUtil) TaskRuntimeEvent(org.activiti.api.task.model.events.TaskRuntimeEvent) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Assertions.tuple(org.assertj.core.api.Assertions.tuple) RuntimeEvent(org.activiti.api.model.shared.event.RuntimeEvent) BPMNActivityEvent(org.activiti.api.process.model.events.BPMNActivityEvent) BPMNActivityImpl(org.activiti.api.runtime.model.impl.BPMNActivityImpl) Page(org.activiti.api.runtime.shared.query.Page) BPMNSignalReceivedEvent(org.activiti.api.process.model.events.BPMNSignalReceivedEvent) Test(org.junit.jupiter.api.Test) BPMNSignalEvent(org.activiti.api.process.model.events.BPMNSignalEvent) AfterEach(org.junit.jupiter.api.AfterEach) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) BPMNActivity(org.activiti.api.process.model.BPMNActivity) ProcessAdminRuntime(org.activiti.api.process.runtime.ProcessAdminRuntime) BPMNActivity(org.activiti.api.process.model.BPMNActivity) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 80 with ProcessInstance

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();
}
Also used : BPMNActivityImpl(org.activiti.api.runtime.model.impl.BPMNActivityImpl) BPMNSignalReceivedEvent(org.activiti.api.process.model.events.BPMNSignalReceivedEvent) ProcessInstance(org.activiti.api.process.model.ProcessInstance) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ProcessInstance (org.activiti.api.process.model.ProcessInstance)154 Test (org.junit.jupiter.api.Test)123 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)116 Task (org.activiti.api.task.model.Task)73 AfterEach (org.junit.jupiter.api.AfterEach)57 VariableInstance (org.activiti.api.model.shared.model.VariableInstance)54 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)39 Autowired (org.springframework.beans.factory.annotation.Autowired)39 BeforeEach (org.junit.jupiter.api.BeforeEach)38 Page (org.activiti.api.runtime.shared.query.Page)37 SecurityUtil (org.activiti.spring.boot.security.util.SecurityUtil)37 ProcessCleanUpUtil (org.activiti.spring.boot.test.util.ProcessCleanUpUtil)37 Import (org.springframework.context.annotation.Import)35 List (java.util.List)33 Assertions.tuple (org.assertj.core.api.Assertions.tuple)33 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)31 LocalEventSource (org.activiti.test.LocalEventSource)30 RuntimeEvent (org.activiti.api.model.shared.event.RuntimeEvent)29 ProcessRuntimeEvent (org.activiti.api.process.model.events.ProcessRuntimeEvent)29 TaskRuntimeEvent (org.activiti.api.task.model.events.TaskRuntimeEvent)29