Search in sources :

Example 6 with TopicCategoryDO

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));
}
Also used : TopicCategoryDO(org.neusoft.neubbs.entity.TopicCategoryDO) Test(org.junit.Test)

Example 7 with TopicCategoryDO

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();
}
Also used : TopicContentDO(org.neusoft.neubbs.entity.TopicContentDO) TopicDO(org.neusoft.neubbs.entity.TopicDO) TopicCategoryDO(org.neusoft.neubbs.entity.TopicCategoryDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 8 with TopicCategoryDO

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));
}
Also used : TopicCategoryDO(org.neusoft.neubbs.entity.TopicCategoryDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 9 with TopicCategoryDO

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");
}
Also used : TopicCategoryDO(org.neusoft.neubbs.entity.TopicCategoryDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 10 with TopicCategoryDO

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));
}
Also used : TopicCategoryDO(org.neusoft.neubbs.entity.TopicCategoryDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Aggregations

TopicCategoryDO (org.neusoft.neubbs.entity.TopicCategoryDO)15 Test (org.junit.Test)9 Transactional (javax.transaction.Transactional)8 TopicContentDO (org.neusoft.neubbs.entity.TopicContentDO)3 TopicDO (org.neusoft.neubbs.entity.TopicDO)3 ServiceException (org.neusoft.neubbs.exception.ServiceException)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 TopicActionDO (org.neusoft.neubbs.entity.TopicActionDO)1 TopicReplyDO (org.neusoft.neubbs.entity.TopicReplyDO)1 UserDO (org.neusoft.neubbs.entity.UserDO)1