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