Search in sources :

Example 6 with LocationDTO

use of com.arnaugarcia.uplace.service.dto.LocationDTO 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));
}
Also used : LocationDTO(com.arnaugarcia.uplace.service.dto.LocationDTO) Location(com.arnaugarcia.uplace.domain.Location) Timed(com.codahale.metrics.annotation.Timed)

Example 7 with LocationDTO

use of com.arnaugarcia.uplace.service.dto.LocationDTO in project uplace.es by Uplace.

the class LocationResourceIntTest method dtoEqualsVerifier.

@Test
@Transactional
public void dtoEqualsVerifier() throws Exception {
    TestUtil.equalsVerifier(LocationDTO.class);
    LocationDTO locationDTO1 = new LocationDTO();
    locationDTO1.setId(1L);
    LocationDTO locationDTO2 = new LocationDTO();
    assertThat(locationDTO1).isNotEqualTo(locationDTO2);
    locationDTO2.setId(locationDTO1.getId());
    assertThat(locationDTO1).isEqualTo(locationDTO2);
    locationDTO2.setId(2L);
    assertThat(locationDTO1).isNotEqualTo(locationDTO2);
    locationDTO1.setId(null);
    assertThat(locationDTO1).isNotEqualTo(locationDTO2);
}
Also used : LocationDTO(com.arnaugarcia.uplace.service.dto.LocationDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with LocationDTO

use of com.arnaugarcia.uplace.service.dto.LocationDTO 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);
}
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)

Aggregations

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