### Question:
BasicService implements EntityService, AccessibilityCheck { protected void checkFieldAccess(NeutralQuery query, boolean isSelf) { if (query != null) { Collection<GrantedAuthority> auths = getAuths(isSelf); rightAccessValidator.checkFieldAccess(query, defn.getType(), auths); } } BasicService(String collectionName, List<Treatment> treatments, Repository<Entity> repo); @Override long count(NeutralQuery neutralQuery); @Override long countBasedOnContextualRoles(NeutralQuery neutralQuery); @Override List<String> create(List<EntityBody> content); @Override List<String> createBasedOnContextualRoles(List<EntityBody> content); @Override Iterable<String> listIds(final NeutralQuery neutralQuery); @Override String create(EntityBody content); @Override String createBasedOnContextualRoles(EntityBody content); @Override boolean accessibilityCheck(String id); @Override void delete(String id); @Override void deleteBasedOnContextualRoles(String id); @Override boolean update(String id, EntityBody content, boolean applySecurityContext); @Override boolean patch(String id, EntityBody content, boolean applySecurityContext); @Override EntityBody get(String id); @Override EntityBody get(String id, NeutralQuery neutralQuery); @Override Iterable<EntityBody> get(Iterable<String> ids); @Override Iterable<EntityBody> get(Iterable<String> ids, final NeutralQuery neutralQuery); @Override Iterable<EntityBody> list(NeutralQuery neutralQuery); @Override Iterable<EntityBody> listBasedOnContextualRoles(NeutralQuery neutralQuery); @Override boolean exists(String id); @Override EntityBody getCustom(String id); @Override void deleteCustom(String id); @Override void createOrUpdateCustom(String id, EntityBody customEntity); void setDefn(EntityDefinition defn); @Override EntityDefinition getEntityDefinition(); long getCountLimit(); int getBatchSize(); @Override CalculatedData<String> getCalculatedValues(String id); @Override CalculatedData<Map<String, Integer>> getAggregates(String id); @Override boolean collectionExists(String collection);  }### Answer:
@Test public void testCheckFieldAccessAdmin() { securityContextInjector.setAdminContextWithElevatedRights(); NeutralQuery query = new NeutralQuery(); query.addCriteria(new NeutralCriteria("economicDisadvantaged", "=", "true")); NeutralQuery query1 = new NeutralQuery(query); service.checkFieldAccess(query, false); assertTrue("Should match", query1.equals(query)); }
@Test (expected = QueryParseException.class) public void testCheckFieldAccessEducator() { securityContextInjector.setEducatorContext(); NeutralQuery query = new NeutralQuery(); query.addCriteria(new NeutralCriteria("economicDisadvantaged", "=", "true")); service.checkFieldAccess(query, false); }