@Test
  public void sendWriteSingleMessageTest() throws Exception {
    if (blobFormatVersion >= MessageFormatRecord.Blob_Version_V2) {
      ByteBuffer encryptionKey = ByteBuffer.wrap(TestUtils.getRandomBytes(256));
      MessageFormatRecord.headerVersionToUse = MessageFormatRecord.Message_Header_Version_V1;
      doSendWriteSingleMessageTest(null, null, false);
      doSendWriteSingleMessageTest(encryptionKey.duplicate(), null, false);

      MessageFormatRecord.headerVersionToUse = MessageFormatRecord.Message_Header_Version_V2;
      doSendWriteSingleMessageTest(null, null, false);
      doSendWriteSingleMessageTest(ByteBuffer.allocate(0), ByteBuffer.allocate(0), false);
      doSendWriteSingleMessageTest(encryptionKey.duplicate(), encryptionKey.duplicate(), false);

      MessageFormatRecord.headerVersionToUse = MessageFormatRecord.Message_Header_Version_V3;
      doSendWriteSingleMessageTest(null, null, false);
      doSendWriteSingleMessageTest(ByteBuffer.allocate(0), ByteBuffer.allocate(0), false);
      doSendWriteSingleMessageTest(encryptionKey.duplicate(), encryptionKey.duplicate(), false);
    } else {
      doSendWriteSingleMessageTest(null, null, false);
    }
  }
Tests cases involving single messages across different header versions and with and without encryption keys
ambry-messageformat/src/test/java/com/github/ambry/messageformat/MessageFormatSendTest.java