@Test
  public void testComparisons() {
    // the version check is to do this inter-version test just once (since this is a parametrized test).
    assumeTrue(version == BLOB_ID_V1);
    for (int i = 0; i < 100; i++) {
      Map<Short, Pair<BlobId, BlobId>> blobIds = Arrays.stream(BlobId.getAllValidVersions())
          .collect(Collectors.toMap(Function.identity(), v -> new Pair<>(getRandomBlobId(v), getRandomBlobId(v))));

      for (short version : BlobId.getAllValidVersions()) {
        BlobId blobId = blobIds.get(version).getFirst();
        BlobId altBlobId = blobIds.get(version).getSecond();
        assertEquals("blobIdV" + version + " should be equal to itself", 0, blobId.compareTo(blobId));
        assertEquals("blobIdV" + version + " should be equal to itself", blobId, blobId);

        assertThat("Two randomly generated blobIdV" + version + "s should be unequal", blobId.compareTo(altBlobId),
            not(0));
        assertThat("Two randomly generated blobIdV" + version + "s should be unequal", blobId, not(altBlobId));
        for (short otherVersion = 1; otherVersion < version; otherVersion++) {
          BlobId otherBlobId = blobIds.get(otherVersion).getFirst();
          assertThat("blobIdV" + otherVersion + " should not equal blobIdV" + version, otherBlobId, not(blobId));
          assertThat("blobIdV" + version + " should not equal blobIdV" + otherVersion, blobId, not(otherBlobId));
          boolean differentVersionGroup =
              version < BLOB_ID_V3 || (version < BLOB_ID_V6 ? otherVersion < BLOB_ID_V3 : otherVersion < BLOB_ID_V6);
          if (differentVersionGroup) {
            assertTrue("blobIdV" + otherVersion + " should be less than blobIdV" + version,
                otherBlobId.compareTo(blobId) < 0);
            assertTrue("blobIdV" + version + " should be greater than blobIdV" + otherVersion,
                blobId.compareTo(otherBlobId) > 0);
          } else {
            assertEquals(
                "Comparison between blobIdV" + version + " and blobIDV" + otherVersion + " are based on uuid only",
                blobId.getUuid().compareTo(otherBlobId.getUuid()), blobId.compareTo(otherBlobId));
            assertEquals(
                "Comparison between blobIdV" + otherVersion + " and blobIDV" + version + " are based on uuid only",
                otherBlobId.getUuid().compareTo(blobId.getUuid()), otherBlobId.compareTo(blobId));
          }
        }
      }
    }
  }
Tests blobIds comparisons. Among other things, ensures the following requirements are met:
<br>
V1s are always less than V2s and V3s.
V2s are always less than V3s.
ambry-commons/src/test/java/com/github/ambry/commons/BlobIdTest.java