Search in sources :

Example 6 with Series

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);
}
Also used : Series(com.furyviewer.domain.Series) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with Series

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);
}
Also used : Series(com.furyviewer.domain.Series) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with Series

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);
}
Also used : FavouriteSeries(com.furyviewer.domain.FavouriteSeries) Series(com.furyviewer.domain.Series) FavouriteSeries(com.furyviewer.domain.FavouriteSeries) Timed(com.codahale.metrics.annotation.Timed)

Example 9 with Series

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);
}
Also used : BadRequestAlertException(com.furyviewer.web.rest.errors.BadRequestAlertException) Series(com.furyviewer.domain.Series) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 10 with Series

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;
}
Also used : Series(com.furyviewer.domain.Series) SeriesOmdbDTO(com.furyviewer.service.dto.OpenMovieDatabase.SeriesOmdbDTO) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Series (com.furyviewer.domain.Series)11 Transactional (org.springframework.transaction.annotation.Transactional)6 Timed (com.codahale.metrics.annotation.Timed)5 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 SeriesOmdbDTO (com.furyviewer.service.dto.OpenMovieDatabase.SeriesOmdbDTO)2 FavouriteSeries (com.furyviewer.domain.FavouriteSeries)1 BadRequestAlertException (com.furyviewer.web.rest.errors.BadRequestAlertException)1 URI (java.net.URI)1