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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations