@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 getAllHotels() throws Exception { // Initialize the database hotelRepository.saveAndFlush(hotel); // Get all the hotels restHotelMockMvc .perform(get("/api/hotels")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.[*].id").value(hasItem(hotel.getId().intValue()))) .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME.toString()))) .andExpect(jsonPath("$.[*].code").value(hasItem(DEFAULT_CODE))); }
@Test @Transactional public void deleteHotel() throws Exception { // Initialize the database hotelRepository.saveAndFlush(hotel); int databaseSizeBeforeDelete = hotelRepository.findAll().size(); // Get the hotel restHotelMockMvc .perform(delete("/api/hotels/{id}", hotel.getId()).accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<Hotel> hotels = hotelRepository.findAll(); assertThat(hotels).hasSize(databaseSizeBeforeDelete - 1); }