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