use of org.neusoft.neubbs.entity.TopicCategoryDO in project neubbs by nuitcoder.
the class MapFilterUtilTest method testFilterTopicCategory.
/**
* 测试 filterTopicCategory()
*/
@Test
public void testFilterTopicCategory() {
TopicCategoryDO topicCategory = new TopicCategoryDO();
topicCategory.setId(1);
topicCategory.setNick("music");
Map<String, Object> topicCategoryInfoMap = JsonUtil.toMapByObject(topicCategory);
System.out.println("filter before: " + topicCategoryInfoMap);
MapFilterUtil.filterTopicCategory(topicCategoryInfoMap);
System.out.println("filter after: " + topicCategoryInfoMap);
Assert.assertNotNull(topicCategoryInfoMap);
Assert.assertNull(topicCategoryInfoMap.get(ParamConst.NICK));
Assert.assertNotNull(topicCategoryInfoMap.get(ParamConst.ID));
}
use of org.neusoft.neubbs.entity.TopicCategoryDO in project neubbs by nuitcoder.
the class TopicControllerTest method testUpdateTopicSuccess.
/**
* 测试 /api/topic-update
* - 编辑话题成功
* - 需要权限:@LoginAuthorization @AccountActivation
*/
@Test
@Transactional
public void testUpdateTopicSuccess() throws Exception {
int topicId = 1;
String newCategoryNick = "school";
String newTitle = "new title";
String newContent = "update new content";
String requestBody = "{" + util.getJsonField("topicid", topicId) + "," + util.getJsonField("category", newCategoryNick) + "," + util.getJsonField("title", newTitle) + "," + util.getJsonField("content", newContent) + "}";
System.out.println("input request-body: " + requestBody);
mockMvc.perform(MockMvcRequestBuilders.post("/api/topic-update").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").exists());
// compare database data, topic content, topic title and topic content
TopicDO afterTopic = topicDAO.getTopicById(topicId);
TopicContentDO afterTopicContent = topicContentDAO.getTopicContentByTopicId(topicId);
TopicCategoryDO afterTopicCategory = topicCategoryDAO.getTopicCategoryById(afterTopic.getCategoryid());
String afterCategory = afterTopicCategory.getNick();
String afterTitle = afterTopic.getTitle();
String afterContent = afterTopicContent.getContent();
Assert.assertEquals(newCategoryNick, afterCategory);
Assert.assertEquals(newTitle, afterTitle);
Assert.assertEquals(newContent, afterContent);
util.printSuccessMessage();
}
use of org.neusoft.neubbs.entity.TopicCategoryDO in project neubbs by nuitcoder.
the class TopicCategoryDAOTest method testGetTopicCategoryByName.
/**
* 测试(name)获取话题分类
*/
@Test
@Transactional
public void testGetTopicCategoryByName() {
TopicCategoryDO category = this.savaTestTopicCategoryDOToDatabase();
String categoryName = category.getName();
Assert.assertNotNull(topicCategoryDAO.getTopicCategoryByName(categoryName));
System.out.println("get topic category information: " + topicCategoryDAO.getTopicCategoryByName(categoryName));
}
use of org.neusoft.neubbs.entity.TopicCategoryDO in project neubbs by nuitcoder.
the class TopicCategoryDAOTest method testRemoveTopicCategoryById.
/**
* 测试删除话题分类
*/
@Test
@Transactional
public void testRemoveTopicCategoryById() {
TopicCategoryDO category = this.savaTestTopicCategoryDOToDatabase();
int categoryId = category.getId();
Assert.assertEquals(1, topicCategoryDAO.removeTopicCategoryById(categoryId));
Assert.assertNull(topicCategoryDAO.getTopicCategoryById(categoryId));
System.out.println("delete categoryid=" + categoryId + " topic category");
}
use of org.neusoft.neubbs.entity.TopicCategoryDO in project neubbs by nuitcoder.
the class TopicCategoryDAOTest method testGetTopicCategoryById.
/**
* 测试(id)获取话题分类
*/
@Test
@Transactional
public void testGetTopicCategoryById() {
TopicCategoryDO category = this.savaTestTopicCategoryDOToDatabase();
int categoryId = category.getId();
Assert.assertNotNull(topicCategoryDAO.getTopicCategoryById(categoryId));
System.out.println("get topic category information: " + topicCategoryDAO.getTopicCategoryById(categoryId));
}
Aggregations