use of com.github.tomakehurst.wiremock.extension.PostServeActionDefinition in project spring-cloud-contract by spring-cloud.
the class DefaultWireMockStubPostProcessorTests method thenPostServerActionWasSet.
private void thenPostServerActionWasSet(StubMapping result) {
then(result.getRequest().getMethod().getName()).isEqualTo("GET");
then(result.getResponse().getStatus()).isEqualTo(200);
then(result.getResponse().getBody()).isEqualTo("pong");
then(result.getPostServeActions().stream().map(a -> a.getName()).collect(Collectors.toList())).contains("webhook");
PostServeActionDefinition definition = result.getPostServeActions().stream().filter(a -> a.getName().equals("webhook")).findFirst().orElseThrow(() -> new AssertionError("No webhook action found"));
then(definition.getParameters().getString("method")).isEqualTo("POST");
}
use of com.github.tomakehurst.wiremock.extension.PostServeActionDefinition in project wiremock by wiremock.
the class StubRequestHandler method afterResponseSent.
@Override
protected void afterResponseSent(ServeEvent serveEvent, Response response) {
for (PostServeAction postServeAction : postServeActions.values()) {
postServeAction.doGlobalAction(serveEvent, admin);
}
List<PostServeActionDefinition> postServeActionDefs = serveEvent.getPostServeActions();
for (PostServeActionDefinition postServeActionDef : postServeActionDefs) {
PostServeAction action = postServeActions.get(postServeActionDef.getName());
if (action != null) {
Parameters parameters = postServeActionDef.getParameters();
action.doAction(serveEvent, admin, parameters);
} else {
notifier().error("No extension was found named \"" + postServeActionDef.getName() + "\"");
}
}
}
use of com.github.tomakehurst.wiremock.extension.PostServeActionDefinition in project wiremock by wiremock.
the class BasicMappingBuilder method withPostServeAction.
@Override
public <P> BasicMappingBuilder withPostServeAction(String extensionName, P parameters) {
Parameters params = parameters instanceof Parameters ? (Parameters) parameters : Parameters.of(parameters);
postServeActions.add(new PostServeActionDefinition(extensionName, params));
return this;
}
Aggregations