use of com.furyviewer.domain.Series in project FuryViewer by TheDoctor-95.
the class SeriesResourceIntTest method createSeries.
@Test
@Transactional
public void createSeries() throws Exception {
int databaseSizeBeforeCreate = seriesRepository.findAll().size();
// Create the Series
restSeriesMockMvc.perform(post("/api/series").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(series))).andExpect(status().isCreated());
// Validate the Series in the database
List<Series> seriesList = seriesRepository.findAll();
assertThat(seriesList).hasSize(databaseSizeBeforeCreate + 1);
Series testSeries = seriesList.get(seriesList.size() - 1);
assertThat(testSeries.getName()).isEqualTo(DEFAULT_NAME);
assertThat(testSeries.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
assertThat(testSeries.getState()).isEqualTo(DEFAULT_STATE);
assertThat(testSeries.getReleaseDate()).isEqualTo(DEFAULT_RELEASE_DATE);
}
use of com.furyviewer.domain.Series in project FuryViewer by TheDoctor-95.
the class SeriesResourceIntTest method updateSeries.
@Test
@Transactional
public void updateSeries() throws Exception {
// Initialize the database
seriesRepository.saveAndFlush(series);
int databaseSizeBeforeUpdate = seriesRepository.findAll().size();
// Update the series
Series updatedSeries = seriesRepository.findOne(series.getId());
updatedSeries.name(UPDATED_NAME).description(UPDATED_DESCRIPTION).state(UPDATED_STATE).releaseDate(UPDATED_RELEASE_DATE);
restSeriesMockMvc.perform(put("/api/series").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedSeries))).andExpect(status().isOk());
// Validate the Series in the database
List<Series> seriesList = seriesRepository.findAll();
assertThat(seriesList).hasSize(databaseSizeBeforeUpdate);
Series testSeries = seriesList.get(seriesList.size() - 1);
assertThat(testSeries.getName()).isEqualTo(UPDATED_NAME);
assertThat(testSeries.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
assertThat(testSeries.getState()).isEqualTo(UPDATED_STATE);
assertThat(testSeries.getReleaseDate()).isEqualTo(UPDATED_RELEASE_DATE);
}
use of com.furyviewer.domain.Series in project FuryViewer by TheDoctor-95.
the class FavouriteSeriesResource method favouriteSeries.
@PostMapping("/favourite-series/id/{idSeries}/liked")
@Timed
public ResponseEntity<FavouriteSeries> favouriteSeries(@PathVariable Long idSeries) throws URISyntaxException {
log.debug("REST request to save FavouriteSeries : {}", idSeries);
Series s = seriesRepository.findOne(idSeries);
FavouriteSeries fS = new FavouriteSeries();
fS.setSeries(s);
fS.setLiked(true);
return createFavouriteSeries(fS);
}
use of com.furyviewer.domain.Series in project FuryViewer by TheDoctor-95.
the class SeriesResource method createSeries.
/**
* POST /series : Create a new series.
*
* @param series the series to create
* @return the ResponseEntity with status 201 (Created) and with body the new series, or with status 400 (Bad Request) if the series has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/series")
@Timed
public ResponseEntity<Series> createSeries(@RequestBody Series series) throws URISyntaxException {
log.debug("REST request to save Series : {}", series);
if (series.getId() != null) {
throw new BadRequestAlertException("A new series cannot already have an ID", ENTITY_NAME, "idexists");
}
Series result = seriesRepository.save(series);
return ResponseEntity.created(new URI("/api/series/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.furyviewer.domain.Series in project FuryViewer by TheDoctor-95.
the class SeriesOmdbDTOService method importSeriesByTitle.
/**
* Devuelve una Series a partir del titulo existente en la base de datos o en caso de no existir hace una peticion a
* la api.
* @param title String | Titulo de la series.
* @return Series | Contiene la informacion de una serie en el formato FuryViewer.
*/
@Transactional
public Series importSeriesByTitle(String title) {
// Comprobamos si ya está en nuestra base de datos.
SeriesOmdbDTO seriesOmdbDTO = getSeries(title);
Optional<Series> s = seriesRepository.findByImdb_id(seriesOmdbDTO.getImdbID());
if (s.isPresent()) {
return s.get();
}
Series ss = new Series();
// Comprobamos que la API nos devuelve información.
if (seriesOmdbDTO.getResponse().equalsIgnoreCase("true")) {
ss = importSeries(seriesOmdbDTO);
} else {
System.out.println("==================\nBúsqueda sin resultados\n==================");
}
return ss;
}
Aggregations