@Test @Transactional public void createLocation() throws Exception { int databaseSizeBeforeCreate = locationRepository.findAll().size(); // Create the Location restLocationMockMvc .perform( post("/api/locations") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(location))) .andExpect(status().isCreated()); // Validate the Location in the database List<Location> locations = locationRepository.findAll(); assertThat(locations).hasSize(databaseSizeBeforeCreate + 1); Location testLocation = locations.get(locations.size() - 1); assertThat(testLocation.getAddressLine1()).isEqualTo(DEFAULT_ADDRESS_LINE1); assertThat(testLocation.getAddressLine2()).isEqualTo(DEFAULT_ADDRESS_LINE2); assertThat(testLocation.getAddressLine3()).isEqualTo(DEFAULT_ADDRESS_LINE3); assertThat(testLocation.getLongitude()).isEqualTo(DEFAULT_LONGITUDE); assertThat(testLocation.getLatitude()).isEqualTo(DEFAULT_LATITUDE); assertThat(testLocation.getZipCode()).isEqualTo(DEFAULT_ZIP_CODE); }
@Test @Transactional public void updateLocation() throws Exception { // Initialize the database locationRepository.saveAndFlush(location); int databaseSizeBeforeUpdate = locationRepository.findAll().size(); // Update the location location.setAddressLine1(UPDATED_ADDRESS_LINE1); location.setAddressLine2(UPDATED_ADDRESS_LINE2); location.setAddressLine3(UPDATED_ADDRESS_LINE3); location.setLongitude(UPDATED_LONGITUDE); location.setLatitude(UPDATED_LATITUDE); location.setZipCode(UPDATED_ZIP_CODE); restLocationMockMvc .perform( put("/api/locations") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(location))) .andExpect(status().isOk()); // Validate the Location in the database List<Location> locations = locationRepository.findAll(); assertThat(locations).hasSize(databaseSizeBeforeUpdate); Location testLocation = locations.get(locations.size() - 1); assertThat(testLocation.getAddressLine1()).isEqualTo(UPDATED_ADDRESS_LINE1); assertThat(testLocation.getAddressLine2()).isEqualTo(UPDATED_ADDRESS_LINE2); assertThat(testLocation.getAddressLine3()).isEqualTo(UPDATED_ADDRESS_LINE3); assertThat(testLocation.getLongitude()).isEqualTo(UPDATED_LONGITUDE); assertThat(testLocation.getLatitude()).isEqualTo(UPDATED_LATITUDE); assertThat(testLocation.getZipCode()).isEqualTo(UPDATED_ZIP_CODE); }
@Test @Transactional public void deleteLocation() throws Exception { // Initialize the database locationRepository.saveAndFlush(location); int databaseSizeBeforeDelete = locationRepository.findAll().size(); // Get the location restLocationMockMvc .perform( delete("/api/locations/{id}", location.getId()).accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<Location> locations = locationRepository.findAll(); assertThat(locations).hasSize(databaseSizeBeforeDelete - 1); }
@Test @Transactional public void checkAddressLine1IsRequired() throws Exception { int databaseSizeBeforeTest = locationRepository.findAll().size(); // set the field null location.setAddressLine1(null); // Create the Location, which fails. restLocationMockMvc .perform( post("/api/locations") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(location))) .andExpect(status().isBadRequest()); List<Location> locations = locationRepository.findAll(); assertThat(locations).hasSize(databaseSizeBeforeTest); }
@Test @Transactional public void getLocation() throws Exception { // Initialize the database locationRepository.saveAndFlush(location); // Get the location restLocationMockMvc .perform(get("/api/locations/{id}", location.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id").value(location.getId().intValue())) .andExpect(jsonPath("$.addressLine1").value(DEFAULT_ADDRESS_LINE1.toString())) .andExpect(jsonPath("$.addressLine2").value(DEFAULT_ADDRESS_LINE2.toString())) .andExpect(jsonPath("$.addressLine3").value(DEFAULT_ADDRESS_LINE3.toString())) .andExpect(jsonPath("$.longitude").value(DEFAULT_LONGITUDE.doubleValue())) .andExpect(jsonPath("$.latitude").value(DEFAULT_LATITUDE.doubleValue())) .andExpect(jsonPath("$.zipCode").value(DEFAULT_ZIP_CODE.toString())); }