Search in sources :

Example 1 with Location

use of com.arnaugarcia.uplace.domain.Location in project uplace.es by Uplace.

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);
}
Also used : Location(com.arnaugarcia.uplace.domain.Location) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Location

use of com.arnaugarcia.uplace.domain.Location in project uplace.es by Uplace.

the class LocationResourceIntTest method updateLocation.

@Test
@Transactional
public void updateLocation() throws Exception {
    // Initialize the database
    locationRepository.saveAndFlush(location);
    int databaseSizeBeforeUpdate = locationRepository.findAll().size();
    // Update the location
    Location updatedLocation = locationRepository.findOne(location.getId());
    // Disconnect from session so that the updates on updatedLocation are not directly saved in db
    em.detach(updatedLocation);
    updatedLocation.latitude(UPDATED_LATITUDE).postalCode(UPDATED_POSTAL_CODE).longitude(UPDATED_LONGITUDE).city(UPDATED_CITY).fullAddress(UPDATED_FULL_ADDRESS).hide(UPDATED_HIDE).urlGMaps(UPDATED_URL_G_MAPS);
    LocationDTO locationDTO = locationMapper.toDto(updatedLocation);
    restLocationMockMvc.perform(put("/api/locations").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(locationDTO))).andExpect(status().isOk());
    // Validate the Location in the database
    List<Location> locationList = locationRepository.findAll();
    assertThat(locationList).hasSize(databaseSizeBeforeUpdate);
    Location testLocation = locationList.get(locationList.size() - 1);
    assertThat(testLocation.getLatitude()).isEqualTo(UPDATED_LATITUDE);
    assertThat(testLocation.getPostalCode()).isEqualTo(UPDATED_POSTAL_CODE);
    assertThat(testLocation.getLongitude()).isEqualTo(UPDATED_LONGITUDE);
    assertThat(testLocation.getCity()).isEqualTo(UPDATED_CITY);
    assertThat(testLocation.getFullAddress()).isEqualTo(UPDATED_FULL_ADDRESS);
    assertThat(testLocation.isHide()).isEqualTo(UPDATED_HIDE);
    assertThat(testLocation.getUrlGMaps()).isEqualTo(UPDATED_URL_G_MAPS);
}
Also used : LocationDTO(com.arnaugarcia.uplace.service.dto.LocationDTO) Location(com.arnaugarcia.uplace.domain.Location) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Location

use of com.arnaugarcia.uplace.domain.Location in project uplace.es by Uplace.

the class LocationResourceIntTest method updateNonExistingLocation.

@Test
@Transactional
public void updateNonExistingLocation() throws Exception {
    int databaseSizeBeforeUpdate = locationRepository.findAll().size();
    // Create the Location
    LocationDTO locationDTO = locationMapper.toDto(location);
    // If the entity doesn't have an ID, it will be created instead of just being updated
    restLocationMockMvc.perform(put("/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(databaseSizeBeforeUpdate + 1);
}
Also used : LocationDTO(com.arnaugarcia.uplace.service.dto.LocationDTO) Location(com.arnaugarcia.uplace.domain.Location) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Location

use of com.arnaugarcia.uplace.domain.Location in project uplace.es by Uplace.

the class LocationResourceIntTest method createLocationWithExistingId.

@Test
@Transactional
public void createLocationWithExistingId() throws Exception {
    int databaseSizeBeforeCreate = locationRepository.findAll().size();
    // Create the Location with an existing ID
    location.setId(1L);
    LocationDTO locationDTO = locationMapper.toDto(location);
    // An entity with an existing ID cannot be created, so this API call must fail
    restLocationMockMvc.perform(post("/api/locations").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(locationDTO))).andExpect(status().isBadRequest());
    // Validate the Location in the database
    List<Location> locationList = locationRepository.findAll();
    assertThat(locationList).hasSize(databaseSizeBeforeCreate);
}
Also used : LocationDTO(com.arnaugarcia.uplace.service.dto.LocationDTO) Location(com.arnaugarcia.uplace.domain.Location) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Location

use of com.arnaugarcia.uplace.domain.Location in project uplace.es by Uplace.

the class LocationResource method updateLocation.

/**
 * PUT  /locations : Updates an existing location.
 *
 * @param locationDTO the locationDTO to update
 * @return the ResponseEntity with status 200 (OK) and with body the updated locationDTO,
 * or with status 400 (Bad Request) if the locationDTO is not valid,
 * or with status 500 (Internal Server Error) if the locationDTO couldn't be updated
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PutMapping("/locations")
@Timed
public ResponseEntity<LocationDTO> updateLocation(@RequestBody LocationDTO locationDTO) throws URISyntaxException {
    log.debug("REST request to update Location : {}", locationDTO);
    if (locationDTO.getId() == null) {
        return createLocation(locationDTO);
    }
    Location location = locationMapper.toEntity(locationDTO);
    location = locationRepository.save(location);
    LocationDTO result = locationMapper.toDto(location);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, locationDTO.getId().toString())).body(result);
}
Also used : LocationDTO(com.arnaugarcia.uplace.service.dto.LocationDTO) Location(com.arnaugarcia.uplace.domain.Location) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

Location (com.arnaugarcia.uplace.domain.Location)9 LocationDTO (com.arnaugarcia.uplace.service.dto.LocationDTO)7 Test (org.junit.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 Transactional (org.springframework.transaction.annotation.Transactional)6 Timed (com.codahale.metrics.annotation.Timed)3 BadRequestAlertException (com.arnaugarcia.uplace.web.rest.errors.BadRequestAlertException)1 URI (java.net.URI)1