LockEntry { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((key == null) ? 0 : key.hashCode()); result = prime * result + ((owner == null) ? 0 : owner.hashCode()); return result; } LockEntry(String key, long lockAquiredTime, OLATPrincipal owner); long getLockAquiredTime(); OLATPrincipal getOwner(); String getKey(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testHashCode() { assertFalse("Wrong equals implementation, different types are recognized as equals ", leOne.equals(new Integer(1))); assertFalse("Wrong equals implementation, different users are recognized as equals ", leOne.equals(leThree)); assertFalse("Wrong equals implementation, null value is recognized as equals ", leOne.equals(null)); assertTrue("Wrong equals implementation, same users are NOT recognized as equals ", leOne.equals(leOne)); assertTrue("Wrong equals implementation, same users are NOT recognized as equals ", leOne.equals(sameAsLeOne)); }
@Test public void testEqualsObject() { assertTrue("Wrong hashCode implementation, same users have NOT same hash-code ", leOne.hashCode() == leOne.hashCode()); assertFalse("Wrong hashCode implementation, different users have same hash-code", leOne.hashCode() == leThree.hashCode()); assertTrue("Wrong hashCode implementation, same users have NOT same hash-code ", leOne.hashCode() == sameAsLeOne.hashCode()); }