@Test
  public void replicateBlobRequestResponseTest() throws IOException {
    RequestOrResponseType operationType =
        RequestOrResponseType.values()[Utils.getRandomShort(TestUtils.RANDOM) % RequestOrResponseType.values().length];
    short[] versions = new short[]{ReplicateBlobRequest.VERSION_1, ReplicateBlobRequest.VERSION_2};
    for (short version : versions) {
      final ReplicateBlobRequest replicateBlobRequest;
      if (version == ReplicateBlobRequest.VERSION_1) {
        replicateBlobRequest = new ReplicateBlobRequest(correlationId, clientId, blobId, "datacenter1_host1", 15058);
      } else {
        replicateBlobRequest =
            new ReplicateBlobRequest(correlationId, clientId, blobId, "datacenter1_host1", 15058, operationType,
                System.currentTimeMillis(), (short) 1, 1L);
      }
      DataInputStream requestStream = serAndPrepForRead(replicateBlobRequest);
      MockRequest mockRequest = new MockRequest(requestStream);
      // 1. Verify request is decoded correctly
      RequestOrResponse request = requestResponseHelper.getDecodedRequest(mockRequest);
      assertEquals("Mismatch in request type", request.getRequestType(), RequestOrResponseType.ReplicateBlobRequest);
      // 2. Verify response is formed correctly
      Response response = requestResponseHelper.createErrorResponse(request, ServerErrorCode.RetryAfterBackoff);
      assertEquals("Mismatch in response type", response.getRequestType(), RequestOrResponseType.ReplicateBlobResponse);
      assertEquals("Mismatch in response correlation id", response.getCorrelationId(), correlationId);
      assertEquals("Mismatch in response client id", response.getClientId(), clientId);
      assertEquals("Mismatch in error code", response.getError(), ServerErrorCode.RetryAfterBackoff);
      request.release();
      response.release();
    }
  }
Test for undelete request and response.
@throws IOException
ambry-network/src/test/java/com/github/ambry/network/ServerRequestResponseHelperTest.java