Skip to content

Commit e935247

Browse files
committed
test: build 시 문제되는 테스트 코드 수정
1 parent f923196 commit e935247

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/test/java/com/example/log4u/domain/Map/service/MapServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ void getDiariesByGeohash_success_allDiaryCacheMiss() {
153153
DiaryMarkerResponseDto dto1 = DiaryMarkerResponseDto.of(diary1);
154154
DiaryMarkerResponseDto dto2 = DiaryMarkerResponseDto.of(diary2);
155155

156-
given(diaryCacheDao.getDiaryIdSetFromCache(geohash)).willReturn(cachedIds);
156+
given(diaryCacheDao.getDiaryIdSetFromCache("wydmt")).willReturn(cachedIds);
157157
given(diaryCacheDao.getDiaryFromCache(1L)).willReturn(null);
158158
given(diaryCacheDao.getDiaryFromCache(2L)).willReturn(null);
159159
given(diaryService.getDiaries(List.of(1L, 2L))).willReturn(List.of(diary1, diary2));
160160

161161
// when
162-
List<DiaryMarkerResponseDto> result = mapService.getDiariesByGeohash(geohash);
162+
List<DiaryMarkerResponseDto> result = mapService.getDiariesByGeohash("wydmt");
163163

164164
// then
165165
assertThat(result).containsExactlyInAnyOrder(dto1, dto2);

src/test/java/com/example/log4u/domain/diary/facade/DiaryFacadeTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.example.log4u.domain.diary.dto.DiaryRequestDto;
2222
import com.example.log4u.domain.diary.dto.DiaryResponseDto;
2323
import com.example.log4u.domain.diary.entity.Diary;
24+
import com.example.log4u.domain.diary.service.DiaryGeohashService;
2425
import com.example.log4u.domain.diary.service.DiaryService;
2526
import com.example.log4u.domain.hashtag.service.HashtagService;
2627
import com.example.log4u.domain.like.service.LikeService;
@@ -54,6 +55,9 @@ class DiaryFacadeTest {
5455
@Mock
5556
private HashtagService hashtagService;
5657

58+
@Mock
59+
private DiaryGeohashService diaryGeohashService;
60+
5761
@InjectMocks
5862
private DiaryFacade diaryFacade;
5963

@@ -77,9 +81,18 @@ void createDiary() {
7781
verify(diaryService).saveDiary(userId, request, thumbnailUrl);
7882
verify(mediaService).saveMedia(diary.getDiaryId(), request.mediaList());
7983
verify(hashtagService).saveOrUpdateHashtag(diary.getDiaryId(), request.hashtagList());
80-
verify(mapService).increaseRegionDiaryCount(request.location().latitude(), request.location().longitude());
84+
verify(mapService).increaseRegionDiaryCount(
85+
request.location().latitude(),
86+
request.location().longitude()
87+
);
88+
verify(diaryGeohashService).saveGeohash(
89+
diary.getDiaryId(),
90+
request.location().latitude(),
91+
request.location().longitude()
92+
);
8193
}
8294

95+
8396
@Test
8497
@DisplayName("다이어리 삭제 성공")
8598
void deleteDiary() {
@@ -97,9 +110,15 @@ void deleteDiary() {
97110
verify(diaryService).getDiaryAfterValidateOwnership(diaryId, userId);
98111
verify(mediaService).deleteMediaByDiaryId(diaryId);
99112
verify(hashtagService).deleteHashtagsByDiaryId(diaryId);
113+
verify(mapService).decreaseRegionDiaryCount(
114+
diary.getLocation().getLatitude(),
115+
diary.getLocation().getLongitude()
116+
);
117+
verify(diaryGeohashService).deleteGeohashAndCache(diaryId);
100118
verify(diaryService).deleteDiary(diary);
101119
}
102120

121+
103122
@Test
104123
@DisplayName("다이어리 수정 성공")
105124
void updateDiary() {

0 commit comments

Comments
 (0)