mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-17 12:30:59 +08:00
Revert "feat: support paginated notifications"
This reverts commit a64fd71bbe.
This commit is contained in:
@@ -45,7 +45,7 @@ class NotificationControllerTest {
|
||||
p.setId(2L);
|
||||
n.setPost(p);
|
||||
n.setCreatedAt(LocalDateTime.now());
|
||||
when(notificationService.listNotifications("alice", 0, 30))
|
||||
when(notificationService.listNotifications("alice", null))
|
||||
.thenReturn(List.of(n));
|
||||
|
||||
NotificationDto dto = new NotificationDto();
|
||||
@@ -62,23 +62,6 @@ class NotificationControllerTest {
|
||||
.andExpect(jsonPath("$[0].post.id").value(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listUnreadNotifications() throws Exception {
|
||||
Notification n = new Notification();
|
||||
n.setId(1L);
|
||||
when(notificationService.listUnreadNotifications("alice", 0, 30))
|
||||
.thenReturn(List.of(n));
|
||||
|
||||
NotificationDto dto = new NotificationDto();
|
||||
dto.setId(1L);
|
||||
when(notificationMapper.toDto(n)).thenReturn(dto);
|
||||
|
||||
mockMvc.perform(get("/api/notifications/unread")
|
||||
.principal(new UsernamePasswordAuthenticationToken("alice","p")))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$[0].id").value(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void markReadEndpoint() throws Exception {
|
||||
mockMvc.perform(post("/api/notifications/read")
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.mockito.Mockito;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
@@ -66,12 +65,12 @@ class NotificationServiceTest {
|
||||
when(uRepo.findByUsername("bob")).thenReturn(Optional.of(user));
|
||||
|
||||
Notification n = new Notification();
|
||||
when(nRepo.findByUser(eq(user), any(Pageable.class))).thenReturn(new org.springframework.data.domain.PageImpl<>(List.of(n)));
|
||||
when(nRepo.findByUserOrderByCreatedAtDesc(user)).thenReturn(List.of(n));
|
||||
|
||||
List<Notification> list = service.listNotifications("bob", 0, 30);
|
||||
List<Notification> list = service.listNotifications("bob", null);
|
||||
|
||||
assertEquals(1, list.size());
|
||||
verify(nRepo).findByUser(eq(user), any(Pageable.class));
|
||||
verify(nRepo).findByUserOrderByCreatedAtDesc(user);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user