Skip to content

Commit

Permalink
PET-282 refactor : TodoCompletionCheckEvent record로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
tlarbals824 committed Dec 28, 2023
1 parent 00d4b03 commit dcd739f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class TodoCompletionCheckOnTodoHandler {
public void changeTodoStatus(TodoCompletionCheckEvent todoCompletionCheckEvent) throws InterruptedException {
while(true) {
try {
final List<Assign> assigns = assignQueryService.findAllAssignByTodoId(todoCompletionCheckEvent.getTodoId());
final Todo todo = todoQueryService.findTodoByTodoId(todoCompletionCheckEvent.getTodoId());
final List<Assign> assigns = assignQueryService.findAllAssignByTodoId(todoCompletionCheckEvent.todoId());
final Todo todo = todoQueryService.findTodoByTodoId(todoCompletionCheckEvent.todoId());
final boolean isAllCompleteTodo = assigns.stream().allMatch(Assign::isCompleted);
todo.updateCompletionStatus(isAllCompleteTodo);
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
package com.pawith.todoapplication.handler.event;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public class TodoCompletionCheckEvent {
private final Long todoId;
public record TodoCompletionCheckEvent(Long todoId) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ void changeTodoStatus() throws InterruptedException {
.giveMeBuilder(Todo.class)
.set("completionStatus", CompletionStatus.INCOMPLETE)
.sample();
given(assignQueryService.findAllAssignByTodoId(todoCompletionCheckEvent.getTodoId())).willReturn(mockAssigns);
given(todoQueryService.findTodoByTodoId(todoCompletionCheckEvent.getTodoId())).willReturn(mockTodo);
given(assignQueryService.findAllAssignByTodoId(todoCompletionCheckEvent.todoId())).willReturn(mockAssigns);
given(todoQueryService.findTodoByTodoId(todoCompletionCheckEvent.todoId())).willReturn(mockTodo);
// when
todoCompletionCheckOnTodoHandler.changeTodoStatus(todoCompletionCheckEvent);
// then
Expand All @@ -73,8 +73,8 @@ void changeTodoStatusWithIncompletedAssignee() throws InterruptedException {
.giveMeBuilder(Todo.class)
.set("completionStatus", CompletionStatus.INCOMPLETE)
.sample();
given(assignQueryService.findAllAssignByTodoId(todoCompletionCheckEvent.getTodoId())).willReturn(mockAssigns);
given(todoQueryService.findTodoByTodoId(todoCompletionCheckEvent.getTodoId())).willReturn(mockTodo);
given(assignQueryService.findAllAssignByTodoId(todoCompletionCheckEvent.todoId())).willReturn(mockAssigns);
given(todoQueryService.findTodoByTodoId(todoCompletionCheckEvent.todoId())).willReturn(mockTodo);
// when
todoCompletionCheckOnTodoHandler.changeTodoStatus(todoCompletionCheckEvent);
// then
Expand Down

0 comments on commit dcd739f

Please sign in to comment.