@Test public void testEqualsTransitive() { Wrapper<Object> objectWrapper1 = createTestWrapper(); Wrapper<Object> objectWrapper2 = createTestWrapper().wrap(objectWrapper1); Wrapper<Object> objectWrapper3 = createTestWrapper().wrap(objectWrapper1); Wrapper<Object> objectWrapper4 = createTestWrapper().wrap(objectWrapper1); String errorMessage = "Equals method should be transitive"; Assert.assertThat(errorMessage, objectWrapper2, equalTo(objectWrapper3)); Assert.assertThat(errorMessage, objectWrapper3, equalTo(objectWrapper4)); Assert.assertThat(errorMessage, objectWrapper2, equalTo(objectWrapper4)); }
public Wrapper<T> wrap(T wrapped) { this.wrapped = wrapped; return this; }
Wrapper { public Wrapper<T> wrap(T wrapped) { this.wrapped = wrapped; return this; } }
Wrapper { public Wrapper<T> wrap(T wrapped) { this.wrapped = wrapped; return this; }  }
Wrapper { public Wrapper<T> wrap(T wrapped) { this.wrapped = wrapped; return this; }  Wrapper<T> wrap(T wrapped); T getWrapped(); void setPosition(int position); int getPosition(); @Override int hashCode(); @Override @SuppressWarnings("unchecked") boolean equals(Object obj); @Override String toString(); abstract boolean safelyEquals(T actual, T expected); abstract String asString(T obj); }
Wrapper { public Wrapper<T> wrap(T wrapped) { this.wrapped = wrapped; return this; }  Wrapper<T> wrap(T wrapped); T getWrapped(); void setPosition(int position); int getPosition(); @Override int hashCode(); @Override @SuppressWarnings("unchecked") boolean equals(Object obj); @Override String toString(); abstract boolean safelyEquals(T actual, T expected); abstract String asString(T obj);  }