From dcd739fc51604bee8d83dfb989856116bd845539 Mon Sep 17 00:00:00 2001 From: tlarbals824 Date: Thu, 28 Dec 2023 21:41:33 +0900 Subject: [PATCH] =?UTF-8?q?PET-282=20refactor=20:=20TodoCompletionCheckEve?= =?UTF-8?q?nt=20record=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/TodoCompletionCheckOnTodoHandler.java | 4 ++-- .../handler/event/TodoCompletionCheckEvent.java | 8 +------- .../handler/TodoCompletionCheckOnTodoHandlerTest.java | 8 ++++---- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Domain-Module/Todo-Module/Todo-Application/src/main/java/com/pawith/todoapplication/handler/TodoCompletionCheckOnTodoHandler.java b/Domain-Module/Todo-Module/Todo-Application/src/main/java/com/pawith/todoapplication/handler/TodoCompletionCheckOnTodoHandler.java index bb3f79d4..c408560c 100644 --- a/Domain-Module/Todo-Module/Todo-Application/src/main/java/com/pawith/todoapplication/handler/TodoCompletionCheckOnTodoHandler.java +++ b/Domain-Module/Todo-Module/Todo-Application/src/main/java/com/pawith/todoapplication/handler/TodoCompletionCheckOnTodoHandler.java @@ -26,8 +26,8 @@ public class TodoCompletionCheckOnTodoHandler { public void changeTodoStatus(TodoCompletionCheckEvent todoCompletionCheckEvent) throws InterruptedException { while(true) { try { - final List assigns = assignQueryService.findAllAssignByTodoId(todoCompletionCheckEvent.getTodoId()); - final Todo todo = todoQueryService.findTodoByTodoId(todoCompletionCheckEvent.getTodoId()); + final List assigns = assignQueryService.findAllAssignByTodoId(todoCompletionCheckEvent.todoId()); + final Todo todo = todoQueryService.findTodoByTodoId(todoCompletionCheckEvent.todoId()); final boolean isAllCompleteTodo = assigns.stream().allMatch(Assign::isCompleted); todo.updateCompletionStatus(isAllCompleteTodo); break; diff --git a/Domain-Module/Todo-Module/Todo-Application/src/main/java/com/pawith/todoapplication/handler/event/TodoCompletionCheckEvent.java b/Domain-Module/Todo-Module/Todo-Application/src/main/java/com/pawith/todoapplication/handler/event/TodoCompletionCheckEvent.java index 15bb4f0c..e4900a9a 100644 --- a/Domain-Module/Todo-Module/Todo-Application/src/main/java/com/pawith/todoapplication/handler/event/TodoCompletionCheckEvent.java +++ b/Domain-Module/Todo-Module/Todo-Application/src/main/java/com/pawith/todoapplication/handler/event/TodoCompletionCheckEvent.java @@ -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) { } diff --git a/Domain-Module/Todo-Module/Todo-Application/src/test/java/com/pawith/todoapplication/handler/TodoCompletionCheckOnTodoHandlerTest.java b/Domain-Module/Todo-Module/Todo-Application/src/test/java/com/pawith/todoapplication/handler/TodoCompletionCheckOnTodoHandlerTest.java index f1e41be2..cdec8c42 100644 --- a/Domain-Module/Todo-Module/Todo-Application/src/test/java/com/pawith/todoapplication/handler/TodoCompletionCheckOnTodoHandlerTest.java +++ b/Domain-Module/Todo-Module/Todo-Application/src/test/java/com/pawith/todoapplication/handler/TodoCompletionCheckOnTodoHandlerTest.java @@ -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 @@ -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