TSK-795: Changed Exception when creating a Task with a non-empty taskId (#1575)
This commit is contained in:
parent
c4ffa222d9
commit
b8892020d9
|
|
@ -170,8 +170,8 @@ public class TaskServiceImpl implements TaskService {
|
||||||
try {
|
try {
|
||||||
taskanaEngine.openConnection();
|
taskanaEngine.openConnection();
|
||||||
|
|
||||||
if (task.getId() != null && !task.getId().equals("")) {
|
if (task.getId() != null && !task.getId().isEmpty()) {
|
||||||
throw new TaskAlreadyExistException(task.getId());
|
throw new InvalidArgumentException("taskId must be empty when creating a task");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.debug("Task {} cannot be found, so it can be created.", task.getId());
|
LOGGER.debug("Task {} cannot be found, so it can be created.", task.getId());
|
||||||
|
|
@ -902,12 +902,14 @@ public class TaskServiceImpl implements TaskService {
|
||||||
serviceLevelHandler.refreshPriorityAndDueDatesOfTasks(
|
serviceLevelHandler.refreshPriorityAndDueDatesOfTasks(
|
||||||
tasks, serviceLevelChanged, priorityChanged);
|
tasks, serviceLevelChanged, priorityChanged);
|
||||||
} else {
|
} else {
|
||||||
taskanaEngine.getEngine().runAsAdmin(
|
taskanaEngine
|
||||||
() -> {
|
.getEngine()
|
||||||
serviceLevelHandler.refreshPriorityAndDueDatesOfTasks(
|
.runAsAdmin(
|
||||||
tasks, serviceLevelChanged, priorityChanged);
|
() -> {
|
||||||
return null;
|
serviceLevelHandler.refreshPriorityAndDueDatesOfTasks(
|
||||||
});
|
tasks, serviceLevelChanged, priorityChanged);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
LOGGER.debug("exit from refreshPriorityAndDueDateOfTasks");
|
LOGGER.debug("exit from refreshPriorityAndDueDateOfTasks");
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import pro.taskana.task.api.models.AttachmentSummary;
|
||||||
import pro.taskana.task.api.models.ObjectReference;
|
import pro.taskana.task.api.models.ObjectReference;
|
||||||
import pro.taskana.task.api.models.Task;
|
import pro.taskana.task.api.models.Task;
|
||||||
import pro.taskana.task.internal.AttachmentMapper;
|
import pro.taskana.task.internal.AttachmentMapper;
|
||||||
|
import pro.taskana.task.internal.models.TaskImpl;
|
||||||
import pro.taskana.workbasket.api.WorkbasketService;
|
import pro.taskana.workbasket.api.WorkbasketService;
|
||||||
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
|
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
|
||||||
import pro.taskana.workbasket.api.models.Workbasket;
|
import pro.taskana.workbasket.api.models.Workbasket;
|
||||||
|
|
@ -672,12 +673,13 @@ class CreateTaskAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
@WithAccessId(user = "user-1-1")
|
@WithAccessId(user = "user-1-1")
|
||||||
@Test
|
@Test
|
||||||
void testCreateTaskAlreadyExisting() throws Exception {
|
void should_ThrowException_When_CreatingTaskWithNonEmptyId() {
|
||||||
|
|
||||||
Task existingTask = taskService.getTask("TKI:000000000000000000000000000000000000");
|
Task newTask = taskService.newTask();
|
||||||
|
((TaskImpl) newTask).setId("TKI:000000000000000000000000000000000000");
|
||||||
|
|
||||||
ThrowingCallable call = () -> taskService.createTask(existingTask);
|
ThrowingCallable call = () -> taskService.createTask(newTask);
|
||||||
assertThatThrownBy(call).isInstanceOf(TaskAlreadyExistException.class);
|
assertThatThrownBy(call).isInstanceOf(InvalidArgumentException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(user = "user-1-1")
|
@WithAccessId(user = "user-1-1")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue