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));
}
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");
}
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!");
}
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!");
}
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();
}
Aggregations