use of com.icthh.xm.ms.entity.domain.Vote in project xm-ms-entity by xm-online.
the class VoteService method save.
/**
* Save a vote.
*
* @param vote the entity to save
* @return the persisted entity
*/
public Vote save(Vote vote) {
startUpdateDateGenerationStrategy.preProcessStartDate(vote, vote.getId(), voteRepository, Vote::setEntryDate, Vote::getEntryDate);
Vote result = voteRepository.save(vote);
voteSearchRepository.save(result);
return result;
}
use of com.icthh.xm.ms.entity.domain.Vote in project xm-ms-entity by xm-online.
the class VoteResource method searchVotes.
/**
* SEARCH /_search/votes?query=:query : search for the vote corresponding
* to the query.
*
* @param query the query of the vote search
* @param pageable the pagination information
* @return the result of the search
*/
@GetMapping("/_search/votes")
@Timed
public ResponseEntity<List<Vote>> searchVotes(@RequestParam String query, @ApiParam Pageable pageable) {
Page<Vote> page = voteService.search(query, pageable, null);
HttpHeaders headers = PaginationUtil.generateSearchPaginationHttpHeaders(query, page, "/api/_search/votes");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
use of com.icthh.xm.ms.entity.domain.Vote in project xm-ms-entity by xm-online.
the class VoteResourceExtendedIntTest method createVoteWithEntryDate.
@Test
@Transactional
public void createVoteWithEntryDate() throws Exception {
int databaseSizeBeforeCreate = voteRepository.findAll().size();
// 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()));
// Validate the Vote in the database
List<Vote> voteList = voteRepository.findAll();
assertThat(voteList).hasSize(databaseSizeBeforeCreate + 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);
}
use of com.icthh.xm.ms.entity.domain.Vote in project xm-ms-entity by xm-online.
the class VoteResourceExtendedIntTest method checkStartDateIsRequiredInDb.
@Test
@Transactional
public void checkStartDateIsRequiredInDb() throws Exception {
Vote o = voteService.save(vote);
// set the field null
when(startUpdateDateGenerationStrategy.generateStartDate()).thenReturn(null);
o.setEntryDate(null);
voteService.save(o);
try {
voteRepository.flush();
fail("DataIntegrityViolationException exception was expected!");
} catch (DataIntegrityViolationException e) {
assertThat(e.getMostSpecificCause().getMessage()).containsIgnoringCase("NULL not allowed for column \"ENTRY_DATE\"");
}
}
use of com.icthh.xm.ms.entity.domain.Vote in project xm-ms-entity by xm-online.
the class VoteResourceIntTest method createVote.
@Test
@Transactional
public void createVote() throws Exception {
int databaseSizeBeforeCreate = voteRepository.findAll().size();
// Create the Vote
restVoteMockMvc.perform(post("/api/votes").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(vote))).andExpect(status().isCreated());
// Validate the Vote in the database
List<Vote> voteList = voteRepository.findAll();
assertThat(voteList).hasSize(databaseSizeBeforeCreate + 1);
Vote testVote = voteList.get(voteList.size() - 1);
assertThat(testVote.getUserKey()).isEqualTo(DEFAULT_USER_KEY);
assertThat(testVote.getValue()).isEqualTo(DEFAULT_VALUE);
assertThat(testVote.getMessage()).isEqualTo(DEFAULT_MESSAGE);
assertThat(testVote.getEntryDate()).isEqualTo(UPDATED_ENTRY_DATE);
// Validate the Vote in Elasticsearch
Vote voteEs = voteSearchRepository.findOne(testVote.getId());
assertThat(voteEs).isEqualToComparingFieldByField(testVote);
}
Aggregations