3737
3838import static org .mockito .ArgumentMatchers .eq ;
3939import static org .mockito .BDDMockito .given ;
40+ import static org .mockito .BDDMockito .willDoNothing ;
4041import static org .mockito .Mockito .verify ;
4142import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .asyncDispatch ;
43+ import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .delete ;
4244import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
4345import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .patch ;
4446import 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