33import static org .assertj .core .api .AssertionsForInterfaceTypes .*;
44import static org .mockito .BDDMockito .*;
55
6+ import java .util .ArrayList ;
67import java .util .Collections ;
78import java .util .List ;
89import java .util .Optional ;
910import java .util .Set ;
11+ import java .util .stream .Collectors ;
1012
1113import org .junit .jupiter .api .DisplayName ;
1214import org .junit .jupiter .api .Test ;
@@ -130,7 +132,7 @@ void getDiariesByGeohash_success_allCacheHit() {
130132 DiaryMarkerResponseDto dto2 = DiaryMarkerFixture .createDiaryMarker (2L );
131133
132134 given (diaryCacheDao .getDiaryIdSetFromCache ("wydmt" )).willReturn (cachedIds );
133- given (diaryCacheDao .getDiariesFromCacheBulk (List . of ( 1L , 2L ))).willReturn (List .of (dto1 , dto2 ));
135+ given (diaryCacheDao .getDiariesFromCacheBulk (anyList ( ))).willReturn (List .of (dto1 , dto2 ));
134136
135137 // when
136138 List <DiaryMarkerResponseDto > result = mapService .getDiariesByGeohash ("wydmt" );
@@ -141,42 +143,22 @@ void getDiariesByGeohash_success_allCacheHit() {
141143 verify (diaryGeohashService , never ()).getDiaryIdsByGeohash (any ());
142144 }
143145
144-
145- @ DisplayName ("성공 : geohash 캐시 HIT + 모든 diary 캐시 MISS" )
146- @ Test
147- void getDiariesByGeohash_success_allDiaryCacheMiss () {
148- // given
149- String geohash = "wydmt" ;
150- Set <Long > cachedIds = Set .of (1L , 2L );
151- Diary diary1 = DiaryFixture .createDiaryFixture (1L );
152- Diary diary2 = DiaryFixture .createDiaryFixture (2L );
153- DiaryMarkerResponseDto dto1 = DiaryMarkerResponseDto .of (diary1 );
154- DiaryMarkerResponseDto dto2 = DiaryMarkerResponseDto .of (diary2 );
155-
156- given (diaryCacheDao .getDiaryIdSetFromCache ("wydmt" )).willReturn (cachedIds );
157- given (diaryCacheDao .getDiariesFromCacheBulk (List .of (1L , 2L ))).willReturn (List .of ());
158- given (diaryService .getDiaries (List .of (1L , 2L ))).willReturn (List .of (diary1 , diary2 ));
159-
160- // when
161- List <DiaryMarkerResponseDto > result = mapService .getDiariesByGeohash ("wydmt" );
162-
163- // then
164- assertThat (result ).containsExactlyInAnyOrder (dto1 , dto2 );
165- verify (diaryCacheDao ).cacheAllDiaries (List .of (dto1 , dto2 ));
166- }
167-
168146 @ DisplayName ("성공 : geohash 캐시 HIT + 일부 diary 캐시 MISS" )
169147 @ Test
170148 void getDiariesByGeohash_success_partialDiaryCacheMiss () {
171149 // given
172150 String geohash = "wydmt" ;
173151 Set <Long > cachedIds = Set .of (1L , 2L );
152+ List <Long > sortedIds = new ArrayList <>(cachedIds );
153+ Collections .sort (sortedIds );
154+
174155 DiaryMarkerResponseDto dto1 = DiaryMarkerFixture .createDiaryMarker (1L );
175156 Diary diary2 = DiaryFixture .createDiaryFixture (2L );
176157 DiaryMarkerResponseDto dto2 = DiaryMarkerResponseDto .of (diary2 );
177158
178159 given (diaryCacheDao .getDiaryIdSetFromCache ("wydmt" )).willReturn (cachedIds );
179- given (diaryCacheDao .getDiariesFromCacheBulk (List .of (1L , 2L ))).willReturn (List .of (dto1 ));
160+ given (diaryCacheDao .getDiariesFromCacheBulk (anyList ()))
161+ .willReturn (List .of (dto1 ));
180162 given (diaryService .getDiaries (List .of (2L ))).willReturn (List .of (diary2 ));
181163
182164 // when
@@ -187,6 +169,7 @@ void getDiariesByGeohash_success_partialDiaryCacheMiss() {
187169 verify (diaryCacheDao ).cacheAllDiaries (List .of (dto2 ));
188170 }
189171
172+
190173 @ DisplayName ("성공 : geohash 캐시 MISS → DB 조회 → 모든 diary 캐시 HIT" )
191174 @ Test
192175 void getDiariesByGeohash_success_geohashMiss_allDiaryCacheHit () {
0 commit comments