@Test public void testFilterWithCircularReferences() { DescribeSObjectResult dsrRef1 = new DescribeSObjectResult(); dsrRef1.setName("RefObject1__c"); DescribeSObjectResult dsrRef2 = new DescribeSObjectResult(); dsrRef2.setName("RefObject2__c"); Field refField1 = new Field(); refField1.setName("RefField1__c"); refField1.setType(FieldType.reference); refField1.setReferenceTo(new String[] {"RefObject1__c"}); dsrRef2.setFields(new Field[] {refField1}); Field refField2 = new Field(); refField2.setName("RefField2__c"); refField2.setType(FieldType.reference); refField2.setReferenceTo(new String[] {"RefObject2__c"}); dsrRef1.setFields(new Field[] {refField2}); List<DescribeSObjectResult> dsrs = new ObjectNameWithRefFilter("RefObject1__c").filter(Lists.newArrayList(dsrRef1, dsrRef2)); assertNotNull(dsrs, "An object name with references filter of a non-null value should be non-null"); assertEquals(dsrs.size(), 2, "Unexpected number of DescribeSObjectResults after object name with references filter"); }
@Override public List<DescribeSObjectResult> filter(List<DescribeSObjectResult> dsrs) { for (DescribeSObjectResult dsr : dsrs) { objectMap.put(dsr.getName(), dsr); } filterObjectAndReferences(objectNames); return filteredResult; }
ObjectNameWithRefFilter implements ObjectFilter { @Override public List<DescribeSObjectResult> filter(List<DescribeSObjectResult> dsrs) { for (DescribeSObjectResult dsr : dsrs) { objectMap.put(dsr.getName(), dsr); } filterObjectAndReferences(objectNames); return filteredResult; } }
ObjectNameWithRefFilter implements ObjectFilter { @Override public List<DescribeSObjectResult> filter(List<DescribeSObjectResult> dsrs) { for (DescribeSObjectResult dsr : dsrs) { objectMap.put(dsr.getName(), dsr); } filterObjectAndReferences(objectNames); return filteredResult; } ObjectNameWithRefFilter(Set<String> objectNames);  ObjectNameWithRefFilter(String... objectNames); }
ObjectNameWithRefFilter implements ObjectFilter { @Override public List<DescribeSObjectResult> filter(List<DescribeSObjectResult> dsrs) { for (DescribeSObjectResult dsr : dsrs) { objectMap.put(dsr.getName(), dsr); } filterObjectAndReferences(objectNames); return filteredResult; } ObjectNameWithRefFilter(Set<String> objectNames);  ObjectNameWithRefFilter(String... objectNames); @Override List<DescribeSObjectResult> filter(List<DescribeSObjectResult> dsrs); }
ObjectNameWithRefFilter implements ObjectFilter { @Override public List<DescribeSObjectResult> filter(List<DescribeSObjectResult> dsrs) { for (DescribeSObjectResult dsr : dsrs) { objectMap.put(dsr.getName(), dsr); } filterObjectAndReferences(objectNames); return filteredResult; } ObjectNameWithRefFilter(Set<String> objectNames);  ObjectNameWithRefFilter(String... objectNames); @Override List<DescribeSObjectResult> filter(List<DescribeSObjectResult> dsrs);  }