Search in sources :

Example 11 with PactVerification

use of au.com.dius.pact.consumer.PactVerification in project pact-jvm by DiUS.

the class PactProviderHttpsKeystoreTest method testSslHandshakeException.

@Test(expected = SSLHandshakeException.class)
@PactVerification(value = "test_provider")
public void testSslHandshakeException() throws IOException {
    testKeystoreHappyPath();
    new ConsumerHttpsClient(mockTestProvider.getConfig().url()).getAsMap("/", "");
}
Also used : ConsumerHttpsClient(au.com.dius.pact.consumer.exampleclients.ConsumerHttpsClient) PactVerification(au.com.dius.pact.consumer.PactVerification) Test(org.junit.Test)

Example 12 with PactVerification

use of au.com.dius.pact.consumer.PactVerification in project pact-jvm by DiUS.

the class PactProviderHttpsTest method runTestWithUserCodeFailure.

@Test(expected = AssertionError.class)
@PactVerification("test_provider")
public void runTestWithUserCodeFailure() throws IOException {
    Assert.assertEquals(new ConsumerHttpsClient(mockTestProvider.getConfig().url()).options("/second"), 200);
    Map expectedResponse = new HashMap();
    expectedResponse.put("responsetest", true);
    expectedResponse.put("name", "fred");
    assertEquals(new ConsumerHttpsClient(mockTestProvider.getConfig().url()).getAsMap("/", ""), expectedResponse);
}
Also used : ConsumerHttpsClient(au.com.dius.pact.consumer.exampleclients.ConsumerHttpsClient) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) PactVerification(au.com.dius.pact.consumer.PactVerification) Test(org.junit.Test)

Example 13 with PactVerification

use of au.com.dius.pact.consumer.PactVerification 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)

Example 14 with PactVerification

use of au.com.dius.pact.consumer.PactVerification in project pact-jvm by DiUS.

the class PactProviderTest method runTest.

@Test
@PactVerification(value = "test_provider")
public void runTest() throws IOException {
    Assert.assertEquals(new ConsumerClient(mockTestProvider.getUrl()).options("/second"), 200);
    Map expectedResponse = new HashMap();
    expectedResponse.put("responsetest", true);
    expectedResponse.put("name", "harry");
    assertEquals(new ConsumerClient(mockTestProvider.getUrl()).getAsMap("/", ""), expectedResponse);
}
Also used : ConsumerClient(au.com.dius.pact.consumer.exampleclients.ConsumerClient) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) PactVerification(au.com.dius.pact.consumer.PactVerification) Test(org.junit.Test)

Example 15 with PactVerification

use of au.com.dius.pact.consumer.PactVerification in project pact-jvm by DiUS.

the class PactProviderWithMultipleFragmentsTest method runTestWithFragment1.

@Test
@PactVerification(value = "test_provider", fragment = "createFragment")
public void runTestWithFragment1() throws IOException {
    Assert.assertEquals(new ConsumerClient(mockTestProvider.getUrl()).options("/second"), 200);
    Map expectedResponse = new HashMap();
    expectedResponse.put("responsetest", true);
    expectedResponse.put("name", "harry");
    assertEquals(new ConsumerClient(mockTestProvider.getUrl()).getAsMap("/", ""), expectedResponse);
}
Also used : ConsumerClient(au.com.dius.pact.consumer.exampleclients.ConsumerClient) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) PactVerification(au.com.dius.pact.consumer.PactVerification) Test(org.junit.Test)

Aggregations

PactVerification (au.com.dius.pact.consumer.PactVerification)18 Test (org.junit.Test)18 HashMap (java.util.HashMap)8 Map (java.util.Map)8 ConsumerClient (au.com.dius.pact.consumer.exampleclients.ConsumerClient)7 PactVerificationResult (au.com.dius.pact.consumer.PactVerificationResult)5 ConsumerHttpsClient (au.com.dius.pact.consumer.exampleclients.ConsumerHttpsClient)3 RequestPartMismatch (au.com.dius.pact.model.RequestPartMismatch)2 ArticlesRestClient (au.com.dius.pact.consumer.exampleclients.ArticlesRestClient)1 MockHttpsKeystoreProviderConfig (au.com.dius.pact.model.MockHttpsKeystoreProviderConfig)1 MockHttpsProviderConfig (au.com.dius.pact.model.MockHttpsProviderConfig)1 Request (au.com.dius.pact.model.Request)1 File (java.io.File)1 Response (javax.ws.rs.core.Response)1 HttpResponse (org.apache.http.HttpResponse)1 EidasCountryDto (uk.gov.ida.hub.policy.domain.EidasCountryDto)1 SessionId (uk.gov.ida.hub.policy.domain.SessionId)1