use of au.com.dius.pact.consumer.PactVerification in project pact-jvm by DiUS.
the class PactProviderHttpsTest method runTest.
@Test
@PactVerification(value = "test_provider")
public void runTest() throws IOException {
LOGGER.info("Config: " + mockTestProvider.getConfig());
MockHttpsProviderConfig config = (MockHttpsProviderConfig) mockTestProvider.getConfig();
LOGGER.info("Config Cert: " + config.getHttpsCertificate().certificate());
Assert.assertEquals(new ConsumerHttpsClient(mockTestProvider.getConfig().url()).options("/second"), 200);
Map expectedResponse = new HashMap();
expectedResponse.put("responsetest", true);
expectedResponse.put("name", "harry");
assertEquals(new ConsumerHttpsClient(mockTestProvider.getConfig().url()).getAsMap("/", ""), expectedResponse);
}
use of au.com.dius.pact.consumer.PactVerification 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.PactVerification 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.PactVerification in project pact-jvm by DiUS.
the class ArticlesTest method testArticles.
@PactVerification("ArticlesProvider")
@Test
public void testArticles() throws IOException {
ArticlesRestClient providerRestClient = new ArticlesRestClient();
providerRestClient.getArticles("http://localhost:1234");
}
use of au.com.dius.pact.consumer.PactVerification in project pact-jvm by DiUS.
the class PactMultiProviderTest method provider1Fails.
@Test
@PactVerification(value = { "test_provider", "test_provider2" })
public void provider1Fails() throws IOException, InterruptedException {
mockTestProvider.validateResultWith((result, t) -> {
assertThat(t, is(instanceOf(AssertionError.class)));
assertThat(t.getMessage(), startsWith("The following mismatched requests occurred:\nUnexpected Request:\n\tmethod: GET\n\tpath: /abc"));
assertThat(result, is(instanceOf(PactVerificationResult.Mismatches.class)));
PactVerificationResult.Mismatches error = (PactVerificationResult.Mismatches) result;
assertThat(error.getMismatches(), hasSize(1));
PactVerificationResult result1 = error.getMismatches().get(0);
assertThat(result1, is(instanceOf(PactVerificationResult.UnexpectedRequest.class)));
PactVerificationResult.UnexpectedRequest unexpectedRequest = (PactVerificationResult.UnexpectedRequest) result1;
assertThat(unexpectedRequest.getRequest().getPath(), is("/abc"));
});
doTest("/abc", NAME_LARRY_JSON);
}
Aggregations