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