public List<String> getRolesForUser( String username ) { return userRoleListService.getRolesForUser( null, username ); }
private IUserRoleListService getUserRoleListServiceMock( String userName, String[] roles ) { IUserRoleListService mockUserRoleListService = mock( IUserRoleListService.class ); List<String> noRoles = new ArrayList<String>(); List<String> allRoles = new ArrayList<String>( Arrays.asList( roles ) ); when( mockUserRoleListService.getRolesForUser( Matchers.<ITenant>any(), eq( userName ) ) ).thenReturn( allRoles ); when( mockUserRoleListService.getRolesForUser( Matchers.<ITenant>any(), AdditionalMatchers.not( eq( userName ) ) ) ) .thenReturn( noRoles ); return mockUserRoleListService; } }
roles = userRoleListService.getRolesForUser( null, principalName );
List<String> roles = getUserRoleListService().getRolesForUser( JcrTenantUtils.getCurrentTenant(), username ); authorities = new ArrayList<GrantedAuthority>( roles.size() ); for ( String role : roles ) {
when( userRoleListService.getRolesForUser( Matchers.<ITenant>any(), eq( "suzy" ) ) ).thenReturn( Collections.singletonList( "authenticated" ) );
when( userRoleListService.getRolesForUser( Matchers.<ITenant>any(), eq( "suzy" ) ) ) .thenReturn( Collections.singletonList( "authenticated" ) );
mp.defineInstance( IRepositoryFileAclDao.class, repositoryFileAclDao ); IUserRoleListService userRoleListService = mock( IUserRoleListService.class ); when( userRoleListService.getRolesForUser( any( ITenant.class ), anyString() ) ).thenReturn( Arrays.asList( tenantAdminRoleName, AUTHENTICATED_ROLE_NAME ) ); mp.defineInstance( IUserRoleListService.class, userRoleListService );