Search in sources :

Example 6 with Vote

use of com.icthh.xm.ms.entity.domain.Vote in project xm-ms-entity by xm-online.

the class VoteResourceIntTest method updateVote.

@Test
@Transactional
public void updateVote() throws Exception {
    // Initialize the database
    voteRepository.saveAndFlush(vote);
    voteSearchRepository.save(vote);
    int databaseSizeBeforeUpdate = voteRepository.findAll().size();
    // Update the vote
    Vote updatedVote = voteRepository.findOne(vote.getId());
    updatedVote.userKey(UPDATED_USER_KEY).value(UPDATED_VALUE).message(UPDATED_MESSAGE).entryDate(UPDATED_ENTRY_DATE);
    restVoteMockMvc.perform(put("/api/votes").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedVote))).andExpect(status().isOk());
    // Validate the Vote in the database
    List<Vote> voteList = voteRepository.findAll();
    assertThat(voteList).hasSize(databaseSizeBeforeUpdate);
    Vote testVote = voteList.get(voteList.size() - 1);
    assertThat(testVote.getUserKey()).isEqualTo(UPDATED_USER_KEY);
    assertThat(testVote.getValue()).isEqualTo(UPDATED_VALUE);
    assertThat(testVote.getMessage()).isEqualTo(UPDATED_MESSAGE);
    assertThat(testVote.getEntryDate()).isEqualTo(UPDATED_ENTRY_DATE);
    // Validate the Vote in Elasticsearch
    Vote voteEs = voteSearchRepository.findOne(testVote.getId());
    assertThat(voteEs).isEqualToComparingFieldByField(testVote);
}
Also used : Vote(com.icthh.xm.ms.entity.domain.Vote) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with Vote

use of com.icthh.xm.ms.entity.domain.Vote in project xm-ms-entity by xm-online.

the class VoteResourceExtendedIntTest method checkEntryDateIsNotRequired.

@Test
@Transactional
public void checkEntryDateIsNotRequired() throws Exception {
    int databaseSizeBeforeTest = voteRepository.findAll().size();
    // set the field null
    vote.setEntryDate(null);
    // Create the Vote.
    restVoteMockMvc.perform(post("/api/votes").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(vote))).andExpect(status().isCreated()).andExpect(jsonPath("$.entryDate").value(MOCKED_ENTRY_DATE.toString()));
    List<Vote> voteList = voteRepository.findAll();
    assertThat(voteList).hasSize(databaseSizeBeforeTest + 1);
    Vote testVote = voteList.get(voteList.size() - 1);
    assertThat(testVote.getEntryDate()).isEqualTo(MOCKED_ENTRY_DATE);
    // Validate the Vote in Elasticsearch
    Vote voteEs = voteSearchRepository.findOne(testVote.getId());
    assertThat(voteEs).isEqualToComparingFieldByField(testVote);
}
Also used : Vote(com.icthh.xm.ms.entity.domain.Vote) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with Vote

use of com.icthh.xm.ms.entity.domain.Vote 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 9 with Vote

use of com.icthh.xm.ms.entity.domain.Vote in project xm-ms-entity by xm-online.

the class VoteResourceIntTest method equalsVerifier.

@Test
@Transactional
public void equalsVerifier() throws Exception {
    TestUtil.equalsVerifier(Vote.class);
    Vote vote1 = new Vote();
    vote1.setId(1L);
    Vote vote2 = new Vote();
    vote2.setId(vote1.getId());
    assertThat(vote1).isEqualTo(vote2);
    vote2.setId(2L);
    assertThat(vote1).isNotEqualTo(vote2);
    vote1.setId(null);
    assertThat(vote1).isNotEqualTo(vote2);
}
Also used : Vote(com.icthh.xm.ms.entity.domain.Vote) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with Vote

use of com.icthh.xm.ms.entity.domain.Vote 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

Vote (com.icthh.xm.ms.entity.domain.Vote)12 Test (org.junit.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 Transactional (org.springframework.transaction.annotation.Transactional)6 Rating (com.icthh.xm.ms.entity.domain.Rating)3 XmEntity (com.icthh.xm.ms.entity.domain.XmEntity)3 Timed (com.codahale.metrics.annotation.Timed)2 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 HttpHeaders (org.springframework.http.HttpHeaders)2 ResponseEntity (org.springframework.http.ResponseEntity)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)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