Search in sources :

Example 1 with FindRequestsResult

use of com.github.tomakehurst.wiremock.verification.FindRequestsResult in project wiremock by wiremock.

the class FindRequestsTask method execute.

@Override
public ResponseDefinition execute(Admin admin, Request request, PathParams pathParams) {
    RequestPattern requestPattern = Json.read(request.getBodyAsString(), RequestPattern.class);
    FindRequestsResult result = admin.findRequestsMatching(requestPattern);
    return responseDefinition().withStatus(HTTP_OK).withBody(Json.write(result)).withHeader("Content-Type", "application/json").build();
}
Also used : FindRequestsResult(com.github.tomakehurst.wiremock.verification.FindRequestsResult) RequestPattern(com.github.tomakehurst.wiremock.matching.RequestPattern)

Example 2 with FindRequestsResult

use of com.github.tomakehurst.wiremock.verification.FindRequestsResult in project chutney by chutney-testing.

the class HttpsListenerTask method execute.

@Override
public TaskExecutionResult execute() {
    FindRequestsResult result = httpsServer.findRequestsMatching(RequestPatternBuilder.newRequestPattern(RequestMethod.fromString(verb), WireMock.urlMatching(uri)).build());
    int requestReceived = result.getRequests().size();
    if (requestReceived < expectedMessageCount) {
        logger.error("Expected " + expectedMessageCount + " message(s). Receive only " + requestReceived + " message(s)");
        return TaskExecutionResult.ko();
    }
    httpsServer.resetRequests();
    return TaskExecutionResult.ok(toOutputs(result.getRequests()));
}
Also used : FindRequestsResult(com.github.tomakehurst.wiremock.verification.FindRequestsResult)

Aggregations

FindRequestsResult (com.github.tomakehurst.wiremock.verification.FindRequestsResult)2 RequestPattern (com.github.tomakehurst.wiremock.matching.RequestPattern)1