Search in sources :

Example 1 with TopicReplyDO

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

the class TopicServiceImpl method getTopicReplyModelMap.

@Override
public Map<String, Object> getTopicReplyModelMap(int replyId) {
    TopicReplyDO reply = this.getTopicReplyNotNull(replyId);
    UserDO replyUser = this.getUserNotNullById(reply.getUserid());
    Map<String, Object> replyInfoMap = this.getTopicReplyInfoMap(reply);
    replyInfoMap.put(ParamConst.USER, this.getTopicUserInfoMap(replyUser));
    return replyInfoMap;
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) UserDO(org.neusoft.neubbs.entity.UserDO)

Example 2 with TopicReplyDO

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

the class TopicControllerTest method testReleaseTopicReplySuccess.

/**
 * 测试 /api/topic/reply (POST)
 *      - 发布话题回复成功
 *      - 需要权限: @LoginAuthorization @AccountActivation
 */
@Test
@Transactional
public void testReleaseTopicReplySuccess() throws Exception {
    int topicId = 1;
    String content = "new reply content";
    String requestBody = "{" + util.getJsonField("topicid", topicId) + "," + util.getJsonField("content", content) + "}";
    System.out.println("input request-body: " + requestBody);
    // before publish reply
    TopicDO beforeTopic = topicDAO.getTopicById(topicId);
    Assert.assertNotNull(beforeTopic);
    MvcResult result = mockMvc.perform(MockMvcRequestBuilders.post("/api/topic/reply").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()).andReturn();
    Map resultMap = (Map) JSON.parse(result.getResponse().getContentAsString());
    // judge $.model.replyid
    Map modelMap = (Map) resultMap.get("model");
    // validate reply information
    TopicReplyDO reply = topicReplyDAO.getTopicReplyById((Integer) modelMap.get("replyid"));
    Assert.assertEquals(topicId, (int) reply.getTopicid());
    Assert.assertEquals(content, reply.getContent());
    // validate topic information
    TopicDO afterTopic = topicDAO.getTopicById(reply.getTopicid());
    Assert.assertNotNull(afterTopic);
    Assert.assertEquals(beforeTopic.getReplies() + 1, (int) afterTopic.getReplies());
    Assert.assertNotEquals(beforeTopic.getLastreplytime(), afterTopic.getLastreplytime());
    Assert.assertEquals(reply.getCreatetime(), afterTopic.getLastreplytime());
    util.printSuccessMessage();
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) TopicDO(org.neusoft.neubbs.entity.TopicDO) MvcResult(org.springframework.test.web.servlet.MvcResult) Map(java.util.Map) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 3 with TopicReplyDO

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

the class MapFilterUtilTest method testFilterTopicReply.

/**
 * 测试 filterTopicReply()
 */
@Test
public void testFilterTopicReply() {
    TopicReplyDO topicReply = new TopicReplyDO();
    topicReply.setId(1);
    topicReply.setUserid(1);
    Map<String, Object> topicReplyInfoMap = JsonUtil.toMapByObject(topicReply);
    System.out.println("filter before: " + topicReplyInfoMap);
    MapFilterUtil.filterTopicReply(topicReplyInfoMap);
    System.out.println("filter after: " + topicReplyInfoMap);
    Assert.assertNotNull(topicReplyInfoMap);
    Assert.assertNull(topicReplyInfoMap.get(ParamConst.ID));
    Assert.assertNull(topicReplyInfoMap.get(ParamConst.USER_ID));
    Assert.assertNotNull(topicReplyInfoMap.get(ParamConst.REPLY_ID));
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) Test(org.junit.Test)

Example 4 with TopicReplyDO

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

the class TopicReplyDAOTest method saveTestReplyToDatabase.

/**
 * 保存回复至数据库
 *      - need exist
 *          - fu_id from forum_user
 *          - ft_id from forum_topic
 *
 * @return TopicReplyDO 数据库保存后,重新查询回复
 */
private TopicReplyDO saveTestReplyToDatabase() {
    // build TopicDO, sava database
    TopicDO topic = new TopicDO();
    topic.setUserid(1);
    topic.setCategoryid(1);
    topic.setTitle("topic title");
    Assert.assertEquals(1, topicDAO.saveTopic(topic));
    // build TopicReplyDO, save database
    TopicReplyDO reply = new TopicReplyDO();
    reply.setUserid(1);
    reply.setTopicid(topic.getId());
    reply.setContent("reply content");
    Assert.assertEquals(1, topicReplyDAO.saveTopicReply(reply));
    return topicReplyDAO.getTopicReplyById(reply.getId());
}
Also used : TopicReplyDO(org.neusoft.neubbs.entity.TopicReplyDO) TopicDO(org.neusoft.neubbs.entity.TopicDO)

Example 5 with TopicReplyDO

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

the class TopicReplyDAOTest method testSaveTopicReply.

/**
 * 测试保存回复
 */
@Test
@Transactional
public void testSaveTopicReply() {
    TopicReplyDO reply = this.saveTestReplyToDatabase();
    System.out.println("insert reply information:" + reply);
}
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