List<String> systemRoles = Arrays.asList( USERNAME_ADMIN );
List<String> extraRoles = Arrays.asList( AUTHENTICATED_ROLE_NAME, ANONYMOUS_ROLE_NAME );
String adminRole = USERNAME_ADMIN;
UserRoleDaoUserDetailsService userDetailsService = new UserRoleDaoUserDetailsService();
UserRoleDaoUserRoleListService service =
new UserRoleDaoUserRoleListService( userRoleDao, userDetailsService, userNameUtils, systemRoles,
extraRoles, adminRole );
userDetailsService.setUserRoleDao( userRoleDao );
logout();
login( USERNAME_ADMIN, mainTenant_1, new String[]{ tenantAdminRoleName, tenantAuthenticatedRoleName } );
List<String> allRolesForDefaultTenant = service.getAllRoles();
List<String> allRolesForTenant = service.getAllRoles( mainTenant_2 );
logger.info( "allRolesForDefaultTenant.size() ==" + allRolesForDefaultTenant.size() );
logger.info( "allRolesForTenant.size() ==" + allRolesForTenant.size() );
assertTrue( allRolesForDefaultTenant.size() == 2 + DEFAULT_ROLE_COUNT );
assertEquals( 3 + DEFAULT_ROLE_COUNT, allRolesForTenant.size() );
logout();
login( USERNAME_ADMIN, mainTenant_2, new String[]{ tenantAdminRoleName, tenantAuthenticatedRoleName } );
allRolesForDefaultTenant = service.getAllRoles();
allRolesForTenant = service.getAllRoles( mainTenant_1 );
assertTrue( allRolesForDefaultTenant.size() == 3 + DEFAULT_ROLE_COUNT );
assertEquals( 2 + DEFAULT_ROLE_COUNT, allRolesForTenant.size() );
allRolesForTenant = service.getAllRoles( mainTenant_2 );
assertEquals( 3 + DEFAULT_ROLE_COUNT, allRolesForTenant.size() );
allRolesForTenant = service.getAllRoles( mainTenant_1 );
assertEquals( 2 + DEFAULT_ROLE_COUNT, allRolesForTenant.size() );
logout();
login( USERNAME_ADMIN, mainTenant_1, new String[]{ tenantAdminRoleName, tenantAuthenticatedRoleName } );
allRolesForTenant = service.getAllRoles( mainTenant_1 );
assertEquals( 2 + DEFAULT_ROLE_COUNT, allRolesForTenant.size() );
allRolesForTenant = service.getAllRoles( mainTenant_2 );
assertEquals( 3 + DEFAULT_ROLE_COUNT, allRolesForTenant.size() );
cleanupUserAndRoles( mainTenant_1 );
cleanupUserAndRoles( mainTenant_2 );
}