### Question:
ChunkHash implements Comparable<ChunkHash> { @Override public int compareTo(ChunkHash other) { return lexicographicalCompareUnsignedBytes(getHash(), other.getHash()); } ChunkHash(byte[] hash); byte[] getHash(); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(ChunkHash other); @Override String toString(); static final int HASH_LENGTH_BYTES; }### Answer:
@Test public void testCompareTo_whenEqual_returnsZero() { ChunkHash chunkHash = new ChunkHash(TEST_HASH_1); ChunkHash equalChunkHash = new ChunkHash(TEST_HASH_1); int result = chunkHash.compareTo(equalChunkHash); assertThat(result).isEqualTo(0); }
@Test public void testCompareTo_whenArgumentGreater_returnsNegative() { ChunkHash chunkHash1 = new ChunkHash(TEST_HASH_1); ChunkHash chunkHash2 = new ChunkHash(TEST_HASH_2); int result = chunkHash1.compareTo(chunkHash2); assertThat(result).isLessThan(0); }
@Test public void testCompareTo_whenArgumentSmaller_returnsPositive() { ChunkHash chunkHash1 = new ChunkHash(TEST_HASH_1); ChunkHash chunkHash2 = new ChunkHash(TEST_HASH_2); int result = chunkHash2.compareTo(chunkHash1); assertThat(result).isGreaterThan(0); }