UserRoleDaoService { public void deleteRoles( String roleNames ) throws SecurityException, UncategorizedUserRoleDaoException { if ( canAdminister() ) { StringTokenizer tokenizer = new StringTokenizer( roleNames, "\t" ); while ( tokenizer.hasMoreTokens() ) { IPentahoRole role = getRoleDao().getRole( null, tokenizer.nextToken() ); if ( role != null ) { getRoleDao().deleteRole( role ); } } } else { throw new SecurityException(); } }  UserListWrapper getUsers(); RoleListWrapper getRolesForUser( String user ); void assignRolesToUser( String userName, String roleNames ); void removeRolesFromUser( String userName, String roleNames ); void createRole( String roleName ); RoleListWrapper getRoles(); UserListWrapper getRoleMembers( String roleName ); void createUser( User user ); void changeUserPassword( final String userName, final String newPass, String oldPass ); void deleteUsers( String userNames ); void deleteRoles( String roleNames ); SystemRolesMap getRoleBindingStruct( String locale ); void setLogicalRoles( LogicalRoleAssignments roleAssignments ); void updatePassword( User user, String administratorPassword ); void updatePassword( User user ); static final String PUC_USER_PASSWORD_LENGTH; static final String PUC_USER_PASSWORD_REQUIRE_SPECIAL_CHARACTER; }
@Test public void testDeleteRole() { String roles = "role1\trole2\t"; setupMockSessionUser( SESSION_USER_NAME, true ); IPentahoRole role = mock( IPentahoRole.class ); IUserRoleDao roleDao = mock( IUserRoleDao.class ); when( roleDao.getRole( any( ITenant.class ), anyString() ) ).thenReturn( role ); PentahoSystem.registerObject( roleDao ); userRoleService.deleteRoles( roles ); verify( roleDao, times( 2 ) ).deleteRole( any( IPentahoRole.class ) ); }
@Test( expected = UncategorizedUserRoleDaoException.class ) public void testDeleteRoleUncategorizedUserRoleDaoException() { String roles = "role1\trole2\t"; setupMockSessionUser( SESSION_USER_NAME, true ); IUserRoleDao roleDao = mock( IUserRoleDao.class ); when( roleDao.getRole( any( ITenant.class ), anyString() ) ).thenThrow( new UncategorizedUserRoleDaoException( "expectedTestException" ) ); PentahoSystem.registerObject( roleDao ); userRoleService.deleteRoles( roles ); }