Search in sources :

Example 1 with ConsumerClient

use of au.com.dius.pact.consumer.junit.exampleclients.ConsumerClient 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.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 2 with ConsumerClient

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

the class MissingRequestConsumerPassesTest method runTest.

@Override
protected void runTest(MockServer mockServer, PactTestExecutionContext context) throws IOException {
    Map<String, Object> expectedResponse = new HashMap<String, Object>();
    expectedResponse.put("responsetest", true);
    expectedResponse.put("name", "fred");
    ConsumerClient consumerClient = new ConsumerClient(mockServer.getUrl());
    assertEquals(consumerClient.getAsMap("/", ""), expectedResponse);
}
Also used : ConsumerClient(au.com.dius.pact.consumer.junit.exampleclients.ConsumerClient) HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString)

Example 3 with ConsumerClient

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

the class StatusCodeMatcherPactTest method runTest.

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

Example 4 with ConsumerClient

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

the class PactProviderWithMultipleFragmentsTest method runTestWithAllFragments.

@Test
@PactVerifications({ @PactVerification(value = "test_provider", fragment = "createFragment"), @PactVerification(value = "test_provider2", fragment = "createFragment2"), @PactVerification(value = "test_provider2", fragment = "createFragment3") })
public void runTestWithAllFragments() 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);
    expectedResponse = new HashMap();
    expectedResponse.put("responsetest", true);
    expectedResponse.put("name", "fred");
    assertEquals(new ConsumerClient(mockTestProvider2.getUrl()).getAsMap("/", ""), expectedResponse);
    try {
        new ConsumerClient(mockTestProvider2.getUrl()).getAsMap("/path/2", "");
        fail();
    } catch (IOException ex) {
        ex.printStackTrace();
    // assertThat(ex.getStatusCode(), is(404));
    }
}
Also used : ConsumerClient(au.com.dius.pact.consumer.junit.exampleclients.ConsumerClient) HashMap(java.util.HashMap) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test) PactVerifications(au.com.dius.pact.consumer.junit.PactVerifications)

Example 5 with ConsumerClient

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

the class PactRuleWithRandomPortTest method runTest.

@Test
@PactVerification("test_provider")
public void runTest() throws IOException {
    Map expectedResponse = new HashMap();
    assertEquals(new ConsumerClient("http://localhost:" + rule.getPort()).getAsMap("/", ""), expectedResponse);
}
Also used : ConsumerClient(au.com.dius.pact.consumer.junit.exampleclients.ConsumerClient) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

ConsumerClient (au.com.dius.pact.consumer.junit.exampleclients.ConsumerClient)19 Map (java.util.Map)14 HashMap (java.util.HashMap)13 Test (org.junit.Test)13 PactVerification (au.com.dius.pact.consumer.junit.PactVerification)9 PactVerificationResult (au.com.dius.pact.consumer.PactVerificationResult)2 PactVerifications (au.com.dius.pact.consumer.junit.PactVerifications)2 IOException (java.io.IOException)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 IRequest (au.com.dius.pact.core.model.IRequest)1 HttpResponseException (org.apache.hc.client5.http.HttpResponseException)1