/** * 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); }
/** * 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(); }
/** * 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(); } }
/** * 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(); }
/** * 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(); }
.withPath(calculatePath("some_path_one")) .withHeader("some", "header") .withQueryStringParameter("some", "parameter") .withCookie("some", "parameter") .withBody("some_body_one");
.withPath(calculatePath("some_path.*")) .withHeader("some", "header") .withQueryStringParameter("some", "parameter") .withCookie("some", "parameter") .withBody("some_body");
public void addRequestQueryParameter(String queryParameterName, String queryParameterValue) { request.withQueryStringParameter(queryParameterName, queryParameterValue); }
public void addRequestQueryParameter(String queryParameterName, String queryParameterValue) { request.withQueryStringParameter(queryParameterName, queryParameterValue); }
/** * 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); }
/** * 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(); }
/** * 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(); } }
/** * 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(); }
/** * 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(); }