Versions of artifact au.com.dius:pact-jvm-provider_2.11

pact-jvm-provider_2.11

Pact provider ============= sub project of https://github.com/DiUS/pact-jvm The pact provider is responsible for verifying that an API provider adheres to a number of pacts authored by its clients This library provides the basic tools required to automate the process, and should be usable on its own in many instances. Framework and build tool specific bindings will be provided in separate libraries that build on top of this core functionality. ### Provider State Before each interaction is executed, the provider under test will have the opportunity to enter a state. Generally the state maps to a set of fixture data for mocking out services that the provider is a consumer of (they will have their own pacts) The pact framework will instruct the test server to enter that state by sending: POST "${config.stateChangeUrl.url}/setup" { "state" : "${interaction.stateName}" } ### An example of running provider verification with junit This example uses Groovy, JUnit 4 and Hamcrest matchers to run the provider verification. As the provider service is a DropWizard application, it uses the DropwizardAppRule to startup the service before running any test. **Warning:** It only grabs the first interaction from the pact file with the consumer, where there could be many. (This could possibly be solved with a parameterized test) ```groovy class ReadmeExamplePactJVMProviderJUnitTest { @ClassRule public static TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>( TestDropwizardApplication.class, ResourceHelpers.resourceFilePath("dropwizard/test-config.yaml")) private static ProviderInfo serviceProvider private static Pact<RequestResponseInteraction> testConsumerPact private static ConsumerInfo consumer @BeforeClass static void setupProvider() { serviceProvider = new ProviderInfo("Dropwizard App") serviceProvider.setProtocol("http") serviceProvider.setHost("localhost") serviceProvider.setPort(8080) serviceProvider.setPath("/") consumer = new ConsumerInfo() consumer.setName("test_consumer") consumer.setPactSource(new UrlSource( ReadmeExamplePactJVMProviderJUnitTest.getResource("/pacts/zoo_app-animal_service.json").toString())) testConsumerPact = PactReader.loadPact(consumer.getPactSource()) as Pact<RequestResponseInteraction> } @Test void runConsumerPacts() { // grab the first interaction from the pact with consumer Interaction interaction = testConsumerPact.interactions.get(0) // setup the verifier ProviderVerifier verifier = setupVerifier(interaction, serviceProvider, consumer) // setup any provider state // setup the client and interaction to fire against the provider ProviderClient client = new ProviderClient(serviceProvider, new HttpClientFactory()) Map<String, Object> failures = new HashMap<>() verifier.verifyResponseFromProvider(serviceProvider, interaction, interaction.getDescription(), failures, client) if (!failures.isEmpty()) { verifier.displayFailures(failures) } // Assert all good assertThat(failures, is(empty())) } private ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) { ProviderVerifier verifier = new ProviderVerifier() verifier.initialiseReporters(provider) verifier.reportVerificationForConsumer(consumer, provider) if (!interaction.getProviderStates().isEmpty()) { for (ProviderState providerState: interaction.getProviderStates()) { verifier.reportStateForInteraction(providerState.getName(), provider, consumer, true) } } verifier.reportInteractionDescription(interaction) return verifier } } ``` ### An example of running provider verification with spock This example uses groovy and spock to run the provider verification

Artifact Version Name Latest uploaded at
3.5.24 pact-jvm-provider_2.11 2018-11-04 08:33:23 UTC
3.5.23 pact-jvm-provider_2.11 2018-09-23 07:32:58 UTC
3.5.22 pact-jvm-provider_2.11 2018-09-09 05:03:28 UTC
3.5.21 pact-jvm-provider_2.11 2018-08-12 06:36:56 UTC
3.5.20 pact-jvm-provider_2.11 2018-07-28 09:15:59 UTC
3.5.19 pact-jvm-provider_2.11 2018-07-10 09:49:46 UTC
3.5.18 pact-jvm-provider_2.11 2018-06-17 08:29:19 UTC
3.5.17 pact-jvm-provider_2.11 2018-06-03 06:29:40 UTC
3.5.16 pact-jvm-provider_2.11 2018-05-06 11:05:28 UTC
3.5.15 pact-jvm-provider_2.11 2018-04-22 06:57:17 UTC
2.4.20 pact-jvm-provider_2.11 2018-04-14 12:06:35 UTC
3.5.14 pact-jvm-provider_2.11 2018-03-19 03:44:02 UTC
3.5.13 pact-jvm-provider_2.11 2018-02-22 21:16:37 UTC
3.5.12 pact-jvm-provider_2.11 2018-01-27 01:53:49 UTC
3.5.11 pact-jvm-provider_2.11 2017-12-22 00:28:33 UTC
3.5.10 pact-jvm-provider_2.11 2017-11-21 22:01:57 UTC
3.5.9 pact-jvm-provider_2.11 2017-11-15 04:09:56 UTC
3.5.8 pact-jvm-provider_2.11 2017-10-13 02:46:26 UTC
3.5.7-jre7.0 pact-jvm-provider_2.11 2017-10-03 05:55:51 UTC
3.5.7 pact-jvm-provider_2.11 2017-10-03 00:52:16 UTC
3.5.6-jre7.0 pact-jvm-provider_2.11 2017-09-28 05:20:57 UTC
3.5.6 pact-jvm-provider_2.11 2017-09-27 02:21:04 UTC
3.5.5-jre7.0 pact-jvm-provider_2.11 2017-09-14 02:41:44 UTC
3.5.5 pact-jvm-provider_2.11 2017-09-11 23:16:59 UTC
3.5.4-jre7.0 pact-jvm-provider_2.11 2017-08-19 08:03:17 UTC
3.5.4 pact-jvm-provider_2.11 2017-08-18 05:41:44 UTC
2.4.19 pact-jvm-provider_2.11 2017-08-17 00:10:19 UTC
3.5.3-jre7.0 pact-jvm-provider_2.11 2017-08-10 00:34:34 UTC
3.5.3 pact-jvm-provider_2.11 2017-08-06 08:03:21 UTC
3.5.2 pact-jvm-provider_2.11 2017-07-12 01:15:32 UTC