Search in sources :

Example 1 with NotMatchedRenderer

use of com.github.tomakehurst.wiremock.verification.notmatched.NotMatchedRenderer in project wiremock by wiremock.

the class NotMatchedPageAcceptanceTest method supportsCustomNoMatchRenderer.

@Test
public void supportsCustomNoMatchRenderer() {
    configure(wireMockConfig().notMatchedRenderer(new NotMatchedRenderer() {

        @Override
        protected ResponseDefinition render(Admin admin, Request request) {
            return ResponseDefinitionBuilder.responseDefinition().withStatus(403).withBody("No you don't!").build();
        }
    }));
    WireMockResponse response = testClient.get("/should-not-match");
    assertThat(response.statusCode(), is(403));
    assertThat(response.content(), is("No you don't!"));
}
Also used : WireMockResponse(com.github.tomakehurst.wiremock.testsupport.WireMockResponse) NotMatchedRenderer(com.github.tomakehurst.wiremock.verification.notmatched.NotMatchedRenderer) Request(com.github.tomakehurst.wiremock.http.Request) Admin(com.github.tomakehurst.wiremock.core.Admin) Test(org.junit.jupiter.api.Test)

Aggregations

Admin (com.github.tomakehurst.wiremock.core.Admin)1 Request (com.github.tomakehurst.wiremock.http.Request)1 WireMockResponse (com.github.tomakehurst.wiremock.testsupport.WireMockResponse)1 NotMatchedRenderer (com.github.tomakehurst.wiremock.verification.notmatched.NotMatchedRenderer)1 Test (org.junit.jupiter.api.Test)1