### Question:
SnapshotMetadata { @Override public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } if (!(obj instanceof SnapshotMetadata)) { return false; } SnapshotMetadata other = (SnapshotMetadata) obj; return hasPendingWrites == other.hasPendingWrites && isFromCache == other.isFromCache; } SnapshotMetadata(boolean hasPendingWrites, boolean isFromCache); boolean hasPendingWrites(); boolean isFromCache(); @Override boolean equals(@Nullable Object obj); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testEquals() { SnapshotMetadata foo = new SnapshotMetadata(true, true); SnapshotMetadata fooDup = new SnapshotMetadata(true, true); SnapshotMetadata bar = new SnapshotMetadata(true, false); SnapshotMetadata baz = new SnapshotMetadata(false, true); assertEquals(foo, fooDup); assertNotEquals(foo, bar); assertNotEquals(foo, baz); assertNotEquals(bar, baz); assertEquals(foo.hashCode(), fooDup.hashCode()); assertNotEquals(foo.hashCode(), bar.hashCode()); assertNotEquals(foo.hashCode(), baz.hashCode()); assertNotEquals(bar.hashCode(), baz.hashCode()); }