Skip to content

Commit

Permalink
[COZY-228] feat: NotificationLog 반환순서 최신순으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
eple0329 authored Aug 29, 2024
1 parent e919e34 commit 6810183
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public String sendNotificationTest(@AuthenticationPrincipal MemberDetails member
// public String sendTodoNotification(@AuthenticationPrincipal MemberDetails memberDetails) {
// Member member = memberDetails.getMember();
//
// //Optional<Mate> mate = mateRepository.findByMember(member);
// //Optional<Mate> mate = mateRepository.findByMemberOrderByIdDesc(member);
//
// List<String> todoList = new ArrayList<>();
// todoList.add("설거지하기");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public interface NotificationLogRepository extends JpaRepository<NotificationLog, Long> {

List<NotificationLog> findByMemberAndCategory(Member member, NotificationCategory notificationCategory);
List<NotificationLog> findByMemberAndCategoryOrderByIdDesc(Member member, NotificationCategory notificationCategory);

List<NotificationLog> findByMember(Member member);
List<NotificationLog> findByMemberOrderByIdDesc(Member member);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public List<NotificationLogResponseDto> getNotificationLogList(Member member,
NotificationCategory notificationCategory) {
List<NotificationLog> notificationLogs;
if (notificationCategory != null) {
notificationLogs = notificationLogRepository.findByMemberAndCategory(
notificationLogs = notificationLogRepository.findByMemberAndCategoryOrderByIdDesc(
member, notificationCategory);
} else {
notificationLogs = notificationLogRepository.findByMember(member);
notificationLogs = notificationLogRepository.findByMemberOrderByIdDesc(member);
}

List<NotificationLogResponseDto> notificationLogResponseDtoList = notificationLogs.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void setUp() {
notificationLogA = spy(notificationLog1);
given(notificationLogA.getCreatedAt()).willReturn(
LocalDateTime.now().minusDays(1));
given(notificationLogRepository.findByMemberAndCategory(memberA,
given(notificationLogRepository.findByMemberAndCategoryOrderByIdDesc(memberA,
notificationLogA.getCategory())).willReturn(List.of(notificationLogA));

}
Expand Down Expand Up @@ -87,7 +87,7 @@ void setUp() {
notificationLogC = spy(notificationLog3);
given(notificationLogC.getCreatedAt()).willReturn(
LocalDateTime.now().minusMinutes(5));
given(notificationLogRepository.findByMember(memberA)).willReturn(
given(notificationLogRepository.findByMemberOrderByIdDesc(memberA)).willReturn(
List.of(notificationLogA, notificationLogC));
}

Expand All @@ -113,7 +113,7 @@ class 결과가_존재하지_않는_경우 {
void setUp() {
memberA = NotificationLogTestBuilder.testNotificationLogBuild().getMember();

given(notificationLogRepository.findByMemberAndCategory(any(Member.class), any(
given(notificationLogRepository.findByMemberAndCategoryOrderByIdDesc(any(Member.class), any(
NotificationCategory.class))).willReturn(new ArrayList<>());
}

Expand Down

0 comments on commit 6810183

Please sign in to comment.