use of org.activiti.cloud.api.task.model.impl.events.CloudTaskCreatedEventImpl in project activiti-cloud by Activiti.
the class QueryTasksIT method shouldSetProcessDefinitionVersionAndBusinessKeyOnTaskWhenThisInformationIsAvailableInTheEvent.
@Test
public void shouldSetProcessDefinitionVersionAndBusinessKeyOnTaskWhenThisInformationIsAvailableInTheEvent() {
// given
// event with process definition version set
TaskImpl task1 = aCreatedTask("Task1");
CloudTaskCreatedEventImpl task1Created = new CloudTaskCreatedEventImpl(task1);
task1Created.setProcessDefinitionVersion(10);
task1Created.setBusinessKey("businessKey");
eventsAggregator.addEvents(task1Created);
// event with process definition unset
TaskImpl task2 = aCreatedTask("Task2");
eventsAggregator.addEvents(new CloudTaskCreatedEventImpl(task2));
eventsAggregator.sendAll();
await().untilAsserted(() -> {
// when
ResponseEntity<PagedResources<Task>> responseEntity = executeRequestGetTasks();
// then
assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(responseEntity.getBody()).isNotNull();
Collection<Task> tasks = responseEntity.getBody().getContent();
assertThat(tasks).extracting(Task::getId, Task::getStatus, Task::getProcessDefinitionVersion, Task::getBusinessKey).contains(tuple(task1.getId(), Task.TaskStatus.CREATED, 10, "businessKey"), tuple(task2.getId(), Task.TaskStatus.CREATED, null, null));
});
await().untilAsserted(() -> {
// when
ResponseEntity<PagedResources<Task>> responseEntity = testRestTemplate.exchange(TASKS_URL + "?processDefinitionVersion={processDefinitionVersion}", HttpMethod.GET, keycloakTokenProducer.entityWithAuthorizationHeader(), PAGED_TASKS_RESPONSE_TYPE, 10);
// then
assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(responseEntity.getBody()).isNotNull();
Collection<Task> tasks = responseEntity.getBody().getContent();
assertThat(tasks).extracting(Task::getId).containsExactly(task1.getId());
});
}
use of org.activiti.cloud.api.task.model.impl.events.CloudTaskCreatedEventImpl in project activiti-cloud by Activiti.
the class QueryTasksIT method shouldGetAvailableStandaloneTasksFilteredByNameDescription.
@Test
public void shouldGetAvailableStandaloneTasksFilteredByNameDescription() {
// given
Task task1 = taskEventContainedBuilder.aCreatedTask("Task 1 for filter", runningProcessInstance);
Task task2 = taskEventContainedBuilder.aCreatedTask("Task 2 not filter", null);
Task task3 = taskEventContainedBuilder.aCreatedTask("Task 3 for filter standalone", null);
TaskImpl task4 = aCreatedTask("Task 4 for filter description");
task4.setDescription("My task description");
eventsAggregator.addEvents(new CloudTaskCreatedEventImpl(task4));
eventsAggregator.sendAll();
await().untilAsserted(() -> {
// when
ResponseEntity<PagedResources<Task>> responseEntity = executeRequestGetTasksFiltered("for filter", null);
// then
assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(responseEntity.getBody()).isNotNull();
Collection<Task> task = responseEntity.getBody().getContent();
assertThat(task).extracting(Task::getId, Task::getStatus).contains(tuple(task1.getId(), Task.TaskStatus.CREATED), tuple(task3.getId(), Task.TaskStatus.CREATED), tuple(task4.getId(), Task.TaskStatus.CREATED));
});
await().untilAsserted(() -> {
// when
ResponseEntity<PagedResources<Task>> responseEntity = executeRequestGetTasksFiltered("for filter", "task descr");
// then
assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(responseEntity.getBody()).isNotNull();
Collection<Task> task = responseEntity.getBody().getContent();
assertThat(task).extracting(Task::getId, Task::getStatus).contains(tuple(task4.getId(), Task.TaskStatus.CREATED));
});
}
use of org.activiti.cloud.api.task.model.impl.events.CloudTaskCreatedEventImpl in project activiti-cloud by Activiti.
the class QueryTasksIT method shouldGetAvailableRootTasksWithStatus.
@Test
public void shouldGetAvailableRootTasksWithStatus() {
// given
TaskImpl rootTaskNoSubtask = new TaskImpl(UUID.randomUUID().toString(), "Root task without subtask", Task.TaskStatus.ASSIGNED);
rootTaskNoSubtask.setProcessInstanceId(runningProcessInstance.getId());
rootTaskNoSubtask.setParentTaskId(null);
eventsAggregator.addEvents(new CloudTaskCreatedEventImpl(rootTaskNoSubtask));
TaskImpl rootTask = aCreatedTask("Root task");
rootTask.setProcessInstanceId(runningProcessInstance.getId());
rootTask.setParentTaskId(null);
eventsAggregator.addEvents(new CloudTaskCreatedEventImpl(rootTask));
TaskImpl task = aCreatedTask("Task with parent");
task.setProcessInstanceId(runningProcessInstance.getId());
task.setParentTaskId(rootTask.getId());
eventsAggregator.addEvents(new CloudTaskCreatedEventImpl(task));
eventsAggregator.sendAll();
await().untilAsserted(() -> {
// when
ResponseEntity<PagedResources<Task>> responseEntity = testRestTemplate.exchange(TASKS_URL + "?rootTasksOnly=true&status={status}", HttpMethod.GET, keycloakTokenProducer.entityWithAuthorizationHeader(), PAGED_TASKS_RESPONSE_TYPE, Task.TaskStatus.CREATED);
// then
assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(responseEntity.getBody()).isNotNull();
Collection<Task> tasks = responseEntity.getBody().getContent();
assertThat(tasks).extracting(Task::getId).containsExactly(rootTask.getId());
});
}
use of org.activiti.cloud.api.task.model.impl.events.CloudTaskCreatedEventImpl in project activiti-cloud by Activiti.
the class QueryEventHandlerContextTest method handleShouldSelectHandlerBasedOnEventType.
@Test
public void handleShouldSelectHandlerBasedOnEventType() {
// given
CloudTaskCreatedEvent event = new CloudTaskCreatedEventImpl();
// when
context.handle(event);
// then
verify(handler).handle(event);
}
use of org.activiti.cloud.api.task.model.impl.events.CloudTaskCreatedEventImpl in project activiti-cloud by Activiti.
the class ToCloudTaskRuntimeEventConverter method from.
public CloudTaskCreatedEvent from(TaskCreatedEvent event) {
CloudTaskCreatedEventImpl cloudEvent = new CloudTaskCreatedEventImpl(event.getEntity());
runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudEvent);
return cloudEvent;
}
Aggregations