### Question:
DefaultXWikiBridge implements XWikiBridge { @Override public EntityReference toCompatibleEntityReference(EntityReference reference) { if (reference == null) { return reference; } EntityReference compatibleReference = this.currentResolver.resolve(reference, reference.getType()); if (compatibleReference.getType() == EntityType.PAGE || compatibleReference.getType().isAllowedAncestor(EntityType.PAGE)) { XWikiContext xcontext = this.xcontextProvider.get(); compatibleReference = xcontext.getWiki().getDocumentReference(reference, xcontext); } return compatibleReference; }  @Override WikiReference getMainWikiReference(); @Override boolean isWikiReadOnly(); @Override boolean needsAuthentication(Right right); @Override EntityReference toCompatibleEntityReference(EntityReference reference);  }### Answer:
@Test public void toCompatibleEntityReferenceWhenNull() { assertNull(this.bridge.toCompatibleEntityReference(null)); }
@Test public void toCompatibleEntityReferenceWhenPartial() { EntityReference entityReference = new EntityReference("document", EntityType.DOCUMENT); DocumentReference documentReference = new DocumentReference("currentwiki", "currentspace", "document"); when(this.currentResolver.resolve(entityReference, entityReference.getType())).thenReturn(documentReference); assertEquals(documentReference, this.bridge.toCompatibleEntityReference(entityReference)); }
@Test public void toCompatibleEntityReferenceWhenPage() { PageReference pageReference = new PageReference("wiki", "page"); DocumentReference documentReference = new DocumentReference("wiki", "page", "WebHome"); when(this.currentResolver.resolve(pageReference, pageReference.getType())).thenReturn(pageReference); doReturn(documentReference).when(this.oldcore.getSpyXWiki()).getDocumentReference(pageReference, this.oldcore.getXWikiContext()); assertEquals(documentReference, this.bridge.toCompatibleEntityReference(pageReference)); }