Skip to content

Commit

Permalink
refactor : 코드 리포멧팅
Browse files Browse the repository at this point in the history
  • Loading branch information
hyun2371 committed Jan 7, 2024
1 parent 4e9f960 commit 3e8ca95
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ public interface WaitingRepository extends JpaRepository<Waiting, Long> {

@Query("select w from Waiting w join fetch w.shop "
+ "where w.member = :member and w.status = :status")
Optional<Waiting> findByMemberAndStatusWithShop(@Param("member")Member member, @Param("status")WaitingStatus status);
Optional<Waiting> findByMemberAndStatusWithShop(@Param("member") Member member,
@Param("status") WaitingStatus status);
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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
Expand Down

0 comments on commit 3e8ca95

Please sign in to comment.