Search in sources :

Example 6 with TopicReplyDO

use of org.neusoft.neubbs.entity.TopicReplyDO in project neubbs by nuitcoder.

the class TopicReplyDAOTest method testGetTopicReplyById.

/**
 * 测试获取话题回复
 */
@Test
@Transactional
public void testGetTopicReplyById() {
    TopicReplyDO reply = this.saveTestReplyToDatabase();
    int replyId = reply.getId();
    System.out.println("get reply information:" + topicReplyDAO.getTopicReplyById(replyId));
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 7 with TopicReplyDO

use of org.neusoft.neubbs.entity.TopicReplyDO in project neubbs by nuitcoder.

the class TopicReplyDAOTest method testRemoveListTopicReplyByTopicId.

/**
 * 测试删除指定 topicId 所有回复
 */
@Test
@Transactional
public void testRemoveListTopicReplyByTopicId() {
    TopicReplyDO reply = this.saveTestReplyToDatabase();
    Assert.assertEquals(1, topicReplyDAO.removeTopicAllReplyByTopicId(reply.getTopicid()));
    Assert.assertNull(topicReplyDAO.getTopicReplyById(reply.getId()));
    System.out.println("delete topicid=" + reply.getTopicid() + " topic all reply");
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 8 with TopicReplyDO

use of org.neusoft.neubbs.entity.TopicReplyDO in project neubbs by nuitcoder.

the class TopicReplyDAOTest method testUpdateAgreeAddOneById.

/**
 * 测试更新回复点赞数(自动 +1)
 */
@Test
@Transactional
public void testUpdateAgreeAddOneById() {
    TopicReplyDO reply = this.saveTestReplyToDatabase();
    int replyId = reply.getId();
    int beforeAgree = reply.getAgree();
    Assert.assertEquals(1, topicReplyDAO.updateAgreeAddOneById(replyId));
    int afterAgree = topicReplyDAO.getTopicReplyById(replyId).getAgree();
    Assert.assertEquals(beforeAgree + 1, afterAgree);
    System.out.println("update replyid=" + replyId + " reply agree+1 success!");
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 9 with TopicReplyDO

use of org.neusoft.neubbs.entity.TopicReplyDO in project neubbs by nuitcoder.

the class TopicReplyDAOTest method testUpdateAgreeCutOneById.

/**
 * 测试回复点赞数(自动 -1)
 */
@Test
@Transactional
public void testUpdateAgreeCutOneById() {
    TopicReplyDO reply = this.saveTestReplyToDatabase();
    int replyId = reply.getId();
    int beforeAgree = reply.getAgree();
    Assert.assertEquals(1, topicReplyDAO.updateAgreeCutOneById(replyId));
    int afterAgree = topicReplyDAO.getTopicReplyById(replyId).getAgree();
    Assert.assertEquals(beforeAgree - 1, afterAgree);
    System.out.println("update replyid=" + replyId + " reply agree-1 success!");
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 10 with TopicReplyDO

use of org.neusoft.neubbs.entity.TopicReplyDO in project neubbs by nuitcoder.

the class TopicControllerTest method testRemoveTopicReply.

/**
 * 测试 /api/topic/reply-remove
 *      - 删除回复成功
 *      - 需要权限:@LoginAuthorization @AccountActivation
 */
@Test
@Transactional
public void testRemoveTopicReply() throws Exception {
    int replyId = 1;
    String requestBody = "{" + util.getJsonField("replyid", replyId) + "}";
    System.out.println("input request-body: " + requestBody);
    // save reply before to remove
    TopicReplyDO reply = topicReplyDAO.getTopicReplyById(replyId);
    Assert.assertNotNull(reply);
    int replyTopicId = reply.getTopicid();
    TopicDO beforeTopic = topicDAO.getTopicById(replyTopicId);
    mockMvc.perform(MockMvcRequestBuilders.post("/api/topic/reply-remove").cookie(util.getAlreadyLoginUserCookie()).contentType(MediaType.APPLICATION_JSON).content(requestBody).accept(MediaType.APPLICATION_JSON)).andExpect(MockMvcResultMatchers.jsonPath("$.success").value(true)).andExpect(MockMvcResultMatchers.jsonPath("$.message").value("")).andExpect(MockMvcResultMatchers.jsonPath("$.model").value(CoreMatchers.notNullValue()));
    // confirm database already remove reply and related topic 'replies' - 1
    Assert.assertNull(topicReplyDAO.getTopicReplyById(replyId));
    TopicDO afterTopic = topicDAO.getTopicById(replyTopicId);
    Assert.assertEquals(beforeTopic.getReplies() - 1, (int) afterTopic.getReplies());
    util.printSuccessMessage();
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) TopicDO(org.neusoft.neubbs.entity.TopicDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Aggregations

TopicReplyDO (org.neusoft.neubbs.entity.TopicReplyDO)18 Test (org.junit.Test)14 Transactional (javax.transaction.Transactional)13 TopicDO (org.neusoft.neubbs.entity.TopicDO)4 Map (java.util.Map)2 UserDO (org.neusoft.neubbs.entity.UserDO)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 TopicCategoryDO (org.neusoft.neubbs.entity.TopicCategoryDO)1 TopicContentDO (org.neusoft.neubbs.entity.TopicContentDO)1 ServiceException (org.neusoft.neubbs.exception.ServiceException)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1