comments from Holger Hagen
This commit is contained in:
parent
636135bf1a
commit
dffb139a82
|
@ -414,7 +414,6 @@ public interface TaskService {
|
||||||
/**
|
/**
|
||||||
* Deletes the task comment with the given Id.
|
* Deletes the task comment with the given Id.
|
||||||
*
|
*
|
||||||
* @param taskId The task id where the comment is supposed to be attached to
|
|
||||||
* @param taskCommentId The id of the task comment to delete.
|
* @param taskCommentId The id of the task comment to delete.
|
||||||
* @throws NotAuthorizedException If the current user has no authorization to delete a task
|
* @throws NotAuthorizedException If the current user has no authorization to delete a task
|
||||||
* comment or is not authorized to access the task.
|
* comment or is not authorized to access the task.
|
||||||
|
@ -425,14 +424,13 @@ public interface TaskService {
|
||||||
* existing task.
|
* existing task.
|
||||||
* @throws InvalidArgumentException If the given taskCommentId is null or empty
|
* @throws InvalidArgumentException If the given taskCommentId is null or empty
|
||||||
*/
|
*/
|
||||||
void deleteTaskComment(String taskId, String taskCommentId)
|
void deleteTaskComment(String taskCommentId)
|
||||||
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException,
|
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException,
|
||||||
InvalidArgumentException;
|
InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a task comment for a given taskCommentId.
|
* Retrieves a task comment for a given taskCommentId.
|
||||||
*
|
*
|
||||||
* @param taskId The task id where the comment is supposed to be attached to
|
|
||||||
* @param taskCommentId The id of the task comment which should be retrieved
|
* @param taskCommentId The id of the task comment which should be retrieved
|
||||||
* @return the task comment identified by taskCommentId
|
* @return the task comment identified by taskCommentId
|
||||||
* @throws TaskCommentNotFoundException If the given taskCommentId in the TaskComment does not
|
* @throws TaskCommentNotFoundException If the given taskCommentId in the TaskComment does not
|
||||||
|
@ -443,7 +441,7 @@ public interface TaskService {
|
||||||
* existing task.
|
* existing task.
|
||||||
* @throws InvalidArgumentException If the given taskCommentId is null or empty
|
* @throws InvalidArgumentException If the given taskCommentId is null or empty
|
||||||
*/
|
*/
|
||||||
TaskComment getTaskComment(String taskId, String taskCommentId)
|
TaskComment getTaskComment(String taskCommentId)
|
||||||
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
||||||
InvalidArgumentException;
|
InvalidArgumentException;
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ public interface TaskCommentMapper {
|
||||||
"<script> SELECT ID, TASK_ID, TEXT_FIELD, CREATOR, CREATED, MODIFIED"
|
"<script> SELECT ID, TASK_ID, TEXT_FIELD, CREATOR, CREATED, MODIFIED"
|
||||||
+ " FROM TASK_COMMENT "
|
+ " FROM TASK_COMMENT "
|
||||||
+ "WHERE ID = #{taskCommentId} "
|
+ "WHERE ID = #{taskCommentId} "
|
||||||
+ "AND TASK_ID = #{taskId} "
|
|
||||||
+ "<if test=\"_databaseId == 'db2'\">with UR </if> "
|
+ "<if test=\"_databaseId == 'db2'\">with UR </if> "
|
||||||
+ "</script>")
|
+ "</script>")
|
||||||
@Results(
|
@Results(
|
||||||
|
@ -62,5 +61,5 @@ public interface TaskCommentMapper {
|
||||||
@Result(property = "modified", column = "MODIFIED"),
|
@Result(property = "modified", column = "MODIFIED"),
|
||||||
})
|
})
|
||||||
TaskCommentImpl findById(
|
TaskCommentImpl findById(
|
||||||
@Param("taskId") String taskId, @Param("taskCommentId") String taskCommentId);
|
@Param("taskCommentId") String taskCommentId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ class TaskCommentServiceImpl {
|
||||||
|| taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN)) {
|
|| taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN)) {
|
||||||
|
|
||||||
TaskComment oldTaskComment =
|
TaskComment oldTaskComment =
|
||||||
getTaskComment(taskCommentImplToUpdate.getTaskId(), taskCommentImplToUpdate.getId());
|
getTaskComment(taskCommentImplToUpdate.getId());
|
||||||
|
|
||||||
checkModifiedHasNotChanged(oldTaskComment, taskCommentImplToUpdate);
|
checkModifiedHasNotChanged(oldTaskComment, taskCommentImplToUpdate);
|
||||||
|
|
||||||
|
@ -128,12 +128,12 @@ class TaskCommentServiceImpl {
|
||||||
return taskCommentImplToCreate;
|
return taskCommentImplToCreate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteTaskComment(String taskId, String taskCommentId)
|
void deleteTaskComment(String taskCommentId)
|
||||||
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException,
|
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
|
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
"entry to deleteTaskComment (taskId = {}, taskComment = {}", taskId, taskCommentId);
|
"entry to deleteTaskComment (taskComment = {}", taskCommentId);
|
||||||
|
|
||||||
String userId = CurrentUserContext.getUserid();
|
String userId = CurrentUserContext.getUserid();
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ class TaskCommentServiceImpl {
|
||||||
|
|
||||||
taskanaEngine.openConnection();
|
taskanaEngine.openConnection();
|
||||||
|
|
||||||
TaskComment taskCommentToDelete = getTaskComment(taskId, taskCommentId);
|
TaskComment taskCommentToDelete = getTaskComment(taskCommentId);
|
||||||
|
|
||||||
if (taskCommentToDelete.getCreator().equals(userId)
|
if (taskCommentToDelete.getCreator().equals(userId)
|
||||||
|| taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN)) {
|
|| taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN)) {
|
||||||
|
@ -189,11 +189,11 @@ class TaskCommentServiceImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskComment getTaskComment(String taskId, String taskCommentId)
|
TaskComment getTaskComment(String taskCommentId)
|
||||||
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
|
|
||||||
LOGGER.debug("entry to getTaskComment (taskId= {}, taskCommentId = {})", taskId, taskCommentId);
|
LOGGER.debug("entry to getTaskComment (taskCommentId = {})", taskCommentId);
|
||||||
|
|
||||||
TaskCommentImpl result;
|
TaskCommentImpl result;
|
||||||
|
|
||||||
|
@ -203,14 +203,14 @@ class TaskCommentServiceImpl {
|
||||||
|
|
||||||
taskanaEngine.openConnection();
|
taskanaEngine.openConnection();
|
||||||
|
|
||||||
result = taskCommentMapper.findById(taskId, taskCommentId);
|
result = taskCommentMapper.findById(taskCommentId);
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
throw new TaskCommentNotFoundException(
|
throw new TaskCommentNotFoundException(
|
||||||
taskCommentId,
|
taskCommentId,
|
||||||
String.format(
|
String.format(
|
||||||
"TaskComment for taskId '%s' and taskCommentId '%s' was not found",
|
"TaskComment for taskCommentId '%s' was not found",
|
||||||
taskId, taskCommentId));
|
taskCommentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
taskService.getTask(result.getTaskId());
|
taskService.getTask(result.getTaskId());
|
||||||
|
|
|
@ -614,17 +614,17 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteTaskComment(String taskId, String taskCommentId)
|
public void deleteTaskComment(String taskCommentId)
|
||||||
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException,
|
throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
taskCommentService.deleteTaskComment(taskId, taskCommentId);
|
taskCommentService.deleteTaskComment(taskCommentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskComment getTaskComment(String taskId, String taskCommentid)
|
public TaskComment getTaskComment(String taskCommentid)
|
||||||
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
return taskCommentService.getTaskComment(taskId, taskCommentid);
|
return taskCommentService.getTaskComment(taskCommentid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class CreateTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_1",
|
userName = "user_1_1",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testCreateTaskComment()
|
void should_CreateTaskComment_For_TaskComment()
|
||||||
throws TaskNotFoundException, NotAuthorizedException, InvalidArgumentException {
|
throws TaskNotFoundException, NotAuthorizedException, InvalidArgumentException {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
@ -52,7 +52,7 @@ public class CreateTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_1",
|
userName = "user_1_1",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testCreateTaskCommentForNullOrNonExistingTaskIdShouldFail() {
|
void should_FailToCreateTaskComment_When_TaskIdIsNullOrNonExisting() {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_1",
|
userName = "user_1_1",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testDeleteTaskComment()
|
void should_DeleteTaskComment_For_TaskCommentId()
|
||||||
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
|
||||||
assertThat(taskComments).hasSize(2);
|
assertThat(taskComments).hasSize(2);
|
||||||
|
|
||||||
taskService.deleteTaskComment(
|
taskService.deleteTaskComment(
|
||||||
"TKI:000000000000000000000000000000000001", "TCI:000000000000000000000000000000000004");
|
"TCI:000000000000000000000000000000000004");
|
||||||
|
|
||||||
// make sure the task comment was deleted
|
// make sure the task comment was deleted
|
||||||
List<TaskComment> taskCommentsAfterDeletion =
|
List<TaskComment> taskCommentsAfterDeletion =
|
||||||
|
@ -52,7 +52,7 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testDeleteTaskCommentWithNoAuthorizationShouldFail()
|
void should_FailToDeleteTaskComment_When_UserHasNoAuthorization()
|
||||||
throws NotAuthorizedException, TaskNotFoundException {
|
throws NotAuthorizedException, TaskNotFoundException {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
@ -64,7 +64,7 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
|
||||||
ThrowingCallable lambda =
|
ThrowingCallable lambda =
|
||||||
() ->
|
() ->
|
||||||
taskService.deleteTaskComment(
|
taskService.deleteTaskComment(
|
||||||
"TKI:000000000000000000000000000000000001",
|
|
||||||
"TCI:000000000000000000000000000000000005");
|
"TCI:000000000000000000000000000000000005");
|
||||||
assertThatThrownBy(lambda).isInstanceOf(NotAuthorizedException.class);
|
assertThatThrownBy(lambda).isInstanceOf(NotAuthorizedException.class);
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_1",
|
userName = "user_1_1",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testDeleteTaskCommentWithInvalidTaskCommentIdShouldFail()
|
void should_FailToDeleteTaskComment_When_TaskCommentIdIsInvalid()
|
||||||
throws NotAuthorizedException, TaskNotFoundException {
|
throws NotAuthorizedException, TaskNotFoundException {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
@ -87,16 +87,10 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
|
||||||
taskService.getTaskComments("TKI:000000000000000000000000000000000002");
|
taskService.getTaskComments("TKI:000000000000000000000000000000000002");
|
||||||
assertThat(taskComments).hasSize(2);
|
assertThat(taskComments).hasSize(2);
|
||||||
|
|
||||||
assertThatThrownBy(() -> taskService.deleteTaskComment("", ""))
|
assertThatThrownBy(() -> taskService.deleteTaskComment(""))
|
||||||
.isInstanceOf(InvalidArgumentException.class);
|
.isInstanceOf(InvalidArgumentException.class);
|
||||||
|
|
||||||
assertThatThrownBy(() -> taskService.deleteTaskComment("", null))
|
assertThatThrownBy(() -> taskService.deleteTaskComment(null))
|
||||||
.isInstanceOf(InvalidArgumentException.class);
|
|
||||||
|
|
||||||
assertThatThrownBy(() -> taskService.deleteTaskComment(null, ""))
|
|
||||||
.isInstanceOf(InvalidArgumentException.class);
|
|
||||||
|
|
||||||
assertThatThrownBy(() -> taskService.deleteTaskComment(null, null))
|
|
||||||
.isInstanceOf(InvalidArgumentException.class);
|
.isInstanceOf(InvalidArgumentException.class);
|
||||||
|
|
||||||
// make sure that no task comment was deleted
|
// make sure that no task comment was deleted
|
||||||
|
@ -109,7 +103,7 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_1",
|
userName = "user_1_1",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testDeleteNonExistingTaskCommentShouldFail()
|
void should_FailToDeleteTaskComment_When_TaskCommentIsNotExisting()
|
||||||
throws NotAuthorizedException, TaskNotFoundException {
|
throws NotAuthorizedException, TaskNotFoundException {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
@ -119,7 +113,7 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
|
||||||
assertThat(taskComments).hasSize(2);
|
assertThat(taskComments).hasSize(2);
|
||||||
|
|
||||||
ThrowingCallable lambda =
|
ThrowingCallable lambda =
|
||||||
() -> taskService.deleteTaskComment("invalidTaskId", "non existing task comment id");
|
() -> taskService.deleteTaskComment("non existing task comment id");
|
||||||
assertThatThrownBy(lambda).isInstanceOf(TaskCommentNotFoundException.class);
|
assertThatThrownBy(lambda).isInstanceOf(TaskCommentNotFoundException.class);
|
||||||
|
|
||||||
// make sure the task comment was not deleted
|
// make sure the task comment was not deleted
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class GetTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_1",
|
userName = "user_1_1",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testGetTaskComments() throws NotAuthorizedException, TaskNotFoundException {
|
void should_ReturnTaskComments_For_TaskId() throws NotAuthorizedException, TaskNotFoundException {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class GetTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_1",
|
userName = "user_1_1",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testGetNonExistingTaskCommentsShouldReturnEmptyList()
|
void should_ReturnEmptyList_When_TaskCommentsDontExist()
|
||||||
throws NotAuthorizedException, TaskNotFoundException {
|
throws NotAuthorizedException, TaskNotFoundException {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
@ -55,7 +55,7 @@ public class GetTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_1",
|
userName = "user_1_1",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testGetTaskCommentsOfNotVisibleTaskShouldFail() {
|
void should_FailToReturnTaskComments_When_TaskIstNotVisible() {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
|
||||||
|
@ -70,15 +70,14 @@ public class GetTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_1",
|
userName = "user_1_1",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testGetTaskComment()
|
void should_ReturnTaskComment_For_TaskCommentId()
|
||||||
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
|
||||||
TaskComment taskComment =
|
TaskComment taskComment =
|
||||||
taskService.getTaskComment(
|
taskService.getTaskComment("TCI:000000000000000000000000000000000007");
|
||||||
"TKI:000000000000000000000000000000000002", "TCI:000000000000000000000000000000000007");
|
|
||||||
assertThat(taskComment.getCreator()).isEqualTo("user_1_1");
|
assertThat(taskComment.getCreator()).isEqualTo("user_1_1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,14 +85,12 @@ public class GetTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_1",
|
userName = "user_1_1",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testGetNonExistingTaskCommentFromNonExistingTaskShouldFail() {
|
void should_FailToReturnTaskComment_When_TaskCommentIsNotExisting() {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
|
||||||
ThrowingCallable lambda =
|
ThrowingCallable lambda =
|
||||||
() ->
|
() -> taskService.getTaskComment("Definately Non Existing Task Comment Id");
|
||||||
taskService.getTaskComment(
|
|
||||||
"Invalid Task Id", "Definately Non Existing Task Comment Id");
|
|
||||||
assertThatThrownBy(lambda).isInstanceOf(TaskCommentNotFoundException.class);
|
assertThatThrownBy(lambda).isInstanceOf(TaskCommentNotFoundException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,47 +98,12 @@ public class GetTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_1",
|
userName = "user_1_1",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testGetNonExistingTaskCommentShouldFail() {
|
void should_FailToReturntaskComment_When_TaskIstNotVisible() {
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
|
||||||
ThrowingCallable lambda =
|
ThrowingCallable lambda =
|
||||||
() ->
|
() -> taskService.getTaskComment("TCI:000000000000000000000000000000000012");
|
||||||
taskService.getTaskComment(
|
|
||||||
"TKI:000000000000000000000000000000000002",
|
|
||||||
"Definately Non Existing Task Comment Id");
|
|
||||||
assertThatThrownBy(lambda).isInstanceOf(TaskCommentNotFoundException.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(
|
|
||||||
userName = "user_1_1",
|
|
||||||
groupNames = {"group_1"})
|
|
||||||
@Test
|
|
||||||
void testGetTaskCommentFromDifferentTaskShouldFail() {
|
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
|
||||||
|
|
||||||
ThrowingCallable lambda =
|
|
||||||
() ->
|
|
||||||
taskService.getTaskComment(
|
|
||||||
"TKI:000000000000000000000000000000000000",
|
|
||||||
"TCI:000000000000000000000000000000000003");
|
|
||||||
assertThatThrownBy(lambda).isInstanceOf(TaskCommentNotFoundException.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(
|
|
||||||
userName = "user_1_1",
|
|
||||||
groupNames = {"group_1"})
|
|
||||||
@Test
|
|
||||||
void testGetTaskCommentOfNotVisibleTaskShouldFail() {
|
|
||||||
|
|
||||||
TaskService taskService = taskanaEngine.getTaskService();
|
|
||||||
|
|
||||||
ThrowingCallable lambda =
|
|
||||||
() ->
|
|
||||||
taskService.getTaskComment(
|
|
||||||
"TKI:000000000000000000000000000000000004",
|
|
||||||
"TCI:000000000000000000000000000000000012");
|
|
||||||
assertThatThrownBy(lambda).isInstanceOf(NotAuthorizedException.class);
|
assertThatThrownBy(lambda).isInstanceOf(NotAuthorizedException.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class UpdateTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_1",
|
userName = "user_1_1",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testUpdateTaskComment()
|
void should_UpdateTaskComment_For_TaskComment()
|
||||||
throws TaskCommentNotFoundException, NotAuthorizedException, ConcurrencyException,
|
throws TaskCommentNotFoundException, NotAuthorizedException, ConcurrencyException,
|
||||||
TaskNotFoundException, InvalidArgumentException {
|
TaskNotFoundException, InvalidArgumentException {
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public class UpdateTaskCommentAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
TaskComment taskComment =
|
TaskComment taskComment =
|
||||||
taskService.getTaskComment(
|
taskService.getTaskComment(
|
||||||
"TKI:000000000000000000000000000000000025", "TCI:000000000000000000000000000000000003");
|
"TCI:000000000000000000000000000000000003");
|
||||||
taskComment.setTextField("updated textfield");
|
taskComment.setTextField("updated textfield");
|
||||||
|
|
||||||
taskService.updateTaskComment(taskComment);
|
taskService.updateTaskComment(taskComment);
|
||||||
|
@ -56,7 +56,7 @@ public class UpdateTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_2",
|
userName = "user_1_2",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testUpdateTaskCommentWithNoAuthorizationShouldFail()
|
void should_FailToUpdateTaskComment_When_UserHasNoAuthorization()
|
||||||
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class UpdateTaskCommentAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
TaskComment taskComment =
|
TaskComment taskComment =
|
||||||
taskService.getTaskComment(
|
taskService.getTaskComment(
|
||||||
"TKI:000000000000000000000000000000000000", "TCI:000000000000000000000000000000000001");
|
"TCI:000000000000000000000000000000000001");
|
||||||
taskComment.setTextField("updated textfield");
|
taskComment.setTextField("updated textfield");
|
||||||
|
|
||||||
assertThatThrownBy(() -> taskService.updateTaskComment(taskComment))
|
assertThatThrownBy(() -> taskService.updateTaskComment(taskComment))
|
||||||
|
@ -86,7 +86,7 @@ public class UpdateTaskCommentAccTest extends AbstractAccTest {
|
||||||
userName = "user_1_1",
|
userName = "user_1_1",
|
||||||
groupNames = {"group_1"})
|
groupNames = {"group_1"})
|
||||||
@Test
|
@Test
|
||||||
void testUpdateTaskCommentWithConcurrentModificationShouldFail()
|
void should_FailToUpdateTaskComment_When_TaskCommentWasModifiedConcurrently()
|
||||||
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
|
||||||
ConcurrencyException, InvalidArgumentException {
|
ConcurrencyException, InvalidArgumentException {
|
||||||
|
|
||||||
|
@ -99,12 +99,12 @@ public class UpdateTaskCommentAccTest extends AbstractAccTest {
|
||||||
|
|
||||||
TaskComment taskCommentToUpdate =
|
TaskComment taskCommentToUpdate =
|
||||||
taskService.getTaskComment(
|
taskService.getTaskComment(
|
||||||
"TKI:000000000000000000000000000000000000", "TCI:000000000000000000000000000000000002");
|
"TCI:000000000000000000000000000000000002");
|
||||||
taskCommentToUpdate.setTextField("updated textfield");
|
taskCommentToUpdate.setTextField("updated textfield");
|
||||||
|
|
||||||
TaskComment concurrentTaskCommentToUpdate =
|
TaskComment concurrentTaskCommentToUpdate =
|
||||||
taskService.getTaskComment(
|
taskService.getTaskComment(
|
||||||
"TKI:000000000000000000000000000000000000", "TCI:000000000000000000000000000000000002");
|
"TCI:000000000000000000000000000000000002");
|
||||||
concurrentTaskCommentToUpdate.setTextField("concurrently updated textfield");
|
concurrentTaskCommentToUpdate.setTextField("concurrently updated textfield");
|
||||||
|
|
||||||
taskService.updateTaskComment(taskCommentToUpdate);
|
taskService.updateTaskComment(taskCommentToUpdate);
|
||||||
|
|
|
@ -25,7 +25,8 @@ public final class Mapping {
|
||||||
public static final String URL_VERSION = PRE + "version";
|
public static final String URL_VERSION = PRE + "version";
|
||||||
public static final String URL_TASKS = PRE + "tasks";
|
public static final String URL_TASKS = PRE + "tasks";
|
||||||
public static final String URL_TASKS_ID = URL_TASKS + "/{taskId}";
|
public static final String URL_TASKS_ID = URL_TASKS + "/{taskId}";
|
||||||
public static final String URL_TASK_COMMENTS = URL_TASKS_ID + "/comments";
|
public static final String URL_TASK_GET_POST_COMMENTS = URL_TASKS_ID + "/comments";
|
||||||
|
public static final String URL_TASK_COMMENTS = URL_TASKS + "/comments";
|
||||||
public static final String URL_TASK_COMMENT = URL_TASK_COMMENTS + "/{taskCommentId}";
|
public static final String URL_TASK_COMMENT = URL_TASK_COMMENTS + "/{taskCommentId}";
|
||||||
public static final String URL_TASKS_ID_CLAIM = URL_TASKS_ID + "/claim";
|
public static final String URL_TASKS_ID_CLAIM = URL_TASKS_ID + "/claim";
|
||||||
public static final String URL_TASKS_ID_COMPLETE = URL_TASKS_ID + "/complete";
|
public static final String URL_TASKS_ID_COMPLETE = URL_TASKS_ID + "/complete";
|
||||||
|
|
|
@ -45,15 +45,14 @@ public class TaskCommentController {
|
||||||
|
|
||||||
@GetMapping(path = Mapping.URL_TASK_COMMENT)
|
@GetMapping(path = Mapping.URL_TASK_COMMENT)
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskCommentResource> getTaskComment(
|
public ResponseEntity<TaskCommentResource> getTaskComment(@PathVariable String taskCommentId)
|
||||||
@PathVariable String taskId, @PathVariable String taskCommentId)
|
|
||||||
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
|
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Entry to getTaskComment(taskId= {}, taskCommentId= {})", taskId, taskCommentId);
|
LOGGER.debug("Entry to getTaskComment(taskCommentId= {})", taskCommentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskComment taskComment = taskService.getTaskComment(taskId, taskCommentId);
|
TaskComment taskComment = taskService.getTaskComment(taskCommentId);
|
||||||
|
|
||||||
TaskCommentResource taskCommentResource = taskCommentResourceAssembler.toResource(taskComment);
|
TaskCommentResource taskCommentResource = taskCommentResourceAssembler.toResource(taskComment);
|
||||||
|
|
||||||
|
@ -66,7 +65,7 @@ public class TaskCommentController {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = Mapping.URL_TASK_COMMENTS)
|
@GetMapping(path = Mapping.URL_TASK_GET_POST_COMMENTS)
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskCommentListResource> getTaskComments(@PathVariable String taskId)
|
public ResponseEntity<TaskCommentListResource> getTaskComments(@PathVariable String taskId)
|
||||||
throws NotAuthorizedException, TaskNotFoundException {
|
throws NotAuthorizedException, TaskNotFoundException {
|
||||||
|
@ -90,16 +89,14 @@ public class TaskCommentController {
|
||||||
|
|
||||||
@DeleteMapping(path = Mapping.URL_TASK_COMMENT)
|
@DeleteMapping(path = Mapping.URL_TASK_COMMENT)
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskCommentResource> deleteTaskComment(
|
public ResponseEntity<TaskCommentResource> deleteTaskComment(@PathVariable String taskCommentId)
|
||||||
@PathVariable String taskId, @PathVariable String taskCommentId)
|
|
||||||
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
|
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug(
|
LOGGER.debug("Entry to deleteTaskComment(taskCommentId= {})", taskCommentId);
|
||||||
"Entry to deleteTaskComment(taskId= {}, taskCommentId= {})", taskId, taskCommentId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
taskService.deleteTaskComment(taskId, taskCommentId);
|
taskService.deleteTaskComment(taskCommentId);
|
||||||
|
|
||||||
ResponseEntity<TaskCommentResource> result = ResponseEntity.noContent().build();
|
ResponseEntity<TaskCommentResource> result = ResponseEntity.noContent().build();
|
||||||
|
|
||||||
|
@ -113,23 +110,19 @@ public class TaskCommentController {
|
||||||
@PutMapping(path = Mapping.URL_TASK_COMMENT)
|
@PutMapping(path = Mapping.URL_TASK_COMMENT)
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskCommentResource> updateTaskComment(
|
public ResponseEntity<TaskCommentResource> updateTaskComment(
|
||||||
@PathVariable String taskId,
|
@PathVariable String taskCommentId, @RequestBody TaskCommentResource taskCommentResource)
|
||||||
@PathVariable String taskCommentId,
|
|
||||||
@RequestBody TaskCommentResource taskCommentResource)
|
|
||||||
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
|
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
|
||||||
InvalidArgumentException, ConcurrencyException {
|
InvalidArgumentException, ConcurrencyException {
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
"Entry to updateTaskComment(taskId= {}, taskCommentId= {}, taskCommentResource= {})",
|
"Entry to updateTaskComment(taskCommentId= {}, taskCommentResource= {})",
|
||||||
taskId,
|
|
||||||
taskCommentId,
|
taskCommentId,
|
||||||
taskCommentResource);
|
taskCommentResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseEntity<TaskCommentResource> result;
|
ResponseEntity<TaskCommentResource> result = null;
|
||||||
|
|
||||||
if ((taskCommentId.equals(taskCommentResource.getTaskCommentId())
|
if ((taskCommentId.equals(taskCommentResource.getTaskCommentId()))) {
|
||||||
&& (taskId.equals(taskCommentResource.getTaskId())))) {
|
|
||||||
|
|
||||||
TaskComment taskComment = taskCommentResourceAssembler.toModel(taskCommentResource);
|
TaskComment taskComment = taskCommentResourceAssembler.toModel(taskCommentResource);
|
||||||
|
|
||||||
|
@ -138,9 +131,9 @@ public class TaskCommentController {
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
String.format(
|
String.format(
|
||||||
"TaskCommentId ('%s') or TaskId ('%s') are not identical with the ids"
|
"TaskCommentId ('%s') is not identical with the id"
|
||||||
+ " of object in the payload which should be updated",
|
+ " of the object in the payload which should be updated",
|
||||||
taskCommentId, taskId));
|
taskCommentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
@ -150,7 +143,7 @@ public class TaskCommentController {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(path = Mapping.URL_TASK_COMMENTS)
|
@PostMapping(path = Mapping.URL_TASK_GET_POST_COMMENTS)
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ResponseEntity<TaskCommentResource> createTaskComment(
|
public ResponseEntity<TaskCommentResource> createTaskComment(
|
||||||
@PathVariable String taskId, @RequestBody TaskCommentResource taskCommentResource)
|
@PathVariable String taskId, @RequestBody TaskCommentResource taskCommentResource)
|
||||||
|
@ -158,29 +151,22 @@ public class TaskCommentController {
|
||||||
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
"Entry to createTaskComment(taskId = {}, taskCommentResource= {})",
|
"Entry to createTaskComment(taskId= {}, taskCommentResource= {})",
|
||||||
taskId,
|
taskId,
|
||||||
taskCommentResource);
|
taskCommentResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taskCommentResource.setTaskId(taskId);
|
||||||
|
|
||||||
|
TaskComment taskCommentFromResource = taskCommentResourceAssembler.toModel(taskCommentResource);
|
||||||
|
TaskComment createdTaskComment = taskService.createTaskComment(taskCommentFromResource);
|
||||||
|
|
||||||
ResponseEntity<TaskCommentResource> result;
|
ResponseEntity<TaskCommentResource> result;
|
||||||
|
|
||||||
if (taskId.equals(taskCommentResource.getTaskId())) {
|
result =
|
||||||
|
ResponseEntity.status(HttpStatus.CREATED)
|
||||||
|
.body(taskCommentResourceAssembler.toResource(createdTaskComment));
|
||||||
|
|
||||||
TaskComment taskCommentFromResource =
|
|
||||||
taskCommentResourceAssembler.toModel(taskCommentResource);
|
|
||||||
TaskComment createdTaskComment = taskService.createTaskComment(taskCommentFromResource);
|
|
||||||
|
|
||||||
result =
|
|
||||||
ResponseEntity.status(HttpStatus.CREATED)
|
|
||||||
.body(taskCommentResourceAssembler.toResource(createdTaskComment));
|
|
||||||
} else {
|
|
||||||
throw new InvalidArgumentException(
|
|
||||||
String.format(
|
|
||||||
"TaskId ('%s') is not identical with the taskId of the"
|
|
||||||
+ "object in the payload which should be updated.",
|
|
||||||
taskCommentResource.getTaskId()));
|
|
||||||
}
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Exit from createTaskComment(), returning {}", result);
|
LOGGER.debug("Exit from createTaskComment(), returning {}", result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class TaskCommentResourceAssembler
|
||||||
taskCommentResource.add(
|
taskCommentResource.add(
|
||||||
linkTo(
|
linkTo(
|
||||||
methodOn(TaskCommentController.class)
|
methodOn(TaskCommentController.class)
|
||||||
.getTaskComment(taskComment.getTaskId(), taskComment.getId()))
|
.getTaskComment(taskComment.getId()))
|
||||||
.withSelfRel());
|
.withSelfRel());
|
||||||
} catch (TaskCommentNotFoundException
|
} catch (TaskCommentNotFoundException
|
||||||
| TaskNotFoundException
|
| TaskNotFoundException
|
||||||
|
|
|
@ -92,7 +92,8 @@ public class TaskCommentControllerRestDocumentation extends BaseRestDocumentatio
|
||||||
.perform(
|
.perform(
|
||||||
RestDocumentationRequestBuilders.get(
|
RestDocumentationRequestBuilders.get(
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(
|
||||||
Mapping.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000000"))
|
Mapping.URL_TASK_GET_POST_COMMENTS,
|
||||||
|
"TKI:000000000000000000000000000000000000"))
|
||||||
.accept(MediaTypes.HAL_JSON)
|
.accept(MediaTypes.HAL_JSON)
|
||||||
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
||||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||||
|
@ -108,9 +109,7 @@ public class TaskCommentControllerRestDocumentation extends BaseRestDocumentatio
|
||||||
.perform(
|
.perform(
|
||||||
RestDocumentationRequestBuilders.get(
|
RestDocumentationRequestBuilders.get(
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(
|
||||||
Mapping.URL_TASK_COMMENT,
|
Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000"))
|
||||||
"TKI:000000000000000000000000000000000000",
|
|
||||||
"TCI:000000000000000000000000000000000000"))
|
|
||||||
.accept(MediaTypes.HAL_JSON)
|
.accept(MediaTypes.HAL_JSON)
|
||||||
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
||||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||||
|
@ -123,10 +122,8 @@ public class TaskCommentControllerRestDocumentation extends BaseRestDocumentatio
|
||||||
void updateTaskCommentDocTest() throws Exception {
|
void updateTaskCommentDocTest() throws Exception {
|
||||||
URL url =
|
URL url =
|
||||||
new URL(
|
new URL(
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000"));
|
||||||
Mapping.URL_TASK_COMMENT,
|
|
||||||
"TKI:000000000000000000000000000000000000",
|
|
||||||
"TCI:000000000000000000000000000000000000"));
|
|
||||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
con.setRequestMethod("GET");
|
con.setRequestMethod("GET");
|
||||||
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
|
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
|
||||||
|
@ -148,9 +145,7 @@ public class TaskCommentControllerRestDocumentation extends BaseRestDocumentatio
|
||||||
.perform(
|
.perform(
|
||||||
RestDocumentationRequestBuilders.put(
|
RestDocumentationRequestBuilders.put(
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(
|
||||||
Mapping.URL_TASK_COMMENT,
|
Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000"))
|
||||||
"TKI:000000000000000000000000000000000000",
|
|
||||||
"TCI:000000000000000000000000000000000000"))
|
|
||||||
.header("Authorization", "Basic YWRtaW46YWRtaW4=")
|
.header("Authorization", "Basic YWRtaW46YWRtaW4=")
|
||||||
.contentType(MediaTypes.HAL_JSON)
|
.contentType(MediaTypes.HAL_JSON)
|
||||||
.content(modifiedTaskComment))
|
.content(modifiedTaskComment))
|
||||||
|
@ -174,7 +169,8 @@ public class TaskCommentControllerRestDocumentation extends BaseRestDocumentatio
|
||||||
.perform(
|
.perform(
|
||||||
RestDocumentationRequestBuilders.post(
|
RestDocumentationRequestBuilders.post(
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(
|
||||||
Mapping.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000000"))
|
Mapping.URL_TASK_GET_POST_COMMENTS,
|
||||||
|
"TKI:000000000000000000000000000000000000"))
|
||||||
.contentType(MediaTypes.HAL_JSON)
|
.contentType(MediaTypes.HAL_JSON)
|
||||||
.content(createTaskCommentContent)
|
.content(createTaskCommentContent)
|
||||||
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
|
||||||
|
@ -193,10 +189,7 @@ public class TaskCommentControllerRestDocumentation extends BaseRestDocumentatio
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(
|
.perform(
|
||||||
RestDocumentationRequestBuilders.delete(
|
RestDocumentationRequestBuilders.delete(
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(Mapping.URL_TASK_COMMENT, newId))
|
||||||
Mapping.URL_TASK_COMMENT,
|
|
||||||
"TKI:000000000000000000000000000000000000",
|
|
||||||
newId))
|
|
||||||
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
|
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
|
||||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||||
.andDo(MockMvcRestDocumentation.document("DeleteTaskCommentDocTest"));
|
.andDo(MockMvcRestDocumentation.document("DeleteTaskCommentDocTest"));
|
||||||
|
|
|
@ -42,13 +42,10 @@ class TaskCommentControllerIntTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetNonExistentCommentShouldFail() {
|
void should_FailToReturnTaskComment_When_TaskCommentIsNotExisting() {
|
||||||
|
|
||||||
String urlToNonExistingTaskComment =
|
String urlToNonExistingTaskComment =
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "Non existing task comment Id");
|
||||||
Mapping.URL_TASK_COMMENT,
|
|
||||||
"TKI:000000000000000000000000000000000000",
|
|
||||||
"Non existing task comment Id");
|
|
||||||
|
|
||||||
ThrowingCallable httpCall =
|
ThrowingCallable httpCall =
|
||||||
() -> {
|
() -> {
|
||||||
|
@ -63,27 +60,9 @@ class TaskCommentControllerIntTest {
|
||||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testGetCommentsForNonExistingTaskShouldFail() {
|
|
||||||
|
|
||||||
String urlToNonExistingTask = restHelper.toUrl(Mapping.URL_TASK_COMMENTS, "nonExistingTaskId");
|
|
||||||
|
|
||||||
ThrowingCallable httpCall =
|
|
||||||
() -> {
|
|
||||||
template.exchange(
|
|
||||||
urlToNonExistingTask,
|
|
||||||
HttpMethod.GET,
|
|
||||||
new HttpEntity<String>(restHelper.getHeadersAdmin()),
|
|
||||||
ParameterizedTypeReference.forType(TaskCommentListResource.class));
|
|
||||||
};
|
|
||||||
assertThatThrownBy(httpCall)
|
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
|
||||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Disabled("Disabled until Authorization check is up!")
|
@Disabled("Disabled until Authorization check is up!")
|
||||||
@Test
|
@Test
|
||||||
void testGetTaskCommentsOfNotVisibleTaskShouldFail() {
|
void should_FailToReturnTaskComments_When_TaskIstNotVisible() {
|
||||||
|
|
||||||
String urlToNotVisibleTask =
|
String urlToNotVisibleTask =
|
||||||
restHelper.toUrl(Mapping.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000004");
|
restHelper.toUrl(Mapping.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000004");
|
||||||
|
@ -103,20 +82,17 @@ class TaskCommentControllerIntTest {
|
||||||
|
|
||||||
@Disabled("Disabled until Authorization check is up!")
|
@Disabled("Disabled until Authorization check is up!")
|
||||||
@Test
|
@Test
|
||||||
void testGetTaskCommentOfNotVisibleTaskShouldFail() {
|
void should_FailToReturnTaskComment_When_TaskIstNotVisible() {
|
||||||
|
|
||||||
String urlToNotVisibleTask =
|
String urlToNotVisibleTask =
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000012");
|
||||||
Mapping.URL_TASK_COMMENT,
|
|
||||||
"TKI:000000000000000000000000000000000004",
|
|
||||||
"TCI:000000000000000000000000000000000013");
|
|
||||||
|
|
||||||
ThrowingCallable httpCall =
|
ThrowingCallable httpCall =
|
||||||
() -> {
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
urlToNotVisibleTask,
|
urlToNotVisibleTask,
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
new HttpEntity<String>(restHelper.getHeadersUser_1_1()),
|
new HttpEntity<String>(restHelper.getHeadersUser_1_2()),
|
||||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||||
};
|
};
|
||||||
assertThatThrownBy(httpCall)
|
assertThatThrownBy(httpCall)
|
||||||
|
@ -126,17 +102,17 @@ class TaskCommentControllerIntTest {
|
||||||
|
|
||||||
@Disabled("Disabled until Authorization check is up!")
|
@Disabled("Disabled until Authorization check is up!")
|
||||||
@Test
|
@Test
|
||||||
void testCreateTaskCommentForNotVisibleTaskShouldFail() {
|
void should_FailToCreateTaskComment_When_TaskIsNotVisible() {
|
||||||
|
|
||||||
TaskCommentResource taskCommentResourceToCreate = new TaskCommentResource();
|
TaskCommentResource taskCommentResourceToCreate = new TaskCommentResource();
|
||||||
taskCommentResourceToCreate.setTaskId("TKI:000000000000000000000000000000000004");
|
taskCommentResourceToCreate.setTaskId("TKI:000000000000000000000000000000000000");
|
||||||
taskCommentResourceToCreate.setTextField("newly created task comment");
|
taskCommentResourceToCreate.setTextField("newly created task comment");
|
||||||
|
|
||||||
ThrowingCallable httpCall =
|
ThrowingCallable httpCall =
|
||||||
() -> {
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(
|
||||||
Mapping.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000004"),
|
Mapping.URL_TASK_GET_POST_COMMENTS, "TKI:000000000000000000000000000000000000"),
|
||||||
HttpMethod.POST,
|
HttpMethod.POST,
|
||||||
new HttpEntity<>(taskCommentResourceToCreate, restHelper.getHeadersUser_1_1()),
|
new HttpEntity<>(taskCommentResourceToCreate, restHelper.getHeadersUser_1_1()),
|
||||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||||
|
@ -147,7 +123,7 @@ class TaskCommentControllerIntTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCreateTaskCommentForNotExistingTaskShouldFail() {
|
void should_FailToCreateTaskComment_When_TaskIdIsNonExisting() {
|
||||||
|
|
||||||
TaskCommentResource taskCommentResourceToCreate = new TaskCommentResource();
|
TaskCommentResource taskCommentResourceToCreate = new TaskCommentResource();
|
||||||
taskCommentResourceToCreate.setTaskId("DefinatelyNotExistingId");
|
taskCommentResourceToCreate.setTaskId("DefinatelyNotExistingId");
|
||||||
|
@ -156,7 +132,7 @@ class TaskCommentControllerIntTest {
|
||||||
ThrowingCallable httpCall =
|
ThrowingCallable httpCall =
|
||||||
() -> {
|
() -> {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
restHelper.toUrl(Mapping.URL_TASK_COMMENTS, "DefinatelyNotExistingId"),
|
restHelper.toUrl(Mapping.URL_TASK_GET_POST_COMMENTS, "DefinatelyNotExistingId"),
|
||||||
HttpMethod.POST,
|
HttpMethod.POST,
|
||||||
new HttpEntity<>(taskCommentResourceToCreate, restHelper.getHeadersAdmin()),
|
new HttpEntity<>(taskCommentResourceToCreate, restHelper.getHeadersAdmin()),
|
||||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||||
|
@ -164,38 +140,17 @@ class TaskCommentControllerIntTest {
|
||||||
assertThatThrownBy(httpCall)
|
assertThatThrownBy(httpCall)
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testCreateTaskCommentWithDifferentTaskIdInResourceShouldFail() {
|
|
||||||
|
|
||||||
TaskCommentResource taskCommentResourceToCreate = new TaskCommentResource();
|
|
||||||
taskCommentResourceToCreate.setTaskId("TKI:000000000000000000000000000000000000");
|
|
||||||
taskCommentResourceToCreate.setTextField("newly created task comment");
|
|
||||||
|
|
||||||
ThrowingCallable httpCall =
|
|
||||||
() -> {
|
|
||||||
template.exchange(
|
|
||||||
restHelper.toUrl(Mapping.URL_TASK_COMMENTS, "DifferentTaskId"),
|
|
||||||
HttpMethod.POST,
|
|
||||||
new HttpEntity<>(taskCommentResourceToCreate, restHelper.getHeadersAdmin()),
|
|
||||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
|
||||||
};
|
|
||||||
assertThatThrownBy(httpCall)
|
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
|
||||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testUpdateTaskCommentWithConcurrentModificationShouldFail() {
|
void should_FailToUpdateTaskComment_When_TaskCommentWasModifiedConcurrently() {
|
||||||
|
|
||||||
final ObjectMapper mapper = new ObjectMapper();
|
final ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
String url =
|
String url =
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000");
|
||||||
Mapping.URL_TASK_COMMENT,
|
|
||||||
"TKI:000000000000000000000000000000000000",
|
|
||||||
"TCI:000000000000000000000000000000000000");
|
|
||||||
|
|
||||||
ResponseEntity<TaskCommentResource> getTaskCommentResponse =
|
ResponseEntity<TaskCommentResource> getTaskCommentResponse =
|
||||||
template.exchange(
|
template.exchange(
|
||||||
|
@ -227,15 +182,12 @@ class TaskCommentControllerIntTest {
|
||||||
|
|
||||||
@Disabled("Disabled until Authorization check is up!")
|
@Disabled("Disabled until Authorization check is up!")
|
||||||
@Test
|
@Test
|
||||||
void testUpdateTaskCommentWithNoAuthorizationShouldFail() {
|
void should_FailToUpdateTaskComment_When_UserHasNoAuthorization() {
|
||||||
|
|
||||||
final ObjectMapper mapper = new ObjectMapper();
|
final ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
String url =
|
String url =
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000");
|
||||||
Mapping.URL_TASK_COMMENT,
|
|
||||||
"TKI:000000000000000000000000000000000000",
|
|
||||||
"TCI:000000000000000000000000000000000000");
|
|
||||||
|
|
||||||
ResponseEntity<TaskCommentResource> getTaskCommentResponse =
|
ResponseEntity<TaskCommentResource> getTaskCommentResponse =
|
||||||
template.exchange(
|
template.exchange(
|
||||||
|
@ -266,7 +218,7 @@ class TaskCommentControllerIntTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testUpdateTaskCommentOfNotExistingTaskShouldFail() {
|
void should_FailToUpdateTaskComment_When_TaskIsNotExisting() {
|
||||||
final ObjectMapper mapper = new ObjectMapper();
|
final ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
TaskCommentResource taskCommentResourceToUpdate = new TaskCommentResource();
|
TaskCommentResource taskCommentResourceToUpdate = new TaskCommentResource();
|
||||||
|
@ -275,10 +227,7 @@ class TaskCommentControllerIntTest {
|
||||||
taskCommentResourceToUpdate.setTextField("updated text");
|
taskCommentResourceToUpdate.setTextField("updated text");
|
||||||
|
|
||||||
String url =
|
String url =
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000");
|
||||||
Mapping.URL_TASK_COMMENT,
|
|
||||||
"TKI:000000000000000000000000000000009999",
|
|
||||||
"TCI:000000000000000000000000000000000000");
|
|
||||||
|
|
||||||
ThrowingCallable httpCall =
|
ThrowingCallable httpCall =
|
||||||
() -> {
|
() -> {
|
||||||
|
@ -296,15 +245,12 @@ class TaskCommentControllerIntTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testUpdateTaskCommentWithDifferentIdsInResourceShouldFail() {
|
void should_FailToUpdateTaskComment_When_TaskCommentIdInResourceDoesNotMatchPathVariable() {
|
||||||
|
|
||||||
final ObjectMapper mapper = new ObjectMapper();
|
final ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
String url =
|
String url =
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000");
|
||||||
Mapping.URL_TASK_COMMENT,
|
|
||||||
"TKI:000000000000000000000000000000000000",
|
|
||||||
"TCI:000000000000000000000000000000000000");
|
|
||||||
|
|
||||||
ResponseEntity<TaskCommentResource> getTaskCommentResponse =
|
ResponseEntity<TaskCommentResource> getTaskCommentResponse =
|
||||||
template.exchange(
|
template.exchange(
|
||||||
|
@ -318,7 +264,7 @@ class TaskCommentControllerIntTest {
|
||||||
|
|
||||||
TaskCommentResource taskCommentResourceToUpdate = getTaskCommentResponse.getBody();
|
TaskCommentResource taskCommentResourceToUpdate = getTaskCommentResponse.getBody();
|
||||||
taskCommentResourceToUpdate.setTextField("updated text");
|
taskCommentResourceToUpdate.setTextField("updated text");
|
||||||
taskCommentResourceToUpdate.setTaskId("DifferentTaskid");
|
taskCommentResourceToUpdate.setTaskCommentId("DifferentTaskCommentId");
|
||||||
|
|
||||||
ThrowingCallable httpCall =
|
ThrowingCallable httpCall =
|
||||||
() -> {
|
() -> {
|
||||||
|
@ -333,28 +279,11 @@ class TaskCommentControllerIntTest {
|
||||||
assertThatThrownBy(httpCall)
|
assertThatThrownBy(httpCall)
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||||
|
|
||||||
taskCommentResourceToUpdate.setTaskId("TKI:000000000000000000000000000000000000");
|
|
||||||
taskCommentResourceToUpdate.setTaskCommentId("DifferentTaskCommentId");
|
|
||||||
|
|
||||||
ThrowingCallable httpCall2 =
|
|
||||||
() -> {
|
|
||||||
template.exchange(
|
|
||||||
url,
|
|
||||||
HttpMethod.PUT,
|
|
||||||
new HttpEntity<>(
|
|
||||||
mapper.writeValueAsString(taskCommentResourceToUpdate),
|
|
||||||
restHelper.getHeadersUser_1_1()),
|
|
||||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
|
||||||
};
|
|
||||||
assertThatThrownBy(httpCall2)
|
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
|
||||||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("Disabled until Authorization check is up!")
|
@Disabled("Disabled until Authorization check is up!")
|
||||||
@Test
|
@Test
|
||||||
void testDeleteTaskCommentWithDifferentUserThanCreatorShouldFail() {
|
void should_FailToDeleteTaskComment_When_UserHasNoAuthorization() {
|
||||||
|
|
||||||
ResponseEntity<TaskCommentListResource> getTaskCommentsBeforeDeleteionResponse =
|
ResponseEntity<TaskCommentListResource> getTaskCommentsBeforeDeleteionResponse =
|
||||||
template.exchange(
|
template.exchange(
|
||||||
|
@ -365,10 +294,7 @@ class TaskCommentControllerIntTest {
|
||||||
assertThat(getTaskCommentsBeforeDeleteionResponse.getBody().getContent()).hasSize(2);
|
assertThat(getTaskCommentsBeforeDeleteionResponse.getBody().getContent()).hasSize(2);
|
||||||
|
|
||||||
String url =
|
String url =
|
||||||
restHelper.toUrl(
|
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000004");
|
||||||
Mapping.URL_TASK_COMMENT,
|
|
||||||
"TKI:000000000000000000000000000000000001",
|
|
||||||
"TCI:000000000000000000000000000000000004");
|
|
||||||
|
|
||||||
ThrowingCallable httpCall =
|
ThrowingCallable httpCall =
|
||||||
() -> {
|
() -> {
|
||||||
|
@ -384,35 +310,9 @@ class TaskCommentControllerIntTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDeleteNonExistingTaskCommentShouldFail() {
|
void should_FailToDeleteTaskComment_When_TaskCommentIsNotExisting() {
|
||||||
|
|
||||||
String url =
|
String url = restHelper.toUrl(Mapping.URL_TASK_COMMENT, "NotExistingTaskComment");
|
||||||
restHelper.toUrl(
|
|
||||||
Mapping.URL_TASK_COMMENT,
|
|
||||||
"TKI:000000000000000000000000000000000001",
|
|
||||||
"NotExistingTaskComment");
|
|
||||||
|
|
||||||
ThrowingCallable httpCall =
|
|
||||||
() -> {
|
|
||||||
template.exchange(
|
|
||||||
url,
|
|
||||||
HttpMethod.DELETE,
|
|
||||||
new HttpEntity<String>(restHelper.getHeadersAdmin()),
|
|
||||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
|
||||||
};
|
|
||||||
assertThatThrownBy(httpCall)
|
|
||||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
|
||||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testDeleteTaskCommentOfNotExistingTaskShouldFail() {
|
|
||||||
|
|
||||||
String url =
|
|
||||||
restHelper.toUrl(
|
|
||||||
Mapping.URL_TASK_COMMENT,
|
|
||||||
"NotExistingTaskId",
|
|
||||||
"TCI:000000000000000000000000000000000004");
|
|
||||||
|
|
||||||
ThrowingCallable httpCall =
|
ThrowingCallable httpCall =
|
||||||
() -> {
|
() -> {
|
||||||
|
|
Loading…
Reference in New Issue