@Test
  public void testBlobIdInRequestHeader() {
    String prefixToRemove = "media";
    JSONObject headers = new JSONObject();
    String blobId = TestUtils.getRandomString(10);
    // we purposely add prefix and sub resource into blob id string in request header
    headers.putOpt(RestUtils.Headers.BLOB_ID,
        prefixToRemove + "/" + CLUSTER_NAME + "/" + blobId + "/" + RestUtils.SubResource.Segment);

    // test when operationOrBlobId is specified in url, then this operationOrBlobId should show up in expected RequestPath
    String path = prefixToRemove + "/" + CLUSTER_NAME + "/" + Operations.GET_SIGNED_URL;
    RequestPath expectedRequestPath =
        new RequestPath(prefixToRemove, CLUSTER_NAME, "/" + Operations.GET_SIGNED_URL, "/" + Operations.GET_SIGNED_URL,
            null, NO_BLOB_SEGMENT_IDX_SPECIFIED);
    parseRequestPathAndVerify(path, Collections.singletonList(prefixToRemove), CLUSTER_NAME, expectedRequestPath,
        headers);

    // test when operationOrBlobId is not specified in url and blob id is provided in request header, we verify that
    // RequestPath will take the updated "x-ambry-blob-id" header as operationOrBlobId.
    path = prefixToRemove + "/" + CLUSTER_NAME;
    // the operationOrBlobId in expected request path should be pure blob id without any prefix or SubResource.
    expectedRequestPath =
        new RequestPath(prefixToRemove, CLUSTER_NAME, "", "/" + blobId, null, NO_BLOB_SEGMENT_IDX_SPECIFIED);
    parseRequestPathAndVerify(path, Collections.singletonList(prefixToRemove), CLUSTER_NAME, expectedRequestPath,
        headers);
  }
Test that blob id string (with prefix and sub-resource) is specified in request header. The {@link RequestPath#parse(RestRequest, List, String)}
should correctly remove prefix, sub-resource and use pure blob id to update request header.
ambry-api/src/test/java/com/github/ambry/rest/RequestPathTest.java