Search in sources :

Example 6 with Page

use of org.activiti.api.runtime.shared.query.Page in project Activiti by Activiti.

the class TaskRuntimeMultiInstanceIT method processWithParallelMultiInstancesOn_CallActivity_Boundary_Event.

@Test
public void processWithParallelMultiInstancesOn_CallActivity_Boundary_Event() {
    ProcessInstance parentProcessInstance = processBaseRuntime.startProcessWithProcessDefinitionKey("miParallelCallActivityBoundaryEvent");
    final Page<ProcessInstance> childrenProcessInstances = processBaseRuntime.getChildrenProcessInstances(parentProcessInstance.getId());
    assertThat(childrenProcessInstances.getContent()).hasSize(2);
    assertThat(localEventSource.getEvents(ProcessStartedEvent.class)).extracting(RuntimeEvent::getEventType, event -> event.getEntity().getId(), event -> event.getEntity().getParentId()).containsExactlyInAnyOrder(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, parentProcessInstance.getId(), null), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, childrenProcessInstances.getContent().get(0).getId(), parentProcessInstance.getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, childrenProcessInstances.getContent().get(1).getId(), parentProcessInstance.getId()));
    assertActivityEvents("miCallActivity", BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
    assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactlyInAnyOrder(tuple(TaskRuntimeEvent.TaskEvents.TASK_CREATED, "User Task", childrenProcessInstances.getContent().get(0).getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_CREATED, "User Task", childrenProcessInstances.getContent().get(1).getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "User Task", childrenProcessInstances.getContent().get(0).getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "User Task", childrenProcessInstances.getContent().get(1).getId()));
    assertThat(localEventSource.getEvents(ProcessCompletedEvent.class)).isEmpty();
    // when
    localEventSource.clearEvents();
    processBaseRuntime.signal("goMiParallelCallActivityBoundaryEvent");
    // then
    assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactlyInAnyOrder(tuple(TaskRuntimeEvent.TaskEvents.TASK_CANCELLED, "User Task", childrenProcessInstances.getContent().get(0).getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_CANCELLED, "User Task", childrenProcessInstances.getContent().get(1).getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_CREATED, "Escalation Task", parentProcessInstance.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "Escalation Task", parentProcessInstance.getId()));
    assertActivityEvents("miCallActivity", BPMNActivityEvent.ActivityEvents.ACTIVITY_CANCELLED, BPMNActivityEvent.ActivityEvents.ACTIVITY_CANCELLED);
    assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, event -> ((ProcessInstance) event.getEntity()).getId()).containsExactlyInAnyOrder(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_CANCELLED, childrenProcessInstances.getContent().get(0).getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_CANCELLED, childrenProcessInstances.getContent().get(1).getId()));
    List<Task> tasks = taskBaseRuntime.getTasks(parentProcessInstance);
    assertThat(tasks.size()).isEqualTo(1);
    assertThat(tasks).extracting(Task::getName).contains("Escalation Task");
    localEventSource.clearEvents();
    taskBaseRuntime.completeTask(tasks.get(0));
    assertThat(taskBaseRuntime.getTasks(parentProcessInstance)).isEmpty();
    assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, RuntimeEvent::getProcessInstanceId).containsExactly(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, parentProcessInstance.getId()));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) DummyBPMNTimerCancelledListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerCancelledListener) ProcessRuntimeEvent(org.activiti.api.process.model.events.ProcessRuntimeEvent) Task(org.activiti.api.task.model.Task) Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) BPMNActivityStartedEvent(org.activiti.api.process.model.events.BPMNActivityStartedEvent) SecurityUtil(org.activiti.spring.boot.security.util.SecurityUtil) ProcessStartedEvent(org.activiti.api.process.runtime.events.ProcessStartedEvent) Autowired(org.springframework.beans.factory.annotation.Autowired) ProcessCompletedEvent(org.activiti.api.process.runtime.events.ProcessCompletedEvent) ActiveProfiles(org.springframework.test.context.ActiveProfiles) DummyBPMNTimerScheduledListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerScheduledListener) ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) BPMNTimerEvent(org.activiti.api.process.model.events.BPMNTimerEvent) TaskCreatedEvent(org.activiti.api.task.runtime.events.TaskCreatedEvent) Arrays.asList(java.util.Arrays.asList) DummyBPMNTimerExecutedListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerExecutedListener) LocalEventSource(org.activiti.test.LocalEventSource) Collections.singletonMap(java.util.Collections.singletonMap) TaskRuntimeEvent(org.activiti.api.task.model.events.TaskRuntimeEvent) BPMNActivityCancelledEvent(org.activiti.api.process.model.events.BPMNActivityCancelledEvent) ProcessInstance(org.activiti.api.process.model.ProcessInstance) BPMNActivityCompletedEvent(org.activiti.api.process.model.events.BPMNActivityCompletedEvent) Awaitility.await(org.awaitility.Awaitility.await) Assertions.tuple(org.assertj.core.api.Assertions.tuple) TimerTestConfigurator(org.activiti.spring.boot.process.TimerTestConfigurator) RuntimeEvent(org.activiti.api.model.shared.event.RuntimeEvent) BPMNActivityEvent(org.activiti.api.process.model.events.BPMNActivityEvent) Import(org.springframework.context.annotation.Import) Page(org.activiti.api.runtime.shared.query.Page) Collectors(java.util.stream.Collectors) TaskAssignedEvent(org.activiti.api.task.runtime.events.TaskAssignedEvent) DummyBPMNTimerFiredListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerFiredListener) Test(org.junit.jupiter.api.Test) ProcessRuntimeBPMNTimerIT(org.activiti.spring.boot.process.ProcessRuntimeBPMNTimerIT) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ProcessCleanUpUtil(org.activiti.spring.boot.test.util.ProcessCleanUpUtil) VariableInstance(org.activiti.api.model.shared.model.VariableInstance) ProcessBaseRuntime(org.activiti.spring.boot.process.ProcessBaseRuntime) Task(org.activiti.api.task.model.Task) ProcessStartedEvent(org.activiti.api.process.runtime.events.ProcessStartedEvent) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with Page

use of org.activiti.api.runtime.shared.query.Page in project Activiti by Activiti.

the class ProcessRuntimeIT method should_processDefinitionAlwaysHaveAppVersion.

@Test
public void should_processDefinitionAlwaysHaveAppVersion() {
    Page<ProcessDefinition> processDefinitionPage = processRuntime.processDefinitions(PAGEABLE);
    assertThat(processDefinitionPage.getContent()).isNotEmpty();
    List<ProcessDefinition> processDefinitions = processDefinitionPage.getContent().stream().filter(c -> c.getKey().equals(SUPER_PROCESS)).collect(Collectors.toList());
    assertThat(processDefinitions).hasSize(1);
    ProcessDefinition result = processDefinitions.get(0);
    assertThat(result.getAppVersion()).isEqualTo("1");
}
Also used : RuntimeService(org.activiti.engine.RuntimeService) BeforeEach(org.junit.jupiter.api.BeforeEach) Pageable(org.activiti.api.runtime.shared.query.Pageable) ProcessRuntimeImpl(org.activiti.runtime.api.impl.ProcessRuntimeImpl) Task(org.activiti.api.task.model.Task) APIVariableInstanceConverter(org.activiti.runtime.api.model.impl.APIVariableInstanceConverter) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SecurityUtil(org.activiti.spring.boot.security.util.SecurityUtil) Autowired(org.springframework.beans.factory.annotation.Autowired) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) Mockito.spy(org.mockito.Mockito.spy) ProcessPayloadBuilder(org.activiti.api.process.model.builders.ProcessPayloadBuilder) Deployment(org.activiti.api.process.model.Deployment) ProcessRuntime(org.activiti.api.process.runtime.ProcessRuntime) RepositoryService(org.activiti.engine.RepositoryService) BigDecimal(java.math.BigDecimal) ProcessSecurityPoliciesManager(org.activiti.core.common.spring.security.policies.ProcessSecurityPoliciesManager) ProcessAdminRuntimeImpl(org.activiti.runtime.api.impl.ProcessAdminRuntimeImpl) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) APIProcessInstanceConverter(org.activiti.runtime.api.model.impl.APIProcessInstanceConverter) TaskRuntime(org.activiti.api.task.runtime.TaskRuntime) APIProcessDefinitionConverter(org.activiti.runtime.api.model.impl.APIProcessDefinitionConverter) ProcessVariablesPayloadValidator(org.activiti.runtime.api.impl.ProcessVariablesPayloadValidator) ProcessInstance(org.activiti.api.process.model.ProcessInstance) ProcessRuntimeConfiguration(org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration) APIDeploymentConverter(org.activiti.runtime.api.model.impl.APIDeploymentConverter) TaskPayloadBuilder(org.activiti.api.task.model.builders.TaskPayloadBuilder) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) UpdateProcessPayload(org.activiti.api.process.model.payloads.UpdateProcessPayload) Page(org.activiti.api.runtime.shared.query.Page) AccessDeniedException(org.springframework.security.access.AccessDeniedException) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) StartProcessPayload(org.activiti.api.process.model.payloads.StartProcessPayload) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) RuntimeTestConfiguration(org.activiti.spring.boot.RuntimeTestConfiguration) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ProcessCleanUpUtil(org.activiti.spring.boot.test.util.ProcessCleanUpUtil) ProcessAdminRuntime(org.activiti.api.process.runtime.ProcessAdminRuntime) VariableInstance(org.activiti.api.model.shared.model.VariableInstance) Tuple.tuple(org.assertj.core.groups.Tuple.tuple) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with Page

use of org.activiti.api.runtime.shared.query.Page in project Activiti by Activiti.

the class ProcessRuntimeBPMNSignalReceivedIT method shouldGetSignalReceivedEventsForProcessWithSignalStart.

@Test
public void shouldGetSignalReceivedEventsForProcessWithSignalStart() {
    // In this test processWithSignalStart1 should be started
    // given
    securityUtil.logInAs("user");
    Page<ProcessDefinition> processDefinitionPage = processRuntime.processDefinitions(Pageable.of(0, 10), ProcessPayloadBuilder.processDefinitions().withProcessDefinitionKey("processWithSignalStart1").build());
    assertThat(processDefinitionPage.getContent()).hasSize(1);
    // when
    SignalPayload signalPayload = new SignalPayload("The Signal", null);
    processRuntime.signal(signalPayload);
    // then
    String processDefinitionId = processDefinitionPage.getContent().get(0).getId();
    assertThat(listener.getSignalReceivedEvents()).extracting(BPMNSignalReceivedEvent::getEventType, BPMNSignalReceivedEvent::getProcessDefinitionId, event -> event.getEntity().getSignalPayload().getName(), event -> event.getEntity().getElementId(), event -> event.getEntity().getProcessDefinitionId()).contains(Tuple.tuple(BPMNSignalEvent.SignalEvents.SIGNAL_RECEIVED, processDefinitionId, "The Signal", "theStart", processDefinitionId));
}
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) Assertions.tuple(org.assertj.core.api.Assertions.tuple) 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) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) Page(org.activiti.api.runtime.shared.query.Page) ProcessPayloadBuilder(org.activiti.api.process.model.builders.ProcessPayloadBuilder) BPMNSignalReceivedEvent(org.activiti.api.process.model.events.BPMNSignalReceivedEvent) ProcessRuntime(org.activiti.api.process.runtime.ProcessRuntime) Test(org.junit.jupiter.api.Test) BPMNSignalEvent(org.activiti.api.process.model.events.BPMNSignalEvent) AfterEach(org.junit.jupiter.api.AfterEach) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ProcessCleanUpUtil(org.activiti.spring.boot.test.util.ProcessCleanUpUtil) ProcessInstanceStatus(org.activiti.api.process.model.ProcessInstance.ProcessInstanceStatus) DummyBPMNSignalReceivedListener(org.activiti.spring.boot.process.listener.DummyBPMNSignalReceivedListener) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) 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)8 Page (org.activiti.api.runtime.shared.query.Page)8 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)8 AfterEach (org.junit.jupiter.api.AfterEach)8 Test (org.junit.jupiter.api.Test)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)8 Pageable (org.activiti.api.runtime.shared.query.Pageable)7 Task (org.activiti.api.task.model.Task)7 SecurityUtil (org.activiti.spring.boot.security.util.SecurityUtil)7 ProcessCleanUpUtil (org.activiti.spring.boot.test.util.ProcessCleanUpUtil)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 List (java.util.List)6 VariableInstance (org.activiti.api.model.shared.model.VariableInstance)6 ProcessPayloadBuilder (org.activiti.api.process.model.builders.ProcessPayloadBuilder)5 ProcessRuntime (org.activiti.api.process.runtime.ProcessRuntime)5 TaskPayloadBuilder (org.activiti.api.task.model.builders.TaskPayloadBuilder)5 TaskRuntime (org.activiti.api.task.runtime.TaskRuntime)5 Assertions.tuple (org.assertj.core.api.Assertions.tuple)5 Import (org.springframework.context.annotation.Import)5