feat: add paginated notification API and frontend support

This commit is contained in:
Tim
2025-08-19 17:07:27 +08:00
parent 35bcd2cdc2
commit df7ca77652
7 changed files with 256 additions and 185 deletions

View File

@@ -65,12 +65,15 @@ class NotificationServiceTest {
when(uRepo.findByUsername("bob")).thenReturn(Optional.of(user));
Notification n = new Notification();
when(nRepo.findByUserOrderByCreatedAtDesc(user)).thenReturn(List.of(n));
org.springframework.data.domain.Page<Notification> page =
new org.springframework.data.domain.PageImpl<>(List.of(n));
when(nRepo.findByUserOrderByCreatedAtDesc(eq(user), any(org.springframework.data.domain.Pageable.class)))
.thenReturn(page);
List<Notification> list = service.listNotifications("bob", null);
assertEquals(1, list.size());
verify(nRepo).findByUserOrderByCreatedAtDesc(user);
verify(nRepo).findByUserOrderByCreatedAtDesc(eq(user), any(org.springframework.data.domain.Pageable.class));
}
@Test