Search in sources :

Example 1 with Comment

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

the class CommentResource method getAllComments.

/**
 * GET  /comments : get all the comments.
 *
 * @param pageable the pagination information
 * @return the ResponseEntity with status 200 (OK) and the list of comments in body
 */
@GetMapping("/comments")
@Timed
public ResponseEntity<List<Comment>> getAllComments(@ApiParam Pageable pageable) {
    Page<Comment> page = commentService.findAll(pageable, null);
    HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/comments");
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
Also used : Comment(com.icthh.xm.ms.entity.domain.Comment) HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) GetMapping(org.springframework.web.bind.annotation.GetMapping) Timed(com.codahale.metrics.annotation.Timed)

Example 2 with Comment

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

the class CommentResource method searchComments.

/**
 * SEARCH  /_search/comments?query=:query : search for the comment corresponding
 * to the query.
 *
 * @param query the query of the comment search
 * @param pageable the pagination information
 * @return the result of the search
 */
@GetMapping("/_search/comments")
@Timed
public ResponseEntity<List<Comment>> searchComments(@RequestParam String query, @ApiParam Pageable pageable) {
    Page<Comment> page = commentService.search(query, pageable, null);
    HttpHeaders headers = PaginationUtil.generateSearchPaginationHttpHeaders(query, page, "/api/_search/comments");
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
Also used : Comment(com.icthh.xm.ms.entity.domain.Comment) HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) GetMapping(org.springframework.web.bind.annotation.GetMapping) Timed(com.codahale.metrics.annotation.Timed)

Example 3 with Comment

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

the class CommentResourceIntTest method updateComment.

@Test
@Transactional
public void updateComment() throws Exception {
    // Initialize the database
    commentService.save(comment);
    int databaseSizeBeforeUpdate = commentRepository.findAll().size();
    // Update the comment
    Comment updatedComment = commentRepository.findOne(comment.getId());
    updatedComment.userKey(UPDATED_USER_KEY).message(UPDATED_MESSAGE).entryDate(UPDATED_ENTRY_DATE);
    restCommentMockMvc.perform(put("/api/comments").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedComment))).andExpect(status().isOk());
    // Validate the Comment in the database
    List<Comment> commentList = commentRepository.findAll();
    assertThat(commentList).hasSize(databaseSizeBeforeUpdate);
    Comment testComment = commentList.get(commentList.size() - 1);
    assertThat(testComment.getUserKey()).isEqualTo(DEFAULT_USER_KEY);
    assertThat(testComment.getMessage()).isEqualTo(UPDATED_MESSAGE);
    assertThat(testComment.getEntryDate()).isEqualTo(UPDATED_ENTRY_DATE);
    // Validate the Comment in Elasticsearch
    Comment commentEs = commentSearchRepository.findOne(testComment.getId());
    assertThat(commentEs).isEqualToComparingFieldByField(testComment);
}
Also used : Comment(com.icthh.xm.ms.entity.domain.Comment) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Comment

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

the class CommentResourceIntTest method equalsVerifier.

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

Example 5 with Comment

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

the class CommentResourceIntTest 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 Comment createEntity(EntityManager em) {
    Comment comment = new Comment().userKey(DEFAULT_USER_KEY).message(DEFAULT_MESSAGE).entryDate(DEFAULT_ENTRY_DATE);
    // Add required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    comment.setXmEntity(xmEntity);
    return comment;
}
Also used : Comment(com.icthh.xm.ms.entity.domain.Comment) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity)

Aggregations

Comment (com.icthh.xm.ms.entity.domain.Comment)9 XmEntity (com.icthh.xm.ms.entity.domain.XmEntity)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Transactional (org.springframework.transaction.annotation.Transactional)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 Location (com.icthh.xm.ms.entity.domain.Location)2 Rating (com.icthh.xm.ms.entity.domain.Rating)2 Tag (com.icthh.xm.ms.entity.domain.Tag)2 Vote (com.icthh.xm.ms.entity.domain.Vote)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