Search in sources :

Example 6 with UpdateTaskPayload

use of org.activiti.api.task.model.payloads.UpdateTaskPayload in project Activiti by Activiti.

the class TaskRuntimeUpdateTaskTest method createClaimAndAdminUpdateStandaloneTask.

@Test
public void createClaimAndAdminUpdateStandaloneTask() {
    securityUtil.logInAs("garth");
    // create
    Task standaloneTask = taskRuntime.create(TaskPayloadBuilder.create().withName("test task update").withDescription("test task update description").withDueDate(new Date()).withPriority(50).build());
    assertThat(RuntimeTestConfiguration.createdTasks).contains(standaloneTask.getId());
    Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 50));
    assertThat(tasks.getTotalItems()).isEqualTo(1);
    assertThat(tasks.getContent()).extracting("status", "id").contains(tuple(Task.TaskStatus.CREATED, standaloneTask.getId()));
    final UpdateTaskPayload updateTaskPayload = TaskPayloadBuilder.update().withTaskId(standaloneTask.getId()).withName(standaloneTask.getName() + " [UPDATED]").withPriority(60).withDueDate(new Date()).withDescription(standaloneTask.getDescription() + " [UPDATED]").build();
    // admin should update a task
    securityUtil.logInAs("admin");
    final Task updatedTask = taskAdminRuntime.update(updateTaskPayload);
    tasks = taskAdminRuntime.tasks(Pageable.of(0, 50));
    assertThat(RuntimeTestConfiguration.updatedTasks).contains(updatedTask.getId());
    assertThat(tasks.getContent()).extracting("id", "name", "description", "priority").contains(tuple(standaloneTask.getId(), updateTaskPayload.getName(), updateTaskPayload.getDescription(), updateTaskPayload.getPriority()));
}
Also used : Task(org.activiti.api.task.model.Task) UpdateTaskPayload(org.activiti.api.task.model.payloads.UpdateTaskPayload) Date(java.util.Date) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

UpdateTaskPayload (org.activiti.api.task.model.payloads.UpdateTaskPayload)6 Test (org.junit.jupiter.api.Test)6 Date (java.util.Date)3 Task (org.activiti.api.task.model.Task)3 Task (org.activiti.engine.task.Task)3 TaskImpl (org.activiti.api.task.model.impl.TaskImpl)2 TaskQuery (org.activiti.engine.task.TaskQuery)2 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2