Search in sources :

Example 16 with TopicDO

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

the class TopicDAOTest method testUpdateTitleById.

/**
 * 测试更新话题名
 */
@Test
@Transactional
public void testUpdateTitleById() {
    TopicDO topic = this.saveTestTopicToDB();
    String newTitle = "test update new Title";
    Assert.assertEquals(1, topicDAO.updateTitleById(topic.getId(), newTitle));
    Assert.assertNotEquals(topic.getTitle(), topicDAO.getTopicById(topic.getId()).getTitle());
    System.out.println("update topicId=" + topic.getId() + " topic title=<" + newTitle + "> success!");
}
Also used : TopicDO(org.neusoft.neubbs.entity.TopicDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 17 with TopicDO

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

the class TopicDAOTest method testUpdateLastReplyTimeById.

/**
 * 测试更新最后回复时间
 *      - 插入数据时,默认最后回复时间 == 发布时间
 */
@Test
@Transactional
public void testUpdateLastReplyTimeById() throws InterruptedException {
    TopicDO topic = this.saveTestTopicToDB();
    Assert.assertEquals(1, topicDAO.updateLastReplyTimeById(topic.getId(), new Date()));
    Thread.sleep(10);
    TopicDO newTopic = topicDAO.getTopicById(topic.getId());
    Assert.assertNotEquals(topic.getLastreplytime(), newTopic.getLastreplytime());
    System.out.println("update topicId=" + topic.getId() + " topic lastreplytime=<" + newTopic.getLastreplytime() + "> success!");
}
Also used : TopicDO(org.neusoft.neubbs.entity.TopicDO) Date(java.util.Date) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 18 with TopicDO

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

the class TopicDAOTest method testUpdateRepliesAddOneById.

/**
 * 测试更新评论回复数(自动 +1)
 */
@Test
@Transactional
public void testUpdateRepliesAddOneById() {
    TopicDO topic = this.saveTestTopicToDB();
    Assert.assertEquals(1, topicDAO.updateRepliesAddOneById(topic.getId()));
    // default 0 + 1 = 1
    Integer expectReplies = 1;
    Assert.assertEquals(expectReplies, topicDAO.getTopicById(topic.getId()).getReplies());
    System.out.println("update topicId=" + topic.getId() + " topic replies+1 success!");
}
Also used : TopicDO(org.neusoft.neubbs.entity.TopicDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 19 with TopicDO

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

the class TopicActionDAOTest method saveTestTopicActionDOToDatabase.

/**
 * 保存测试 TopicActionDO 对象至数据库
 *      - 新建测试话题
 *      - 保存,且重新查询数据库获得对象(根据话题 id,进行查询)
 *
 * @return TopicActionDO 话题行为对象
 */
private TopicActionDO saveTestTopicActionDOToDatabase() {
    TopicDO topic = new TopicDO();
    topic.setUserid(1);
    topic.setCategoryid(1);
    topic.setTitle("test title");
    Assert.assertEquals(1, topicDAO.saveTopic(topic));
    TopicActionDO topicAction = new TopicActionDO();
    topicAction.setTopicId(topic.getId());
    Assert.assertEquals(1, topicActionDAO.saveTopicAction(topicAction));
    return topicActionDAO.getTopicAction(topic.getId());
}
Also used : TopicDO(org.neusoft.neubbs.entity.TopicDO) TopicActionDO(org.neusoft.neubbs.entity.TopicActionDO)

Example 20 with TopicDO

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

the class TopicDAOTest method testListTopicByStartRowByCountByCategory.

/**
 * 测试(降序,分类)获取话题列表
 */
@Test
@Transactional
public void testListTopicByStartRowByCountByCategory() {
    this.saveTestTopicToDB();
    // first page
    int startRow = 0, count = 10;
    int categoryId = 1;
    List<TopicDO> listTopic = topicDAO.listTopicDESCByStartRowByCountByCategoryId(startRow, count, categoryId);
    Assert.assertTrue(listTopic.size() >= 1);
    // foreach list
    int recordCount = 1;
    for (TopicDO topic : listTopic) {
        System.out.println("output categoryid=" + categoryId + " topic information (No." + (recordCount++) + " recoders): " + topic);
    }
}
Also used : TopicDO(org.neusoft.neubbs.entity.TopicDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Aggregations

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