示例#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);
 }
示例#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);
  }
示例#3
0
 @Override
 public VerificationResult countRequestsMatching(RequestPattern requestPattern) {
   String body =
       postJsonAssertOkAndReturnBody(
           urlFor(GetRequestCountTask.class), Json.write(requestPattern), HTTP_OK);
   return VerificationResult.from(body);
 }
示例#4
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);
  }
示例#5
0
 @Override
 public void updateGlobalSettings(GlobalSettings settings) {
   postJsonAssertOkAndReturnBody(
       urlFor(GlobalSettingsUpdateTask.class), Json.write(settings), HTTP_OK);
 }
示例#6
0
 @Override
 public FindNearMissesResult findNearMissesForUnmatchedRequests() {
   String body =
       getJsonAssertOkAndReturnBody(urlFor(FindNearMissesForUnmatchedTask.class), HTTP_OK);
   return Json.read(body, FindNearMissesResult.class);
 }
示例#7
0
 @Override
 public void removeStubMapping(StubMapping stubbMapping) {
   postJsonAssertOkAndReturnBody(
       urlFor(OldRemoveStubMappingTask.class), Json.write(stubbMapping), HTTP_OK);
 }
示例#8
0
 @Override
 public void editStubMapping(StubMapping stubMapping) {
   postJsonAssertOkAndReturnBody(
       urlFor(OldEditStubMappingTask.class), Json.write(stubMapping), HTTP_NO_CONTENT);
 }
示例#9
0
 @Override
 public ListStubMappingsResult listAllStubMappings() {
   String body = getJsonAssertOkAndReturnBody(urlFor(RootTask.class), HTTP_OK);
   return Json.read(body, ListStubMappingsResult.class);
 }
示例#10
0
 @Override
 public void addStubMapping(StubMapping stubMapping) {
   postJsonAssertOkAndReturnBody(
       urlFor(NewStubMappingTask.class), Json.write(stubMapping), HTTP_CREATED);
 }
示例#11
0
 @Override
 public void addSocketAcceptDelay(RequestDelaySpec spec) {
   postJsonAssertOkAndReturnBody(urlFor(SocketDelayTask.class), Json.write(spec), HTTP_OK);
 }