### Question:
AttachmentReference extends EntityReference { @Override public AttachmentReference replaceParent(EntityReference oldParent, EntityReference newParent) { if (newParent == oldParent) { return this; } return new AttachmentReference(this, oldParent, newParent); } AttachmentReference(EntityReference reference); protected  AttachmentReference(EntityReference reference, EntityReference oldReference, EntityReference newReference);  AttachmentReference(EntityReference reference, EntityReference parent);  AttachmentReference(String fileName, DocumentReference parent); @Transient DocumentReference getDocumentReference(); @Override AttachmentReference replaceParent(EntityReference oldParent, EntityReference newParent); @Override AttachmentReference replaceParent(EntityReference newParent);  }### Answer:
@Test public void testReplaceParent() { AttachmentReference reference = new AttachmentReference("file", new DocumentReference("wiki", "space", "page")) .replaceParent(new DocumentReference("wiki2", "space2", "page2")); assertEquals(new AttachmentReference("file", new DocumentReference("wiki2", "space2", "page2")), reference); assertSame(reference, reference.replaceParent(reference.getParent())); }