private void testGetRequestResponse(short getVersionToUse, short messageInfoAutoVersion) throws IOException {
    GetResponse.CURRENT_VERSION = getVersionToUse;
    MessageInfoAndMetadataListSerde.AUTO_VERSION = messageInfoAutoVersion;
    MockClusterMap clusterMap = new MockClusterMap();
    short accountId = Utils.getRandomShort(TestUtils.RANDOM);
    short containerId = Utils.getRandomShort(TestUtils.RANDOM);
    BlobId id1 = new BlobId(CommonTestUtils.getCurrentBlobIdVersion(), BlobId.BlobIdType.NATIVE,
        ClusterMap.UNKNOWN_DATACENTER_ID, accountId, containerId,
        clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0), false,
        BlobId.BlobDataType.DATACHUNK);
    ArrayList<BlobId> blobIdList = new ArrayList<BlobId>();
    blobIdList.add(id1);
    PartitionRequestInfo partitionRequestInfo1 = new PartitionRequestInfo(new MockPartitionId(), blobIdList);
    ArrayList<PartitionRequestInfo> partitionRequestInfoList = new ArrayList<PartitionRequestInfo>();
    partitionRequestInfoList.add(partitionRequestInfo1);
    GetRequest getRequest =
        new GetRequest(1234, "clientId", MessageFormatFlags.Blob, partitionRequestInfoList, GetOption.None);
    DataInputStream requestStream = serAndPrepForRead(getRequest, -1, true);
    GetRequest deserializedGetRequest = GetRequest.readFrom(requestStream, clusterMap);
    Assert.assertEquals(deserializedGetRequest.getClientId(), "clientId");
    Assert.assertEquals(deserializedGetRequest.getPartitionInfoList().size(), 1);
    Assert.assertEquals(deserializedGetRequest.getPartitionInfoList().get(0).getBlobIds().size(), 1);
    Assert.assertEquals(deserializedGetRequest.getPartitionInfoList().get(0).getBlobIds().get(0), id1);
    getRequest.release();

    // Test GetResponse with InputStream
    long operationTimeMs = SystemTime.getInstance().milliseconds() + TestUtils.RANDOM.nextInt();
    byte[] encryptionKey = TestUtils.getRandomBytes(256);
    MessageInfo messageInfo =
        new MessageInfo(id1, 1000, false, false, true, 1000, null, accountId, containerId, operationTimeMs, (short) 1);
    MessageMetadata messageMetadata = new MessageMetadata(ByteBuffer.wrap(encryptionKey));
    ArrayList<MessageInfo> messageInfoList = new ArrayList<>();
    ArrayList<MessageMetadata> messageMetadataList = new ArrayList<>();
    messageInfoList.add(messageInfo);
    messageMetadataList.add(messageMetadata);
    PartitionResponseInfo partitionResponseInfo =
        new PartitionResponseInfo(clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0),
            messageInfoList, messageMetadataList);
    List<PartitionResponseInfo> partitionResponseInfoList = new ArrayList<PartitionResponseInfo>();
    partitionResponseInfoList.add(partitionResponseInfo);
    byte[] buf = TestUtils.getRandomBytes(1000);
    ByteArrayInputStream byteStream = new ByteArrayInputStream(buf);
    GetResponse response =
        new GetResponse(1234, "clientId", partitionResponseInfoList, byteStream, ServerErrorCode.NoError);
    requestStream = serAndPrepForRead(response, -1, false);
    GetResponse deserializedGetResponse = GetResponse.readFrom(requestStream, clusterMap);
    Assert.assertEquals(deserializedGetResponse.getCorrelationId(), 1234);
    Assert.assertEquals(deserializedGetResponse.getError(), ServerErrorCode.NoError);
    Assert.assertEquals(deserializedGetResponse.getPartitionResponseInfoList().size(), 1);
    Assert.assertEquals(deserializedGetResponse.getPartitionResponseInfoList().get(0).getMessageInfoList().size(), 1);
    MessageInfo msgInfo = deserializedGetResponse.getPartitionResponseInfoList().get(0).getMessageInfoList().get(0);
    Assert.assertEquals(msgInfo.getSize(), 1000);
    Assert.assertEquals(msgInfo.getStoreKey(), id1);
    Assert.assertEquals(msgInfo.getExpirationTimeInMs(), 1000);
    Assert.assertEquals(deserializedGetResponse.getPartitionResponseInfoList().get(0).getMessageMetadataList().size(),
        1);
    if (GetResponse.getCurrentVersion() >= GetResponse.GET_RESPONSE_VERSION_V_4) {
      MessageMetadata messageMetadataInResponse =
          deserializedGetResponse.getPartitionResponseInfoList().get(0).getMessageMetadataList().get(0);
      Assert.assertEquals(messageMetadata.getEncryptionKey().rewind(), messageMetadataInResponse.getEncryptionKey());
    } else {
      Assert.assertNull(deserializedGetResponse.getPartitionResponseInfoList().get(0).getMessageMetadataList().get(0));
    }
    if (GetResponse.getCurrentVersion() >= GetResponse.GET_RESPONSE_VERSION_V_3) {
      Assert.assertEquals("AccountId mismatch ", accountId, msgInfo.getAccountId());
      Assert.assertEquals("ConatinerId mismatch ", containerId, msgInfo.getContainerId());
      Assert.assertEquals("OperationTime mismatch ", operationTimeMs, msgInfo.getOperationTimeMs());
    } else {
      Assert.assertEquals("AccountId mismatch ", UNKNOWN_ACCOUNT_ID, msgInfo.getAccountId());
      Assert.assertEquals("ConatinerId mismatch ", UNKNOWN_CONTAINER_ID, msgInfo.getContainerId());
      Assert.assertEquals("OperationTime mismatch ", Utils.Infinite_Time, msgInfo.getOperationTimeMs());
    }
    if (messageInfoAutoVersion >= MessageInfoAndMetadataListSerde.VERSION_6) {
      Assert.assertTrue(msgInfo.isUndeleted());
      Assert.assertEquals("LifeVersion mismatch", (short) 1, msgInfo.getLifeVersion());
    } else {
      Assert.assertFalse(msgInfo.isUndeleted());
      Assert.assertEquals("LifeVersion mismatch", (short) 0, msgInfo.getLifeVersion());
    }
    response.release();
    // Test GetResponse with Send
    for (boolean useComposite : new boolean[]{false, true}) {
      for (boolean withContent : new boolean[]{false, true}) {
        operationTimeMs = SystemTime.getInstance().milliseconds() + TestUtils.RANDOM.nextInt();
        encryptionKey = TestUtils.getRandomBytes(256);
        messageInfo =
            new MessageInfo(id1, 1000, false, false, true, 1000, null, accountId, containerId, operationTimeMs,
                (short) 1);
        messageMetadata = new MessageMetadata(ByteBuffer.wrap(encryptionKey));
        messageInfoList.clear();
        messageMetadataList.clear();
        messageInfoList.add(messageInfo);
        messageMetadataList.add(messageMetadata);
        partitionResponseInfo =
            new PartitionResponseInfo(clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0),
                messageInfoList, messageMetadataList);
        partitionResponseInfoList.clear();
        partitionResponseInfoList.add(partitionResponseInfo);
        Send send;
        if (withContent) {
          send = new SendWithContent(1000, useComposite);
        } else {
          send = new SendWithoutContent(1000, useComposite);
        }
        response = new GetResponse(1234, "clientId", partitionResponseInfoList, send, ServerErrorCode.NoError);
        requestStream = serAndPrepForRead(response, -1, false);
        deserializedGetResponse = GetResponse.readFrom(requestStream, clusterMap);
        Assert.assertEquals(deserializedGetResponse.getCorrelationId(), 1234);
        Assert.assertEquals(deserializedGetResponse.getError(), ServerErrorCode.NoError);
        Assert.assertEquals(deserializedGetResponse.getPartitionResponseInfoList().size(), 1);
        Assert.assertEquals(deserializedGetResponse.getPartitionResponseInfoList().get(0).getMessageInfoList().size(),
            1);
        msgInfo = deserializedGetResponse.getPartitionResponseInfoList().get(0).getMessageInfoList().get(0);
        Assert.assertEquals(msgInfo.getSize(), 1000);
        Assert.assertEquals(msgInfo.getStoreKey(), id1);
        Assert.assertEquals(msgInfo.getExpirationTimeInMs(), 1000);
        Assert.assertEquals(
            deserializedGetResponse.getPartitionResponseInfoList().get(0).getMessageMetadataList().size(), 1);
        response.release();
      }
    }
  }
Test Put requests in a specific version.
@param testVersion the version to use for the Put requests. If -1, uses the default version.
@param clusterMap the cluster map to use.
@param correlationId the correlation id associated with the request.
@param clientId the client id associated with the request.
@param blobId the blob id in the request.
@param blobProperties the {@link BlobProperties} associated with the request.
@param userMetadata the user metadata associated with the request.
@param blobType the {@link BlobType} associated with the request.
@param blob the blob content.
@param blobSize the size of the blob.
@param blobKey the encryption key of the blob.
@param expectedKey the expected encryption key from the deserialized Put request.
ambry-protocol/src/test/java/com/github/ambry/protocol/RequestResponseTest.java