Search in sources :

Example 1 with Genre

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

the class GenreResource method getGenre.

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

Example 2 with Genre

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

the class GenreResource method updateGenre.

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

Example 3 with Genre

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

the class GenreResourceIntTest method createGenre.

@Test
@Transactional
public void createGenre() throws Exception {
    int databaseSizeBeforeCreate = genreRepository.findAll().size();
    // Create the Genre
    restGenreMockMvc.perform(post("/api/genres").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(genre))).andExpect(status().isCreated());
    // Validate the Genre in the database
    List<Genre> genreList = genreRepository.findAll();
    assertThat(genreList).hasSize(databaseSizeBeforeCreate + 1);
    Genre testGenre = genreList.get(genreList.size() - 1);
    assertThat(testGenre.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testGenre.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
}
Also used : Genre(com.furyviewer.domain.Genre) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Genre

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

the class GenreResourceIntTest method updateGenre.

@Test
@Transactional
public void updateGenre() throws Exception {
    // Initialize the database
    genreRepository.saveAndFlush(genre);
    int databaseSizeBeforeUpdate = genreRepository.findAll().size();
    // Update the genre
    Genre updatedGenre = genreRepository.findOne(genre.getId());
    updatedGenre.name(UPDATED_NAME).description(UPDATED_DESCRIPTION);
    restGenreMockMvc.perform(put("/api/genres").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedGenre))).andExpect(status().isOk());
    // Validate the Genre in the database
    List<Genre> genreList = genreRepository.findAll();
    assertThat(genreList).hasSize(databaseSizeBeforeUpdate);
    Genre testGenre = genreList.get(genreList.size() - 1);
    assertThat(testGenre.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testGenre.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
}
Also used : Genre(com.furyviewer.domain.Genre) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Genre

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

the class GenreResourceIntTest method equalsVerifier.

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

Aggregations

Genre (com.furyviewer.domain.Genre)7 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 HashSet (java.util.HashSet)1