use of com.github.tomakehurst.wiremock.extension.PostServeAction 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.PostServeAction in project wiremock by wiremock.
the class JettyHttpServerTest method init.
@BeforeEach
public void init() {
Admin admin = Mockito.mock(Admin.class);
adminRequestHandler = new AdminRequestHandler(AdminRoutes.defaults(), admin, new BasicResponseRenderer(), new NoAuthenticator(), false, Collections.<RequestFilter>emptyList());
stubRequestHandler = new StubRequestHandler(Mockito.mock(StubServer.class), Mockito.mock(ResponseRenderer.class), admin, Collections.<String, PostServeAction>emptyMap(), Mockito.mock(RequestJournal.class), Collections.<RequestFilter>emptyList(), false);
}
use of com.github.tomakehurst.wiremock.extension.PostServeAction in project wiremock by wiremock.
the class StubRequestHandlerTest method init.
@BeforeEach
public void init() {
stubServer = mock(StubServer.class);
responseRenderer = mock(ResponseRenderer.class);
httpResponder = new MockHttpResponder();
admin = mock(Admin.class);
requestJournal = mock(RequestJournal.class);
requestHandler = new StubRequestHandler(stubServer, responseRenderer, admin, Collections.<String, PostServeAction>emptyMap(), requestJournal, Collections.<RequestFilter>emptyList(), false);
}
use of com.github.tomakehurst.wiremock.extension.PostServeAction in project wiremock by wiremock.
the class PostServeActionExtensionTest method providesServeEventWithResponseFieldPopulated.
@Test
public void providesServeEventWithResponseFieldPopulated() throws InterruptedException {
final AtomicInteger finalStatus = new AtomicInteger();
initWithOptions(options().dynamicPort().extensions(new PostServeAction() {
@Override
public String getName() {
return "response-field-test";
}
@Override
public void doGlobalAction(ServeEvent serveEvent, Admin admin) {
if (serveEvent.getResponse() != null) {
finalStatus.set(serveEvent.getResponse().getStatus());
}
}
}));
wm.stubFor(get(urlPathEqualTo("/response-status")).willReturn(aResponse().withStatus(418)));
client.get("/response-status");
await().atMost(5, SECONDS).until(getValue(finalStatus), is(418));
}
Aggregations