GroupKeyInfoItemIdentifier extends BaseInfoItemIdentifier { @Override public int hashCode() { return Objects.hash(_groupId, _key); } GroupKeyInfoItemIdentifier(long groupId, String key); @Override boolean equals(Object object); long getGroupId(); String getKey(); @Override int hashCode(); @Override String toString();  }
@Test public void testHashCode() { GroupKeyInfoItemIdentifier groupKeyInfoItemIdentifier1 = new GroupKeyInfoItemIdentifier(12345L, "key"); GroupKeyInfoItemIdentifier groupKeyInfoItemIdentifier2 = new GroupKeyInfoItemIdentifier(12345L, "key"); Assert.assertEquals( groupKeyInfoItemIdentifier1.hashCode(), groupKeyInfoItemIdentifier2.hashCode()); }
@Test public void testHashCodeWithDifferentGroupId() { GroupKeyInfoItemIdentifier groupKeyInfoItemIdentifier1 = new GroupKeyInfoItemIdentifier(12345L, "key"); GroupKeyInfoItemIdentifier groupKeyInfoItemIdentifier2 = new GroupKeyInfoItemIdentifier(22345L, "key"); Assert.assertNotEquals( groupKeyInfoItemIdentifier1.hashCode(), groupKeyInfoItemIdentifier2.hashCode()); }
@Test public void testHashCodeWithDifferentKey() { GroupKeyInfoItemIdentifier groupKeyInfoItemIdentifier1 = new GroupKeyInfoItemIdentifier(12345L, "key1"); GroupKeyInfoItemIdentifier groupKeyInfoItemIdentifier2 = new GroupKeyInfoItemIdentifier(12345L, "key2"); Assert.assertNotEquals( groupKeyInfoItemIdentifier1.hashCode(), groupKeyInfoItemIdentifier2.hashCode()); }