Search in sources :

Example 1 with Social

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

the class SocialResourceIntTest method updateSocial.

@Test
@Transactional
public void updateSocial() throws Exception {
    // Initialize the database
    socialRepository.saveAndFlush(social);
    int databaseSizeBeforeUpdate = socialRepository.findAll().size();
    // Update the social
    Social updatedSocial = socialRepository.findOne(social.getId());
    updatedSocial.url(UPDATED_URL).type(UPDATED_TYPE);
    restSocialMockMvc.perform(put("/api/socials").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedSocial))).andExpect(status().isOk());
    // Validate the Social in the database
    List<Social> socialList = socialRepository.findAll();
    assertThat(socialList).hasSize(databaseSizeBeforeUpdate);
    Social testSocial = socialList.get(socialList.size() - 1);
    assertThat(testSocial.getUrl()).isEqualTo(UPDATED_URL);
    assertThat(testSocial.getType()).isEqualTo(UPDATED_TYPE);
}
Also used : Social(com.furyviewer.domain.Social) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Social

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

the class MarksService method markTransformationSeries.

/**
 * Convierte la informacion de los votos de paginas externas proporcionados por la api al formato FuryViewer.
 * @param ratings List | Lista con as diferentes votaciones proporcionadas por la api.
 * @param ss Series | Series de la cual se quiere guardar las votaciones.
 */
public void markTransformationSeries(List<Rating> ratings, Series ss) {
    for (Rating r : ratings) {
        Optional<Social> seriesOptional = socialRepository.findBySeriesAndType(ss, r.getSource());
        if (!seriesOptional.isPresent()) {
            Social s = new Social();
            s.setType(r.getSource());
            if (s.getType().equalsIgnoreCase("internet movie database")) {
                s.setType("IMDB");
            }
            s.setSeries(ss);
            s.setUrl(markTranformation(r.getSource(), r.getValue()));
            socialRepository.save(s);
        }
    }
}
Also used : Social(com.furyviewer.domain.Social) Rating(com.furyviewer.service.dto.OpenMovieDatabase.Rating)

Example 3 with Social

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

the class MarksService method markTransformationMovie.

/**
 * Convierte la informacion de los votos de paginas externas proporcionados por la api al formato FuryViewer.
 * @param ratings List | Lista con as diferentes votaciones proporcionadas por la api.
 * @param m Movie | Movie de la cual se quiere guardar las votaciones.
 */
public void markTransformationMovie(List<Rating> ratings, Movie m) {
    for (Rating r : ratings) {
        Optional<Social> movieOptional = socialRepository.findByMovieAndType(m, r.getSource());
        if (!movieOptional.isPresent()) {
            Social s = new Social();
            s.setMovie(m);
            s.setType(r.getSource());
            s.setUrl(markTranformation(r.getSource(), r.getValue()));
            socialRepository.save(s);
        }
    }
}
Also used : Social(com.furyviewer.domain.Social) Rating(com.furyviewer.service.dto.OpenMovieDatabase.Rating)

Example 4 with Social

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

the class SocialResource method createSocial.

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

Example 5 with Social

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

the class SocialResourceIntTest method equalsVerifier.

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

Aggregations

Social (com.furyviewer.domain.Social)10 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 Rating (com.furyviewer.service.dto.OpenMovieDatabase.Rating)2 Result (com.furyviewer.service.dto.TheMovieDB.Trailer.Result)2 TrailerTmdbDTO (com.furyviewer.service.dto.TheMovieDB.Trailer.TrailerTmdbDTO)2 IOException (java.io.IOException)2 BadRequestAlertException (com.furyviewer.web.rest.errors.BadRequestAlertException)1 URI (java.net.URI)1