Search in sources :

Example 1 with UserActionDO

use of org.neusoft.neubbs.entity.UserActionDO 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! ****************************");
}
Also used : UserActionDO(org.neusoft.neubbs.entity.UserActionDO) UserDynamicDO(org.neusoft.neubbs.entity.UserDynamicDO) UserDO(org.neusoft.neubbs.entity.UserDO)

Example 2 with UserActionDO

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

the class UserActionDAOTest method testGetUserActionLikeTopicIdJsonArray.

/**
 * 测试获取用户喜欢话题 id 数组
 */
@Test
@Transactional
public void testGetUserActionLikeTopicIdJsonArray() {
    UserActionDO userActionDO = this.saveTestUserActionDOToDatabase();
    int userId = userActionDO.getUserId();
    Assert.assertEquals("[]", userActionDAO.getUserActionLikeTopicIdJsonArray(userId));
    System.out.println("get userId=" + userId + " like topic json array success!");
}
Also used : UserActionDO(org.neusoft.neubbs.entity.UserActionDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 3 with UserActionDO

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

the class UserActionDAOTest method testGetUserAction.

/**
 * 测试获取用户行为对象
 */
@Test
@Transactional
public void testGetUserAction() {
    UserActionDO userAction = this.saveTestUserActionDOToDatabase();
    System.out.println("get userid=" + userAction.getId() + " user action information:" + userAction);
}
Also used : UserActionDO(org.neusoft.neubbs.entity.UserActionDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 4 with UserActionDO

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

the class UserActionDAOTest method testGetUserActionAttentionTopicIdJsonArray.

/**
 * 测试获取用户关注话题 id 数组
 */
@Test
@Transactional
public void testGetUserActionAttentionTopicIdJsonArray() {
    UserActionDO userActionDO = this.saveTestUserActionDOToDatabase();
    int userId = userActionDO.getUserId();
    Assert.assertEquals("[]", userActionDAO.getUserActionAttentionTopicIdJsonArray(userId));
    System.out.println("get userId=" + userId + " attention topic json array success!");
}
Also used : UserActionDO(org.neusoft.neubbs.entity.UserActionDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 5 with UserActionDO

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

the class UserActionDAOTest method testUpdateUserActionAddElementToAppendEnd.

/**
 * 测试更新用户行为,JSON 数组末尾追加
 *      - 喜欢话题 id
 *      - 收藏话题 id
 *      - 关注话题 id
 *      - 主动关注用户 id
 *      - 被关注用户 id
 */
@Test
@Transactional
public void testUpdateUserActionAddElementToAppendEnd() {
    UserActionDO userAction = this.saveTestUserActionDOToDatabase();
    int userId = userAction.getUserId();
    int topicId = 1;
    Assert.assertEquals(1, userActionDAO.updateLikeTopicIdJsonArrayByOneTopicIdToAppendEnd(userId, topicId));
    Assert.assertEquals(1, userActionDAO.updateCollectTopicIdJsonArrayByOneTopicIdToAppendEnd(userId, topicId));
    Assert.assertEquals(1, userActionDAO.updateAttentionTopicIdJsonArrayByOneTopicIdToAppendEnd(userId, topicId));
    System.out.println("success pass update to add like, collect, attention topic test!");
    int followingUserId = 2;
    int followedUserId = 3;
    Assert.assertEquals(1, userActionDAO.updateFollowingUserIdJsonArrayByOneUserIdToAppendEnd(userId, followingUserId));
    Assert.assertEquals(1, userActionDAO.updateFollowedUserIdJsonArrayByOneUserIdToAppendEnd(userId, followedUserId));
    System.out.println("success pass update to add following, followed user test!");
}
Also used : UserActionDO(org.neusoft.neubbs.entity.UserActionDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Aggregations

UserActionDO (org.neusoft.neubbs.entity.UserActionDO)12 Transactional (javax.transaction.Transactional)9 Test (org.junit.Test)9 UserDO (org.neusoft.neubbs.entity.UserDO)3 UserDynamicDO (org.neusoft.neubbs.entity.UserDynamicDO)1 ServiceException (org.neusoft.neubbs.exception.ServiceException)1