use of au.com.dius.pact.consumer.junit.PactVerifications 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));
}
}
use of au.com.dius.pact.consumer.junit.PactVerifications in project pact-jvm by DiUS.
the class PactProviderWithMultipleFragmentsTest method runTestWithBothFragments.
@Test
@PactVerifications({ @PactVerification(value = "test_provider", fragment = "createFragment"), @PactVerification(value = "test_provider2", fragment = "createFragment2") })
public void runTestWithBothFragments() 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);
}
use of au.com.dius.pact.consumer.junit.PactVerifications in project pact-jvm by DiUS.
the class PactProviderWithMultipleFragmentsTest method runTestWithPactVerificationsAndDefaultResponseValuesArePresent.
@Test
@PactVerifications({ @PactVerification(value = "test_provider2", fragment = "createFragment2") })
public void runTestWithPactVerificationsAndDefaultResponseValuesArePresent() throws IOException {
HttpResponse httpResponse = Request.get(mockTestProvider2.getUrl()).addHeader("testreqheader", "testreqheadervalue").execute().returnResponse();
assertThat(Arrays.stream(httpResponse.getHeaders("testresheader")).map(Header::getValue).collect(Collectors.toList()), is(equalTo(List.of("testresheadervalue"))));
}
Aggregations