use of com.arnaugarcia.uplace.domain.Location in project uplace.es by Uplace.
the class LocationResource method createLocation.
/**
* POST /locations : Create a new location.
*
* @param locationDTO the locationDTO to create
* @return the ResponseEntity with status 201 (Created) and with body the new locationDTO, or with status 400 (Bad Request) if the location has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/locations")
@Timed
public ResponseEntity<LocationDTO> createLocation(@RequestBody LocationDTO locationDTO) throws URISyntaxException {
log.debug("REST request to save Location : {}", locationDTO);
if (locationDTO.getId() != null) {
throw new BadRequestAlertException("A new location cannot already have an ID", ENTITY_NAME, "idexists");
}
Location location = locationMapper.toEntity(locationDTO);
location = locationRepository.save(location);
LocationDTO result = locationMapper.toDto(location);
return ResponseEntity.created(new URI("/api/locations/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.arnaugarcia.uplace.domain.Location in project uplace.es by Uplace.
the class LocationResource method getLocation.
/**
* GET /locations/:id : get the "id" location.
*
* @param id the id of the locationDTO to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the locationDTO, or with status 404 (Not Found)
*/
@GetMapping("/locations/{id}")
@Timed
public ResponseEntity<LocationDTO> getLocation(@PathVariable Long id) {
log.debug("REST request to get Location : {}", id);
Location location = locationRepository.findOne(id);
LocationDTO locationDTO = locationMapper.toDto(location);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(locationDTO));
}
use of com.arnaugarcia.uplace.domain.Location in project uplace.es by Uplace.
the class LocationResourceIntTest method createLocation.
@Test
@Transactional
public void createLocation() throws Exception {
int databaseSizeBeforeCreate = locationRepository.findAll().size();
// Create the Location
LocationDTO locationDTO = locationMapper.toDto(location);
restLocationMockMvc.perform(post("/api/locations").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(locationDTO))).andExpect(status().isCreated());
// Validate the Location in the database
List<Location> locationList = locationRepository.findAll();
assertThat(locationList).hasSize(databaseSizeBeforeCreate + 1);
Location testLocation = locationList.get(locationList.size() - 1);
assertThat(testLocation.getLatitude()).isEqualTo(DEFAULT_LATITUDE);
assertThat(testLocation.getPostalCode()).isEqualTo(DEFAULT_POSTAL_CODE);
assertThat(testLocation.getLongitude()).isEqualTo(DEFAULT_LONGITUDE);
assertThat(testLocation.getCity()).isEqualTo(DEFAULT_CITY);
assertThat(testLocation.getFullAddress()).isEqualTo(DEFAULT_FULL_ADDRESS);
assertThat(testLocation.isHide()).isEqualTo(DEFAULT_HIDE);
assertThat(testLocation.getUrlGMaps()).isEqualTo(DEFAULT_URL_G_MAPS);
}
use of com.arnaugarcia.uplace.domain.Location in project uplace.es by Uplace.
the class PropertyResourceIntTest method getAllPropertiesByLocationIsEqualToSomething.
@Test
@Transactional
public void getAllPropertiesByLocationIsEqualToSomething() throws Exception {
// Initialize the database
Location location = LocationResourceIntTest.createEntity(em);
em.persist(location);
em.flush();
property.setLocation(location);
propertyRepository.saveAndFlush(property);
Long locationId = location.getId();
// Get all the propertyList where location equals to locationId
defaultPropertyShouldBeFound("locationId.equals=" + locationId);
// Get all the propertyList where location equals to locationId + 1
defaultPropertyShouldNotBeFound("locationId.equals=" + (locationId + 1));
}
Aggregations