### Question:
FieldReferenceFilter implements FieldFilter { @Override public List<Field> filter(DescribeSObjectResult dsr) { List<Field> fieldList = Lists.newArrayList(dsr.getFields()); Iterator<Field> fieldIter = fieldList.iterator(); while (fieldIter.hasNext()) { Field field = fieldIter.next(); if (field.getType() == FieldType.reference) { for (String referenceTo : field.getReferenceTo()) { if (include != referenceObjectNames.contains(referenceTo)) { fieldIter.remove(); break; } } } } return fieldList; } FieldReferenceFilter(boolean include, Set<String> referenceObjectNames);  FieldReferenceFilter(boolean include, String... referenceObjectNames); @Override List<Field> filter(DescribeSObjectResult dsr); Set<String> getReferenceObjectNames(); boolean isInclude();  }### Answer:
@Test public void testIncludeOneField() { List<Field> fields = new FieldReferenceFilter(true, Collections.singleton("Phone")).filter(dsr); verifyFilteredFields(fields, Arrays.asList(new String[] {"Id", "Name", "Phone"})); }
@SuppressWarnings("unchecked") @Test public void testExcludeZeroFields() { List<Field> fields = new FieldReferenceFilter(false, Collections.EMPTY_SET).filter(dsr); verifyFilteredFields(fields, Arrays.asList(new String[] {"Accepted", "Id", "Name", "Phone"})); }
@SuppressWarnings("unchecked") @Test public void testIncludeZeroFields() { List<Field> fields = new FieldReferenceFilter(true, Collections.EMPTY_SET).filter(dsr); verifyFilteredFields(fields, Arrays.asList(new String[] {"Id", "Name"})); }
@Test public void testExcludeOneField() { List<Field> fields = new FieldReferenceFilter(false, Collections.singleton("Phone")).filter(dsr); verifyFilteredFields(fields, Arrays.asList(new String[] {"Accepted", "Id", "Name"})); }