Skip to content

Commit

Permalink
Closes Taskana#2542 - Flag that counts the comments has been added
Browse files Browse the repository at this point in the history
  • Loading branch information
MM1277 committed Mar 21, 2024
1 parent 83d6cba commit e91ecb3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void should_CreateTaskComment_For_TaskThatAlreadyHasComments() throws Exception
taskService.getTaskComments(taskWithComments.getId());
assertThat(taskCommentsAfterInsert)
.containsExactlyInAnyOrder(comment1, comment2, taskCommentToCreate);

assertThat(3 == taskService.getTask(taskWithComments.getId()).getNumberOfComments());
// Deleting the comment so that the comments remain the same in different tests inside this
// class
taskService.deleteTaskComment(taskCommentToCreate.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void should_DeleteTaskComment_For_TaskCommentId() throws Exception {

List<TaskComment> taskCommentsAfterDeletion = taskService.getTaskComments(task1.getId());
assertThat(taskCommentsAfterDeletion).hasSize(0);
assertThat(0 == taskService.getTask(task1.getId()).getNumberOfComments());
}

@WithAccessId(user = "user-1-2", groups = "user-1-1")
Expand All @@ -104,6 +105,7 @@ void should_FailToDeleteTaskComment_When_UserHasNoAuthorization() throws Excepti

List<TaskComment> taskCommentsAfterDeletion = taskService.getTaskComments(task1.getId());
assertThat(taskCommentsAfterDeletion).hasSize(1);
assertThat(1 == taskService.getTask(task1.getId()).getNumberOfComments());

taskanaEngine.runAsAdmin(
() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ void should_UpdateTaskComment_For_TaskComment() throws Exception {
assertThat(taskCommentsAfterUpdate)
.extracting(TaskComment::getTextField)
.containsExactly("updated textfield");
assertThat(1 == taskService.getTask(task.getId()).getNumberOfComments());
}

@WithAccessId(user = "user-1-2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ void deleteTaskComment(String taskCommentId)
|| taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN)
|| taskanaEngine.getEngine().isUserInRole(TaskanaRole.TASK_ADMIN)) {

taskCommentMapper.delete(taskCommentId);
TaskImpl task =
(TaskImpl) taskService.getTask(taskCommentMapper.findById(taskCommentId).getTaskId());
taskCommentMapper.delete(taskCommentId);
taskMapper.decrementNumberOfComments(task.getId(), Instant.now());
task.decrementNumberOfComments();

Expand Down

0 comments on commit e91ecb3

Please sign in to comment.