Пример #1
0
 @Test
 public void testSetEmptyUsersToRole() throws SecurityException {
   List<String> userCodes = Collections.emptyList();
   userRoleCommandService.setUsersToRole(EXIST_ROLE_1, userCodes);
   List<UserRole> finishList = userRoleDao.findByRoleId(EXIST_ROLE_1);
   Assert.assertEquals(0, finishList.size());
 }
Пример #2
0
  @Test
  public void testSetRolesToUser() throws SecurityException {
    List<String> roleIds = new ArrayList<String>();
    roleIds.add("EXIST_ROLE_1");
    roleIds.add("EXIST_ROLE_3");
    log.info("roleIds : " + roleIds.toString());
    userRoleCommandService.setRolesToUser(EXIST_USER_1, roleIds);
    List<UserRole> finishList = userRoleDao.findByUser(EXIST_USER_1);
    for (UserRole userRole : finishList) {
      log.info("finishList : " + userRole.getRoleId());
    }

    Assert.assertNotNull(finishList);
    Assert.assertEquals(2, listByUser.size());
    Assert.assertEquals(2, finishList.size());

    UserRole staticRole = getStaticRole(listByUser, "EXIST_ROLE_1");
    Assert.assertNotNull(staticRole);
    UserRole finishRole = getStaticRole(finishList, "EXIST_ROLE_1");
    Assert.assertNotNull(finishRole);
    Assert.assertEquals(staticRole.getUserRoleId(), finishRole.getUserRoleId());

    UserRole nullRole = getStaticRole(finishList, "EXIST_ROLE_2");
    Assert.assertNull(nullRole);

    UserRole notNullRole = getStaticRole(finishList, "EXIST_ROLE_3");
    Assert.assertNotNull(notNullRole);
  }
Пример #3
0
  @Test
  public void testSetUsersToRole() throws SecurityException {
    List<String> userCodes = new ArrayList<String>();
    userCodes.add("EXIST_USER_1");
    userCodes.add("EXIST_USER_3");
    userRoleCommandService.setUsersToRole(EXIST_ROLE_1, userCodes);

    List<UserRole> finishList = userRoleDao.findByRoleId(EXIST_ROLE_1);
    for (UserRole userRole : finishList) {
      log.info(userRole.getUserId());
    }

    Assert.assertNotNull(finishList);
    Assert.assertEquals(2, listByRole.size());
    Assert.assertEquals(2, finishList.size());

    UserRole staticRole = getStaticUser(listByRole, "EXIST_USER_1");
    Assert.assertNotNull(staticRole);
    UserRole finishRole = getStaticUser(finishList, "EXIST_USER_1");
    Assert.assertNotNull(finishRole);
    Assert.assertEquals(staticRole.getUserRoleId(), finishRole.getUserRoleId());

    UserRole nullRole = getStaticUser(finishList, "EXIST_USER_2");
    Assert.assertNull(nullRole);
    UserRole notNullRole = getStaticUser(finishList, "EXIST_USER_3");
    Assert.assertNotNull(notNullRole);
  }
Пример #4
0
 @Test
 public void testSetEmptyRolesToUser() throws SecurityException {
   List<String> objects = Collections.emptyList();
   userRoleCommandService.setRolesToUser(EXIST_USER_1, objects);
   List<UserRole> finishList = userRoleDao.findByUser(EXIST_USER_1);
   Assert.assertNotNull(finishList);
   Assert.assertEquals(0, finishList.size());
 }
Пример #5
0
 @Before
 public void setUp() {
   listByUser = userRoleDao.findByUser(EXIST_USER_1);
   listByRole = userRoleDao.findByRoleId(EXIST_ROLE_1);
 }