@Override
 public FindRequestsResult findRequestsMatching(RequestPattern requestPattern) {
   String body =
       postJsonAssertOkAndReturnBody(
           urlFor(FindRequestsTask.class), Json.write(requestPattern), HTTP_OK);
   return Json.read(body, FindRequestsResult.class);
 }
  @Override
  public FindNearMissesResult findTopNearMissesFor(LoggedRequest loggedRequest) {
    String body =
        postJsonAssertOkAndReturnBody(
            urlFor(FindNearMissesForRequestTask.class), Json.write(loggedRequest), HTTP_OK);

    return Json.read(body, FindNearMissesResult.class);
  }
  private <B, R> R executeRequest(
      RequestSpec requestSpec,
      PathParams pathParams,
      B requestBody,
      Class<R> responseType,
      int expectedStatus) {
    String url =
        String.format(
            ADMIN_URL_PREFIX + requestSpec.path(pathParams), scheme, host, port, urlPathPrefix);
    RequestBuilder requestBuilder =
        RequestBuilder.create(requestSpec.method().getName()).setUri(url);

    if (requestBody != null) {
      requestBuilder.setEntity(jsonStringEntity(Json.write(requestBody)));
    }

    String responseBodyString = safelyExecuteRequest(url, expectedStatus, requestBuilder.build());

    return responseType == Void.class ? null : Json.read(responseBodyString, responseType);
  }
 @Override
 public FindNearMissesResult findNearMissesForUnmatchedRequests() {
   String body =
       getJsonAssertOkAndReturnBody(urlFor(FindNearMissesForUnmatchedTask.class), HTTP_OK);
   return Json.read(body, FindNearMissesResult.class);
 }
 @Override
 public ListStubMappingsResult listAllStubMappings() {
   String body = getJsonAssertOkAndReturnBody(urlFor(RootTask.class), HTTP_OK);
   return Json.read(body, ListStubMappingsResult.class);
 }