use of com.furyviewer.domain.RateMovie in project FuryViewer by TheDoctor-95.
the class RateMovieResourceIntTest method updateRateMovie.
@Test
@Transactional
public void updateRateMovie() throws Exception {
// Initialize the database
rateMovieRepository.saveAndFlush(rateMovie);
int databaseSizeBeforeUpdate = rateMovieRepository.findAll().size();
// Update the rateMovie
RateMovie updatedRateMovie = rateMovieRepository.findOne(rateMovie.getId());
updatedRateMovie.rate(UPDATED_RATE).date(UPDATED_DATE);
restRateMovieMockMvc.perform(put("/api/rate-movies").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedRateMovie))).andExpect(status().isOk());
// Validate the RateMovie in the database
List<RateMovie> rateMovieList = rateMovieRepository.findAll();
assertThat(rateMovieList).hasSize(databaseSizeBeforeUpdate);
RateMovie testRateMovie = rateMovieList.get(rateMovieList.size() - 1);
assertThat(testRateMovie.getRate()).isEqualTo(UPDATED_RATE);
assertThat(testRateMovie.getDate()).isEqualTo(UPDATED_DATE);
}
use of com.furyviewer.domain.RateMovie in project FuryViewer by TheDoctor-95.
the class RateMovieResourceIntTest method equalsVerifier.
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(RateMovie.class);
RateMovie rateMovie1 = new RateMovie();
rateMovie1.setId(1L);
RateMovie rateMovie2 = new RateMovie();
rateMovie2.setId(rateMovie1.getId());
assertThat(rateMovie1).isEqualTo(rateMovie2);
rateMovie2.setId(2L);
assertThat(rateMovie1).isNotEqualTo(rateMovie2);
rateMovie1.setId(null);
assertThat(rateMovie1).isNotEqualTo(rateMovie2);
}
use of com.furyviewer.domain.RateMovie in project FuryViewer by TheDoctor-95.
the class RateMovieResource method createRateMovie.
/**
* POST /rate-movies : Create a new rateMovie.
*
* @param rateMovie the rateMovie to create
* @return the ResponseEntity with status 201 (Created) and with body the new rateMovie, or with status 400 (Bad Request) if the rateMovie has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/rate-movies")
@Timed
public ResponseEntity<RateMovie> createRateMovie(@RequestBody RateMovie rateMovie) throws URISyntaxException {
log.debug("REST request to save RateMovie : {}", rateMovie);
if (rateMovie.getId() != null) {
throw new BadRequestAlertException("A new rateMovie cannot already have an ID", ENTITY_NAME, "idexists");
}
Optional<RateMovie> existingRateMovie = rateMovieRepository.findByMovieAndUserLogin(rateMovie.getMovie(), SecurityUtils.getCurrentUserLogin());
if (existingRateMovie.isPresent()) {
rateMovie.setId(existingRateMovie.get().getId());
}
rateMovie.setDate(ZonedDateTime.now());
rateMovie.setUser(userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get());
RateMovie result = rateMovieRepository.save(rateMovie);
return ResponseEntity.created(new URI("/api/rate-movies/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.furyviewer.domain.RateMovie in project FuryViewer by TheDoctor-95.
the class RateMovieResourceIntTest method createRateMovie.
@Test
@Transactional
public void createRateMovie() throws Exception {
int databaseSizeBeforeCreate = rateMovieRepository.findAll().size();
// Create the RateMovie
restRateMovieMockMvc.perform(post("/api/rate-movies").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(rateMovie))).andExpect(status().isCreated());
// Validate the RateMovie in the database
List<RateMovie> rateMovieList = rateMovieRepository.findAll();
assertThat(rateMovieList).hasSize(databaseSizeBeforeCreate + 1);
RateMovie testRateMovie = rateMovieList.get(rateMovieList.size() - 1);
assertThat(testRateMovie.getRate()).isEqualTo(DEFAULT_RATE);
assertThat(testRateMovie.getDate()).isEqualTo(DEFAULT_DATE);
}
use of com.furyviewer.domain.RateMovie in project FuryViewer by TheDoctor-95.
the class RateMovieResource method getRateMovieUSer.
@GetMapping("/rate-movies/MovieRate/{id}")
@Timed
public ResponseEntity<RateMovie> getRateMovieUSer(@PathVariable Long id) {
log.debug("REST request to get RateMovie : {}", id);
RateMovie rateMovie = rateMovieRepository.findByUserAndMovieId(userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get(), id);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(rateMovie));
}
Aggregations