### Question:
EntityRightsFilter { @SuppressWarnings("unchecked") protected void filterFields(EntityBody entityBody, Collection<GrantedAuthority> auths, String prefix, String entityType) { if (!auths.contains(Right.FULL_ACCESS)) { List<String> toRemove = new LinkedList<String>(); for (Iterator<Map.Entry<String, Object>> it = entityBody.entrySet().iterator(); it.hasNext();) { String fieldName = it.next().getKey(); Set<Right> neededRights = rightAccessValidator.getNeededRights(prefix + fieldName, entityType); if (!neededRights.isEmpty() && !rightAccessValidator.intersection(auths, neededRights)) { it.remove(); } } } }  EntityBody makeEntityBody(Entity entity, List<Treatment> treamts, EntityDefinition defn, boolean isSelf,
                                     Collection<GrantedAuthority> nonSelfAuths, SecurityUtil.UserContext context); EntityBody makeEntityBody(Entity entity, List<Treatment> treamts, EntityDefinition defn,
            Collection<GrantedAuthority> nonSelfAuths, Collection<GrantedAuthority> selfAuths); EntityBody exposeTreatments(Entity entity, List<Treatment> treatments, EntityDefinition defn); void setRightAccessValidator(RightAccessValidator rightAccessValidator);  }### Answer:
@Test public void testFilterFields() { Collection<GrantedAuthority> auths = new HashSet<GrantedAuthority>(); auths.add(Right.READ_GENERAL); Entity student = createStudentEntity(EntityNames.STUDENT, STUDENT_ID); EntityBody sb = new EntityBody(student.getBody()); entityRightsFilter.filterFields(sb, auths, "", EntityNames.STUDENT); Assert.assertEquals(1, sb.size()); Assert.assertEquals(STUDENT_UNIQUE_STATE_ID, sb.get(ParameterConstants.STUDENT_UNIQUE_STATE_ID)); }