Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test
- void shouldThrowExceptionIllegalArgument() throws Exception {
- String rentDate = "2020-06-15";
- String returnDate = "2020-06-18";
- String idRentLocation = "1";
- String idReturnLocation = "1";
- try {
- this.mockMvc.perform(post("/podsumowanieWypozyczenia/{id}", 19L)
- .with(user("user").roles("USER"))
- .param("rentDate", rentDate)
- .param("returnDate", returnDate)
- .param("locationsW", idRentLocation)
- .param("locationsZ", idReturnLocation));
- } catch (NestedServletException ex) {
- assertTrue(ex.getCause() instanceof IllegalArgumentException);
- assertEquals(ex.getCause().getMessage(),"Empty offer");
- }
- }
- @Test
- void shouldAddNewRent() throws Exception {
- String rentDate = "2020-06-15";
- String returnDate = "2020-06-18";
- String idRentLocation = "1";
- String idReturnLocation = "1";
- this.mockMvc.perform(post("/podsumowanieWypozyczenia/{id}", 1L)
- .with(user("user").roles("USER"))
- .param("rentDate", rentDate)
- .param("returnDate", returnDate)
- .param("locationsW", idRentLocation)
- .param("locationsZ", idReturnLocation))
- .andExpect(status().isOk())
- .andExpect(view().name("podsumowanieWypozyczenia"))
- .andExpect(model().attributeExists("kwota","rentDate","returnDate","rentLocation","returnLocation","nameCar"));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement