@Test
  public void testBlobPropertyV1() throws IOException, MessageFormatException {
    // Test Blob property Format V1 for all versions of BlobPropertiesSerDe
    short[] versions = new short[]{VERSION_1, VERSION_2, VERSION_3, VERSION_4};
    for (short version : versions) {
      BlobProperties properties;
      long blobSize = TestUtils.RANDOM.nextLong();
      long ttl = TestUtils.RANDOM.nextInt();
      boolean isEncrypted = TestUtils.RANDOM.nextBoolean();
      if (version == VERSION_1) {
        properties = new BlobProperties(blobSize, "id", "member", "test", true, ttl, Account.UNKNOWN_ACCOUNT_ID,
            Container.UNKNOWN_CONTAINER_ID, isEncrypted, null, null, null);
      } else {
        short accountId = Utils.getRandomShort(TestUtils.RANDOM);
        short containerId = Utils.getRandomShort(TestUtils.RANDOM);
        properties =
            new BlobProperties(blobSize, "id", "member", "test", true, ttl, accountId, containerId, isEncrypted, null,
                "gzip", "filename");
      }
      ByteBuffer stream;
      if (version == VERSION_1) {
        stream = ByteBuffer.allocate(getBlobPropertiesV1RecordSize(properties));
        serializeBlobPropertiesV1Record(stream, properties);
      } else if (version == VERSION_2) {
        stream = ByteBuffer.allocate(getBlobPropertiesV2RecordSize(properties));
        serializeBlobPropertiesV2Record(stream, properties);
      } else if (version == VERSION_3) {
        stream = ByteBuffer.allocate(getBlobPropertiesV3RecordSize(properties));
        serializeBlobPropertiesV3Record(stream, properties);
      } else {
        stream = ByteBuffer.allocate(getBlobPropertiesRecordSize(properties));
        MessageFormatRecord.BlobProperties_Format_V1.serializeBlobPropertiesRecord(stream, properties);
      }
      stream.flip();
      BlobProperties result = MessageFormatRecord.deserializeBlobProperties(new ByteBufferInputStream(stream));
      Assert.assertEquals(properties.getBlobSize(), result.getBlobSize());
      Assert.assertEquals(properties.getContentType(), result.getContentType());
      Assert.assertEquals(properties.getCreationTimeInMs(), result.getCreationTimeInMs());
      Assert.assertEquals(properties.getOwnerId(), result.getOwnerId());
      Assert.assertEquals(properties.getServiceId(), result.getServiceId());
      Assert.assertEquals(properties.getAccountId(), result.getAccountId());
      Assert.assertEquals(properties.getContainerId(), result.getContainerId());
      if (version > VERSION_2) {
        Assert.assertEquals(properties.isEncrypted(), result.isEncrypted());
      }
      if (version > VERSION_3) {
        Assert.assertEquals(properties.getContentEncoding(), result.getContentEncoding());
        Assert.assertEquals(properties.getFilename(), result.getFilename());
      }

      // corrupt blob property V1 record
      stream.flip();
      stream.put(10, (byte) (stream.get(10) + 1));
      try {
        MessageFormatRecord.deserializeBlobProperties(new ByteBufferInputStream(stream));
        fail("Deserialization of BlobProperties should have failed ");
      } catch (MessageFormatException e) {
        Assert.assertEquals(e.getErrorCode(), MessageFormatErrorCodes.DataCorrupt);
      }
    }

    // failure case
    BlobProperties properties =
        new BlobProperties(1000, "id", "member", "test", true, Utils.Infinite_Time, Account.UNKNOWN_ACCOUNT_ID,
            Container.UNKNOWN_CONTAINER_ID, false, null, "gzip", "filename");
    ByteBuffer stream = ByteBuffer.allocate(getBlobPropertiesRecordSize(properties) - 10);
    try {
      MessageFormatRecord.BlobProperties_Format_V1.serializeBlobPropertiesRecord(stream, properties);
      Assert.fail("Serialization of BlobProperties should have failed since the buffer does not have sufficient space");
    } catch (IllegalArgumentException e) {
    }
  }
Tests {@link MessageFormatRecord#BlobProperties_Version_V1} for different versions of {@link BlobPropertiesSerDe}
@throws IOException
@throws MessageFormatException
ambry-messageformat/src/test/java/com/github/ambry/messageformat/MessageFormatRecordTest.java