Search in sources :

Example 6 with Rating

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;
}
Also used : Vote(com.icthh.xm.ms.entity.domain.Vote) Rating(com.icthh.xm.ms.entity.domain.Rating) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity)

Example 7 with Rating

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\"");
    }
}
Also used : Rating(com.icthh.xm.ms.entity.domain.Rating) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with Rating

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);
}
Also used : Rating(com.icthh.xm.ms.entity.domain.Rating) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with Rating

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);
}
Also used : Rating(com.icthh.xm.ms.entity.domain.Rating) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with Rating

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;
}
Also used : Comment(com.icthh.xm.ms.entity.domain.Comment) Vote(com.icthh.xm.ms.entity.domain.Vote) Calendar(com.icthh.xm.ms.entity.domain.Calendar) Rating(com.icthh.xm.ms.entity.domain.Rating) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Event(com.icthh.xm.ms.entity.domain.Event) Attachment(com.icthh.xm.ms.entity.domain.Attachment) Tag(com.icthh.xm.ms.entity.domain.Tag) FunctionContext(com.icthh.xm.ms.entity.domain.FunctionContext) Location(com.icthh.xm.ms.entity.domain.Location)

Aggregations

Rating (com.icthh.xm.ms.entity.domain.Rating)11 Test (org.junit.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 Transactional (org.springframework.transaction.annotation.Transactional)6 XmEntity (com.icthh.xm.ms.entity.domain.XmEntity)4 Vote (com.icthh.xm.ms.entity.domain.Vote)3 Attachment (com.icthh.xm.ms.entity.domain.Attachment)2 Calendar (com.icthh.xm.ms.entity.domain.Calendar)2 Comment (com.icthh.xm.ms.entity.domain.Comment)2 Location (com.icthh.xm.ms.entity.domain.Location)2 Tag (com.icthh.xm.ms.entity.domain.Tag)2 LogicExtensionPoint (com.icthh.xm.commons.lep.LogicExtensionPoint)1 Event (com.icthh.xm.ms.entity.domain.Event)1 FunctionContext (com.icthh.xm.ms.entity.domain.FunctionContext)1 Link (com.icthh.xm.ms.entity.domain.Link)1 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)1