Search in sources :

Example 1 with HatredArtist

use of com.furyviewer.domain.HatredArtist in project FuryViewer by TheDoctor-95.

the class HatredArtistResourceIntTest method createHatredArtist.

@Test
@Transactional
public void createHatredArtist() throws Exception {
    int databaseSizeBeforeCreate = hatredArtistRepository.findAll().size();
    // Create the HatredArtist
    restHatredArtistMockMvc.perform(post("/api/hatred-artists").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(hatredArtist))).andExpect(status().isCreated());
    // Validate the HatredArtist in the database
    List<HatredArtist> hatredArtistList = hatredArtistRepository.findAll();
    assertThat(hatredArtistList).hasSize(databaseSizeBeforeCreate + 1);
    HatredArtist testHatredArtist = hatredArtistList.get(hatredArtistList.size() - 1);
    assertThat(testHatredArtist.isHated()).isEqualTo(DEFAULT_HATED);
    assertThat(testHatredArtist.getDate()).isEqualTo(DEFAULT_DATE);
}
Also used : HatredArtist(com.furyviewer.domain.HatredArtist) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with HatredArtist

use of com.furyviewer.domain.HatredArtist in project FuryViewer by TheDoctor-95.

the class HatredArtistResourceIntTest method equalsVerifier.

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

Example 3 with HatredArtist

use of com.furyviewer.domain.HatredArtist in project FuryViewer by TheDoctor-95.

the class HatredArtistResource method getHatredArtist.

/**
 * GET  /hatred-artists/:id : get the "id" hatredArtist.
 *
 * @param id the id of the hatredArtist to retrieve
 * @return the ResponseEntity with status 200 (OK) and with body the hatredArtist, or with status 404 (Not Found)
 */
@GetMapping("/hatred-artists/{id}")
@Timed
public ResponseEntity<HatredArtist> getHatredArtist(@PathVariable Long id) {
    log.debug("REST request to get HatredArtist : {}", id);
    HatredArtist hatredArtist = hatredArtistRepository.findOne(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(hatredArtist));
}
Also used : HatredArtist(com.furyviewer.domain.HatredArtist) Timed(com.codahale.metrics.annotation.Timed)

Example 4 with HatredArtist

use of com.furyviewer.domain.HatredArtist in project FuryViewer by TheDoctor-95.

the class HatredArtistResource method updateHatredArtist.

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

Example 5 with HatredArtist

use of com.furyviewer.domain.HatredArtist in project FuryViewer by TheDoctor-95.

the class HatredArtistResource method createHatredArtist.

/**
 * POST  /hatred-artists : Create a new hatredArtist.
 *
 * @param hatredArtist the hatredArtist to create
 * @return the ResponseEntity with status 201 (Created) and with body the new hatredArtist, or with status 400 (Bad Request) if the hatredArtist has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/hatred-artists")
@Timed
public ResponseEntity<HatredArtist> createHatredArtist(@RequestBody HatredArtist hatredArtist) throws URISyntaxException {
    log.debug("REST request to save HatredArtist : {}", hatredArtist);
    if (hatredArtist.getId() != null) {
        throw new BadRequestAlertException("A new hatredArtist cannot already have an ID", ENTITY_NAME, "idexists");
    }
    Optional<HatredArtist> existingHatredArtist = hatredArtistRepository.findByArtistAndUserLogin(hatredArtist.getArtist(), SecurityUtils.getCurrentUserLogin());
    if (existingHatredArtist.isPresent()) {
        throw new BadRequestAlertException("Artista ya aƱadido en Hatred", ENTITY_NAME, "hatredExist");
    }
    hatredArtist.setDate(ZonedDateTime.now());
    hatredArtist.setUser(userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get());
    HatredArtist result = hatredArtistRepository.save(hatredArtist);
    return ResponseEntity.created(new URI("/api/hatred-artists/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : BadRequestAlertException(com.furyviewer.web.rest.errors.BadRequestAlertException) HatredArtist(com.furyviewer.domain.HatredArtist) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

HatredArtist (com.furyviewer.domain.HatredArtist)6 Timed (com.codahale.metrics.annotation.Timed)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Transactional (org.springframework.transaction.annotation.Transactional)3 BadRequestAlertException (com.furyviewer.web.rest.errors.BadRequestAlertException)1 URI (java.net.URI)1