コード例 #1
0
  @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);
  }
コード例 #2
0
  @Test
  @Transactional
  public void getHotel() throws Exception {
    // Initialize the database
    hotelRepository.saveAndFlush(hotel);

    // Get the hotel
    restHotelMockMvc
        .perform(get("/api/hotels/{id}", hotel.getId()))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.id").value(hotel.getId().intValue()))
        .andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString()))
        .andExpect(jsonPath("$.code").value(DEFAULT_CODE));
  }
コード例 #3
0
  @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);
  }
コード例 #4
0
  @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);
  }
コード例 #5
0
 @Before
 public void initTest() {
   hotel = new Hotel();
   hotel.setName(DEFAULT_NAME);
   hotel.setCode(DEFAULT_CODE);
 }