use of com.icthh.xm.ms.entity.domain.Location in project xm-ms-entity by xm-online.
the class LocationService method save.
/**
* Save a xmEntity.
*
* @param location the location to save
* @return the persisted XmEntity
*/
public Location save(Location location) {
log.debug("Request to save location : {}", location);
Location result = locationRepository.save(location);
locationSearchRepository.save(location);
return result;
}
use of com.icthh.xm.ms.entity.domain.Location in project xm-ms-entity by xm-online.
the class LocationResource method createLocation.
/**
* POST /locations : Create a new location.
*
* @param location the location to create
* @return the ResponseEntity with status 201 (Created) and with body the new location, 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
@PreAuthorize("hasPermission({'location': #location}, 'LOCATION.CREATE')")
public ResponseEntity<Location> createLocation(@Valid @RequestBody Location location) throws URISyntaxException {
if (location.getId() != null) {
throw new BusinessException(ErrorConstants.ERR_BUSINESS_IDEXISTS, "A new location cannot already have an ID");
}
Location result = locationRepository.save(location);
locationSearchRepository.save(result);
return ResponseEntity.created(new URI("/api/locations/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.icthh.xm.ms.entity.domain.Location in project xm-ms-entity by xm-online.
the class XmEntityResourceExtendedIntTest method createEntityComplexIncoming.
/**
* Creates incoming Entity as from HTTP request.
* Potentially cam be moved to DTO
*
* @param em - Entity manager
* @return XmEntity for incoming request
*/
public static XmEntity createEntityComplexIncoming(EntityManager em) {
XmEntity entity = createEntity(em);
entity.getTags().add(new Tag().typeKey(DEFAULT_TAG_KEY).startDate(DEFAULT_START_DATE).name(DEFAULT_TAG_NAME));
entity.getAttachments().add(new Attachment().typeKey(DEFAULT_ATTACHMENT_KEY).name(DEFAULT_ATTACHMENT_NAME).startDate(DEFAULT_ATTACHMENT_START_DATE).endDate(DEFAULT_ATTACHMENT_END_DATE).valueContentType(DEFAULT_ATTACHMENT_CONTENT_TYPE).content(new Content().value(DEFAULT_ATTACHMENT_CONTENT_VALUE.getBytes())).contentUrl(DEFAULT_ATTACHMENT_URL).description(DEFAULT_ATTACHMENT_DESCRIPTION));
entity.getLocations().add(new Location().typeKey(DEFAULT_LOCATION_KEY).name(DEFAULT_LOCATION_NAME).countryKey(DEFAULT_LOCATION_COUNTRY_KEY));
return entity;
}
use of com.icthh.xm.ms.entity.domain.Location in project xm-ms-entity by xm-online.
the class LocationResourceIntTest method createLocation.
@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> locationList = locationRepository.findAll();
assertThat(locationList).hasSize(databaseSizeBeforeCreate + 1);
Location testLocation = locationList.get(locationList.size() - 1);
assertThat(testLocation.getTypeKey()).isEqualTo(DEFAULT_TYPE_KEY);
assertThat(testLocation.getCountryKey()).isEqualTo(DEFAULT_COUNTRY_KEY);
assertThat(testLocation.getLongitude()).isEqualTo(DEFAULT_LONGITUDE);
assertThat(testLocation.getLatitude()).isEqualTo(DEFAULT_LATITUDE);
assertThat(testLocation.getName()).isEqualTo(DEFAULT_NAME);
assertThat(testLocation.getAddressLine1()).isEqualTo(DEFAULT_ADDRESS_LINE_1);
assertThat(testLocation.getAddressLine2()).isEqualTo(DEFAULT_ADDRESS_LINE_2);
assertThat(testLocation.getCity()).isEqualTo(DEFAULT_CITY);
assertThat(testLocation.getRegion()).isEqualTo(DEFAULT_REGION);
assertThat(testLocation.getZip()).isEqualTo(DEFAULT_ZIP);
// Validate the Location in Elasticsearch
Location locationEs = locationSearchRepository.findOne(testLocation.getId());
assertThat(locationEs).isEqualToComparingFieldByField(testLocation);
}
use of com.icthh.xm.ms.entity.domain.Location in project xm-ms-entity by xm-online.
the class LocationResourceIntTest method equalsVerifier.
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Location.class);
Location location1 = new Location();
location1.setId(1L);
Location location2 = new Location();
location2.setId(location1.getId());
assertThat(location1).isEqualTo(location2);
location2.setId(2L);
assertThat(location1).isNotEqualTo(location2);
location1.setId(null);
assertThat(location1).isNotEqualTo(location2);
}
Aggregations