use of com.icthh.xm.ms.entity.domain.Rating in project xm-ms-entity by xm-online.
the class RatingService method save.
/**
* Save a rating.
*
* @param rating the entity to save
* @return the persisted entity
*/
public Rating save(Rating rating) {
startUpdateDateGenerationStrategy.preProcessStartDate(rating, rating.getId(), ratingRepository, Rating::setStartDate, Rating::getStartDate);
Rating result = ratingRepository.save(rating);
ratingSearchRepository.save(result);
return result;
}
use of com.icthh.xm.ms.entity.domain.Rating in project xm-ms-entity by xm-online.
the class RatingResourceExtendedIntTest method createRatingWithEntryDate.
@Test
@Transactional
public void createRatingWithEntryDate() throws Exception {
int databaseSizeBeforeCreate = ratingRepository.findAll().size();
// Create the Rating
restRatingMockMvc.perform(post("/api/ratings").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(rating))).andExpect(status().isCreated()).andExpect(jsonPath("$.startDate").value(MOCKED_START_DATE.toString()));
// Validate the Rating in the database
List<Rating> voteList = ratingRepository.findAll();
assertThat(voteList).hasSize(databaseSizeBeforeCreate + 1);
Rating testRating = voteList.get(voteList.size() - 1);
assertThat(testRating.getStartDate()).isEqualTo(MOCKED_START_DATE);
// Validate the Rating in Elasticsearch
Rating ratingEs = ratingSearchRepository.findOne(testRating.getId());
assertThat(ratingEs).isEqualToComparingFieldByField(testRating);
}
use of com.icthh.xm.ms.entity.domain.Rating in project xm-ms-entity by xm-online.
the class RatingResourceExtendedIntTest method checkStartDateIsNotRequired.
@Test
@Transactional
public void checkStartDateIsNotRequired() throws Exception {
int databaseSizeBeforeTest = ratingRepository.findAll().size();
// set the field null
rating.setStartDate(null);
// Create the Rating.
restRatingMockMvc.perform(post("/api/ratings").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(rating))).andExpect(status().isCreated()).andExpect(jsonPath("$.startDate").value(MOCKED_START_DATE.toString()));
List<Rating> ratingList = ratingRepository.findAll();
assertThat(ratingList).hasSize(databaseSizeBeforeTest + 1);
Rating testRating = ratingList.get(ratingList.size() - 1);
assertThat(testRating.getStartDate()).isEqualTo(MOCKED_START_DATE);
// Validate the Rating in Elasticsearch
Rating ratingEs = ratingSearchRepository.findOne(testRating.getId());
assertThat(ratingEs).isEqualToComparingFieldByField(testRating);
}
use of com.icthh.xm.ms.entity.domain.Rating in project xm-ms-entity by xm-online.
the class RatingResourceIntTest method createEntity.
/**
* Create an entity for this test.
* <p>
* This is a static method, as tests for other entities might also need it,
* if they test an entity which requires the current entity.
*/
public static Rating createEntity(EntityManager em) {
Rating rating = new Rating().typeKey(DEFAULT_TYPE_KEY).value(DEFAULT_VALUE).startDate(DEFAULT_START_DATE).endDate(DEFAULT_END_DATE);
// Add required entity
XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
em.persist(xmEntity);
em.flush();
rating.setXmEntity(xmEntity);
return rating;
}
use of com.icthh.xm.ms.entity.domain.Rating in project xm-ms-entity by xm-online.
the class RatingResourceIntTest method equalsVerifier.
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Rating.class);
Rating rating1 = new Rating();
rating1.setId(1L);
Rating rating2 = new Rating();
rating2.setId(rating1.getId());
assertThat(rating1).isEqualTo(rating2);
rating2.setId(2L);
assertThat(rating1).isNotEqualTo(rating2);
rating1.setId(null);
assertThat(rating1).isNotEqualTo(rating2);
}
Aggregations