@Test public void detectMutableStateInt() { EqualsVerifier<MutableIntContainer> ev = EqualsVerifier.forClass(MutableIntContainer.class); assertFailure(ev, MUTABILITY, FIELD_NAME); EqualsVerifier.forClass(MutableIntContainer.class).suppress(Warning.NONFINAL_FIELDS).verify(); }
@Test public void secondMutableFieldUsed() { EqualsVerifier<SecondMutableFieldUsed> ev = EqualsVerifier.forClass(SecondMutableFieldUsed.class); assertFailure(ev, MUTABILITY, "second"); EqualsVerifier.forClass(SecondMutableFieldUsed.class) .suppress(Warning.NONFINAL_FIELDS) .verify(); }
@Test public void referenceAndSuperSameHaveSameHashCode() { EqualsVerifier<HashCodeBrokenPoint> ev = EqualsVerifier.forClass(HashCodeBrokenPoint.class); assertFailure( ev, "Superclass", "hashCode for", HashCodeBrokenPoint.class.getSimpleName(), "should be equal to hashCode for superclass instance", Point.class.getSimpleName()); }
@Test public void symmetry() { EqualsVerifier<SymmetryBrokenColorPoint> ev = EqualsVerifier.forClass(SymmetryBrokenColorPoint.class); assertFailure( ev, "Symmetry", SymmetryBrokenColorPoint.class.getSimpleName(), "does not equal superclass instance", Point.class.getSimpleName()); }
@Test public void transitivity() { EqualsVerifier<TransitivityBrokenColorPoint> ev = EqualsVerifier.forClass(TransitivityBrokenColorPoint.class); assertFailure( ev, "Transitivity", "TransitivityBrokenColorPoint:1,1,YELLOW\nand\n TransitivityBrokenColorPoint:1,1,BLUE", "both equal superclass instance", "Point:1,1", "which implies they equal each other."); }
@Test public void mutableFieldNotUsed() { EqualsVerifier.forClass(MutableFieldNotUsed.class).verify(); }
@Test public void emptySuperclassIsIrrelevantWhenTheresEqualsHigherUp() { EqualsVerifier<BrokenCanEqualColorPointWithEmptySuper> ev = EqualsVerifier.forClass(BrokenCanEqualColorPointWithEmptySuper.class); assertFailure(ev, "Symmetry", BrokenCanEqualColorPointWithEmptySuper.class.getSimpleName()); }
@Test public void emptySuperclassesShouldNotFailOnEqualSuperclassInstance() { EqualsVerifier.forClass(SubclassOfEmpty.class).verify(); EqualsVerifier.forClass(SubOfEmptySubOfEmpty.class).verify(); EqualsVerifier.forClass(SubOfEmptySubOfAbstract.class).verify(); }
@Test public void happyPath() { EqualsVerifier.forClass(ColorBlindColorPoint.class).verify(); }
@Test public void toStringThrowsIllegalStateExceptionWhenFieldIsNull() { EqualsVerifier<ToStringIllegalStateThrower> ev = EqualsVerifier.forClass(ToStringIllegalStateThrower.class); assertFailure(ev, TO_STRING, THROWS, ILLEGAL_STATE_EXCEPTION, WHEN_S_IS_NULL); }
@Test public void hashCodeThrowsIllegalStateExceptionWhenFieldIsNull() { EqualsVerifier<HashCodeIllegalStateThrower> ev = EqualsVerifier.forClass(HashCodeIllegalStateThrower.class); assertFailure(ev, HASH_CODE, THROWS, ILLEGAL_STATE_EXCEPTION, WHEN_S_IS_NULL); }
@Test public void equalsThrowsIllegalStateExceptionWhenFieldIsNull() { EqualsVerifier<EqualsIllegalStateThrower> ev = EqualsVerifier.forClass(EqualsIllegalStateThrower.class); assertFailure(ev, EQUALS, THROWS, ILLEGAL_STATE_EXCEPTION, WHEN_S_IS_NULL); }
@Test public void issue31() { EqualsVerifier<Issue31> ev = EqualsVerifier.forClass(Issue31.class); assertFailure(ev, TO_STRING, THROWS, ILLEGAL_FORMAT_CONVERSION_EXCEPTION, WHEN_RED_IS_NULL); }