use of com.icthh.xm.ms.entity.domain.Rating in project xm-ms-entity by xm-online.
the class VoteResourceIntTest method createEntity.
/**
* Create an entity for this test.
*
* 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 Vote createEntity(EntityManager em) {
Vote vote = new Vote().userKey(DEFAULT_USER_KEY).value(DEFAULT_VALUE).message(DEFAULT_MESSAGE).entryDate(DEFAULT_ENTRY_DATE);
// Add required entity
XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
em.persist(xmEntity);
em.flush();
vote.setXmEntity(xmEntity);
Rating rating = RatingResourceIntTest.createEntity(em);
em.persist(rating);
em.flush();
vote.setRating(rating);
return vote;
}
use of com.icthh.xm.ms.entity.domain.Rating in project xm-ms-entity by xm-online.
the class RatingResourceExtendedIntTest method checkStartDateIsRequiredInDb.
@Test
@Transactional
public void checkStartDateIsRequiredInDb() throws Exception {
Rating o = ratingService.save(rating);
// set the field null
when(startUpdateDateGenerationStrategy.generateStartDate()).thenReturn(null);
o.setStartDate(null);
ratingService.save(o);
try {
ratingRepository.flush();
fail("DataIntegrityViolationException exception was expected!");
} catch (DataIntegrityViolationException e) {
assertThat(e.getMostSpecificCause().getMessage()).containsIgnoringCase("NULL not allowed for column \"START_DATE\"");
}
}
use of com.icthh.xm.ms.entity.domain.Rating in project xm-ms-entity by xm-online.
the class RatingResourceIntTest method updateRating.
@Test
@Transactional
public void updateRating() throws Exception {
// Initialize the database
ratingService.save(rating);
int databaseSizeBeforeUpdate = ratingRepository.findAll().size();
// Update the rating
Rating updatedRating = ratingRepository.findOne(rating.getId());
updatedRating.typeKey(UPDATED_TYPE_KEY).value(UPDATED_VALUE).startDate(UPDATED_START_DATE).endDate(UPDATED_END_DATE);
restRatingMockMvc.perform(put("/api/ratings").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedRating))).andExpect(status().isOk());
// Validate the Rating in the database
List<Rating> ratingList = ratingRepository.findAll();
assertThat(ratingList).hasSize(databaseSizeBeforeUpdate);
Rating testRating = ratingList.get(ratingList.size() - 1);
assertThat(testRating.getTypeKey()).isEqualTo(UPDATED_TYPE_KEY);
assertThat(testRating.getValue()).isEqualTo(UPDATED_VALUE);
assertThat(testRating.getStartDate()).isEqualTo(UPDATED_START_DATE);
assertThat(testRating.getEndDate()).isEqualTo(UPDATED_END_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 createRating.
@Test
@Transactional
public void createRating() 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());
// Validate the Rating in the database
List<Rating> ratingList = ratingRepository.findAll();
assertThat(ratingList).hasSize(databaseSizeBeforeCreate + 1);
Rating testRating = ratingList.get(ratingList.size() - 1);
assertThat(testRating.getTypeKey()).isEqualTo(DEFAULT_TYPE_KEY);
assertThat(testRating.getValue()).isEqualTo(DEFAULT_VALUE);
assertThat(testRating.getStartDate()).isEqualTo(DEFAULT_START_DATE);
assertThat(testRating.getEndDate()).isEqualTo(DEFAULT_END_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 DeleteEntityTest method createXmEntity.
private XmEntity createXmEntity() {
XmEntity xmEntity = new XmEntity().key(randomUUID().toString()).typeKey("TEST_DELETE");
xmEntity.name("name").functionContexts(asSet(new FunctionContext().key("1").typeKey("A").xmEntity(xmEntity), new FunctionContext().key("2").typeKey("A").xmEntity(xmEntity), new FunctionContext().key("3").typeKey("A").xmEntity(xmEntity))).attachments(asSet(new Attachment().typeKey("A").name("1"), new Attachment().typeKey("A").name("2"), new Attachment().typeKey("A").name("3"))).calendars(asSet(new Calendar().typeKey("A").name("1").events(asSet(new Event().typeKey("A").title("1"), new Event().typeKey("A").title("2"))), new Calendar().typeKey("A").name("2").events(asSet(new Event().typeKey("A").title("3"), new Event().typeKey("A").title("4"))))).locations(asSet(new Location().typeKey("A").name("1"), new Location().typeKey("A").name("2"))).ratings(asSet(new Rating().typeKey("A").votes(asSet(new Vote().message("1").value(1.1).userKey("1"), new Vote().message("2").value(2.1).userKey("2"))))).tags(asSet(new Tag().typeKey("A").name("1"), new Tag().typeKey("A").name("2"))).comments(asSet(new Comment().message("1").userKey("1"), new Comment().message("2").userKey("1")));
return xmEntity;
}
Aggregations