use of au.com.dius.pact.consumer.exampleclients.ConsumerClient in project pact-jvm by DiUS.
the class PactProviderTest method runTestWithUserCodeFailure.
@Test
@PactVerification("test_provider")
public void runTestWithUserCodeFailure() throws IOException {
mockTestProvider.validateResultWith((result, t) -> {
assertThat(t, is(instanceOf(AssertionError.class)));
assertThat(t.getMessage(), is("Pact Test function failed with an exception: expected:" + "<{responsetest=true, name=harry}> but was:<{responsetest=true, name=fred}>"));
assertThat(result, is(instanceOf(PactVerificationResult.Error.class)));
PactVerificationResult.Error error = (PactVerificationResult.Error) result;
assertThat(error.getMockServerState(), is(instanceOf(PactVerificationResult.Ok.INSTANCE.getClass())));
assertThat(error.getError(), is(instanceOf(AssertionError.class)));
});
Assert.assertEquals(new ConsumerClient(mockTestProvider.getUrl()).options("/second"), 200);
Map expectedResponse = new HashMap();
expectedResponse.put("responsetest", true);
expectedResponse.put("name", "fred");
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 runTestWithFragment2.
@Test
@PactVerification(value = "test_provider", fragment = "createFragment2")
public void runTestWithFragment2() throws IOException {
Map expectedResponse = new HashMap();
expectedResponse.put("responsetest", true);
expectedResponse.put("name", "fred");
assertEquals(new ConsumerClient(mockTestProvider.getUrl()).getAsMap("/", ""), expectedResponse);
}
use of au.com.dius.pact.consumer.exampleclients.ConsumerClient in project pact-jvm by DiUS.
the class MissingRequestConsumerPassesTest method runTest.
@Override
protected void runTest(MockServer mockServer) 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);
}
use of au.com.dius.pact.consumer.exampleclients.ConsumerClient in project pact-jvm by DiUS.
the class UnexpectedRequestConsumerPassesTest method runTest.
@Override
protected void runTest(MockServer mockServer) 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);
consumerClient.options("/options");
}
use of au.com.dius.pact.consumer.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);
}
Aggregations