### Question:
DefaultModelBridge implements ModelBridge { @Override public boolean checkXObjectPresence(List<String> xObjectTypes, Object source) { if (xObjectTypes.isEmpty()) { return true; } else if (source instanceof XWikiDocument) { XWikiDocument document = (XWikiDocument) source; Map<DocumentReference, List<BaseObject>> documentXObjects = document.getXObjects(); for (String objectType : xObjectTypes) { LocalDocumentReference localXObjectReference = documentReferenceResolver.resolve(objectType).getLocalDocumentReference(); for (DocumentReference documentReference : documentXObjects.keySet()) { if (documentReference.getLocalDocumentReference().equals(localXObjectReference)) { return true; } } } } return false; }  @Override DocumentReference getAuthorReference(EntityReference entityReference); @Override boolean checkXObjectPresence(List<String> xObjectTypes, Object source);  }### Answer:
@Test public void testCheckXObjectPresenceWithEmptyList() throws Exception { Object object = new Object(); List<String> xObjectTypes = Collections.EMPTY_LIST; assertTrue(this.mocker.getComponentUnderTest().checkXObjectPresence(xObjectTypes, object)); }
@Test public void testCheckXObjectPresenceWithPresentXObject() throws Exception { XWikiDocument document = mock(XWikiDocument.class); List<String> xObjectTypes = Arrays.asList("type1"); DocumentReference documentReferenceFromDocumentXObjects = mock(DocumentReference.class); Map<DocumentReference, List<BaseObject>> documentXObjects = new HashMap<DocumentReference, List<BaseObject>>() {{ put(documentReferenceFromDocumentXObjects, Collections.EMPTY_LIST); }}; DocumentReference resolvedType1 = mock(DocumentReference.class); LocalDocumentReference localDocumentReferenceType1 = mock(LocalDocumentReference.class); when(resolvedType1.getLocalDocumentReference()).thenReturn(localDocumentReferenceType1); when(this.documentReferenceResolver.resolve(eq("type1"))).thenReturn(resolvedType1); when(document.getXObjects()).thenReturn(documentXObjects); when(documentReferenceFromDocumentXObjects.getLocalDocumentReference()).thenReturn(localDocumentReferenceType1); DocumentReference resolvedType2 = mock(DocumentReference.class); LocalDocumentReference localDocumentReferenceType2 = mock(LocalDocumentReference.class); when(resolvedType2.getLocalDocumentReference()).thenReturn(localDocumentReferenceType2); when(this.documentReferenceResolver.resolve(eq("type2"))).thenReturn(resolvedType2); assertTrue(this.mocker.getComponentUnderTest().checkXObjectPresence(xObjectTypes, document)); assertFalse(this.mocker.getComponentUnderTest().checkXObjectPresence(Arrays.asList("type2"), document)); }