org.mockserver.model.HttpRequest.withQueryStringParameter()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中org.mockserver.model.HttpRequest.withQueryStringParameter()方法的一些代码示例,展示了HttpRequest.withQueryStringParameter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.withQueryStringParameter()方法的具体详情如下:
包路径:org.mockserver.model.HttpRequest
类名称:HttpRequest
方法名:withQueryStringParameter

HttpRequest.withQueryStringParameter介绍

[英]Adds one query string parameter to match which can specified using plain strings or regular expressions (for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
[中]添加一个查询字符串参数以匹配可以使用普通字符串或正则表达式指定的参数(有关支持的正则表达式语法的更多详细信息,请参阅http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)

代码示例

代码示例来源:origin: jamesdbloom/mockserver

/**
 * Clear expectations, logs or both that match the http
 *
 * @param httpRequest the http request that is matched against when deciding whether to clear each expectation if null all expectations are cleared
 * @param type        the type to clear, EXPECTATION, LOG or BOTH
 */
public MockServerClient clear(HttpRequest httpRequest, ClearType type) {
  sendRequest(request().withMethod("PUT").withPath(calculatePath("clear")).withQueryStringParameter("type", type.name().toLowerCase()).withBody(httpRequest != null ? httpRequestSerializer.serialize(httpRequest) : "", StandardCharsets.UTF_8));
  return clientClass.cast(this);
}

代码示例来源:origin: jamesdbloom/mockserver

/**
 * Retrieve the recorded requests that match the httpRequest parameter, use null for the parameter to retrieve all requests
 *
 * @param httpRequest the http request that is matched against when deciding whether to return each request, use null for the parameter to retrieve for all requests
 * @param format      the format to retrieve the expectations, either JAVA or JSON
 * @return an array of all requests that have been recorded by the MockServer in the order they have been received and including duplicates where the same request has been received multiple times
 */
public String retrieveRecordedRequests(HttpRequest httpRequest, Format format) {
  HttpResponse httpResponse = sendRequest(
    request()
      .withMethod("PUT")
      .withPath(calculatePath("retrieve"))
      .withQueryStringParameter("type", RetrieveType.REQUESTS.name())
      .withQueryStringParameter("format", format.name())
      .withBody(httpRequest != null ? httpRequestSerializer.serialize(httpRequest) : "", StandardCharsets.UTF_8)
  );
  return httpResponse.getBodyAsString();
}

代码示例来源:origin: jamesdbloom/mockserver

/**
   * Retrieve the active expectations match the httpRequest parameter, use null for the parameter to retrieve all expectations
   *
   * @param httpRequest the http request that is matched against when deciding whether to return each expectation, use null for the parameter to retrieve for all requests
   * @param format      the format to retrieve the expectations, either JAVA or JSON
   * @return an array of all expectations that have been setup and have not expired
   */
  public String retrieveActiveExpectations(HttpRequest httpRequest, Format format) {
    HttpResponse httpResponse = sendRequest(
      request()
        .withMethod("PUT")
        .withPath(calculatePath("retrieve"))
        .withQueryStringParameter("type", RetrieveType.ACTIVE_EXPECTATIONS.name())
        .withQueryStringParameter("format", format.name())
        .withBody(httpRequest != null ? httpRequestSerializer.serialize(httpRequest) : "", StandardCharsets.UTF_8)
    );
    return httpResponse.getBodyAsString();
  }
}

代码示例来源:origin: jamesdbloom/mockserver

/**
 * Retrieve the request-response combinations that have been recorded as a list of expectations, only those that match the httpRequest parameter are returned, use null to retrieve all requests
 *
 * @param httpRequest the http request that is matched against when deciding whether to return each request, use null for the parameter to retrieve for all requests
 * @param format      the format to retrieve the expectations, either JAVA or JSON
 * @return an array of all expectations that have been recorded by the MockServer in the order they have been received and including duplicates where the same request has been received multiple times
 */
public String retrieveRecordedExpectations(HttpRequest httpRequest, Format format) {
  HttpResponse httpResponse = sendRequest(
    request()
      .withMethod("PUT")
      .withPath(calculatePath("retrieve"))
      .withQueryStringParameter("type", RetrieveType.RECORDED_EXPECTATIONS.name())
      .withQueryStringParameter("format", format.name())
      .withBody(httpRequest != null ? httpRequestSerializer.serialize(httpRequest) : "", StandardCharsets.UTF_8)
  );
  return httpResponse.getBodyAsString();
}

代码示例来源:origin: jamesdbloom/mockserver

/**
 * Retrieve the logs associated to a specific requests, this shows all logs for expectation matching, verification, clearing, etc
 *
 * @param httpRequest the http request that is matched against when deciding whether to return each request, use null for the parameter to retrieve for all requests
 * @return all log messages recorded by the MockServer when creating expectations, matching expectations, performing verification, clearing logs, etc
 */
public String retrieveLogMessages(HttpRequest httpRequest) {
  HttpResponse httpResponse = sendRequest(
    request()
      .withMethod("PUT")
      .withPath(calculatePath("retrieve"))
      .withQueryStringParameter("type", RetrieveType.LOGS.name())
      .withBody(httpRequest != null ? httpRequestSerializer.serialize(httpRequest) : "", StandardCharsets.UTF_8)
  );
  return httpResponse.getBodyAsString();
}

代码示例来源:origin: jamesdbloom/mockserver

.withPath(calculatePath("some_path_one"))
.withHeader("some", "header")
.withQueryStringParameter("some", "parameter")
.withCookie("some", "parameter")
.withBody("some_body_one");

代码示例来源:origin: jamesdbloom/mockserver

.withPath(calculatePath("some_path.*"))
.withHeader("some", "header")
.withQueryStringParameter("some", "parameter")
.withCookie("some", "parameter")
.withBody("some_body");

代码示例来源:origin: lv.ctco.cukes/cukes-http-mock

public void addRequestQueryParameter(String queryParameterName, String queryParameterValue) {
  request.withQueryStringParameter(queryParameterName, queryParameterValue);
}

代码示例来源:origin: ctco/cukes

public void addRequestQueryParameter(String queryParameterName, String queryParameterValue) {
  request.withQueryStringParameter(queryParameterName, queryParameterValue);
}

代码示例来源:origin: org.mock-server/mockserver-client-java

/**
 * Clear expectations, logs or both that match the http
 *
 * @param httpRequest the http request that is matched against when deciding whether to clear each expectation if null all expectations are cleared
 * @param type        the type to clear, EXPECTATION, LOG or BOTH
 */
public MockServerClient clear(HttpRequest httpRequest, ClearType type) {
  sendRequest(request().withMethod("PUT").withPath(calculatePath("clear")).withQueryStringParameter("type", type.name().toLowerCase()).withBody(httpRequest != null ? httpRequestSerializer.serialize(httpRequest) : "", StandardCharsets.UTF_8));
  return clientClass.cast(this);
}

代码示例来源:origin: org.mock-server/mockserver-client-java

/**
 * Retrieve the recorded requests that match the httpRequest parameter, use null for the parameter to retrieve all requests
 *
 * @param httpRequest the http request that is matched against when deciding whether to return each request, use null for the parameter to retrieve for all requests
 * @param format      the format to retrieve the expectations, either JAVA or JSON
 * @return an array of all requests that have been recorded by the MockServer in the order they have been received and including duplicates where the same request has been received multiple times
 */
public String retrieveRecordedRequests(HttpRequest httpRequest, Format format) {
  HttpResponse httpResponse = sendRequest(
    request()
      .withMethod("PUT")
      .withPath(calculatePath("retrieve"))
      .withQueryStringParameter("type", RetrieveType.REQUESTS.name())
      .withQueryStringParameter("format", format.name())
      .withBody(httpRequest != null ? httpRequestSerializer.serialize(httpRequest) : "", StandardCharsets.UTF_8)
  );
  return httpResponse.getBodyAsString();
}

代码示例来源:origin: org.mock-server/mockserver-client-java

/**
   * Retrieve the active expectations match the httpRequest parameter, use null for the parameter to retrieve all expectations
   *
   * @param httpRequest the http request that is matched against when deciding whether to return each expectation, use null for the parameter to retrieve for all requests
   * @param format      the format to retrieve the expectations, either JAVA or JSON
   * @return an array of all expectations that have been setup and have not expired
   */
  public String retrieveActiveExpectations(HttpRequest httpRequest, Format format) {
    HttpResponse httpResponse = sendRequest(
      request()
        .withMethod("PUT")
        .withPath(calculatePath("retrieve"))
        .withQueryStringParameter("type", RetrieveType.ACTIVE_EXPECTATIONS.name())
        .withQueryStringParameter("format", format.name())
        .withBody(httpRequest != null ? httpRequestSerializer.serialize(httpRequest) : "", StandardCharsets.UTF_8)
    );
    return httpResponse.getBodyAsString();
  }
}

代码示例来源:origin: org.mock-server/mockserver-client-java

/**
 * Retrieve the request-response combinations that have been recorded as a list of expectations, only those that match the httpRequest parameter are returned, use null to retrieve all requests
 *
 * @param httpRequest the http request that is matched against when deciding whether to return each request, use null for the parameter to retrieve for all requests
 * @param format      the format to retrieve the expectations, either JAVA or JSON
 * @return an array of all expectations that have been recorded by the MockServer in the order they have been received and including duplicates where the same request has been received multiple times
 */
public String retrieveRecordedExpectations(HttpRequest httpRequest, Format format) {
  HttpResponse httpResponse = sendRequest(
    request()
      .withMethod("PUT")
      .withPath(calculatePath("retrieve"))
      .withQueryStringParameter("type", RetrieveType.RECORDED_EXPECTATIONS.name())
      .withQueryStringParameter("format", format.name())
      .withBody(httpRequest != null ? httpRequestSerializer.serialize(httpRequest) : "", StandardCharsets.UTF_8)
  );
  return httpResponse.getBodyAsString();
}

代码示例来源:origin: org.mock-server/mockserver-client-java

/**
 * Retrieve the logs associated to a specific requests, this shows all logs for expectation matching, verification, clearing, etc
 *
 * @param httpRequest the http request that is matched against when deciding whether to return each request, use null for the parameter to retrieve for all requests
 * @return all log messages recorded by the MockServer when creating expectations, matching expectations, performing verification, clearing logs, etc
 */
public String retrieveLogMessages(HttpRequest httpRequest) {
  HttpResponse httpResponse = sendRequest(
    request()
      .withMethod("PUT")
      .withPath(calculatePath("retrieve"))
      .withQueryStringParameter("type", RetrieveType.LOGS.name())
      .withBody(httpRequest != null ? httpRequestSerializer.serialize(httpRequest) : "", StandardCharsets.UTF_8)
  );
  return httpResponse.getBodyAsString();
}

相关文章