private void verifyUserMetadataConstructionSuccess(JSONObject headers, Map<String, String> inputUserMetadata)
      throws Exception {
    RestRequest restRequest = createRestRequest(RestMethod.POST, "/", headers);
    byte[] userMetadata = RestUtils.buildUserMetadata(restRequest.getArgs());
    Map<String, String> userMetadataMap = RestUtils.buildUserMetadata(userMetadata);
    assertEquals("Total number of entries doesnt match ", inputUserMetadata.size(), userMetadataMap.size());
    for (String key : inputUserMetadata.keySet()) {
      String keyInOutputMap = RestUtils.Headers.USER_META_DATA_HEADER_PREFIX + key.substring(
          RestUtils.Headers.USER_META_DATA_HEADER_PREFIX.length());
      assertTrue("Key " + keyInOutputMap + " not found in input user metadata",
          userMetadataMap.containsKey(keyInOutputMap));
      assertEquals("Values didn't match for key " + key, inputUserMetadata.get(key),
          userMetadataMap.get(keyInOutputMap));
    }
  }
Verifies that a request with headers defined by {@code headers} builds UserMetadata successfully and
matches the values with those in {@code headers}.
@param headers the headers that need to go with the request that is used to construct the User Metadata
@throws Exception
ambry-api/src/test/java/com/github/ambry/rest/RestUtilsTest.java