@Test
  public void testInstantiationAndSerDe() throws Exception {
    ByteBuffer encryptionKey = ByteBuffer.wrap(TestUtils.getRandomBytes(256));
    MessageMetadata messageMetadata = new MessageMetadata(encryptionKey.duplicate());
    ByteBuf serializedBuf = Unpooled.buffer(messageMetadata.sizeInBytes());
    messageMetadata.serializeMessageMetadata(serializedBuf);
    MessageMetadata deserialized =
        MessageMetadata.deserializeMessageMetadata(new DataInputStream(new ByteBufInputStream(serializedBuf)));
    Assert.assertEquals(encryptionKey, deserialized.getEncryptionKey());
  }
Test instantiation and serialization/deserialization of MessageMetadata.
@throws Exception
ambry-messageformat/src/test/java/com/github/ambry/messageformat/MessageMetadataTest.java