public static RestRequest createMockRequestWithMethod(RestMethod restMethod, String uri, long bytesReceived)
      throws RestServiceException {
    RestRequest restRequest = mock(RestRequest.class);
    when(restRequest.getRestMethod()).thenReturn(restMethod);
    when(restRequest.getBlobBytesReceived()).thenReturn(bytesReceived);
    when(restRequest.getBytesReceived()).thenReturn(bytesReceived);
    if (restMethod == RestMethod.POST) {
      when(restRequest.getUri()).thenReturn("/");
      when(restRequest.getPath()).thenReturn("/");
    } else {
      when(restRequest.getUri()).thenReturn(uri);
      when(restRequest.getPath()).thenReturn(uri);
    }
    RequestPath requestPath = RequestPath.parse(restRequest, null, "ambry-test");
    if (restMethod == RestMethod.PUT && bytesReceived != -1) {
      requestPath =
          RequestPath.parse("/" + Operations.NAMED_BLOB, Collections.emptyMap(), Collections.emptyList(), "ambry-test");
    }
    Map<String, Object> args = new HashMap<>();
    args.put(RestUtils.InternalKeys.REQUEST_PATH, requestPath);
    when(restRequest.getArgs()).thenReturn(args);
    return restRequest;
  }
Creates a mock {@link RestRequest} object for test.
@param restMethod {@link RestMethod} of the RestRequest.
@param bytesReceived number of bytes received in the request.
@return RestRequest object.
ambry-test-utils/src/main/java/com/github/ambry/quota/CostPolicyTestUtils.java