Search in sources :

Example 1 with CloudTaskCreatedEventImpl

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());
    });
}
Also used : CloudTaskCreatedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCreatedEventImpl) Task(org.activiti.api.task.model.Task) CloudTask(org.activiti.cloud.api.task.model.CloudTask) TaskImpl(org.activiti.api.task.model.impl.TaskImpl) PagedResources(org.springframework.hateoas.PagedResources) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with CloudTaskCreatedEventImpl

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));
    });
}
Also used : CloudTaskCreatedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCreatedEventImpl) Task(org.activiti.api.task.model.Task) CloudTask(org.activiti.cloud.api.task.model.CloudTask) TaskImpl(org.activiti.api.task.model.impl.TaskImpl) PagedResources(org.springframework.hateoas.PagedResources) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with CloudTaskCreatedEventImpl

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());
    });
}
Also used : CloudTaskCreatedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCreatedEventImpl) Task(org.activiti.api.task.model.Task) CloudTask(org.activiti.cloud.api.task.model.CloudTask) TaskImpl(org.activiti.api.task.model.impl.TaskImpl) PagedResources(org.springframework.hateoas.PagedResources) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with CloudTaskCreatedEventImpl

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);
}
Also used : CloudTaskCreatedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCreatedEventImpl) CloudTaskCreatedEvent(org.activiti.cloud.api.task.model.events.CloudTaskCreatedEvent) Test(org.junit.jupiter.api.Test)

Example 5 with CloudTaskCreatedEventImpl

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;
}
Also used : CloudTaskCreatedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCreatedEventImpl)

Aggregations

CloudTaskCreatedEventImpl (org.activiti.cloud.api.task.model.impl.events.CloudTaskCreatedEventImpl)13 TaskImpl (org.activiti.api.task.model.impl.TaskImpl)8 Test (org.junit.jupiter.api.Test)8 Task (org.activiti.api.task.model.Task)5 CloudTask (org.activiti.cloud.api.task.model.CloudTask)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 PagedResources (org.springframework.hateoas.PagedResources)5 ArrayList (java.util.ArrayList)3 CloudTaskAssignedEventImpl (org.activiti.cloud.api.task.model.impl.events.CloudTaskAssignedEventImpl)3 CloudTaskCancelledEventImpl (org.activiti.cloud.api.task.model.impl.events.CloudTaskCancelledEventImpl)3 CloudRuntimeEvent (org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent)2 CloudBPMNActivityCancelledEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityCancelledEventImpl)2 CloudBPMNActivityCompletedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityCompletedEventImpl)2 CloudBPMNActivityStartedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl)2 CloudIntegrationErrorReceivedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudIntegrationErrorReceivedEventImpl)2 CloudIntegrationRequestedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudIntegrationRequestedEventImpl)2 CloudIntegrationResultReceivedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudIntegrationResultReceivedEventImpl)2 CloudProcessCancelledEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessCancelledEventImpl)2 CloudProcessCompletedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessCompletedEventImpl)2 CloudProcessDeployedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessDeployedEventImpl)2