use of au.com.dius.pact.consumer.junit.exampleclients.ConsumerClient 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);
}
use of au.com.dius.pact.consumer.junit.exampleclients.ConsumerClient 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.exampleclients.ConsumerClient in project pact-jvm by DiUS.
the class PactConsumer400Test method runTestAndHandleTheException.
@Test
@PactVerification("test_provider")
public void runTestAndHandleTheException() throws IOException {
try {
new ConsumerClient("http://localhost:" + rule.getPort()).getAsMap("/does-not-exist", "");
fail("Should have thrown an exception");
} catch (HttpResponseException e) {
// correct behaviour
}
}
use of au.com.dius.pact.consumer.junit.exampleclients.ConsumerClient in project pact-jvm by DiUS.
the class PactDslJsonBodyTest method runTest.
@Override
protected void runTest(MockServer mockServer, PactTestExecutionContext context) {
Map response;
try {
response = new ConsumerClient(mockServer.getUrl()).getAsMap("/", "");
} catch (Exception e) {
throw new RuntimeException(e);
}
Map<String, Object> object2 = (Map<String, Object>) response.get("2");
assertThat(object2, hasKey("test"));
assertThat(object2.get("test"), is(nullValue()));
}
Aggregations