From 3e8ca953cfe7e6ff4fef50e405f83334a9e134c4 Mon Sep 17 00:00:00 2001 From: hs12 Date: Sun, 7 Jan 2024 16:32:23 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20:=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8F=AC=EB=A9=A7=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/prgrms/catchtable/waiting/domain/Waiting.java | 1 - .../waiting/repository/WaitingRepository.java | 3 ++- .../controller/MemberWaitingControllerTest.java | 3 --- .../waiting/service/MemberWaitingServiceTest.java | 11 +++++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/prgrms/catchtable/waiting/domain/Waiting.java b/src/main/java/com/prgrms/catchtable/waiting/domain/Waiting.java index 421c1184..ad159813 100644 --- a/src/main/java/com/prgrms/catchtable/waiting/domain/Waiting.java +++ b/src/main/java/com/prgrms/catchtable/waiting/domain/Waiting.java @@ -1,6 +1,5 @@ package com.prgrms.catchtable.waiting.domain; -import static com.prgrms.catchtable.common.exception.ErrorCode.CAN_NOT_CANCEL_WAITING; import static com.prgrms.catchtable.common.exception.ErrorCode.CAN_NOT_COMPLETE_WAITING; import static com.prgrms.catchtable.common.exception.ErrorCode.POSTPONE_REMAINING_CNT_0; import static com.prgrms.catchtable.waiting.domain.WaitingStatus.CANCELED; diff --git a/src/main/java/com/prgrms/catchtable/waiting/repository/WaitingRepository.java b/src/main/java/com/prgrms/catchtable/waiting/repository/WaitingRepository.java index 0ddd920c..3ae6e878 100644 --- a/src/main/java/com/prgrms/catchtable/waiting/repository/WaitingRepository.java +++ b/src/main/java/com/prgrms/catchtable/waiting/repository/WaitingRepository.java @@ -18,5 +18,6 @@ public interface WaitingRepository extends JpaRepository { @Query("select w from Waiting w join fetch w.shop " + "where w.member = :member and w.status = :status") - Optional findByMemberAndStatusWithShop(@Param("member")Member member, @Param("status")WaitingStatus status); + Optional findByMemberAndStatusWithShop(@Param("member") Member member, + @Param("status") WaitingStatus status); } diff --git a/src/test/java/com/prgrms/catchtable/waiting/controller/MemberWaitingControllerTest.java b/src/test/java/com/prgrms/catchtable/waiting/controller/MemberWaitingControllerTest.java index 30274744..24963131 100644 --- a/src/test/java/com/prgrms/catchtable/waiting/controller/MemberWaitingControllerTest.java +++ b/src/test/java/com/prgrms/catchtable/waiting/controller/MemberWaitingControllerTest.java @@ -1,7 +1,6 @@ package com.prgrms.catchtable.waiting.controller; import static com.prgrms.catchtable.waiting.domain.WaitingStatus.CANCELED; -import static com.prgrms.catchtable.waiting.domain.WaitingStatus.COMPLETED; import static com.prgrms.catchtable.waiting.domain.WaitingStatus.PROGRESS; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -145,8 +144,6 @@ void postponeWaiting_fails() throws Exception { .andExpect(status().isBadRequest()) .andExpect(jsonPath("$.message").value("이미 맨뒤라 웨이팅을 미룰 수 없습니다.")) .andDo(MockMvcResultHandlers.print()); -// Waiting waiting = waitingRepository.findById(waiting3.getId()).orElse(null); -// Assertions.assertThat(waiting.getPostponeRemainingCount()).isEqualTo(2); } diff --git a/src/test/java/com/prgrms/catchtable/waiting/service/MemberWaitingServiceTest.java b/src/test/java/com/prgrms/catchtable/waiting/service/MemberWaitingServiceTest.java index c9f4b597..80c38d05 100644 --- a/src/test/java/com/prgrms/catchtable/waiting/service/MemberWaitingServiceTest.java +++ b/src/test/java/com/prgrms/catchtable/waiting/service/MemberWaitingServiceTest.java @@ -86,7 +86,8 @@ void postponeWaiting() { Waiting waiting = mock(Waiting.class); given(memberRepository.findById(1L)).willReturn(Optional.of(member)); - given(waitingRepository.findByMemberAndStatusWithShop(member,PROGRESS)).willReturn(Optional.of(waiting)); + given(waitingRepository.findByMemberAndStatusWithShop(member, PROGRESS)).willReturn( + Optional.of(waiting)); given(waiting.getShop()).willReturn(shop); given(waiting.getStatus()).willReturn(PROGRESS); given(waitingLineRepository.findRank(anyLong(), anyLong())).willReturn(3L); @@ -112,7 +113,8 @@ void cancelWaiting() { Waiting waiting = mock(Waiting.class); given(memberRepository.findById(1L)).willReturn(Optional.of(member)); - given(waitingRepository.findByMemberAndStatusWithShop(member,PROGRESS)).willReturn(Optional.of(waiting)); + given(waitingRepository.findByMemberAndStatusWithShop(member, PROGRESS)).willReturn( + Optional.of(waiting)); given(waiting.getShop()).willReturn(shop); given(waiting.getStatus()).willReturn(CANCELED); doNothing().when(waiting).changeStatusCanceled(); @@ -130,14 +132,15 @@ void cancelWaiting() { @DisplayName("웨이팅를 조회할 수 있다.") @Test - void getWaiting(){ + void getWaiting() { //given Shop shop = mock(Shop.class); Member member = mock(Member.class); Waiting waiting = mock(Waiting.class); given(memberRepository.findById(1L)).willReturn(Optional.of(member)); - given(waitingRepository.findByMemberAndStatusWithShop(member,PROGRESS)).willReturn(Optional.of(waiting)); + given(waitingRepository.findByMemberAndStatusWithShop(member, PROGRESS)).willReturn( + Optional.of(waiting)); given(waiting.getShop()).willReturn(shop); given(waiting.getStatus()).willReturn(PROGRESS); //when