@Test @Transactional public void updateHotel() throws Exception { // Initialize the database hotelRepository.saveAndFlush(hotel); int databaseSizeBeforeUpdate = hotelRepository.findAll().size(); // Update the hotel hotel.setName(UPDATED_NAME); hotel.setCode(UPDATED_CODE); restHotelMockMvc .perform( put("/api/hotels") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(hotel))) .andExpect(status().isOk()); // Validate the Hotel in the database List<Hotel> hotels = hotelRepository.findAll(); assertThat(hotels).hasSize(databaseSizeBeforeUpdate); Hotel testHotel = hotels.get(hotels.size() - 1); assertThat(testHotel.getName()).isEqualTo(UPDATED_NAME); assertThat(testHotel.getCode()).isEqualTo(UPDATED_CODE); }
@Test @Transactional public void createHotel() throws Exception { int databaseSizeBeforeCreate = hotelRepository.findAll().size(); // Create the Hotel restHotelMockMvc .perform( post("/api/hotels") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(hotel))) .andExpect(status().isCreated()); // Validate the Hotel in the database List<Hotel> hotels = hotelRepository.findAll(); assertThat(hotels).hasSize(databaseSizeBeforeCreate + 1); Hotel testHotel = hotels.get(hotels.size() - 1); assertThat(testHotel.getName()).isEqualTo(DEFAULT_NAME); assertThat(testHotel.getCode()).isEqualTo(DEFAULT_CODE); }