Key implements IKey { @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Key key = (Key) o; return !(identifier != null ? !identifier.equals(key.identifier) : key.identifier != null); } Key(final String identifier); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testEqual_ToSelf() { assertTrue("Class equal to itself.", Fixture.x.equals(Fixture.x)); assertTrue("Class equal to itself.", Fixture.xInt.equals(Fixture.xInt)); }
@Test public void testPassIncompatibleType_isFalse() { assertFalse("Passing incompatible object to equals should return false", Fixture.x.equals(Fixture.notx)); assertFalse("Passing incompatible object to equals should return false", Fixture.xInt.equals(Fixture.notxInt)); }
@Test public void testNullReference_isFalse() { assertFalse("Passing null to equals should return false", Fixture.x.equals(null)); assertFalse("Passing null to equals should return false", Fixture.xInt.equals(null)); }
@Test public void testEquals_isReflexive_isSymmetric() { assertTrue("Reflexive test fail x,y", Fixture.x.equals(Fixture.y)); assertTrue("Symmetric test fail y", Fixture.y.equals(Fixture.x)); assertTrue("Reflexive test fail x,y", Fixture.xInt.equals(Fixture.yInt)); assertTrue("Symmetric test fail y", Fixture.yInt.equals(Fixture.xInt)); }
@Test public void testEquals_isTransitive() { assertTrue("Transitive test fails x,y", Fixture.x.equals(Fixture.y)); assertTrue("Transitive test fails y,z", Fixture.y.equals(Fixture.z)); assertTrue("Transitive test fails x,z", Fixture.x.equals(Fixture.z)); assertTrue("Transitive test fails x,y", Fixture.xInt.equals(Fixture.yInt)); assertTrue("Transitive test fails y,z", Fixture.yInt.equals(Fixture.zInt)); assertTrue("Transitive test fails x,z", Fixture.xInt.equals(Fixture.zInt)); }
@Test public void testEquals_isConsistent() { assertTrue("Consistent test fail x,y", Fixture.x.equals(Fixture.y)); assertTrue("Consistent test fail x,y", Fixture.x.equals(Fixture.y)); assertFalse(Fixture.notx.equals(Fixture.x)); assertFalse(Fixture.notx.equals(Fixture.x)); assertTrue("Consistent test fail x,y", Fixture.xInt.equals(Fixture.yInt)); assertTrue("Consistent test fail x,y", Fixture.xInt.equals(Fixture.yInt)); assertFalse(Fixture.notxInt.equals(Fixture.xInt)); assertFalse(Fixture.notxInt.equals(Fixture.xInt)); }