Search in sources :

Example 1 with FavouriteArtist

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

the class FavouriteArtistResourceIntTest method equalsVerifier.

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

Example 2 with FavouriteArtist

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

the class FavouriteArtistResource method updateFavouriteArtist.

/**
 * PUT  /favourite-artists : Updates an existing favouriteArtist.
 *
 * @param favouriteArtist the favouriteArtist to update
 * @return the ResponseEntity with status 200 (OK) and with body the updated favouriteArtist,
 * or with status 400 (Bad Request) if the favouriteArtist is not valid,
 * or with status 500 (Internal Server Error) if the favouriteArtist couldn't be updated
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PutMapping("/favourite-artists")
@Timed
public ResponseEntity<FavouriteArtist> updateFavouriteArtist(@RequestBody FavouriteArtist favouriteArtist) throws URISyntaxException {
    log.debug("REST request to update FavouriteArtist : {}", favouriteArtist);
    if (favouriteArtist.getId() == null) {
        return createFavouriteArtist(favouriteArtist);
    }
    FavouriteArtist result = favouriteArtistRepository.save(favouriteArtist);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, favouriteArtist.getId().toString())).body(result);
}
Also used : FavouriteArtist(com.furyviewer.domain.FavouriteArtist) Timed(com.codahale.metrics.annotation.Timed)

Example 3 with FavouriteArtist

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

the class FavouriteArtistResourceIntTest method createFavouriteArtist.

@Test
@Transactional
public void createFavouriteArtist() throws Exception {
    int databaseSizeBeforeCreate = favouriteArtistRepository.findAll().size();
    // Create the FavouriteArtist
    restFavouriteArtistMockMvc.perform(post("/api/favourite-artists").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(favouriteArtist))).andExpect(status().isCreated());
    // Validate the FavouriteArtist in the database
    List<FavouriteArtist> favouriteArtistList = favouriteArtistRepository.findAll();
    assertThat(favouriteArtistList).hasSize(databaseSizeBeforeCreate + 1);
    FavouriteArtist testFavouriteArtist = favouriteArtistList.get(favouriteArtistList.size() - 1);
    assertThat(testFavouriteArtist.isLiked()).isEqualTo(DEFAULT_LIKED);
    assertThat(testFavouriteArtist.getDate()).isEqualTo(DEFAULT_DATE);
}
Also used : FavouriteArtist(com.furyviewer.domain.FavouriteArtist) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with FavouriteArtist

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

the class FavouriteArtistResourceIntTest method updateFavouriteArtist.

@Test
@Transactional
public void updateFavouriteArtist() throws Exception {
    // Initialize the database
    favouriteArtistRepository.saveAndFlush(favouriteArtist);
    int databaseSizeBeforeUpdate = favouriteArtistRepository.findAll().size();
    // Update the favouriteArtist
    FavouriteArtist updatedFavouriteArtist = favouriteArtistRepository.findOne(favouriteArtist.getId());
    updatedFavouriteArtist.liked(UPDATED_LIKED).date(UPDATED_DATE);
    restFavouriteArtistMockMvc.perform(put("/api/favourite-artists").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedFavouriteArtist))).andExpect(status().isOk());
    // Validate the FavouriteArtist in the database
    List<FavouriteArtist> favouriteArtistList = favouriteArtistRepository.findAll();
    assertThat(favouriteArtistList).hasSize(databaseSizeBeforeUpdate);
    FavouriteArtist testFavouriteArtist = favouriteArtistList.get(favouriteArtistList.size() - 1);
    assertThat(testFavouriteArtist.isLiked()).isEqualTo(UPDATED_LIKED);
    assertThat(testFavouriteArtist.getDate()).isEqualTo(UPDATED_DATE);
}
Also used : FavouriteArtist(com.furyviewer.domain.FavouriteArtist) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with FavouriteArtist

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

the class FavouriteArtistResource method createFavouriteArtist.

/**
 * POST  /favourite-artists : Create a new favouriteArtist.
 *
 * @param favouriteArtist the favouriteArtist to create
 * @return the ResponseEntity with status 201 (Created) and with body the new favouriteArtist, or with status 400 (Bad Request) if the favouriteArtist has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/favourite-artists")
@Timed
public ResponseEntity<FavouriteArtist> createFavouriteArtist(@RequestBody FavouriteArtist favouriteArtist) throws URISyntaxException {
    log.debug("REST request to save FavouriteArtist : {}", favouriteArtist);
    if (favouriteArtist.getId() != null) {
        throw new BadRequestAlertException("A new favouriteArtist cannot already have an ID", ENTITY_NAME, "idexists");
    }
    Optional<FavouriteArtist> existingFavoriteArtist = favouriteArtistRepository.findByArtistAndUserLogin(favouriteArtist.getArtist(), SecurityUtils.getCurrentUserLogin());
    if (existingFavoriteArtist.isPresent()) {
        throw new BadRequestAlertException("ARTISTA JA AÑADIODP EM FAVPROTOS", ENTITY_NAME, "favoriteExists");
    }
    favouriteArtist.setDate(ZonedDateTime.now());
    favouriteArtist.setUser(userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get());
    FavouriteArtist result = favouriteArtistRepository.save(favouriteArtist);
    return ResponseEntity.created(new URI("/api/favourite-artists/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : BadRequestAlertException(com.furyviewer.web.rest.errors.BadRequestAlertException) FavouriteArtist(com.furyviewer.domain.FavouriteArtist) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

FavouriteArtist (com.furyviewer.domain.FavouriteArtist)7 Timed (com.codahale.metrics.annotation.Timed)4 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Transactional (org.springframework.transaction.annotation.Transactional)3 Artist (com.furyviewer.domain.Artist)1 BadRequestAlertException (com.furyviewer.web.rest.errors.BadRequestAlertException)1 URI (java.net.URI)1