@Test
  public void adminResponseWithContentTest() throws IOException {
    int correlationId = 1;
    String clientId = "ambry-healthchecker";

    // test it with some content
    Map<String, String> returnedMap = new HashMap<>();
    returnedMap.put("key1", "value1");
    returnedMap.put("key2", "value2");
    ObjectMapper objectMapper = new ObjectMapper();
    System.out.println(objectMapper.writeValueAsString(returnedMap));
    byte[] content = objectMapper.writeValueAsBytes(returnedMap);
    AdminResponseWithContent response =
        new AdminResponseWithContent(correlationId, clientId, ServerErrorCode.NoError, content);
    DataInputStream responseStream = serAndPrepForRead(response, -1, false);
    AdminResponseWithContent deserializedAdminResponse = AdminResponseWithContent.readFrom(responseStream);
    Assert.assertEquals(deserializedAdminResponse.getCorrelationId(), correlationId);
    Assert.assertEquals(deserializedAdminResponse.getClientId(), clientId);
    Assert.assertEquals(deserializedAdminResponse.getError(), ServerErrorCode.NoError);
    Assert.assertNotNull(deserializedAdminResponse.getContent());

    Map<String, String> deserializedMap =
        objectMapper.readValue(deserializedAdminResponse.getContent(), new TypeReference<Map<String, String>>() {
        });
    Assert.assertEquals(returnedMap, deserializedMap);
    response.release();

    // test it with null content
    response = new AdminResponseWithContent(correlationId, clientId, ServerErrorCode.NoError, null);
    responseStream = serAndPrepForRead(response, -1, false);
    deserializedAdminResponse = AdminResponseWithContent.readFrom(responseStream);
    Assert.assertEquals(deserializedAdminResponse.getCorrelationId(), correlationId);
    Assert.assertEquals(deserializedAdminResponse.getClientId(), clientId);
    Assert.assertEquals(deserializedAdminResponse.getError(), ServerErrorCode.NoError);
    Assert.assertNull(deserializedAdminResponse.getContent());
    response.release();

    // test it with empty content
    response = new AdminResponseWithContent(correlationId, clientId, ServerErrorCode.NoError, new byte[0]);
    responseStream = serAndPrepForRead(response, -1, false);
    deserializedAdminResponse = AdminResponseWithContent.readFrom(responseStream);
    Assert.assertEquals(deserializedAdminResponse.getCorrelationId(), correlationId);
    Assert.assertEquals(deserializedAdminResponse.getClientId(), clientId);
    Assert.assertEquals(deserializedAdminResponse.getError(), ServerErrorCode.NoError);
    Assert.assertNull(deserializedAdminResponse.getContent());
    response.release();
  }
Tests the ser/de of {@link AdminRequest} and {@link AdminResponse} and checks for equality of fields with
reference data.
@throws IOException
ambry-protocol/src/test/java/com/github/ambry/protocol/RequestResponseTest.java