private void verifySievedTransformedMessage(MessageSievingInputStream sievedStream, StoreKey key, String serviceId,
      short accountId, short containerId, byte[] encryptionKey, byte[] usermetadata, byte[] data, short blobVersion,
      BlobType blobType) throws Exception {

    byte[] headerVersion = new byte[Version_Field_Size_In_Bytes];
    sievedStream.read(headerVersion, 0, Version_Field_Size_In_Bytes);
    short version = ByteBuffer.wrap(headerVersion).getShort();
    if (!isValidHeaderVersion(version)) {
      throw new MessageFormatException("Header version not supported " + version, MessageFormatErrorCodes.DataCorrupt);
    }
    int headerSize = getHeaderSizeForVersion(version);
    byte[] headerArr = new byte[headerSize];
    ByteBuffer headerBuffer = ByteBuffer.wrap(headerArr, 0, headerSize);
    headerBuffer.putShort(version);
    sievedStream.read(headerArr, Version_Field_Size_In_Bytes, headerSize - Version_Field_Size_In_Bytes);
    MessageHeader_Format header = getMessageHeader(version, headerBuffer);
    byte[] keyInStreamBytes = ((new MockIdFactory()).getStoreKey(new DataInputStream(sievedStream))).toBytes();
    Assert.assertArrayEquals(key.toBytes(), keyInStreamBytes);
    Assert.assertTrue(header.isPutRecord());
    ByteBuffer encryptionKeyInStream =
        header.hasEncryptionKeyRecord() ? deserializeBlobEncryptionKey(sievedStream) : null;
    BlobProperties propsFromStream = deserializeBlobProperties(sievedStream);
    ByteBuffer userMetadataFromStream = deserializeUserMetadata(sievedStream);
    BlobData blobDataFromStream = deserializeBlob(sievedStream);
    Assert.assertEquals(encryptionKey == null, encryptionKeyInStream == null);
    if (encryptionKey != null) {
      Assert.assertArrayEquals(encryptionKey, encryptionKeyInStream.array());
    }
    Assert.assertEquals(serviceId, propsFromStream.getServiceId());
    Assert.assertEquals(accountId, propsFromStream.getAccountId());
    Assert.assertEquals(containerId, propsFromStream.getContainerId());
    Assert.assertEquals(ByteBuffer.wrap(usermetadata), userMetadataFromStream);
    Assert.assertEquals(blobType, blobDataFromStream.getBlobType());
    ByteBuf byteBuf = blobDataFromStream.content();
    try {
      Assert.assertEquals(Unpooled.wrappedBuffer(data), byteBuf);
    } finally {
      byteBuf.release();
    }
  }
Test the case where there are deprecated messages.
@throws Exception
ambry-messageformat/src/test/java/com/github/ambry/messageformat/MessageSievingInputStreamTest.java