@SuppressWarnings("unchecked")
  @Test
  public void testBuildEntityEdOrgContextRightsWithNoEntityEdOrgsNoMatchingEdOrgs() {
    EdOrgOwnershipArbiter edOrgOwnershipArbiter = Mockito.mock(EdOrgOwnershipArbiter.class);
    entityEdOrgRightBuilder.setEdOrgOwnershipArbiter(edOrgOwnershipArbiter);

    Set<String> edOrgs = new HashSet<String>();
    edOrgs.add("edOrg1");
    edOrgs.add("edOrg6");
    edOrgs.add("edOrg7");

    Entity entity = Mockito.mock(Entity.class);
    Mockito.when(entity.getType()).thenReturn("student");

    Mockito.when(
            edOrgOwnershipArbiter.determineHierarchicalEdorgs(
                Matchers.anyList(), Matchers.anyString()))
        .thenReturn(edOrgs);

    Collection<GrantedAuthority> grantedAuthorities =
        entityEdOrgRightBuilder.buildEntityEdOrgContextRights(
            edOrgContextRights, entity, SecurityUtil.UserContext.DUAL_CONTEXT, false);

    Assert.assertTrue(grantedAuthorities.isEmpty());
  }
  @SuppressWarnings("unchecked")
  @Test
  public void testBuildEntityEdOrgRights() {

    Set<String> edOrgs = new HashSet<String>();
    edOrgs.add("edOrg1");
    edOrgs.add("edOrg2");
    edOrgs.add("edOrg3");
    edOrgs.add("edOrg4");

    Entity entity = Mockito.mock(Entity.class);
    Mockito.when(entity.getType()).thenReturn("student");

    Mockito.when(
            edOrgOwnershipArbiter.determineHierarchicalEdorgs(
                Matchers.anyList(), Matchers.anyString()))
        .thenReturn(edOrgs);

    Collection<GrantedAuthority> grantedAuthorities =
        entityEdOrgRightBuilder.buildEntityEdOrgRights(edOrgRights, entity, false);

    Assert.assertEquals(5, grantedAuthorities.size());
    Assert.assertTrue(grantedAuthorities.contains(READ_PUBLIC));
    Assert.assertTrue(grantedAuthorities.contains(READ_GENERAL));
    Assert.assertTrue(grantedAuthorities.contains(READ_RESTRICTED));
    Assert.assertTrue(grantedAuthorities.contains(WRITE_GENERAL));
    Assert.assertTrue(grantedAuthorities.contains(WRITE_RESTRICTED));
    Assert.assertFalse(grantedAuthorities.contains(AGGREGATE_READ));
    Assert.assertFalse(grantedAuthorities.contains(WRITE_PUBLIC));
    Assert.assertFalse(grantedAuthorities.contains(AGGREGATE_WRITE));
  }