TSK-1333: Review findings

This commit is contained in:
Joerg Heffner 2020-07-23 14:39:29 +02:00 committed by gitgoodjhe
parent b7237021e2
commit 901991e90b
4 changed files with 56 additions and 20 deletions

View File

@ -12,8 +12,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.models.Task;
@ExtendWith(JaasExtension.class)
class CreateHistoryEventOnTaskCancellationAccTest extends AbstractAccTest {
@ -23,7 +21,7 @@ class CreateHistoryEventOnTaskCancellationAccTest extends AbstractAccTest {
@Test
@WithAccessId(user = "admin")
void should_CreateCancelledHistoryEvent_When_TaskIsCancelled() throws Exception {
void should_CreateCancelledHistoryEvent_When_CancelTaskInStateClaimed() throws Exception {
final String taskId = "TKI:000000000000000000000000000000000001";
@ -31,15 +29,35 @@ class CreateHistoryEventOnTaskCancellationAccTest extends AbstractAccTest {
assertThat(listEvents).isEmpty();
assertThat(taskService.getTask(taskId).getState()).isEqualTo(TaskState.CLAIMED);
Task task = taskService.cancelTask(taskId);
assertThat(task.getState()).isEqualTo(TaskState.CANCELLED);
taskService.cancelTask(taskId);
listEvents = historyService.createHistoryQuery().taskIdIn(taskId).list();
assertThat(listEvents).hasSize(1);
assertThat(historyService.getHistoryEvent(listEvents.get(0).getId()).getEventType())
.isEqualTo("TASK_CANCELLED");
String eventType = historyService.getHistoryEvent(listEvents.get(0).getId()).getEventType();
assertThat(eventType).isEqualTo("TASK_CANCELLED");
}
@Test
@WithAccessId(user = "admin")
void should_CreateCancelledHistoryEvent_When_CancelTaskInStateReady() throws Exception {
final String taskId = "TKI:000000000000000000000000000000000003";
List<HistoryEventImpl> listEvents = historyService.createHistoryQuery().taskIdIn(taskId).list();
assertThat(listEvents).isEmpty();
taskService.cancelTask(taskId);
listEvents = historyService.createHistoryQuery().taskIdIn(taskId).list();
assertThat(listEvents).hasSize(1);
String eventType = historyService.getHistoryEvent(listEvents.get(0).getId()).getEventType();
assertThat(eventType).isEqualTo("TASK_CANCELLED");
}
}

View File

@ -12,8 +12,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.models.Task;
@ExtendWith(JaasExtension.class)
class CreateHistoryEventOnTaskTerminationAccTest extends AbstractAccTest {
@ -23,7 +21,7 @@ class CreateHistoryEventOnTaskTerminationAccTest extends AbstractAccTest {
@Test
@WithAccessId(user = "admin")
void should_CreateTerminatedHistoryEvent_When_TaskIsTerminated() throws Exception {
void should_CreateTerminatedHistoryEvent_When_TerminatingTaskInStateClaimed() throws Exception {
final String taskId = "TKI:000000000000000000000000000000000001";
@ -31,15 +29,35 @@ class CreateHistoryEventOnTaskTerminationAccTest extends AbstractAccTest {
assertThat(listEvents).isEmpty();
assertThat(taskService.getTask(taskId).getState()).isEqualTo(TaskState.CLAIMED);
Task task = taskService.terminateTask(taskId);
assertThat(task.getState()).isEqualTo(TaskState.TERMINATED);
taskService.terminateTask(taskId);
listEvents = historyService.createHistoryQuery().taskIdIn(taskId).list();
assertThat(listEvents).hasSize(1);
assertThat(historyService.getHistoryEvent(listEvents.get(0).getId()).getEventType())
.isEqualTo("TASK_TERMINATED");
String eventType = historyService.getHistoryEvent(listEvents.get(0).getId()).getEventType();
assertThat(eventType).isEqualTo("TASK_TERMINATED");
}
@Test
@WithAccessId(user = "admin")
void should_CreateTerminatedHistoryEvent_When_TerminatingTaskInStateReady() throws Exception {
final String taskId = "TKI:000000000000000000000000000000000003";
List<HistoryEventImpl> listEvents = historyService.createHistoryQuery().taskIdIn(taskId).list();
assertThat(listEvents).isEmpty();
taskService.terminateTask(taskId);
listEvents = historyService.createHistoryQuery().taskIdIn(taskId).list();
assertThat(listEvents).hasSize(1);
String eventType = historyService.getHistoryEvent(listEvents.get(0).getId()).getEventType();
assertThat(eventType).isEqualTo("TASK_TERMINATED");
}
}

View File

@ -8,6 +8,6 @@ public class CancelledEvent extends TaskEvent {
public CancelledEvent(String id, Task task, String userId) {
super(id, task, userId, null);
eventType = "TASK_CANCELLED";
created = task.getModified();
created = task.getCompleted();
}
}

View File

@ -8,6 +8,6 @@ public class TerminatedEvent extends TaskEvent {
public TerminatedEvent(String id, Task task, String userId) {
super(id, task, userId, null);
eventType = "TASK_TERMINATED";
created = task.getModified();
created = task.getCompleted();
}
}