Search in sources :

Example 1 with Artist

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

the class ArtistResourceIntTest method equalsVerifier.

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

Example 2 with Artist

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

the class ArtistResource method createArtist.

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

Example 3 with Artist

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

the class ArtistService method importDirector.

/**
 * Metodo que se encarga de convertir un String en un objeto de la clase Artist que contiene su nombre y
 * director como tipo de artista.
 *
 * @param director String | Contiene el nombre del artista.
 * @return Artist | Objeto que contiene la informacion del artista.
 */
public Artist importDirector(String director) {
    Artist artist = null;
    if (stringApiCorrectorService.eraserNA(director) != null) {
        String[] directorArray = director.split(", | \\(");
        Optional<Artist> optionalDirector = artistRepository.findByName(directorArray[0]);
        ArtistType atDirector = artistTypeRepository.findByName(ArtistTypeEnum.DIRECTOR);
        // En caso de que el artista exista se comprueba si ya tiene asignado el tipo director.
        if (optionalDirector.isPresent()) {
            artist = optionalDirector.get();
            if (!artist.getArtistTypes().contains(atDirector)) {
                artist.addArtistType(atDirector);
                artistRepository.save(artist);
            }
        } else {
            // Se crea un artista desde cero.
            artist = artistTmdbDTOService.importArtist(directorArray[0], atDirector);
        }
    }
    return artist;
}
Also used : Artist(com.furyviewer.domain.Artist) ArtistType(com.furyviewer.domain.ArtistType)

Example 4 with Artist

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

the class ArtistResourceIntTest method updateArtist.

@Test
@Transactional
public void updateArtist() throws Exception {
    // Initialize the database
    artistRepository.saveAndFlush(artist);
    int databaseSizeBeforeUpdate = artistRepository.findAll().size();
    // Update the artist
    Artist updatedArtist = artistRepository.findOne(artist.getId());
    updatedArtist.name(UPDATED_NAME).birthdate(UPDATED_BIRTHDATE).sex(UPDATED_SEX).deathdate(UPDATED_DEATHDATE);
    restArtistMockMvc.perform(put("/api/artists").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedArtist))).andExpect(status().isOk());
    // Validate the Artist in the database
    List<Artist> artistList = artistRepository.findAll();
    assertThat(artistList).hasSize(databaseSizeBeforeUpdate);
    Artist testArtist = artistList.get(artistList.size() - 1);
    assertThat(testArtist.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testArtist.getBirthdate()).isEqualTo(UPDATED_BIRTHDATE);
    assertThat(testArtist.getSex()).isEqualTo(UPDATED_SEX);
    assertThat(testArtist.getDeathdate()).isEqualTo(UPDATED_DEATHDATE);
}
Also used : Artist(com.furyviewer.domain.Artist) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Artist

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

the class ArtistResourceIntTest method createArtist.

@Test
@Transactional
public void createArtist() throws Exception {
    int databaseSizeBeforeCreate = artistRepository.findAll().size();
    // Create the Artist
    restArtistMockMvc.perform(post("/api/artists").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(artist))).andExpect(status().isCreated());
    // Validate the Artist in the database
    List<Artist> artistList = artistRepository.findAll();
    assertThat(artistList).hasSize(databaseSizeBeforeCreate + 1);
    Artist testArtist = artistList.get(artistList.size() - 1);
    assertThat(testArtist.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testArtist.getBirthdate()).isEqualTo(DEFAULT_BIRTHDATE);
    assertThat(testArtist.getSex()).isEqualTo(DEFAULT_SEX);
    assertThat(testArtist.getDeathdate()).isEqualTo(DEFAULT_DEATHDATE);
}
Also used : Artist(com.furyviewer.domain.Artist) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Artist (com.furyviewer.domain.Artist)16 Timed (com.codahale.metrics.annotation.Timed)8 Transactional (org.springframework.transaction.annotation.Transactional)6 ArtistType (com.furyviewer.domain.ArtistType)4 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 BadRequestAlertException (com.furyviewer.web.rest.errors.BadRequestAlertException)2 FavouriteArtist (com.furyviewer.domain.FavouriteArtist)1 ArtistTypeEnum (com.furyviewer.domain.enumeration.ArtistTypeEnum)1 CompleteArtistTmdbDTO (com.furyviewer.service.dto.TheMovieDB.Artist.CompleteArtistTmdbDTO)1 Cast (com.furyviewer.service.dto.TheMovieDB.Episode.Cast)1 IOException (java.io.IOException)1 URI (java.net.URI)1