Search in sources :

Example 1 with RealEstate

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

the class RealEstateResource method createRealEstate.

/**
 * POST  /real-estates : Create a new realEstate.
 *
 * @param realEstate the realEstate to create
 * @return the ResponseEntity with status 201 (Created) and with body the new realEstate, or with status 400 (Bad Request) if the realEstate has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/real-estates")
@Timed
public ResponseEntity<RealEstate> createRealEstate(@Valid @RequestBody RealEstate realEstate) throws URISyntaxException {
    log.debug("REST request to save RealEstate : {}", realEstate);
    if (realEstate.getId() != null) {
        throw new BadRequestAlertException("A new realEstate cannot already have an ID", ENTITY_NAME, "idexists");
    }
    RealEstate result = realEstateService.save(realEstate);
    return ResponseEntity.created(new URI("/api/real-estates/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : BadRequestAlertException(com.arnaugarcia.uplace.web.rest.errors.BadRequestAlertException) RealEstate(com.arnaugarcia.uplace.domain.RealEstate) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 2 with RealEstate

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

the class RealEstateResource method updateRealEstate.

/**
 * PUT  /real-estates : Updates an existing realEstate.
 *
 * @param realEstate the realEstate to update
 * @return the ResponseEntity with status 200 (OK) and with body the updated realEstate,
 * or with status 400 (Bad Request) if the realEstate is not valid,
 * or with status 500 (Internal Server Error) if the realEstate couldn't be updated
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PutMapping("/real-estates")
@Timed
public ResponseEntity<RealEstate> updateRealEstate(@Valid @RequestBody RealEstate realEstate) throws URISyntaxException {
    log.debug("REST request to update RealEstate : {}", realEstate);
    if (realEstate.getId() == null) {
        return createRealEstate(realEstate);
    }
    RealEstate result = realEstateService.save(realEstate);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, realEstate.getId().toString())).body(result);
}
Also used : RealEstate(com.arnaugarcia.uplace.domain.RealEstate) Timed(com.codahale.metrics.annotation.Timed)

Example 3 with RealEstate

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

the class RealEstateResource method getRealEstate.

/**
 * GET  /real-estates/:id : get the "id" realEstate.
 *
 * @param id the id of the realEstate to retrieve
 * @return the ResponseEntity with status 200 (OK) and with body the realEstate, or with status 404 (Not Found)
 */
@GetMapping("/real-estates/{id}")
@Timed
public ResponseEntity<RealEstate> getRealEstate(@PathVariable Long id) {
    log.debug("REST request to get RealEstate : {}", id);
    RealEstate realEstate = realEstateService.findOne(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(realEstate));
}
Also used : RealEstate(com.arnaugarcia.uplace.domain.RealEstate) Timed(com.codahale.metrics.annotation.Timed)

Example 4 with RealEstate

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

the class RealEstateResourceIntTest method equalsVerifier.

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

Example 5 with RealEstate

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

the class RealEstateResourceIntTest method createRealEstate.

@Test
@Transactional
public void createRealEstate() throws Exception {
    int databaseSizeBeforeCreate = realEstateRepository.findAll().size();
    // Create the RealEstate
    restRealEstateMockMvc.perform(post("/api/real-estates").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(realEstate))).andExpect(status().isCreated());
    // Validate the RealEstate in the database
    List<RealEstate> realEstateList = realEstateRepository.findAll();
    assertThat(realEstateList).hasSize(databaseSizeBeforeCreate + 1);
    RealEstate testRealEstate = realEstateList.get(realEstateList.size() - 1);
    assertThat(testRealEstate.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testRealEstate.getNif()).isEqualTo(DEFAULT_NIF);
    assertThat(testRealEstate.getReference()).isEqualTo(DEFAULT_REFERENCE);
}
Also used : RealEstate(com.arnaugarcia.uplace.domain.RealEstate) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

RealEstate (com.arnaugarcia.uplace.domain.RealEstate)5 Timed (com.codahale.metrics.annotation.Timed)3 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Transactional (org.springframework.transaction.annotation.Transactional)2 BadRequestAlertException (com.arnaugarcia.uplace.web.rest.errors.BadRequestAlertException)1 URI (java.net.URI)1