Search in sources :

Example 1 with HatredSeries

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

the class HatredSeriesResourceIntTest method equalsVerifier.

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

Example 2 with HatredSeries

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

the class HatredSeriesResourceIntTest method createHatredSeries.

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

Example 3 with HatredSeries

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

the class HatredSeriesResourceIntTest method updateHatredSeries.

@Test
@Transactional
public void updateHatredSeries() throws Exception {
    // Initialize the database
    hatredSeriesRepository.saveAndFlush(hatredSeries);
    int databaseSizeBeforeUpdate = hatredSeriesRepository.findAll().size();
    // Update the hatredSeries
    HatredSeries updatedHatredSeries = hatredSeriesRepository.findOne(hatredSeries.getId());
    updatedHatredSeries.hated(UPDATED_HATED).date(UPDATED_DATE);
    restHatredSeriesMockMvc.perform(put("/api/hatred-series").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedHatredSeries))).andExpect(status().isOk());
    // Validate the HatredSeries in the database
    List<HatredSeries> hatredSeriesList = hatredSeriesRepository.findAll();
    assertThat(hatredSeriesList).hasSize(databaseSizeBeforeUpdate);
    HatredSeries testHatredSeries = hatredSeriesList.get(hatredSeriesList.size() - 1);
    assertThat(testHatredSeries.isHated()).isEqualTo(UPDATED_HATED);
    assertThat(testHatredSeries.getDate()).isEqualTo(UPDATED_DATE);
}
Also used : HatredSeries(com.furyviewer.domain.HatredSeries) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with HatredSeries

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

the class HatredSeriesResource method createHatredSeries.

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

Example 5 with HatredSeries

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

the class HatredSeriesResource method getHatredSeries.

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

Aggregations

HatredSeries (com.furyviewer.domain.HatredSeries)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