Пример #1
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);
  }
Пример #2
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());
 }
Пример #3
0
 @Before
 public void setUp() {
   listByUser = userRoleDao.findByUser(EXIST_USER_1);
   listByRole = userRoleDao.findByRoleId(EXIST_ROLE_1);
 }