22
33
44import static org .mockito .ArgumentMatchers .anyInt ;
5+ import static org .mockito .ArgumentMatchers .anyLong ;
56import static org .mockito .ArgumentMatchers .anyString ;
67import static org .mockito .Mockito .doReturn ;
78import static org .mockito .Mockito .doThrow ;
1314import static org .springframework .restdocs .request .RequestDocumentation .parameterWithName ;
1415
1516import eatda .controller .store .StorePreviewResponse ;
17+ import eatda .controller .store .StoreResponse ;
1618import eatda .controller .store .StoreSearchResponse ;
1719import eatda .controller .store .StoreSearchResponses ;
1820import eatda .controller .store .StoresResponse ;
3234
3335public class StoreDocumentTest extends BaseDocumentTest {
3436
37+ @ Nested
38+ class GetStore {
39+ RestDocsRequest requestDocument = request ()
40+ .tag (Tag .STORE_API )
41+ .summary ("음식점 정보 조회" )
42+ .pathParameter (
43+ parameterWithName ("storeId" ).description ("음식점 ID" )
44+ );
45+
46+ RestDocsResponse responseDocument = response ()
47+ .responseBodyField (
48+ fieldWithPath ("id" ).type (NUMBER ).description ("음식점 ID" ),
49+ fieldWithPath ("kakaoId" ).type (STRING ).description ("카카오 음식점 ID" ),
50+ fieldWithPath ("name" ).type (STRING ).description ("음식점 이름" ),
51+ fieldWithPath ("district" ).type (STRING ).description ("음식점 주소 (구)" ),
52+ fieldWithPath ("neighborhood" ).type (STRING ).description ("음식점 주소 (동)" ),
53+ fieldWithPath ("category" ).type (STRING ).description ("음식점 카테고리" ),
54+ fieldWithPath ("placeUrl" ).type (STRING ).description ("음식점 카카오맵 URL" )
55+ );
56+
57+ @ Test
58+ void 음식점_정보를_조회 () {
59+ StoreResponse response = new StoreResponse (1L , "17163273" , "농민백암순대" , "강남구" , "대치동" ,
60+ "한식" , "https://place.map.kakao.com/17163273" );
61+ doReturn (response ).when (storeService ).getStore (anyLong ());
62+
63+ long storeId = 1L ;
64+ var document = document ("store/get-store" , 200 )
65+ .request (requestDocument )
66+ .response (responseDocument )
67+ .build ();
68+
69+ given (document )
70+ .contentType (ContentType .JSON )
71+ .pathParam ("storeId" , storeId )
72+ .when ().get ("/api/shops/{storeId}" )
73+ .then ().statusCode (200 );
74+ }
75+
76+ @ EnumSource (value = BusinessErrorCode .class , names = {"STORE_NOT_FOUND" })
77+ @ ParameterizedTest
78+ void 음식점_정보_조회_실패 (BusinessErrorCode errorCode ) {
79+ doThrow (new BusinessException (errorCode )).when (storeService ).getStore (anyLong ());
80+
81+ long storeId = 1L ;
82+ var document = document ("store/get-store" , errorCode )
83+ .request (requestDocument )
84+ .response (ERROR_RESPONSE )
85+ .build ();
86+
87+ given (document )
88+ .contentType (ContentType .JSON )
89+ .pathParam ("storeId" , storeId )
90+ .when ().get ("/api/shops/{storeId}" )
91+ .then ().statusCode (errorCode .getStatus ().value ());
92+ }
93+ }
94+
3595 @ Nested
3696 class GetStores {
3797
@@ -62,7 +122,7 @@ class GetStores {
62122 doReturn (response ).when (storeService ).getStores (anyInt ());
63123
64124 int size = 2 ;
65- var document = document ("store/get" , 200 )
125+ var document = document ("store/get-stores " , 200 )
66126 .request (requestDocument )
67127 .response (responseDocument )
68128 .build ();
@@ -80,7 +140,7 @@ class GetStores {
80140 doThrow (new BusinessException (errorCode )).when (storeService ).getStores (anyInt ());
81141
82142 int size = 2 ;
83- var document = document ("store/get" , errorCode )
143+ var document = document ("store/get-stores " , errorCode )
84144 .request (requestDocument )
85145 .response (ERROR_RESPONSE )
86146 .build ();
0 commit comments