Search in sources :

Example 1 with Request

use of au.com.dius.pact.model.Request in project pact-jvm by DiUS.

the class PactProviderTest method runTestWithPactError.

@Test
@PactVerification(value = "test_provider")
public void runTestWithPactError() throws IOException {
    mockTestProvider.validateResultWith((result, t) -> {
        assertThat(t, is(instanceOf(AssertionError.class)));
        assertThat(t.getMessage(), startsWith("The following requests were not received:\n" + "\tmethod: GET\n" + "\tpath: /"));
        assertThat(result, is(instanceOf(PactVerificationResult.ExpectedButNotReceived.class)));
        PactVerificationResult.ExpectedButNotReceived error = (PactVerificationResult.ExpectedButNotReceived) result;
        assertThat(error.getExpectedRequests(), hasSize(1));
        Request request = error.getExpectedRequests().get(0);
        assertThat(request.getPath(), is("/"));
    });
    Assert.assertEquals(new ConsumerClient(mockTestProvider.getUrl()).options("/second"), 200);
}
Also used : ConsumerClient(au.com.dius.pact.consumer.exampleclients.ConsumerClient) Request(au.com.dius.pact.model.Request) PactVerificationResult(au.com.dius.pact.consumer.PactVerificationResult) PactVerification(au.com.dius.pact.consumer.PactVerification) Test(org.junit.Test)

Aggregations

PactVerification (au.com.dius.pact.consumer.PactVerification)1 PactVerificationResult (au.com.dius.pact.consumer.PactVerificationResult)1 ConsumerClient (au.com.dius.pact.consumer.exampleclients.ConsumerClient)1 Request (au.com.dius.pact.model.Request)1 Test (org.junit.Test)1