Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import org.springframework.data.domain.SliceImpl;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

import static com.chooz.comment.domain.QComment.comment;
import static com.chooz.notification.domain.QNotification.notification;
Expand Down Expand Up @@ -81,7 +83,7 @@ private List<NotificationDto> findNotificationsWithTarget(List<NotificationRowDt
row -> new NotificationDto(
row,
targetsByNotificationId.getOrDefault(row.id(), List.of())
)).toList();
)).collect(Collectors.toCollection(ArrayList::new));
}

public Optional<TargetPostDto> findPostByCommentId(Long commentId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.chooz.notification.application;

import com.chooz.common.dto.CursorBasePaginatedResponse;
import com.chooz.notification.application.dto.NotificationContent;
import com.chooz.notification.application.service.NotificationCommandService;
import com.chooz.notification.application.service.NotificationQueryService;
Expand Down Expand Up @@ -86,6 +87,48 @@ void notifications() throws Exception {
);
}
@Test
@DisplayName("알림 10개 이상 조회")
void notificationsOver10() throws Exception {
//given
Long receiverId = 1L;
Long actorId = 2L;
String title = "숨겨진 츄님이 좋아요를 눌렀어요!";
String content = "지금 바로 확인해보세요.";
String profileUrl = "https://cdn.chooz.site/default_profile.png";
List<Target> targets = List.of(Target.of(3L, TargetType.POST));
String imageUrl = "https://cdn.chooz.site/images/20865b3c-4e2c-454a-81a1-9ca31bbaf77d";
LocalDateTime eventAt = LocalDateTime.now();
NotificationType notificationType = NotificationType.COMMENT_LIKED;
for(long i = 0 ; i < 11 ; i++) {
Notification notification = Notification.create(
notificationType,
eventAt,
NotificationContent.of(
receiverId,
actorId + i,
title,
content,
profileUrl,
imageUrl,
targets
)
).get();
notificationCommandService.create(notification);
}
//when
CursorBasePaginatedResponse<NotificationResponse> notifications = notificationQueryService.findNotifications(
receiverId,
null,
10
);

//then
assertAll(
() -> assertThat(notifications.data().size()).isEqualTo(10),
() -> assertThat(notifications.hasNext()).isTrue()
);
}
@Test
@DisplayName("알림 상태 확인")
void present() throws Exception {
//given
Expand Down