use of au.com.dius.pact.consumer.exampleclients.ConsumerClient in project pact-jvm by DiUS.
the class ExampleJavaConsumerPactTest method runTest.
@Override
protected void runTest(MockServer mockServer) throws IOException {
Assert.assertEquals(new ConsumerClient(mockServer.getUrl()).options("/second"), 200);
Map expectedResponse = new HashMap();
expectedResponse.put("responsetest", true);
expectedResponse.put("name", "harry");
assertEquals(new ConsumerClient(mockServer.getUrl()).getAsMap("/", ""), expectedResponse);
assertEquals(new ConsumerClient(mockServer.getUrl()).options("/second"), 200);
}
use of au.com.dius.pact.consumer.exampleclients.ConsumerClient in project pact-jvm by DiUS.
the class PactMultiProviderTest method doTest.
private void doTest(String path, String json) throws IOException {
ConsumerClient consumerClient = new ConsumerClient(mockTestProvider.getUrl());
consumerClient.options("/second");
try {
consumerClient.getAsMap(path, "");
} catch (IOException e) {
}
try {
new ConsumerClient(mockTestProvider2.getUrl()).putAsMap("/", json);
} catch (IOException e) {
}
}
use of au.com.dius.pact.consumer.exampleclients.ConsumerClient 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);
}
use of au.com.dius.pact.consumer.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);
}
use of au.com.dius.pact.consumer.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);
}
Aggregations