@Test public void testRead() { User bruno = admin("bruno").build(); City cidade = city("São Paulo").build(); Hotel c1 = hotel("Days Inn", cidade).build(); saveall(cidade, c1, bruno); signIn(bruno); ResponseEntity<HotelDTO> response = get("/hotel/" + c1.getId()).expectedStatus(HttpStatus.OK).getResponse(HotelDTO.class); HotelDTO dto = convert.toDTO(c1); assertThat(response.getBody(), equalTo(dto)); assertThat(response.getBody().getCity(), equalTo(dto.getCity())); }
@Test public void testCreate() { User bruno = admin("bruno").build(); City cidade = city("São Paulo").build(); saveall(bruno, cidade); signIn(bruno); Hotel c = hotel("Days Inn", cidade).build(); ResponseEntity<HotelDTO> response = post("/hotel") .json(convert.toDTO(c)) .expectedStatus(HttpStatus.CREATED) .getResponse(HotelDTO.class); c.setId(response.getBody().getId()); HotelDTO dto = convert.toDTO(c); assertThat(response.getBody(), equalTo(dto)); assertThat(response.getBody().getCity(), equalTo(dto.getCity())); assertThat(repository.findAll(), hasSize(1)); }