### Question:
TPMDeviceState extends DeviceState { @Override public final int hashCode() { final int prime = 31; int result = 1; result = prime * result + device.hashCode(); return result; } TPMDeviceState(final Device device); protected  TPMDeviceState(); final Long getId(); final Device getDevice(); final List<TPMMeasurementRecord> getTPMMeasurementRecords(); final TPMReport getReport(); final void setTPMReport(final TPMReport report); final boolean contains(final TPMMeasurementRecord record); @Override final int hashCode(); @Override final boolean equals(final Object obj); @Override final String toString();  }### Answer:
@Test public void testEquivalence() { final String deviceName = "Test Device"; final Device device1 = new Device(deviceName); final Device device2 = new Device(deviceName); final TPMDeviceState state1 = new TPMDeviceState(device1); final TPMDeviceState state2 = new TPMDeviceState(device2); Assert.assertEquals(state1, state2); Assert.assertEquals(state1.hashCode(), state2.hashCode()); }
@Test public void testNotEquivalent() { final Device device1 = new Device("Test Device 1"); final TPMDeviceState state1 = new TPMDeviceState(device1); final Device device2 = new Device("Test Device 2"); final TPMDeviceState state2 = new TPMDeviceState(device2); Assert.assertNotEquals(state1, state2); Assert.assertNotEquals(state1.hashCode(), state2.hashCode()); }