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 {
|
||||
taskanaEngine.openConnection();
|
||||
|
||||
if (task.getId() != null && !task.getId().equals("")) {
|
||||
throw new TaskAlreadyExistException(task.getId());
|
||||
if (task.getId() != null && !task.getId().isEmpty()) {
|
||||
throw new InvalidArgumentException("taskId must be empty when creating a task");
|
||||
}
|
||||
|
||||
LOGGER.debug("Task {} cannot be found, so it can be created.", task.getId());
|
||||
|
@ -902,12 +902,14 @@ public class TaskServiceImpl implements TaskService {
|
|||
serviceLevelHandler.refreshPriorityAndDueDatesOfTasks(
|
||||
tasks, serviceLevelChanged, priorityChanged);
|
||||
} else {
|
||||
taskanaEngine.getEngine().runAsAdmin(
|
||||
() -> {
|
||||
serviceLevelHandler.refreshPriorityAndDueDatesOfTasks(
|
||||
tasks, serviceLevelChanged, priorityChanged);
|
||||
return null;
|
||||
});
|
||||
taskanaEngine
|
||||
.getEngine()
|
||||
.runAsAdmin(
|
||||
() -> {
|
||||
serviceLevelHandler.refreshPriorityAndDueDatesOfTasks(
|
||||
tasks, serviceLevelChanged, priorityChanged);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
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.Task;
|
||||
import pro.taskana.task.internal.AttachmentMapper;
|
||||
import pro.taskana.task.internal.models.TaskImpl;
|
||||
import pro.taskana.workbasket.api.WorkbasketService;
|
||||
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.workbasket.api.models.Workbasket;
|
||||
|
@ -672,12 +673,13 @@ class CreateTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
@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);
|
||||
assertThatThrownBy(call).isInstanceOf(TaskAlreadyExistException.class);
|
||||
ThrowingCallable call = () -> taskService.createTask(newTask);
|
||||
assertThatThrownBy(call).isInstanceOf(InvalidArgumentException.class);
|
||||
}
|
||||
|
||||
@WithAccessId(user = "user-1-1")
|
||||
|
|
Loading…
Reference in New Issue