Search in sources :

Example 6 with PactVerification

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

the class PactProviderWithMultipleFragmentsTest method runTestWithFragment2.

@Test
@PactVerification(value = "test_provider2", fragment = "createFragment2")
public void runTestWithFragment2() throws IOException {
    Map expectedResponse = new HashMap();
    expectedResponse.put("responsetest", true);
    expectedResponse.put("name", "fred");
    assertEquals(new ConsumerClient(mockTestProvider2.getUrl()).getAsMap("/", ""), expectedResponse);
}
Also used : ConsumerClient(au.com.dius.pact.consumer.junit.exampleclients.ConsumerClient) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) PactVerification(au.com.dius.pact.consumer.junit.PactVerification) Test(org.junit.Test)

Example 7 with PactVerification

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

the class ArticlesTest method testArticles.

@PactVerification("ArticlesProvider")
@Test
public void testArticles() throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
    ArticlesRestClient providerRestClient = new ArticlesRestClient();
    providerRestClient.getArticles("http://localhost:1234");
}
Also used : ArticlesRestClient(au.com.dius.pact.consumer.junit.exampleclients.ArticlesRestClient) PactVerification(au.com.dius.pact.consumer.junit.PactVerification) Test(org.junit.Test)

Example 8 with PactVerification

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

the class ExampleJavaConsumerPactRuleTest method runTest.

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

Example 9 with PactVerification

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

the class ExampleServiceConsumerTest method testBookCar.

@PactVerification("CarBookingProvider")
@Test
public void testBookCar() throws IOException, ParseException {
    ProviderCarBookingRestClient providerRestClient = new ProviderCarBookingRestClient();
    ClassicHttpResponse response = providerRestClient.placeOrder(provider.getUrl(), DATA_A_ID, DATA_B_ID, "2015-03-15");
    Assert.assertEquals(201, response.getCode());
    String orderDetails = EntityUtils.toString(response.getEntity());
    Assert.assertEquals("{\"id\":\"ORDER_ID_123456\"}", orderDetails);
}
Also used : ClassicHttpResponse(org.apache.hc.core5.http.ClassicHttpResponse) PactVerification(au.com.dius.pact.consumer.junit.PactVerification) Test(org.junit.Test)

Example 10 with PactVerification

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

the class V3PactProviderTest method runTest.

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

Aggregations

PactVerification (au.com.dius.pact.consumer.junit.PactVerification)20 Test (org.junit.Test)20 Map (java.util.Map)10 ConsumerClient (au.com.dius.pact.consumer.junit.exampleclients.ConsumerClient)9 HashMap (java.util.HashMap)8 PactVerificationResult (au.com.dius.pact.consumer.PactVerificationResult)5 ConsumerHttpsClient (au.com.dius.pact.consumer.junit.exampleclients.ConsumerHttpsClient)3 ArticlesRestClient (au.com.dius.pact.consumer.junit.exampleclients.ArticlesRestClient)2 BodyMismatch (au.com.dius.pact.core.matchers.BodyMismatch)2 Mismatch (au.com.dius.pact.core.matchers.Mismatch)2 MockHttpsKeystoreProviderConfig (au.com.dius.pact.consumer.model.MockHttpsKeystoreProviderConfig)1 IRequest (au.com.dius.pact.core.model.IRequest)1 File (java.io.File)1 ClassicHttpResponse (org.apache.hc.core5.http.ClassicHttpResponse)1