Advertisement
kikosiak

Untitled

Jun 14th, 2020
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. @Test
  2. void shouldThrowExceptionIllegalArgument() throws Exception {
  3. String rentDate = "2020-06-15";
  4. String returnDate = "2020-06-18";
  5. String idRentLocation = "1";
  6. String idReturnLocation = "1";
  7. try {
  8. this.mockMvc.perform(post("/podsumowanieWypozyczenia/{id}", 19L)
  9. .with(user("user").roles("USER"))
  10. .param("rentDate", rentDate)
  11. .param("returnDate", returnDate)
  12. .param("locationsW", idRentLocation)
  13. .param("locationsZ", idReturnLocation));
  14. } catch (NestedServletException ex) {
  15. assertTrue(ex.getCause() instanceof IllegalArgumentException);
  16. assertEquals(ex.getCause().getMessage(),"Empty offer");
  17. }
  18. }
  19.  
  20. @Test
  21. void shouldAddNewRent() throws Exception {
  22. String rentDate = "2020-06-15";
  23. String returnDate = "2020-06-18";
  24. String idRentLocation = "1";
  25. String idReturnLocation = "1";
  26.  
  27. this.mockMvc.perform(post("/podsumowanieWypozyczenia/{id}", 1L)
  28. .with(user("user").roles("USER"))
  29. .param("rentDate", rentDate)
  30. .param("returnDate", returnDate)
  31. .param("locationsW", idRentLocation)
  32. .param("locationsZ", idReturnLocation))
  33. .andExpect(status().isOk())
  34. .andExpect(view().name("podsumowanieWypozyczenia"))
  35. .andExpect(model().attributeExists("kwota","rentDate","returnDate","rentLocation","returnLocation","nameCar"));
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement