use of com.furyviewer.domain.Country in project FuryViewer by TheDoctor-95.
the class CountryResourceIntTest method updateCountry.
@Test
@Transactional
public void updateCountry() throws Exception {
// Initialize the database
countryRepository.saveAndFlush(country);
int databaseSizeBeforeUpdate = countryRepository.findAll().size();
// Update the country
Country updatedCountry = countryRepository.findOne(country.getId());
updatedCountry.name(UPDATED_NAME).urlGoogleMaps(UPDATED_URL_GOOGLE_MAPS).latitude(UPDATED_LATITUDE).longitude(UPDATED_LONGITUDE);
restCountryMockMvc.perform(put("/api/countries").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedCountry))).andExpect(status().isOk());
// Validate the Country in the database
List<Country> countryList = countryRepository.findAll();
assertThat(countryList).hasSize(databaseSizeBeforeUpdate);
Country testCountry = countryList.get(countryList.size() - 1);
assertThat(testCountry.getName()).isEqualTo(UPDATED_NAME);
assertThat(testCountry.getUrlGoogleMaps()).isEqualTo(UPDATED_URL_GOOGLE_MAPS);
assertThat(testCountry.getLatitude()).isEqualTo(UPDATED_LATITUDE);
assertThat(testCountry.getLongitude()).isEqualTo(UPDATED_LONGITUDE);
}
use of com.furyviewer.domain.Country in project FuryViewer by TheDoctor-95.
the class CountryResource method updateCountry.
/**
* PUT /countries : Updates an existing country.
*
* @param country the country to update
* @return the ResponseEntity with status 200 (OK) and with body the updated country,
* or with status 400 (Bad Request) if the country is not valid,
* or with status 500 (Internal Server Error) if the country couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/countries")
@Timed
public ResponseEntity<Country> updateCountry(@RequestBody Country country) throws URISyntaxException {
log.debug("REST request to update Country : {}", country);
if (country.getId() == null) {
return createCountry(country);
}
Country result = countryRepository.save(country);
return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, country.getId().toString())).body(result);
}
use of com.furyviewer.domain.Country in project FuryViewer by TheDoctor-95.
the class CountryResourceIntTest method createCountry.
@Test
@Transactional
public void createCountry() throws Exception {
int databaseSizeBeforeCreate = countryRepository.findAll().size();
// Create the Country
restCountryMockMvc.perform(post("/api/countries").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(country))).andExpect(status().isCreated());
// Validate the Country in the database
List<Country> countryList = countryRepository.findAll();
assertThat(countryList).hasSize(databaseSizeBeforeCreate + 1);
Country testCountry = countryList.get(countryList.size() - 1);
assertThat(testCountry.getName()).isEqualTo(DEFAULT_NAME);
assertThat(testCountry.getUrlGoogleMaps()).isEqualTo(DEFAULT_URL_GOOGLE_MAPS);
assertThat(testCountry.getLatitude()).isEqualTo(DEFAULT_LATITUDE);
assertThat(testCountry.getLongitude()).isEqualTo(DEFAULT_LONGITUDE);
}
use of com.furyviewer.domain.Country in project FuryViewer by TheDoctor-95.
the class CountryResourceIntTest method equalsVerifier.
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Country.class);
Country country1 = new Country();
country1.setId(1L);
Country country2 = new Country();
country2.setId(country1.getId());
assertThat(country1).isEqualTo(country2);
country2.setId(2L);
assertThat(country1).isNotEqualTo(country2);
country1.setId(null);
assertThat(country1).isNotEqualTo(country2);
}
use of com.furyviewer.domain.Country in project FuryViewer by TheDoctor-95.
the class CountryResource method createCountry.
/**
* POST /countries : Create a new country.
*
* @param country the country to create
* @return the ResponseEntity with status 201 (Created) and with body the new country, or with status 400 (Bad Request) if the country has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/countries")
@Timed
public ResponseEntity<Country> createCountry(@RequestBody Country country) throws URISyntaxException {
log.debug("REST request to save Country : {}", country);
if (country.getId() != null) {
throw new BadRequestAlertException("A new country cannot already have an ID", ENTITY_NAME, "idexists");
}
Country result = countryRepository.save(country);
return ResponseEntity.created(new URI("/api/countries/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Aggregations