@Test
  public void adminRequestResponseTest() throws IOException {
    int correlationId = 1234;
    String clientId = "client";
    for (AdminRequestOrResponseType type : AdminRequestOrResponseType.values()) {
      MockClusterMap clusterMap = new MockClusterMap();
      PartitionId id = clusterMap.getWritablePartitionIds(MockClusterMap.DEFAULT_PARTITION_CLASS).get(0);
      // with a valid partition id
      AdminRequest adminRequest = new AdminRequest(type, id, correlationId, clientId);
      DataInputStream requestStream = serAndPrepForRead(adminRequest, -1, true);
      deserAdminRequestAndVerify(requestStream, clusterMap, correlationId, clientId, type, id);
      adminRequest.release();
      // with a null partition id
      adminRequest = new AdminRequest(type, null, correlationId, clientId);
      requestStream = serAndPrepForRead(adminRequest, -1, true);
      deserAdminRequestAndVerify(requestStream, clusterMap, correlationId, clientId, type, null);
      adminRequest.release();
      // response
      ServerErrorCode[] values = ServerErrorCode.values();
      int indexToPick = TestUtils.RANDOM.nextInt(values.length);
      ServerErrorCode responseErrorCode = values[indexToPick];
      AdminResponse response = new AdminResponse(correlationId, clientId, responseErrorCode);
      DataInputStream responseStream = serAndPrepForRead(response, -1, false);
      AdminResponse deserializedAdminResponse = AdminResponse.readFrom(responseStream);
      Assert.assertEquals(deserializedAdminResponse.getCorrelationId(), correlationId);
      Assert.assertEquals(deserializedAdminResponse.getClientId(), clientId);
      Assert.assertEquals(deserializedAdminResponse.getError(), responseErrorCode);
      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