@Test
  public void ttlUpdateRequestResponseTest() throws IOException {
    MockClusterMap clusterMap = new MockClusterMap();
    int correlationId = TestUtils.RANDOM.nextInt();
    long opTimeMs = Utils.getRandomLong(TestUtils.RANDOM, Long.MAX_VALUE);
    long expiresAtMs = Utils.getRandomLong(TestUtils.RANDOM, Long.MAX_VALUE);
    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[]{TtlUpdateRequest.TTL_UPDATE_REQUEST_VERSION_1};
    for (short version : versions) {
      TtlUpdateRequest ttlUpdateRequest =
          new TtlUpdateRequest(correlationId, "client", id1, expiresAtMs, opTimeMs, version);
      DataInputStream requestStream = serAndPrepForRead(ttlUpdateRequest, -1, true);
      TtlUpdateRequest deserializedTtlUpdateRequest = TtlUpdateRequest.readFrom(requestStream, clusterMap);
      Assert.assertEquals("Request type mismatch", RequestOrResponseType.TtlUpdateRequest,
          deserializedTtlUpdateRequest.getRequestType());
      Assert.assertEquals("Correlation ID mismatch", correlationId, deserializedTtlUpdateRequest.getCorrelationId());
      Assert.assertEquals("Client ID mismatch", "client", deserializedTtlUpdateRequest.getClientId());
      Assert.assertEquals("Blob ID mismatch", id1, deserializedTtlUpdateRequest.getBlobId());
      Assert.assertEquals("AccountId mismatch ", id1.getAccountId(), deserializedTtlUpdateRequest.getAccountId());
      Assert.assertEquals("ContainerId mismatch ", id1.getContainerId(), deserializedTtlUpdateRequest.getContainerId());
      Assert.assertEquals("ExpiresAtMs mismatch ", expiresAtMs, deserializedTtlUpdateRequest.getExpiresAtMs());
      Assert.assertEquals("DeletionTime mismatch ", opTimeMs, deserializedTtlUpdateRequest.getOperationTimeInMs());
      ttlUpdateRequest.release();

      TtlUpdateResponse response = new TtlUpdateResponse(correlationId, "client", ServerErrorCode.NoError);
      requestStream = serAndPrepForRead(response, -1, false);
      TtlUpdateResponse deserializedTtlUpdateResponse = TtlUpdateResponse.readFrom(requestStream);
      Assert.assertEquals("Response type mismatch", RequestOrResponseType.TtlUpdateResponse,
          deserializedTtlUpdateResponse.getRequestType());
      Assert.assertEquals("Correlation ID mismatch", correlationId, deserializedTtlUpdateResponse.getCorrelationId());
      Assert.assertEquals("Client ID mismatch", "client", deserializedTtlUpdateResponse.getClientId());
      Assert.assertEquals("Server error code mismatch", ServerErrorCode.NoError,
          deserializedTtlUpdateResponse.getError());
      response.release();
    }
  }
Tests for {@link TtlUpdateRequest} and {@link TtlUpdateResponse}.
@throws IOException
ambry-protocol/src/test/java/com/github/ambry/protocol/RequestResponseTest.java