use of org.activiti.api.runtime.shared.query.Page in project Activiti by Activiti.
the class ProcessRuntimeBPMNMessageIT method shouldTestCatchMessageExpressionWithVariableMappingExtensions.
@Test
public void shouldTestCatchMessageExpressionWithVariableMappingExtensions() {
// when
ProcessInstance process = processRuntime.start(ProcessPayloadBuilder.start().withBusinessKey("businessKey").withProcessDefinitionKey("testCatchMessageExpression").build());
// then
List<VariableInstance> variables = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstance(process).build());
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("intermediate_var", ""), tuple("inter_message_var", "check2"));
// when
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 2), TaskPayloadBuilder.tasks().withProcessInstanceId(process.getId()).build());
// then
assertThat(tasks.getContent()).hasSize(1);
String taskId = tasks.getContent().get(0).getId();
// when
taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskId).withVariable("Text0739ze", "foo").build());
// then
variables = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstance(process).build());
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).containsOnly(tuple("intermediate_var", "foo"), tuple("inter_message_var", "check2"));
// when
processRuntime.receive(MessagePayloadBuilder.receive("intermediate-catch-message-check2").withCorrelationKey("foo").build());
// then
tasks = taskRuntime.tasks(Pageable.of(0, 2), TaskPayloadBuilder.tasks().withProcessInstanceId(process.getId()).build());
assertThat(tasks.getContent()).hasSize(1);
taskId = tasks.getContent().get(0).getId();
// then
taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskId).build());
// then
assertThat(MessageTestConfiguration.messageEvents).isNotEmpty().extracting(BPMNMessageEvent::getEventType, BPMNMessageEvent::getProcessDefinitionId, BPMNMessageEvent::getProcessInstanceId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getMessagePayload().getName(), event -> event.getEntity().getMessagePayload().getCorrelationKey(), event -> event.getEntity().getMessagePayload().getBusinessKey(), event -> event.getEntity().getMessagePayload().getVariables()).contains(Tuple.tuple(BPMNMessageEvent.MessageEvents.MESSAGE_WAITING, process.getProcessDefinitionId(), process.getId(), process.getProcessDefinitionId(), process.getId(), "intermediate-catch-message-check2", "foo", process.getBusinessKey(), null), Tuple.tuple(BPMNMessageEvent.MessageEvents.MESSAGE_RECEIVED, process.getProcessDefinitionId(), process.getId(), process.getProcessDefinitionId(), process.getId(), "intermediate-catch-message-check2", "foo", process.getBusinessKey(), null));
}
use of org.activiti.api.runtime.shared.query.Page in project Activiti by Activiti.
the class UserTaskCandidateGroupAndAssigneeTest method shouldCreateAndCompleteATaskAndDontSeeNext.
@Test
public void shouldCreateAndCompleteATaskAndDontSeeNext() {
securityUtil.logInAs("user1");
// given
ProcessInstance processInstance = processOperations.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(processKey).withBusinessKey("my-business-key").withName("my-process-instance-name").build()).expectFields(processInstance().status(ProcessInstance.ProcessInstanceStatus.RUNNING), processInstance().name("my-process-instance-name"), processInstance().businessKey("my-business-key")).expect(processInstance().hasTask("Task User1", Task.TaskStatus.ASSIGNED, withAssignee("user1"))).expectEvents(processInstance().hasBeenStarted(), startEvent("StartEvent_1").hasBeenStarted(), startEvent("StartEvent_1").hasBeenCompleted(), sequenceFlow("SequenceFlow_1uccvwa").hasBeenTaken(), taskWithName("Task User1").hasBeenCreated(), taskWithName("Task User1").hasBeenAssigned()).andReturn();
// I should be able to get the process instance from the Runtime because it is still running
ProcessInstance processInstanceById = processRuntime.processInstance(processInstance.getId());
assertThat(processInstanceById).isEqualTo(processInstance);
// I should get a task for User1
GetTasksPayload processInstanceTasksPayload = TaskPayloadBuilder.tasks().withProcessInstanceId(processInstance.getId()).build();
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 50), processInstanceTasksPayload);
assertThat(tasks.getTotalItems()).isEqualTo(1);
Task task = tasks.getContent().get(0);
// given
taskOperations.complete(TaskPayloadBuilder.complete().withTaskId(task.getId()).build()).expectEvents(task().hasBeenCompleted(), sequenceFlow("SequenceFlow_151v2cg").hasBeenTaken(), taskWithName("Task Group1").hasBeenCreated()).expect(processInstance().hasTask("Task Group1", Task.TaskStatus.CREATED, createdTask -> {
assertThat(taskRuntime.userCandidates(createdTask.getId())).isEmpty();
assertThat(taskRuntime.groupCandidates(createdTask.getId())).contains("group1");
}));
// Check with user1 as he is a candidate
tasks = taskRuntime.tasks(Pageable.of(0, 50), processInstanceTasksPayload);
assertThat(tasks.getTotalItems()).isEqualTo(1);
// Check with user2 candidates which is not a candidate
securityUtil.logInAs("user2");
tasks = taskRuntime.tasks(Pageable.of(0, 50));
assertThat(tasks.getTotalItems()).isEqualTo(0);
// Check with user3 candidates which is a candidate
securityUtil.logInAs("user3");
tasks = taskRuntime.tasks(Pageable.of(0, 50), processInstanceTasksPayload);
assertThat(tasks.getTotalItems()).isEqualTo(1);
}
use of org.activiti.api.runtime.shared.query.Page in project Activiti by Activiti.
the class ProcessRuntimeBPMNTimerIT method shouldGetTimerCanceledEventOnBoundaryEvent.
@Test
public void shouldGetTimerCanceledEventOnBoundaryEvent() {
// given
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(PROCESS_TIMER_CANCELLED_EVENT);
List<BPMNTimerScheduledEvent> eventsScheduled = listenerScheduled.getEvents();
assertThat(eventsScheduled).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_SCHEDULED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
clear();
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 10), TaskPayloadBuilder.tasks().withProcessInstanceId(processInstance.getId()).build());
assertThat(tasks.getContent()).hasSize(1);
Task task = tasks.getContent().get(0);
taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());
taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(task.getId()).build());
List<BPMNTimerCancelledEvent> eventsCanceled = listenerCancelled.getEvents();
assertThat(eventsCanceled).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_CANCELLED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
}
use of org.activiti.api.runtime.shared.query.Page in project Activiti by Activiti.
the class ProcessRuntimeBPMNTimerIT method shouldGetTimerFiredScheduledEventsForProcessWithTimer.
@Test
public void shouldGetTimerFiredScheduledEventsForProcessWithTimer() throws Exception {
// given
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(PROCESS_INTERMEDIATE_TIMER_EVENT);
// when
List<BPMNTimerScheduledEvent> eventsScheduled = listenerScheduled.getEvents();
// then
assertThat(eventsScheduled).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_SCHEDULED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
assertThat(listenerFired.getEvents()).isEmpty();
// when
long waitTime = 10 * 60 * 1000;
Date startTime = new Date();
Date dueDate = new Date(startTime.getTime() + waitTime);
// After setting the clock to time '5minutes and 5 seconds', the second timer should fire
processEngineConfiguration.getClock().setCurrentTime(new Date(dueDate.getTime() + 5000));
// then
await().untilAsserted(() -> {
assertThat(listenerFired.getEvents()).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_FIRED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
assertThat(listenerExecuted.getEvents()).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_EXECUTED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
});
// then the execution reaches the task
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 10), TaskPayloadBuilder.tasks().withProcessInstanceId(processInstance.getId()).build());
assertThat(tasks.getContent()).hasSize(1);
assertThat(tasks.getContent().get(0).getName()).isEqualTo("User Task");
}
use of org.activiti.api.runtime.shared.query.Page in project Activiti by Activiti.
the class ProcessRuntimeIT method should_OnlyProcessDefinitionsFromLatestVersionRetrieved.
@Test
public void should_OnlyProcessDefinitionsFromLatestVersionRetrieved() {
Deployment deployment = processRuntime.selectLatestDeployment();
Page<ProcessDefinition> processDefinitionPage = processRuntime.processDefinitions(PAGEABLE);
assertThat(processDefinitionPage.getContent().stream().filter(c -> c.getKey().equals(SUPER_PROCESS))).extracting(ProcessDefinition::getAppVersion).containsOnly(deployment.getVersion().toString());
}
Aggregations