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

    return Json.read(body, FindNearMissesResult.class);
  }
Esempio n. 3
0
  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);
  }
Esempio n. 4
0
 @Override
 public FindNearMissesResult findNearMissesForUnmatchedRequests() {
   String body =
       getJsonAssertOkAndReturnBody(urlFor(FindNearMissesForUnmatchedTask.class), HTTP_OK);
   return Json.read(body, FindNearMissesResult.class);
 }
Esempio n. 5
0
 @Override
 public ListStubMappingsResult listAllStubMappings() {
   String body = getJsonAssertOkAndReturnBody(urlFor(RootTask.class), HTTP_OK);
   return Json.read(body, ListStubMappingsResult.class);
 }