11package eatda .domain .store ;
22
33import static org .assertj .core .api .Assertions .assertThat ;
4+ import static org .junit .jupiter .api .Assertions .assertAll ;
5+ import static org .junit .jupiter .api .Assertions .assertThrows ;
46
57import eatda .client .map .MapClientStoreSearchResult ;
8+ import eatda .exception .BusinessErrorCode ;
9+ import eatda .exception .BusinessException ;
610import java .util .List ;
711import org .junit .jupiter .api .Nested ;
812import org .junit .jupiter .api .Test ;
@@ -16,7 +20,7 @@ class FilterSearchedStores {
1620
1721 @ Test
1822 void 빈_검색_결과를_넣으면_빈_리스트를_반환한다 () {
19- List <MapClientStoreSearchResult > actual = storeSearchFilter .filterSearchedStores (List .of ());
23+ List <StoreSearchResult > actual = storeSearchFilter .filterSearchedStores (List .of ());
2024
2125 assertThat (actual ).isEmpty ();
2226 }
@@ -29,14 +33,48 @@ class FilterSearchedStores {
2933 MapClientStoreSearchResult store4 = createStore ("4" , "부산음식점" , "FD6" , "부산 연제구 연산동 632-8" );
3034
3135 List <MapClientStoreSearchResult > searchResults = List .of (store1 , store2 , store3 , store4 );
32- List <MapClientStoreSearchResult > actual = storeSearchFilter .filterSearchedStores (searchResults );
36+ List <StoreSearchResult > actual = storeSearchFilter .filterSearchedStores (searchResults );
3337
34- assertThat (actual ).containsExactly (store1 , store3 );
38+ assertThat (actual ).extracting (StoreSearchResult ::kakaoId )
39+ .containsExactlyInAnyOrder ("1" , "3" );
3540 }
3641
37- private MapClientStoreSearchResult createStore (String id , String name , String categoryGroupCode , String location ) {
38- return new MapClientStoreSearchResult (id , categoryGroupCode , "음식점 > 식당" , "010-1234-1234" , name , "https://yapp.co.kr" ,
39- location , null , 37.0d , 128.0d );
42+ }
43+
44+ @ Nested
45+ class FilterStoreByKakaoId {
46+
47+ @ Test
48+ void 음식점_카카오_ID로_검색_결과를_반환한다 () {
49+ MapClientStoreSearchResult store1 = createStore ("1" , "서울음식점1" , "FD6" , "서울 강남구 대치동 896-33" );
50+ MapClientStoreSearchResult store2 = createStore ("2" , "서울음식점2" , "FD6" , "서울 강남구 대치동 896-33" );
51+
52+ List <MapClientStoreSearchResult > searchResults = List .of (store1 , store2 );
53+ StoreSearchResult actual = storeSearchFilter .filterStoreByKakaoId (searchResults , "1" );
54+
55+ assertAll (
56+ () -> assertThat (actual .kakaoId ()).isEqualTo ("1" ),
57+ () -> assertThat (actual .name ()).isEqualTo ("서울음식점1" ),
58+ () -> assertThat (actual .lotNumberAddress ()).isEqualTo ("서울 강남구 대치동 896-33" )
59+
60+ );
61+ }
62+
63+ @ Test
64+ void 존재하지_않는_카카오_ID로_검색하면_예외를_던진다 () {
65+ MapClientStoreSearchResult store = createStore ("1" , "서울음식점1" , "FD6" , "서울 강남구 대치동 896-33" );
66+ List <MapClientStoreSearchResult > searchResults = List .of (store );
67+
68+ BusinessException exception = assertThrows (BusinessException .class ,
69+ () -> storeSearchFilter .filterStoreByKakaoId (searchResults , "999" ));
70+
71+ assertThat (exception .getErrorCode ()).isEqualTo (BusinessErrorCode .STORE_NOT_FOUND );
4072 }
4173 }
74+
75+ private MapClientStoreSearchResult createStore (String id , String name , String categoryGroupCode ,
76+ String location ) {
77+ return new MapClientStoreSearchResult (id , categoryGroupCode , "음식점 > 식당" , "010-1234-1234" , name ,
78+ "https://yapp.co.kr" , location , null , 37.0d , 128.0d );
79+ }
4280}
0 commit comments