Skip to content

Commit 4e3690d

Browse files
committed
test: NotificationControllerTest에 알림 전체 삭제 테스트 케이스 구현
1 parent 7e024e6 commit 4e3690d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/test/java/com/back/domain/notification/controller/NotificationControllerTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737

3838
import static org.mockito.ArgumentMatchers.eq;
3939
import static org.mockito.BDDMockito.given;
40+
import static org.mockito.BDDMockito.willDoNothing;
4041
import static org.mockito.Mockito.verify;
4142
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
43+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
4244
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
4345
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
4446
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
@@ -249,4 +251,21 @@ void goPostLink() throws Exception {
249251

250252
verify(notificationService).markAsReadAndGetPostLink(principal.getId(), 999L);
251253
}
254+
@Test
255+
@DisplayName("Delete notifications")
256+
void deleteNotifications() throws Exception {
257+
SecurityUser principal = createPrincipal(17L);
258+
259+
willDoNothing().given(notificationService).deleteAll(principal.getId());
260+
261+
mockMvc.perform(delete("/me/notifications")
262+
.with(withPrincipal(principal))
263+
.accept(MediaType.APPLICATION_JSON))
264+
.andExpect(status().isOk())
265+
.andExpect(jsonPath("$.code").value(200))
266+
.andExpect(jsonPath("$.message").value("cleared"))
267+
.andExpect(jsonPath("$.data").doesNotExist());
268+
269+
verify(notificationService).deleteAll(principal.getId());
270+
}
252271
}

0 commit comments

Comments
 (0)