use of org.neusoft.neubbs.entity.UserDynamicDO in project neubbs by nuitcoder.
the class InsertTestData method addSixAdministrator.
/*
* ***********************************************
* private method
* ***********************************************
*/
/**
* 添加 6 个管理员
*/
private void addSixAdministrator() {
String[] administratorArray = { "ahonn", "AnAndroidXiang", "kayye", "topLynch", "Nancyshan", "suvan" };
String password = "123456";
String[] emailArray = { "ahonn95@outlook.com", "2389351081@qq.com", "584157012@qq.com", "805742416@qq.com", "1169251031@qq.com", "liushuwei0925@gmail.com" };
int count = 0;
UserDO user = new UserDO();
UserActionDO userAction = new UserActionDO();
UserDynamicDO userDynamic = new UserDynamicDO();
for (String adminName : administratorArray) {
user.setName(adminName);
user.setPassword(SecretUtil.encryptMd5(SecretUtil.encryptMd5(password) + password));
user.setEmail(emailArray[count++]);
// register user newUserId > 0
Assert.assertTrue(userDAO.saveUser(user) > 0);
// change user perssion, effectRow != 0
Assert.assertEquals(1, userDAO.updateUserRankByName(adminName, "admin"));
// activate account, effectRow != 0
Assert.assertEquals(1, userDAO.updateUserStateToActivateByEmail(user.getEmail()));
// send reminder mail
// SendEmailUtil.sendEmail("Nebbbs 开发团队",emailArray[count++],
// "Nebbbs 管理员账号提醒", "欢迎您成为 Neubbs 项目管理员\n您的的管理员帐号:" + adminName + " 密码:123456");
// alter user avator, effectRow != 0
Assert.assertEquals(1, userDAO.updateUserAvatorByName(adminName, ParamConst.USER_DEFAULT_IMAGE));
System.out.println("already add administrator: " + adminName);
// save user action (input admin user id)
userAction.setUserId(user.getId());
Assert.assertEquals(1, userActionDAO.saveUserAction(userAction));
// save user dynamic(input admin user id )
userDynamic.setUserId(user.getId());
Assert.assertEquals(1, userDynamicDAO.saveUserDynamic(userDynamic));
System.out.println("alread add administrator: " + adminName + " default user action!");
}
System.out.println("*************************** success add 6 administrator! ****************************");
}
use of org.neusoft.neubbs.entity.UserDynamicDO in project neubbs by nuitcoder.
the class UserDynamicDAOTest method testUpdatePublicInfoJsonArrayByOneDynamicInforToAppendEnd.
/**
* 测试发布用户动态信息 JSON 数组(JSON 数组,末尾追加)
*/
@Test
@Transactional
public void testUpdatePublicInfoJsonArrayByOneDynamicInforToAppendEnd() {
UserDynamicDO userDynamic = this.saveTestUserDynamicDOToDatabase();
int userId = userDynamic.getUserId();
System.out.println("before append: " + userDynamic);
// build user dynamic json information:
JSONArray jsonUserDynamic = JSON.parseArray(userDynamic.getPublicInfoJsonArray());
int currentJsonLength = jsonUserDynamic.size();
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", currentJsonLength + 1);
jsonObject.put("createTime", System.currentTimeMillis());
jsonObject.put("content", "today very happy");
jsonObject.put("visibilityType", "myself");
Assert.assertEquals(1, userDynamicDAO.updatePublicInfoJsonArrayByOneDynamicInfoToAppendEnd(userId, jsonObject.toJSONString()));
UserDynamicDO afterUserDynamic = userDynamicDAO.getUserDynamic(userId);
Assert.assertEquals(1, JSON.parseArray(afterUserDynamic.getPublicInfoJsonArray()).size());
System.out.println("after append: " + afterUserDynamic);
System.out.println("update user dynamic append on information success!");
}
use of org.neusoft.neubbs.entity.UserDynamicDO in project neubbs by nuitcoder.
the class UserDynamicDAOTest method saveTestUserDynamicDOToDatabase.
/**
* 保存测试 UserDynamicDO 对象至数据库
* - 新建测试用户动态
* - 保存,且重新查询数据库获得对象(根据用户 id,进行查询)
*
* @return UserDynamicDO 用户动态对象
*/
private UserDynamicDO saveTestUserDynamicDOToDatabase() {
UserDO user = new UserDO();
user.setName("testUser");
user.setPassword(SecretUtil.encryptMd5(SecretUtil.encryptMd5("123456") + "123456"));
user.setEmail("testUser@neubbs.com");
Assert.assertEquals(1, userDAO.saveUser(user));
UserDynamicDO userDynamic = new UserDynamicDO();
userDynamic.setUserId(user.getId());
Assert.assertEquals(1, userDynamicDAO.saveUserDynamic(userDynamic));
return userDynamicDAO.getUserDynamic(user.getId());
}
use of org.neusoft.neubbs.entity.UserDynamicDO in project neubbs by nuitcoder.
the class UserDynamicDAOTest method testUpdatePublicInfoJsonArrayByIndexToRemoveOneDynamicInfo.
/**
* 测试删除用户动态信息(JSON 数组,根据索引,删除指定元素)
*/
@Test
@Transactional
public void testUpdatePublicInfoJsonArrayByIndexToRemoveOneDynamicInfo() {
UserDynamicDO userDynamic = this.saveTestUserDynamicDOToDatabase();
int userId = userDynamic.getUserId();
int id = 1;
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", id);
jsonObject.put("createTime", System.currentTimeMillis());
jsonObject.put("content", "today very happy");
jsonObject.put("visibilityType", "myself");
Assert.assertEquals(1, userDynamicDAO.updatePublicInfoJsonArrayByOneDynamicInfoToAppendEnd(userId, jsonObject.toJSONString()));
System.out.println("before remove: " + userDynamicDAO.getUserDynamic(userId));
int removeIndex = id - 1;
Assert.assertEquals(1, userDynamicDAO.updatePublicInfoJsonArrayByIndexToRemoveOneDynamicInfo(userId, removeIndex));
UserDynamicDO afterUserDynamic = userDynamicDAO.getUserDynamic(userId);
Assert.assertEquals(0, JSON.parseArray(afterUserDynamic.getPublicInfoJsonArray()).size());
System.out.println("after remove: " + afterUserDynamic);
System.out.println("update user dynamic remove index information success!");
}
use of org.neusoft.neubbs.entity.UserDynamicDO in project neubbs by nuitcoder.
the class UserDynamicDAOTest method testGetUserDynamic.
/**
* 测试获取用户动态
*/
@Test
@Transactional
public void testGetUserDynamic() {
UserDynamicDO userDynamic = this.saveTestUserDynamicDOToDatabase();
System.out.println("success get userId=" + userDynamic.getUserId() + " user dynamic information: " + userDynamic);
}
Aggregations