@Test
  public void deleteRequestResponseTest() throws IOException {
    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);
    short[] versions = new short[]{DeleteRequest.DELETE_REQUEST_VERSION_1, DeleteRequest.DELETE_REQUEST_VERSION_2};
    for (short version : versions) {
      long deletionTimeMs = Utils.getRandomLong(TestUtils.RANDOM, Long.MAX_VALUE);
      int correlationId = TestUtils.RANDOM.nextInt();
      DeleteRequest deleteRequest;
      if (version == DeleteRequest.DELETE_REQUEST_VERSION_1) {
        deleteRequest = new DeleteRequestV1(correlationId, "client", id1);
      } else {
        deleteRequest = new DeleteRequest(correlationId, "client", id1, deletionTimeMs);
      }
      DataInputStream requestStream = serAndPrepForRead(deleteRequest, -1, true);
      DeleteRequest deserializedDeleteRequest = DeleteRequest.readFrom(requestStream, clusterMap);
      Assert.assertEquals(deserializedDeleteRequest.getClientId(), "client");
      Assert.assertEquals(deserializedDeleteRequest.getBlobId(), id1);
      if (version == DeleteRequest.DELETE_REQUEST_VERSION_2) {
        Assert.assertEquals("AccountId mismatch ", id1.getAccountId(), deserializedDeleteRequest.getAccountId());
        Assert.assertEquals("ContainerId mismatch ", id1.getContainerId(), deserializedDeleteRequest.getContainerId());
        Assert.assertEquals("DeletionTime mismatch ", deletionTimeMs, deserializedDeleteRequest.getDeletionTimeInMs());
      } else {
        Assert.assertEquals("AccountId mismatch ", accountId, deserializedDeleteRequest.getAccountId());
        Assert.assertEquals("ContainerId mismatch ", containerId, deserializedDeleteRequest.getContainerId());
        Assert.assertEquals("DeletionTime mismatch ", Utils.Infinite_Time,
            deserializedDeleteRequest.getDeletionTimeInMs());
      }
      deleteRequest.release();
      DeleteResponse response = new DeleteResponse(correlationId, "client", ServerErrorCode.NoError);
      requestStream = serAndPrepForRead(response, -1, false);
      DeleteResponse deserializedDeleteResponse = DeleteResponse.readFrom(requestStream);
      Assert.assertEquals(deserializedDeleteResponse.getCorrelationId(), correlationId);
      Assert.assertEquals(deserializedDeleteResponse.getError(), ServerErrorCode.NoError);
      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