From bafa22557f7cb0f1bede92a1ad9090ace8886005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EB=8F=99=ED=98=84?= Date: Thu, 14 Sep 2023 23:01:03 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20storeDetail=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EC=88=98=EC=A0=95=20(#265)=20(#271)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: storeDetail 조회 에러 수정 (#265) * docs: 로그아웃 api 문서화 --- src/docs/asciidoc/api/user/user.adoc | 5 +++++ .../be/store/controller/StoreController.java | 7 +++--- .../be/store/service/StoreDetailService.java | 6 ++--- .../store/service/StoreDetailServiceTest.java | 22 ++----------------- 4 files changed, 13 insertions(+), 27 deletions(-) diff --git a/src/docs/asciidoc/api/user/user.adoc b/src/docs/asciidoc/api/user/user.adoc index b941fcec..5791dbff 100644 --- a/src/docs/asciidoc/api/user/user.adoc +++ b/src/docs/asciidoc/api/user/user.adoc @@ -40,6 +40,11 @@ include::{snippets}/find-user-info-doc/http-response.adoc[] include::{snippets}/find-user-info-doc/response-fields-data.adoc[] +=== 로그아웃 +==== HTTP Request +include::{snippets}/user-logout-doc/http-request.adoc[] + + === 사용자가 빌린 우산 조회 ==== HTTP Request diff --git a/src/main/java/upbrella/be/store/controller/StoreController.java b/src/main/java/upbrella/be/store/controller/StoreController.java index 5cbf56a2..01f7f1c0 100644 --- a/src/main/java/upbrella/be/store/controller/StoreController.java +++ b/src/main/java/upbrella/be/store/controller/StoreController.java @@ -15,7 +15,6 @@ import upbrella.be.store.service.StoreMetaService; import upbrella.be.util.CustomResponse; -import javax.servlet.http.HttpSession; import java.time.LocalDateTime; import java.util.List; @@ -28,8 +27,8 @@ public class StoreController { private final ClassificationService classificationService; private final StoreDetailService storeDetailService; - @GetMapping("/stores/{storeId}") - public ResponseEntity> findStoreById(@PathVariable long storeId) { + @GetMapping("/stores/{storeDetailId}") + public ResponseEntity> findStoreById(@PathVariable long storeDetailId) { return ResponseEntity .ok() @@ -37,7 +36,7 @@ public ResponseEntity> findStoreById(@Path "success", 200, "가게 조회 성공", - storeDetailService.findStoreDetailByStoreMetaId(storeId))); + storeDetailService.findStoreDetailByStoreMetaId(storeDetailId))); } @GetMapping("/stores/classification/{classificationId}") diff --git a/src/main/java/upbrella/be/store/service/StoreDetailService.java b/src/main/java/upbrella/be/store/service/StoreDetailService.java index c7b1bb03..d7ae6a60 100644 --- a/src/main/java/upbrella/be/store/service/StoreDetailService.java +++ b/src/main/java/upbrella/be/store/service/StoreDetailService.java @@ -53,10 +53,10 @@ public StoreDetail findStoreDetailById(Long storeId) { } @Transactional - public StoreFindByIdResponse findStoreDetailByStoreMetaId(long storeMetaId) { + public StoreFindByIdResponse findStoreDetailByStoreMetaId(long storeDetailId) { - StoreDetail storeDetail = storeDetailRepository.findByStoreMetaIdUsingFetchJoin(storeMetaId) - .orElseThrow(() -> new NonExistingStoreDetailException("[ERROR] 해당하는 협업 지점이 존재하지 않습니다.")); + StoreDetail storeDetail = findStoreDetailById(storeDetailId); + long storeMetaId = storeDetail.getStoreMeta().getId(); long availableUmbrellaCount = umbrellaService.countAvailableUmbrellaAtStore(storeMetaId); diff --git a/src/test/java/upbrella/be/store/service/StoreDetailServiceTest.java b/src/test/java/upbrella/be/store/service/StoreDetailServiceTest.java index f2f30d1c..35df20ed 100644 --- a/src/test/java/upbrella/be/store/service/StoreDetailServiceTest.java +++ b/src/test/java/upbrella/be/store/service/StoreDetailServiceTest.java @@ -94,7 +94,7 @@ void success() { // given - given(storeDetailRepository.findByStoreMetaIdUsingFetchJoin(3L)) + given(storeDetailRepository.findById(3L)) .willReturn(Optional.of(storeDetail)); given(umbrellaService.countAvailableUmbrellaAtStore(3L)) @@ -109,29 +109,11 @@ void success() { .usingRecursiveComparison() .isEqualTo(storeFindByIdResponseExpected), () -> then(storeDetailRepository).should(times(1)) - .findByStoreMetaIdUsingFetchJoin(3L), + .findById(3L), () -> then(umbrellaService).should(times(1)) .countAvailableUmbrellaAtStore(3L) ); } - - @DisplayName("해당하는 협업 지점이 존재하지 않거나 삭제되었으면 예외를 발생시킨다.") - @Test - void isNotExistingStore() { - - //given - given(storeDetailRepository.findByStoreMetaIdUsingFetchJoin(3L)) - .willReturn(Optional.ofNullable(null)); - - //when & then - assertAll( - () -> assertThatThrownBy(() -> storeDetailService.findStoreDetailByStoreMetaId(3L)) - .isInstanceOf(NonExistingStoreDetailException.class), - () -> then(storeDetailRepository).should(times(1)) - .findByStoreMetaIdUsingFetchJoin(3L), - () -> then(umbrellaService).shouldHaveNoInteractions() - ); - } } @Nested