コード例 #1
0
  @Test
  @Transactional
  public void updateApartment() throws Exception {
    // Initialize the database
    apartmentRepository.saveAndFlush(apartment);

    int databaseSizeBeforeUpdate = apartmentRepository.findAll().size();

    // Update the apartment
    apartment.setApartmentId(UPDATED_APARTMENT_ID);
    apartment.setCreated(UPDATED_CREATED);
    apartment.setUpdated(UPDATED_UPDATED);
    apartment.setUrl(UPDATED_URL);

    restApartmentMockMvc
        .perform(
            put("/api/apartments")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(apartment)))
        .andExpect(status().isOk());

    // Validate the Apartment in the database
    List<Apartment> apartments = apartmentRepository.findAll();
    assertThat(apartments).hasSize(databaseSizeBeforeUpdate);
    Apartment testApartment = apartments.get(apartments.size() - 1);
    assertThat(testApartment.getApartmentId()).isEqualTo(UPDATED_APARTMENT_ID);
    assertThat(testApartment.getCreated()).isEqualTo(UPDATED_CREATED);
    assertThat(testApartment.getUpdated()).isEqualTo(UPDATED_UPDATED);
    assertThat(testApartment.getUrl()).isEqualTo(UPDATED_URL);
  }
コード例 #2
0
  @Test
  @Transactional
  public void createApartment() throws Exception {
    int databaseSizeBeforeCreate = apartmentRepository.findAll().size();

    // Create the Apartment

    restApartmentMockMvc
        .perform(
            post("/api/apartments")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(apartment)))
        .andExpect(status().isCreated());

    // Validate the Apartment in the database
    List<Apartment> apartments = apartmentRepository.findAll();
    assertThat(apartments).hasSize(databaseSizeBeforeCreate + 1);
    Apartment testApartment = apartments.get(apartments.size() - 1);
    assertThat(testApartment.getApartmentId()).isEqualTo(DEFAULT_APARTMENT_ID);
    assertThat(testApartment.getCreated()).isEqualTo(DEFAULT_CREATED);
    assertThat(testApartment.getUpdated()).isEqualTo(DEFAULT_UPDATED);
    assertThat(testApartment.getUrl()).isEqualTo(DEFAULT_URL);
  }