private void generateAndAssertBadBlobId(Short version) throws Exception {
    List<String> invalidBlobIdLikeList = new ArrayList<>();
    PartitionId badPartitionId =
        new MockPartitionId(200000, MockClusterMap.DEFAULT_PARTITION_CLASS, Collections.EMPTY_LIST, 0);
    String goodUUID = UUID.randomUUID().toString();

    // Partition ID not in cluster map
    invalidBlobIdLikeList.add(
        buildBadBlobId(version, referenceType, referenceDatacenterId, referenceAccountId, referenceContainerId,
            badPartitionId, goodUUID.length(), goodUUID, ""));
    // UUID length too long
    invalidBlobIdLikeList.add(
        buildBadBlobId(version, referenceType, referenceDatacenterId, referenceAccountId, referenceContainerId,
            referencePartitionId, goodUUID.length() + 1, goodUUID, ""));
    // UUID length too short
    invalidBlobIdLikeList.add(
        buildBadBlobId(version, referenceType, referenceDatacenterId, referenceAccountId, referenceContainerId,
            referencePartitionId, goodUUID.length() - 1, goodUUID, ""));
    // UUID length is negative. Only matters for blob IDs with the older UUID serialization format
    if (version < BLOB_ID_V6) {
      invalidBlobIdLikeList.add(
          buildBadBlobId(version, referenceType, referenceDatacenterId, referenceAccountId, referenceContainerId,
              referencePartitionId, -1, goodUUID, ""));
    }
    // Extra characters after UUID
    invalidBlobIdLikeList.add(
        buildBadBlobId(version, referenceType, referenceDatacenterId, referenceAccountId, referenceContainerId,
            referencePartitionId, goodUUID.length(), goodUUID, "EXTRA"));
    // Invalid version number
    invalidBlobIdLikeList.add(
        buildBadBlobId((short) (-1), referenceType, referenceDatacenterId, referenceAccountId, referenceContainerId,
            referencePartitionId, goodUUID.length(), goodUUID, ""));
    // Empty blobId
    invalidBlobIdLikeList.add("");
    // short Blob ID
    invalidBlobIdLikeList.add("AA");

    for (String blobIdLike : invalidBlobIdLikeList) {
      try {
        new BlobId(blobIdLike, referenceClusterMap);
        fail("Expected blobId creation to fail with blobId string " + blobIdLike);
      } catch (Exception e) {
        // expected
      }
    }
  }
Generates bad blobId strings, and deserializes from the string.
@param version The version of BlobId.
@throws Exception Any unexpected exception.
ambry-commons/src/test/java/com/github/ambry/commons/BlobIdTest.java