33import static org .assertj .core .api .AssertionsForInterfaceTypes .*;
44import static org .mockito .BDDMockito .*;
55
6+ import java .time .LocalDateTime ;
67import java .util .List ;
78
89import org .junit .jupiter .api .DisplayName ;
1213import org .mockito .Mock ;
1314import org .mockito .junit .jupiter .MockitoExtension ;
1415
16+ import com .example .log4u .domain .diary .repository .DiaryRepository ;
17+ import com .example .log4u .domain .map .dto .response .DiaryMarkerResponseDto ;
1518import com .example .log4u .fixture .AreaClusterFixture ;
1619import com .example .log4u .domain .map .dto .response .DiaryClusterResponseDto ;
1720import com .example .log4u .domain .map .repository .SidoAreasDiaryCountRepository ;
1821import com .example .log4u .domain .map .repository .SidoAreasRepository ;
1922import com .example .log4u .domain .map .repository .SiggAreasDiaryCountRepository ;
2023import com .example .log4u .domain .map .repository .SiggAreasRepository ;
2124import com .example .log4u .domain .map .service .MapService ;
25+ import com .example .log4u .fixture .DiaryMarkerFixture ;
2226
2327@ DisplayName ("지도 API 단위 테스트" )
2428@ ExtendWith (MockitoExtension .class )
@@ -29,12 +33,12 @@ class MapServiceTest {
2933
3034 @ Mock
3135 private SidoAreasRepository sidoAreasRepository ;
32- @ Mock
33- private SidoAreasDiaryCountRepository sidoAreasDiaryCountRepository ;
36+
3437 @ Mock
3538 private SiggAreasRepository siggAreasRepository ;
39+
3640 @ Mock
37- private SiggAreasDiaryCountRepository siggAreasDiaryCountRepository ;
41+ private DiaryRepository diaryRepository ;
3842
3943 @ DisplayName ("성공 테스트: 줌레벨이 10 이하이면 시/도 클러스터 조회" )
4044 @ Test
@@ -75,4 +79,25 @@ void getDiaryClusters_siggAreas_success() {
7579 assertThat (result .get (1 ).diaryCount ()).isEqualTo (30L );
7680 verify (siggAreasRepository ).findSiggAreaClusters (south , north , west , east );
7781 }
82+
83+ @ DisplayName ("성공 테스트: 마커 조회 (줌 14 이상)" )
84+ @ Test
85+ void getDiariesInBounds_success () {
86+ // given
87+ double south = 37.0 , north = 38.0 , west = 126.0 , east = 127.0 ;
88+ List <DiaryMarkerResponseDto > markers = DiaryMarkerFixture .createDiaryMarkers ();
89+
90+ given (diaryRepository .findDiariesInBounds (south , north , west , east ))
91+ .willReturn (markers );
92+
93+ // when
94+ List <DiaryMarkerResponseDto > result = mapService .getDiariesInBounds (south , north , west , east );
95+
96+ // then
97+ assertThat (result ).hasSize (2 );
98+ assertThat (result .get (0 ).title ()).isEqualTo ("첫번째 다이어리" );
99+ assertThat (result .get (1 ).likeCount ()).isEqualTo (7L );
100+ verify (diaryRepository ).findDiariesInBounds (south , north , west , east );
101+ }
102+
78103}
0 commit comments