### Question:
EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { public EntityReference replaceParent(EntityReference oldParent, EntityReference newParent) { if (oldParent == newParent) { return this; } return new EntityReference(this, oldParent, newParent); } EntityReference(EntityReference reference);  EntityReference(EntityReference reference, EntityReference parent); protected  EntityReference(EntityReference reference, EntityReference oldReference, EntityReference newReference);  EntityReference(String name, EntityType type);  EntityReference(String name, EntityType type, EntityReference parent); @Unstable  EntityReference(String name, EntityType type, Map<String, Serializable> parameters);  EntityReference(String name, EntityType type, EntityReference parent, Map<String, Serializable> parameters); @Unstable  EntityReference(EntityReference reference, Map<String, Serializable> parameters); final String getName(); final EntityReference getParent(); final EntityType getType(); final Map<String, Serializable> getParameters(); @Transient EntityReference getRoot(); @Transient List<EntityReference> getReversedReferenceChain(); int size(); EntityReference extractReference(EntityType type); EntityReference extractFirstReference(EntityType type); EntityReference replaceParent(EntityReference oldParent, EntityReference newParent); EntityReference replaceParent(EntityReference newParent); EntityReference appendParent(EntityReference newParent); EntityReference removeParent(EntityReference oldParent); boolean hasParent(EntityReference expectedParent); @Override String toString(); @Override boolean equals(Object obj); boolean equals(EntityReference otherReference, EntityType to); boolean equals(EntityReference otherReference, EntityType from, EntityType to); boolean equalsNonRecursive(EntityReference otherReference); @Override int hashCode(); @Override int compareTo(EntityReference reference);  }### Answer:
@Test public void replaceUnknownParent2() { EntityReference wiki = new EntityReference("wiki", EntityType.WIKI); EntityReference wiki2 = new EntityReference("wiki2", EntityType.WIKI); EntityReference space = new EntityReference("space", EntityType.SPACE, wiki); IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> space.replaceParent(new EntityReference("nowiki", EntityType.WIKI), wiki2)); assertEquals( "The old reference [Wiki nowiki] does not belong to the parents chain of the reference [Wiki wiki]", e.getMessage()); }