Search in sources :

Example 1 with ReviewMovie

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

the class ReviewMovieResourceIntTest method updateReviewMovie.

@Test
@Transactional
public void updateReviewMovie() throws Exception {
    // Initialize the database
    reviewMovieRepository.saveAndFlush(reviewMovie);
    int databaseSizeBeforeUpdate = reviewMovieRepository.findAll().size();
    // Update the reviewMovie
    ReviewMovie updatedReviewMovie = reviewMovieRepository.findOne(reviewMovie.getId());
    updatedReviewMovie.date(UPDATED_DATE).title(UPDATED_TITLE).review(UPDATED_REVIEW);
    restReviewMovieMockMvc.perform(put("/api/review-movies").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedReviewMovie))).andExpect(status().isOk());
    // Validate the ReviewMovie in the database
    List<ReviewMovie> reviewMovieList = reviewMovieRepository.findAll();
    assertThat(reviewMovieList).hasSize(databaseSizeBeforeUpdate);
    ReviewMovie testReviewMovie = reviewMovieList.get(reviewMovieList.size() - 1);
    assertThat(testReviewMovie.getDate()).isEqualTo(UPDATED_DATE);
    assertThat(testReviewMovie.getTitle()).isEqualTo(UPDATED_TITLE);
    assertThat(testReviewMovie.getReview()).isEqualTo(UPDATED_REVIEW);
}
Also used : ReviewMovie(com.furyviewer.domain.ReviewMovie) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ReviewMovie

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

the class ReviewMovieResource method getReviewMovie.

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

Example 3 with ReviewMovie

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

the class ReviewMovieResourceIntTest method equalsVerifier.

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

Example 4 with ReviewMovie

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

the class ReviewMovieResourceIntTest method createReviewMovie.

@Test
@Transactional
public void createReviewMovie() throws Exception {
    int databaseSizeBeforeCreate = reviewMovieRepository.findAll().size();
    // Create the ReviewMovie
    restReviewMovieMockMvc.perform(post("/api/review-movies").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(reviewMovie))).andExpect(status().isCreated());
    // Validate the ReviewMovie in the database
    List<ReviewMovie> reviewMovieList = reviewMovieRepository.findAll();
    assertThat(reviewMovieList).hasSize(databaseSizeBeforeCreate + 1);
    ReviewMovie testReviewMovie = reviewMovieList.get(reviewMovieList.size() - 1);
    assertThat(testReviewMovie.getDate()).isEqualTo(DEFAULT_DATE);
    assertThat(testReviewMovie.getTitle()).isEqualTo(DEFAULT_TITLE);
    assertThat(testReviewMovie.getReview()).isEqualTo(DEFAULT_REVIEW);
}
Also used : ReviewMovie(com.furyviewer.domain.ReviewMovie) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with ReviewMovie

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

the class ReviewMovieResource method createReviewMovie.

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

Aggregations

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