Search in sources :

Example 11 with TopicReplyDO

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

the class TopicReplyDAOTest method testUpdateOpposeAddOneById.

/**
 * 测试回复反对数(自动 +1)
 */
@Test
@Transactional
public void testUpdateOpposeAddOneById() {
    TopicReplyDO reply = this.saveTestReplyToDatabase();
    int replyId = reply.getId();
    int beforeOppose = reply.getOppose();
    Assert.assertEquals(1, topicReplyDAO.updateOpposeAddOneById(replyId));
    int afterOppose = topicReplyDAO.getTopicReplyById(replyId).getOppose();
    Assert.assertEquals(beforeOppose + 1, afterOppose);
    System.out.println("update replyid=" + replyId + " reply oppose+1 success!");
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 12 with TopicReplyDO

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

the class TopicReplyDAOTest method testGetMaxTopicReplyId.

/**
 * 测试获取最大的话题回复 id
 */
@Test
@Transactional
public void testGetMaxTopicReplyId() {
    TopicReplyDO reply = this.saveTestReplyToDatabase();
    Assert.assertEquals(reply.getId(), (Integer) topicReplyDAO.getMaxTopicReplyId());
    System.out.println("success get max reply id");
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 13 with TopicReplyDO

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

the class TopicReplyDAOTest method testListTopicReplyByTopicId.

/**
 * 测试获取指定 topicid 的所有回复
 */
@Test
@Transactional
public void testListTopicReplyByTopicId() {
    TopicReplyDO reply = this.saveTestReplyToDatabase();
    int topicId = reply.getTopicid();
    List<TopicReplyDO> listTopicReply = topicReplyDAO.listTopicReplyByTopicId(topicId);
    Assert.assertTrue(listTopicReply.size() >= 1);
    int replyCount = 1;
    for (TopicReplyDO topicReply : listTopicReply) {
        System.out.println("ouput reply information (" + (replyCount++) + "): " + JsonUtil.toJsonString(topicReply));
    }
    System.out.println("success get topicid=" + topicId + " all reply list");
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 14 with TopicReplyDO

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

the class TopicReplyDAOTest method testUpdateContentByIdByContent.

/**
 * 测试更新回复内容
 */
@Test
@Transactional
public void testUpdateContentByIdByContent() {
    TopicReplyDO reply = this.saveTestReplyToDatabase();
    int replyId = reply.getId();
    String beforeContent = reply.getContent();
    String newContent = "new reply content";
    Assert.assertEquals(1, topicReplyDAO.updateContentByIdByContent(replyId, newContent));
    String afterContent = topicReplyDAO.getTopicReplyById(replyId).getContent();
    Assert.assertNotEquals(beforeContent, afterContent);
    System.out.println("update replyid=" + replyId + " reply content=<" + newContent + "> success!");
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 15 with TopicReplyDO

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

the class TopicReplyDAOTest method testUpdateOpposeCutOneById.

/**
 * 测试回复反对数(自动 -1)
 */
@Test
@Transactional
public void testUpdateOpposeCutOneById() {
    TopicReplyDO reply = this.saveTestReplyToDatabase();
    int replyId = reply.getId();
    int beforeOppose = reply.getOppose();
    Assert.assertEquals(1, topicReplyDAO.updateOpposeCutOneById(replyId));
    int afterOppose = topicReplyDAO.getTopicReplyById(replyId).getOppose();
    Assert.assertEquals(beforeOppose - 1, afterOppose);
    System.out.println("update replyid=" + replyId + " reply oppose-1 success!");
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) 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