### Question:
TPMMeasurementRecord extends ExaminableRecord { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + hash.hashCode(); result = prime * result + pcrId; return result; } TPMMeasurementRecord(final int pcrId, final Digest hash);  TPMMeasurementRecord(final int pcrId, final String hash);  TPMMeasurementRecord(final int pcrId, final byte[] hash); protected  TPMMeasurementRecord(); static void checkForValidPcrId(final int pcrId); int getPcrId(); Digest getHash(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); static final int MIN_PCR_ID; static final int MAX_PCR_ID; static final int SHA_BYTE_LENGTH; static final int SHA_256_BYTE_LENGTH; }### Answer:
@Test public final void testHashCodeEquals() { TPMMeasurementRecord r1 = getDefaultRecord(); TPMMeasurementRecord r2 = getDefaultRecord(); Assert.assertEquals(r1.hashCode(), r2.hashCode()); Assert.assertEquals(r2.hashCode(), r1.hashCode()); Assert.assertEquals(r1.hashCode(), r1.hashCode()); Assert.assertEquals(r2.hashCode(), r2.hashCode()); }
@Test public final void testHashCodeNotEqualsPcrs() { final int pcrId = 5; TPMMeasurementRecord r1 = getDefaultRecord(); TPMMeasurementRecord r2 = new TPMMeasurementRecord(pcrId, getDigest(DEFAULT_HASH)); Assert.assertNotEquals(r1.hashCode(), r2.hashCode()); Assert.assertNotEquals(r2.hashCode(), r1.hashCode()); Assert.assertEquals(r1.hashCode(), r1.hashCode()); Assert.assertEquals(r2.hashCode(), r2.hashCode()); }
@Test public final void testHashCodeNotEqualsHashes() { final String hash = "aacc3c2f7f3003d2e4baddc46ed4763a4954f648"; TPMMeasurementRecord r1 = getDefaultRecord(); TPMMeasurementRecord r2 = new TPMMeasurementRecord(DEFAULT_PCR_ID, getDigest(hash)); Assert.assertNotEquals(r1.hashCode(), r2.hashCode()); Assert.assertNotEquals(r2.hashCode(), r1.hashCode()); Assert.assertEquals(r1.hashCode(), r1.hashCode()); Assert.assertEquals(r2.hashCode(), r2.hashCode()); }