Advertisement
VladNitu

ValidationTestLaimonas

Dec 18th, 2022
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. @Test
  2. void validationTest() throws Exception {
  3. Notification notification = new Notification("", "", null, "", "");
  4. MvcResult mvcResult = mockMvc
  5. .perform(post("/notifyUser")
  6. .contentType(MediaType.APPLICATION_JSON)
  7. .content(objectMapper.writeValueAsString(notification))
  8. )
  9. .andExpect(status().isBadRequest())
  10. .andReturn();
  11.  
  12. String contentAsString = mvcResult.getResponse().getContentAsString();
  13. assertThat(contentAsString).contains("activityId is mandatory and cannot be null");
  14. assertThat(contentAsString).contains("targetId is mandatory and cannot be blank");
  15. assertThat(contentAsString).contains("userId is mandatory and cannot be blank");
  16. assertThat(contentAsString).contains("type is mandatory and cannot be blank");
  17. assertThat(contentAsString).contains("userId is mandatory and cannot be blank");
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement