### Question:
EntityEdOrgRightBuilder { public Collection<GrantedAuthority> buildEntityEdOrgRights(final Map<String, Collection<GrantedAuthority>> edOrgRights, final Entity entity, boolean isRead) { Collection<GrantedAuthority> authorities = new HashSet<GrantedAuthority>(); Set<String> edorgs = edOrgOwnershipArbiter.determineHierarchicalEdorgs(Arrays.asList(entity), entity.getType()); edorgs.retainAll(edOrgRights.keySet()); if (edorgs.isEmpty()) { edorgs = getEdOrgsForStudent(edOrgRights.keySet(), entity, isRead); } for (String edorg : edorgs) { authorities.addAll(edOrgRights.get(edorg)); } return authorities; }  Collection<GrantedAuthority> buildEntityEdOrgRights(final Map<String, Collection<GrantedAuthority>> edOrgRights, final Entity entity, boolean isRead); Collection<GrantedAuthority> buildEntityEdOrgContextRights(final EdOrgContextRightsCache edOrgContextRights, final Entity entity,
                                                                      final SecurityUtil.UserContext context, boolean isRead); void setEdOrgOwnershipArbiter(EdOrgOwnershipArbiter edOrgOwnershipArbiter);  }### Answer:
@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)); }