Skip to content

Commit ca46aa7

Browse files
committed
2 parents 0ea6741 + 69890df commit ca46aa7

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/main/java/com/example/log4u/domain/diary/facade/DiaryFacade.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ public PageResponse<DiaryResponseDto> getDiariesByCursor(
124124
) {
125125
Slice<DiaryResponseDto> dtoSlice = diaryService.getDiaryResponseDtoSlice(userId, targetUserId, cursorId, size);
126126
// 다음 커서 ID 계산
127-
Long nextCursor = !dtoSlice.isEmpty() ? dtoSlice.getContent().getLast().diaryId() : null;
127+
Long nextCursor = (dtoSlice.hasNext() && !dtoSlice.isEmpty())
128+
? dtoSlice.getContent().getLast().diaryId()
129+
: null;
128130
return PageResponse.of(dtoSlice, nextCursor);
129131
}
130132

@@ -144,7 +146,9 @@ public PageResponse<DiaryResponseDto> searchDiariesByCursor(
144146
) {
145147
Slice<DiaryResponseDto> dtoSlice = diaryService.searchDiariesByCursor(keyword, sort, cursorId, size);
146148
// 다음 커서 ID 계산
147-
Long nextCursor = !dtoSlice.isEmpty() ? dtoSlice.getContent().getLast().diaryId() : null;
149+
Long nextCursor = (dtoSlice.hasNext() && !dtoSlice.isEmpty())
150+
? dtoSlice.getContent().getLast().diaryId()
151+
: null;
148152
return PageResponse.of(dtoSlice, nextCursor);
149153
}
150154

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.mockito.InjectMocks;
1212
import org.mockito.Mock;
1313
import org.mockito.junit.jupiter.MockitoExtension;
14+
import org.springframework.data.domain.PageRequest;
1415
import org.springframework.data.domain.Slice;
1516
import org.springframework.data.domain.SliceImpl;
1617

@@ -195,7 +196,7 @@ void getDiariesByCursor() {
195196
)
196197
);
197198

198-
Slice<DiaryResponseDto> dtoSlice = new SliceImpl<>(dtoList);
199+
Slice<DiaryResponseDto> dtoSlice = new SliceImpl<>(dtoList, PageRequest.of(0, size), true);
199200
PageResponse<DiaryResponseDto> pageResponse = PageResponse.of(dtoSlice, 3L);
200201

201202
given(diaryService.getDiaryResponseDtoSlice(userId, targetUserId, cursorId, size)).willReturn(dtoSlice);
@@ -244,7 +245,7 @@ void searchDiariesByCursor() {
244245
)
245246
);
246247

247-
Slice<DiaryResponseDto> dtoSlice = new SliceImpl<>(dtoList);
248+
Slice<DiaryResponseDto> dtoSlice = new SliceImpl<>(dtoList, PageRequest.of(0, size), true);
248249
PageResponse<DiaryResponseDto> pageResponse = PageResponse.of(dtoSlice, 2L);
249250

250251
given(diaryService.searchDiariesByCursor(keyword, sort, cursorId, size)).willReturn(dtoSlice);

src/test/java/com/example/log4u/domain/user/service/UserServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void shouldCreateAndSaveMyUserProfile() {
4747
Long userId = 1L;
4848
UserProfileMakeRequestDto userProfileMakeRequestDto = new UserProfileMakeRequestDto(
4949
"test nickname",
50-
"test msg"
50+
"test img"
5151
);
5252

5353
User mockUser = mock(User.class);

0 commit comments

Comments
 (0)