Search in sources :

Example 1 with IRequest

use of au.com.dius.pact.core.model.IRequest 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));
        IRequest 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.junit.exampleclients.ConsumerClient) IRequest(au.com.dius.pact.core.model.IRequest) PactVerificationResult(au.com.dius.pact.consumer.PactVerificationResult) PactVerification(au.com.dius.pact.consumer.junit.PactVerification) Test(org.junit.Test)

Aggregations

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