Release extends AbstractHibernateObject { @Override public boolean equals(Object anObject) { if (this == anObject) { return true; } if (!(anObject instanceof Release)) { return false; } Release another = (Release) anObject; if (releaseVer == null) { return releaseVer == another.getReleaseVer(); } return releaseVer.equals(another.getReleaseVer()); } Release(String releaseVer);  Release(); String getReleaseVer(); void setReleaseVer(String releaseVer); @Override @XmlTransient Serializable getId(); @Override boolean equals(Object anObject); @Override int hashCode();  }
@Test public void testEquals() { Release rl = new Release("24.1"); Release rl1 = new Release("24.1"); Release rl2 = new Release("18.9"); assertTrue(rl.equals(rl1)); assertFalse(rl.equals(rl2)); assertFalse(rl.equals("345345")); Release rlE = new Release(""); Release rlE2 = new Release(""); assertTrue(rlE.equals(rlE2)); assertTrue(rl.equals(rl)); assertFalse(rl.equals(rlE)); }
@Test public void testNullEquals() { Release r = new Release(null); Release r1 = new Release("2.0"); assertFalse(r.equals(r1)); assertFalse(r1.equals(r)); assertTrue(r.equals(r)); assertTrue(r1.equals(r1)); }