@Test
  public void testGetRolesForUser() throws Exception {

    List<String> allRoles = compositeService.getRolesForUser(mockTenant, "joe");
    assertEquals(1, allRoles.size());
    compositeService.setStrategy(CompositeUserRoleListService.STRATEGY.ADDITIVE);
    allRoles = compositeService.getRolesForUser(mockTenant, "joe");
    assertEquals(2, allRoles.size());
    assertTrue(
        unsortedEqualArrays(
            allRoles.toArray(new String[allRoles.size()]), new String[] {"admin", "rockstar"}));
  }
  @Test
  public void testGetUsersInRole() throws Exception {

    List<String> allUsers = compositeService.getUsersInRole(mockTenant, "ceo");
    assertEquals(1, allUsers.size());
    compositeService.setStrategy(CompositeUserRoleListService.STRATEGY.ADDITIVE);
    allUsers = compositeService.getUsersInRole(mockTenant, "ceo");
    assertEquals(2, allUsers.size());
    assertTrue(
        unsortedEqualArrays(
            allUsers.toArray(new String[allUsers.size()]), new String[] {"ted", "suzy"}));
  }
  @Test
  public void testGetAllUsers() throws Exception {

    List<String> allUsers = compositeService.getAllUsers();
    assertEquals(2, allUsers.size());
    compositeService.setStrategy(CompositeUserRoleListService.STRATEGY.ADDITIVE);
    allUsers = compositeService.getAllUsers();
    assertEquals(3, allUsers.size());
    assertTrue(
        unsortedEqualArrays(
            allUsers.toArray(new String[allUsers.size()]), new String[] {"user1", "suzy", "joe"}));
  }
  @Test
  public void testGetAllRoles() throws Exception {

    List<String> allRoles = compositeService.getAllRoles();
    assertEquals(2, allRoles.size());
    compositeService.setStrategy(CompositeUserRoleListService.STRATEGY.ADDITIVE);
    allRoles = compositeService.getAllRoles();
    assertEquals(3, allRoles.size());
    assertTrue(
        unsortedEqualArrays(
            allRoles.toArray(new String[allRoles.size()]),
            new String[] {"ceo", "admin", "extraRole1"}));
  }
 @Test
 public void testSetStrategy() throws Exception {
   compositeService =
       new CompositeUserRoleListService(Collections.<IUserRoleListService>emptyList());
   assertEquals(
       CompositeUserRoleListService.STRATEGY.FIRST_MATCH, compositeService.getActiveStrategy());
   compositeService.setStrategy(CompositeUserRoleListService.STRATEGY.ADDITIVE);
   assertEquals(
       CompositeUserRoleListService.STRATEGY.ADDITIVE, compositeService.getActiveStrategy());
   compositeService.setStrategy(CompositeUserRoleListService.STRATEGY.FIRST_MATCH);
   assertEquals(
       CompositeUserRoleListService.STRATEGY.FIRST_MATCH, compositeService.getActiveStrategy());
 }
  @Test
  public void testGetSystemRoles() throws Exception {

    List<String> allRoles = compositeService.getSystemRoles();
    assertEquals(2, allRoles.size());
    compositeService.setStrategy(CompositeUserRoleListService.STRATEGY.ADDITIVE);
    allRoles = compositeService.getSystemRoles();
    assertEquals(3, allRoles.size());
    assertTrue(
        unsortedEqualArrays(
            allRoles.toArray(new String[allRoles.size()]),
            new String[] {"authenticated", "anonymous", "serveradmin"}));
  }