Download all versions of provider JAR files with all dependencies
provider from group au.com.dius.pact (version 4.4.0-beta.0)
Pact provider
=============
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 final TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(
TestDropwizardApplication, 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 = DefaultPactReader.INSTANCE.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<>()
VerificationResult result = verifier.verifyResponseFromProvider(serviceProvider, interaction,
interaction.getDescription(), failures, client)
// normally assert all good, but in this example it will fail
assertThat(failures, is(instanceOf(VerificationResult.Failed)))
verifier.displayFailures(result)
}
private ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) {
ProviderVerifier verifier = new ProviderVerifier()
verifier.initialiseReporters(provider)
verifier.reportVerificationForConsumer(consumer, provider, new UrlSource('http://example.example'))
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.
Again the provider service is a DropWizard application, and is using the DropwizardAppRule to startup the service.
This example runs all interactions using spocks Unroll feature
```groovy
class ReadmeExamplePactJVMProviderSpockSpec extends Specification {
@ClassRule @Shared
TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(TestDropwizardApplication,
ResourceHelpers.resourceFilePath('dropwizard/test-config.yaml'))
@Shared
ProviderInfo serviceProvider
ProviderVerifier verifier
def setupSpec() {
serviceProvider = new ProviderInfo('Dropwizard App')
serviceProvider.protocol = 'http'
serviceProvider.host = 'localhost'
serviceProvider.port = 8080
serviceProvider.path = '/'
serviceProvider.hasPactWith('zoo_app') { consumer ->
consumer.pactSource = new FileSource(new File(ResourceHelpers.resourceFilePath('pacts/zoo_app-animal_service.json')))
}
}
def setup() {
verifier = new ProviderVerifier()
}
def cleanup() {
// cleanup provider state
// ie. db.truncateAllTables()
}
def cleanupSpec() {
// cleanup provider
}
@Unroll
def "Provider Pact - With Consumer #consumer"() {
expect:
verifyConsumerPact(consumer) instanceof VerificationResult.Ok
where:
consumer << serviceProvider.consumers
}
private VerificationResult verifyConsumerPact(ConsumerInfo consumer) {
verifier.initialiseReporters(serviceProvider)
def result = verifier.runVerificationForConsumer([:], serviceProvider, consumer)
if (result instanceof VerificationResult.Failed) {
verifier.displayFailures([result])
}
result
}
}
```
Artifact provider
Group au.com.dius.pact
Version 4.4.0-beta.0
Last update 22. March 2022
Tags: authored setpactsource loadpact isempty path pact fire state verificationresult hashmap they resourcehelpers providerstate verifying using instruct opportunity each groovy matchers resourcefilepath object shared haspactwith grabs executed consumerinfo example result where readmeexamplepactjvmproviderjunittest verifyconsumerpact failures setupverifier services many under grab config apos spocks separate bindings solved dropwizard good post startup warning requestresponseinteraction possibly yaml static test maps this extends port final http private string pacts dropwizardconfiguration provided getresource usable provider provides responsible json client class junit getpactsource again libraries specification runconsumerpacts defaultpactreader instanceof with reportverificationforconsumer service there automate setup hamcrest tostring serviceprovider reportinteractiondescription test_consumer classrule required mocking testdropwizardapplication providerinfo number spock httpclientfactory enter providerverifier getproviderstates statename filesource fail setprotocol quot truncatealltables testrule testconsumerpact server assertthat clients getdescription against functionality tools library file sethost feature setupprovider assert setupspec zoo_app have sending could animal_service generally getname expect framework urlsource readmeexamplepactjvmproviderspockspec dropwizardapprule unroll runs first startservicerule return instance data before adheres that protocol should only host from verification localhost void runverificationforconsumer beforeclass failed tool fixture core setname cleanup true pactsource basic setport verifyresponsefromprovider instances their interactions running public parameterized displayfailures setpath consumers consumer providerclient process will statechangeurl reportstateforinteraction 8080 specific cleanupspec initialisereporters application build verifier interaction uses normally
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 6
Dependencies model, matchers, support, pactbroker, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
Group au.com.dius.pact
Version 4.4.0-beta.0
Last update 22. March 2022
Tags: authored setpactsource loadpact isempty path pact fire state verificationresult hashmap they resourcehelpers providerstate verifying using instruct opportunity each groovy matchers resourcefilepath object shared haspactwith grabs executed consumerinfo example result where readmeexamplepactjvmproviderjunittest verifyconsumerpact failures setupverifier services many under grab config apos spocks separate bindings solved dropwizard good post startup warning requestresponseinteraction possibly yaml static test maps this extends port final http private string pacts dropwizardconfiguration provided getresource usable provider provides responsible json client class junit getpactsource again libraries specification runconsumerpacts defaultpactreader instanceof with reportverificationforconsumer service there automate setup hamcrest tostring serviceprovider reportinteractiondescription test_consumer classrule required mocking testdropwizardapplication providerinfo number spock httpclientfactory enter providerverifier getproviderstates statename filesource fail setprotocol quot truncatealltables testrule testconsumerpact server assertthat clients getdescription against functionality tools library file sethost feature setupprovider assert setupspec zoo_app have sending could animal_service generally getname expect framework urlsource readmeexamplepactjvmproviderspockspec dropwizardapprule unroll runs first startservicerule return instance data before adheres that protocol should only host from verification localhost void runverificationforconsumer beforeclass failed tool fixture core setname cleanup true pactsource basic setport verifyresponsefromprovider instances their interactions running public parameterized displayfailures setpath consumers consumer providerclient process will statechangeurl reportstateforinteraction 8080 specific cleanupspec initialisereporters application build verifier interaction uses normally
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 6
Dependencies model, matchers, support, pactbroker, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
provider from group au.com.dius.pact (version 4.3.6)
Pact provider
=============
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 final TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(
TestDropwizardApplication, 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 = DefaultPactReader.INSTANCE.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<>()
VerificationResult result = verifier.verifyResponseFromProvider(serviceProvider, interaction,
interaction.getDescription(), failures, client)
// normally assert all good, but in this example it will fail
assertThat(failures, is(instanceOf(VerificationResult.Failed)))
verifier.displayFailures(result)
}
private ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) {
ProviderVerifier verifier = new ProviderVerifier()
verifier.initialiseReporters(provider)
verifier.reportVerificationForConsumer(consumer, provider, new UrlSource('http://example.example'))
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.
Again the provider service is a DropWizard application, and is using the DropwizardAppRule to startup the service.
This example runs all interactions using spocks Unroll feature
```groovy
class ReadmeExamplePactJVMProviderSpockSpec extends Specification {
@ClassRule @Shared
TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(TestDropwizardApplication,
ResourceHelpers.resourceFilePath('dropwizard/test-config.yaml'))
@Shared
ProviderInfo serviceProvider
ProviderVerifier verifier
def setupSpec() {
serviceProvider = new ProviderInfo('Dropwizard App')
serviceProvider.protocol = 'http'
serviceProvider.host = 'localhost'
serviceProvider.port = 8080
serviceProvider.path = '/'
serviceProvider.hasPactWith('zoo_app') { consumer ->
consumer.pactSource = new FileSource(new File(ResourceHelpers.resourceFilePath('pacts/zoo_app-animal_service.json')))
}
}
def setup() {
verifier = new ProviderVerifier()
}
def cleanup() {
// cleanup provider state
// ie. db.truncateAllTables()
}
def cleanupSpec() {
// cleanup provider
}
@Unroll
def "Provider Pact - With Consumer #consumer"() {
expect:
verifyConsumerPact(consumer) instanceof VerificationResult.Ok
where:
consumer << serviceProvider.consumers
}
private VerificationResult verifyConsumerPact(ConsumerInfo consumer) {
verifier.initialiseReporters(serviceProvider)
def result = verifier.runVerificationForConsumer([:], serviceProvider, consumer)
if (result instanceof VerificationResult.Failed) {
verifier.displayFailures([result])
}
result
}
}
```
Artifact provider
Group au.com.dius.pact
Version 4.3.6
Last update 22. March 2022
Tags: authored setpactsource loadpact isempty path pact fire state verificationresult hashmap they resourcehelpers providerstate verifying using instruct opportunity each groovy matchers resourcefilepath object shared haspactwith grabs executed consumerinfo example result where readmeexamplepactjvmproviderjunittest verifyconsumerpact failures setupverifier services many under grab config apos spocks separate bindings solved dropwizard good post startup warning requestresponseinteraction possibly yaml static test maps this extends port final http private string pacts dropwizardconfiguration provided getresource usable provider provides responsible json client class junit getpactsource again libraries specification runconsumerpacts defaultpactreader instanceof with reportverificationforconsumer service there automate setup hamcrest tostring serviceprovider reportinteractiondescription test_consumer classrule required mocking testdropwizardapplication providerinfo number spock httpclientfactory enter providerverifier getproviderstates statename filesource fail setprotocol quot truncatealltables testrule testconsumerpact server assertthat clients getdescription against functionality tools library file sethost feature setupprovider assert setupspec zoo_app have sending could animal_service generally getname expect framework urlsource readmeexamplepactjvmproviderspockspec dropwizardapprule unroll runs first startservicerule return instance data before adheres that protocol should only host from verification localhost void runverificationforconsumer beforeclass failed tool fixture core setname cleanup true pactsource basic setport verifyresponsefromprovider instances their interactions running public parameterized displayfailures setpath consumers consumer providerclient process will statechangeurl reportstateforinteraction 8080 specific cleanupspec initialisereporters application build verifier interaction uses normally
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 6
Dependencies model, matchers, support, pactbroker, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
Group au.com.dius.pact
Version 4.3.6
Last update 22. March 2022
Tags: authored setpactsource loadpact isempty path pact fire state verificationresult hashmap they resourcehelpers providerstate verifying using instruct opportunity each groovy matchers resourcefilepath object shared haspactwith grabs executed consumerinfo example result where readmeexamplepactjvmproviderjunittest verifyconsumerpact failures setupverifier services many under grab config apos spocks separate bindings solved dropwizard good post startup warning requestresponseinteraction possibly yaml static test maps this extends port final http private string pacts dropwizardconfiguration provided getresource usable provider provides responsible json client class junit getpactsource again libraries specification runconsumerpacts defaultpactreader instanceof with reportverificationforconsumer service there automate setup hamcrest tostring serviceprovider reportinteractiondescription test_consumer classrule required mocking testdropwizardapplication providerinfo number spock httpclientfactory enter providerverifier getproviderstates statename filesource fail setprotocol quot truncatealltables testrule testconsumerpact server assertthat clients getdescription against functionality tools library file sethost feature setupprovider assert setupspec zoo_app have sending could animal_service generally getname expect framework urlsource readmeexamplepactjvmproviderspockspec dropwizardapprule unroll runs first startservicerule return instance data before adheres that protocol should only host from verification localhost void runverificationforconsumer beforeclass failed tool fixture core setname cleanup true pactsource basic setport verifyresponsefromprovider instances their interactions running public parameterized displayfailures setpath consumers consumer providerclient process will statechangeurl reportstateforinteraction 8080 specific cleanupspec initialisereporters application build verifier interaction uses normally
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 6
Dependencies model, matchers, support, pactbroker, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
provider from group au.com.dius.pact (version 4.3.5)
Pact provider
=============
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 final TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(
TestDropwizardApplication, 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 = DefaultPactReader.INSTANCE.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<>()
VerificationResult result = verifier.verifyResponseFromProvider(serviceProvider, interaction,
interaction.getDescription(), failures, client)
// normally assert all good, but in this example it will fail
assertThat(failures, is(instanceOf(VerificationResult.Failed)))
verifier.displayFailures(result)
}
private ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) {
ProviderVerifier verifier = new ProviderVerifier()
verifier.initialiseReporters(provider)
verifier.reportVerificationForConsumer(consumer, provider, new UrlSource('http://example.example'))
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.
Again the provider service is a DropWizard application, and is using the DropwizardAppRule to startup the service.
This example runs all interactions using spocks Unroll feature
```groovy
class ReadmeExamplePactJVMProviderSpockSpec extends Specification {
@ClassRule @Shared
TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(TestDropwizardApplication,
ResourceHelpers.resourceFilePath('dropwizard/test-config.yaml'))
@Shared
ProviderInfo serviceProvider
ProviderVerifier verifier
def setupSpec() {
serviceProvider = new ProviderInfo('Dropwizard App')
serviceProvider.protocol = 'http'
serviceProvider.host = 'localhost'
serviceProvider.port = 8080
serviceProvider.path = '/'
serviceProvider.hasPactWith('zoo_app') { consumer ->
consumer.pactSource = new FileSource(new File(ResourceHelpers.resourceFilePath('pacts/zoo_app-animal_service.json')))
}
}
def setup() {
verifier = new ProviderVerifier()
}
def cleanup() {
// cleanup provider state
// ie. db.truncateAllTables()
}
def cleanupSpec() {
// cleanup provider
}
@Unroll
def "Provider Pact - With Consumer #consumer"() {
expect:
verifyConsumerPact(consumer) instanceof VerificationResult.Ok
where:
consumer << serviceProvider.consumers
}
private VerificationResult verifyConsumerPact(ConsumerInfo consumer) {
verifier.initialiseReporters(serviceProvider)
def result = verifier.runVerificationForConsumer([:], serviceProvider, consumer)
if (result instanceof VerificationResult.Failed) {
verifier.displayFailures([result])
}
result
}
}
```
Artifact provider
Group au.com.dius.pact
Version 4.3.5
Last update 10. February 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature dropwizardconfiguration quot static host setport under possibly number grabs each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer framework should process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol adheres fixture verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 6
Dependencies model, matchers, support, pactbroker, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
Group au.com.dius.pact
Version 4.3.5
Last update 10. February 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature dropwizardconfiguration quot static host setport under possibly number grabs each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer framework should process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol adheres fixture verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 6
Dependencies model, matchers, support, pactbroker, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
provider from group au.com.dius.pact (version 4.2.20)
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 final TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(
TestDropwizardApplication, 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 = DefaultPactReader.INSTANCE.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<>()
VerificationResult result = verifier.verifyResponseFromProvider(serviceProvider, interaction,
interaction.getDescription(), failures, client)
// normally assert all good, but in this example it will fail
assertThat(failures, is(instanceOf(VerificationResult.Failed)))
verifier.displayFailures(result)
}
private ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) {
ProviderVerifier verifier = new ProviderVerifier()
verifier.initialiseReporters(provider)
verifier.reportVerificationForConsumer(consumer, provider, new UrlSource('http://example.example'))
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.
Again the provider service is a DropWizard application, and is using the DropwizardAppRule to startup the service.
This example runs all interactions using spocks Unroll feature
```groovy
class ReadmeExamplePactJVMProviderSpockSpec extends Specification {
@ClassRule @Shared
TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(TestDropwizardApplication,
ResourceHelpers.resourceFilePath('dropwizard/test-config.yaml'))
@Shared
ProviderInfo serviceProvider
ProviderVerifier verifier
def setupSpec() {
serviceProvider = new ProviderInfo('Dropwizard App')
serviceProvider.protocol = 'http'
serviceProvider.host = 'localhost'
serviceProvider.port = 8080
serviceProvider.path = '/'
serviceProvider.hasPactWith('zoo_app') { consumer ->
consumer.pactSource = new FileSource(new File(ResourceHelpers.resourceFilePath('pacts/zoo_app-animal_service.json')))
}
}
def setup() {
verifier = new ProviderVerifier()
}
def cleanup() {
// cleanup provider state
// ie. db.truncateAllTables()
}
def cleanupSpec() {
// cleanup provider
}
@Unroll
def "Provider Pact - With Consumer #consumer"() {
expect:
verifyConsumerPact(consumer) instanceof VerificationResult.Ok
where:
consumer << serviceProvider.consumers
}
private VerificationResult verifyConsumerPact(ConsumerInfo consumer) {
verifier.initialiseReporters(serviceProvider)
def result = verifier.runVerificationForConsumer([:], serviceProvider, consumer)
if (result instanceof VerificationResult.Failed) {
verifier.displayFailures([result])
}
result
}
}
```
Artifact provider
Group au.com.dius.pact
Version 4.2.20
Last update 10. February 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature quot dropwizardconfiguration static host setport under possibly number grabs project each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription https fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts github unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer should framework process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol fixture adheres verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first dius clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 8
Dependencies commons-io, httpclient, model, pactbroker, matchers, support, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
Group au.com.dius.pact
Version 4.2.20
Last update 10. February 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature quot dropwizardconfiguration static host setport under possibly number grabs project each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription https fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts github unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer should framework process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol fixture adheres verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first dius clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 8
Dependencies commons-io, httpclient, model, pactbroker, matchers, support, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
provider from group au.com.dius.pact (version 4.1.34)
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 final TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(
TestDropwizardApplication, 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 = DefaultPactReader.INSTANCE.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<>()
VerificationResult result = verifier.verifyResponseFromProvider(serviceProvider, interaction,
interaction.getDescription(), failures, client)
// normally assert all good, but in this example it will fail
assertThat(failures, is(instanceOf(VerificationResult.Failed)))
verifier.displayFailures(result)
}
private ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) {
ProviderVerifier verifier = new ProviderVerifier()
verifier.initialiseReporters(provider)
verifier.reportVerificationForConsumer(consumer, provider, new UrlSource('http://example.example'))
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.
Again the provider service is a DropWizard application, and is using the DropwizardAppRule to startup the service.
This example runs all interactions using spocks Unroll feature
```groovy
class ReadmeExamplePactJVMProviderSpockSpec extends Specification {
@ClassRule @Shared
TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(TestDropwizardApplication,
ResourceHelpers.resourceFilePath('dropwizard/test-config.yaml'))
@Shared
ProviderInfo serviceProvider
ProviderVerifier verifier
def setupSpec() {
serviceProvider = new ProviderInfo('Dropwizard App')
serviceProvider.protocol = 'http'
serviceProvider.host = 'localhost'
serviceProvider.port = 8080
serviceProvider.path = '/'
serviceProvider.hasPactWith('zoo_app') { consumer ->
consumer.pactSource = new FileSource(new File(ResourceHelpers.resourceFilePath('pacts/zoo_app-animal_service.json')))
}
}
def setup() {
verifier = new ProviderVerifier()
}
def cleanup() {
// cleanup provider state
// ie. db.truncateAllTables()
}
def cleanupSpec() {
// cleanup provider
}
@Unroll
def "Provider Pact - With Consumer #consumer"() {
expect:
verifyConsumerPact(consumer) instanceof VerificationResult.Ok
where:
consumer << serviceProvider.consumers
}
private VerificationResult verifyConsumerPact(ConsumerInfo consumer) {
verifier.initialiseReporters(serviceProvider)
def result = verifier.runVerificationForConsumer([:], serviceProvider, consumer)
if (result instanceof VerificationResult.Failed) {
verifier.displayFailures([result])
}
result
}
}
```
Artifact provider
Group au.com.dius.pact
Version 4.1.34
Last update 09. February 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature quot dropwizardconfiguration static host setport under possibly number grabs project each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription https fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts github unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer should framework process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol fixture adheres verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first dius clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 7
Dependencies commons-io, httpclient, model, pactbroker, matchers, support, kotlin-result,
There are maybe transitive dependencies!
Group au.com.dius.pact
Version 4.1.34
Last update 09. February 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature quot dropwizardconfiguration static host setport under possibly number grabs project each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription https fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts github unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer should framework process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol fixture adheres verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first dius clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 7
Dependencies commons-io, httpclient, model, pactbroker, matchers, support, kotlin-result,
There are maybe transitive dependencies!
provider from group au.com.dius.pact (version 4.3.4)
Pact provider
=============
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 final TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(
TestDropwizardApplication, 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 = DefaultPactReader.INSTANCE.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<>()
VerificationResult result = verifier.verifyResponseFromProvider(serviceProvider, interaction,
interaction.getDescription(), failures, client)
// normally assert all good, but in this example it will fail
assertThat(failures, is(instanceOf(VerificationResult.Failed)))
verifier.displayFailures(result)
}
private ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) {
ProviderVerifier verifier = new ProviderVerifier()
verifier.initialiseReporters(provider)
verifier.reportVerificationForConsumer(consumer, provider, new UrlSource('http://example.example'))
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.
Again the provider service is a DropWizard application, and is using the DropwizardAppRule to startup the service.
This example runs all interactions using spocks Unroll feature
```groovy
class ReadmeExamplePactJVMProviderSpockSpec extends Specification {
@ClassRule @Shared
TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(TestDropwizardApplication,
ResourceHelpers.resourceFilePath('dropwizard/test-config.yaml'))
@Shared
ProviderInfo serviceProvider
ProviderVerifier verifier
def setupSpec() {
serviceProvider = new ProviderInfo('Dropwizard App')
serviceProvider.protocol = 'http'
serviceProvider.host = 'localhost'
serviceProvider.port = 8080
serviceProvider.path = '/'
serviceProvider.hasPactWith('zoo_app') { consumer ->
consumer.pactSource = new FileSource(new File(ResourceHelpers.resourceFilePath('pacts/zoo_app-animal_service.json')))
}
}
def setup() {
verifier = new ProviderVerifier()
}
def cleanup() {
// cleanup provider state
// ie. db.truncateAllTables()
}
def cleanupSpec() {
// cleanup provider
}
@Unroll
def "Provider Pact - With Consumer #consumer"() {
expect:
verifyConsumerPact(consumer) instanceof VerificationResult.Ok
where:
consumer << serviceProvider.consumers
}
private VerificationResult verifyConsumerPact(ConsumerInfo consumer) {
verifier.initialiseReporters(serviceProvider)
def result = verifier.runVerificationForConsumer([:], serviceProvider, consumer)
if (result instanceof VerificationResult.Failed) {
verifier.displayFailures([result])
}
result
}
}
```
Artifact provider
Group au.com.dius.pact
Version 4.3.4
Last update 12. January 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature dropwizardconfiguration quot static host setport under possibly number grabs each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer framework should process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol adheres fixture verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 6
Dependencies model, matchers, support, pactbroker, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
Group au.com.dius.pact
Version 4.3.4
Last update 12. January 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature dropwizardconfiguration quot static host setport under possibly number grabs each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer framework should process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol adheres fixture verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 6
Dependencies model, matchers, support, pactbroker, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
provider from group au.com.dius.pact (version 4.2.19)
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 final TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(
TestDropwizardApplication, 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 = DefaultPactReader.INSTANCE.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<>()
VerificationResult result = verifier.verifyResponseFromProvider(serviceProvider, interaction,
interaction.getDescription(), failures, client)
// normally assert all good, but in this example it will fail
assertThat(failures, is(instanceOf(VerificationResult.Failed)))
verifier.displayFailures(result)
}
private ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) {
ProviderVerifier verifier = new ProviderVerifier()
verifier.initialiseReporters(provider)
verifier.reportVerificationForConsumer(consumer, provider, new UrlSource('http://example.example'))
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.
Again the provider service is a DropWizard application, and is using the DropwizardAppRule to startup the service.
This example runs all interactions using spocks Unroll feature
```groovy
class ReadmeExamplePactJVMProviderSpockSpec extends Specification {
@ClassRule @Shared
TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(TestDropwizardApplication,
ResourceHelpers.resourceFilePath('dropwizard/test-config.yaml'))
@Shared
ProviderInfo serviceProvider
ProviderVerifier verifier
def setupSpec() {
serviceProvider = new ProviderInfo('Dropwizard App')
serviceProvider.protocol = 'http'
serviceProvider.host = 'localhost'
serviceProvider.port = 8080
serviceProvider.path = '/'
serviceProvider.hasPactWith('zoo_app') { consumer ->
consumer.pactSource = new FileSource(new File(ResourceHelpers.resourceFilePath('pacts/zoo_app-animal_service.json')))
}
}
def setup() {
verifier = new ProviderVerifier()
}
def cleanup() {
// cleanup provider state
// ie. db.truncateAllTables()
}
def cleanupSpec() {
// cleanup provider
}
@Unroll
def "Provider Pact - With Consumer #consumer"() {
expect:
verifyConsumerPact(consumer) instanceof VerificationResult.Ok
where:
consumer << serviceProvider.consumers
}
private VerificationResult verifyConsumerPact(ConsumerInfo consumer) {
verifier.initialiseReporters(serviceProvider)
def result = verifier.runVerificationForConsumer([:], serviceProvider, consumer)
if (result instanceof VerificationResult.Failed) {
verifier.displayFailures([result])
}
result
}
}
```
Artifact provider
Group au.com.dius.pact
Version 4.2.19
Last update 12. January 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature quot dropwizardconfiguration static host setport under possibly number grabs project each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription https fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts github unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer should framework process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol fixture adheres verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first dius clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 8
Dependencies commons-io, httpclient, model, pactbroker, matchers, support, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
Group au.com.dius.pact
Version 4.2.19
Last update 12. January 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature quot dropwizardconfiguration static host setport under possibly number grabs project each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription https fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts github unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer should framework process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol fixture adheres verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first dius clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 8
Dependencies commons-io, httpclient, model, pactbroker, matchers, support, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
provider from group au.com.dius.pact (version 4.1.33)
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 final TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(
TestDropwizardApplication, 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 = DefaultPactReader.INSTANCE.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<>()
VerificationResult result = verifier.verifyResponseFromProvider(serviceProvider, interaction,
interaction.getDescription(), failures, client)
// normally assert all good, but in this example it will fail
assertThat(failures, is(instanceOf(VerificationResult.Failed)))
verifier.displayFailures(result)
}
private ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) {
ProviderVerifier verifier = new ProviderVerifier()
verifier.initialiseReporters(provider)
verifier.reportVerificationForConsumer(consumer, provider, new UrlSource('http://example.example'))
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.
Again the provider service is a DropWizard application, and is using the DropwizardAppRule to startup the service.
This example runs all interactions using spocks Unroll feature
```groovy
class ReadmeExamplePactJVMProviderSpockSpec extends Specification {
@ClassRule @Shared
TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(TestDropwizardApplication,
ResourceHelpers.resourceFilePath('dropwizard/test-config.yaml'))
@Shared
ProviderInfo serviceProvider
ProviderVerifier verifier
def setupSpec() {
serviceProvider = new ProviderInfo('Dropwizard App')
serviceProvider.protocol = 'http'
serviceProvider.host = 'localhost'
serviceProvider.port = 8080
serviceProvider.path = '/'
serviceProvider.hasPactWith('zoo_app') { consumer ->
consumer.pactSource = new FileSource(new File(ResourceHelpers.resourceFilePath('pacts/zoo_app-animal_service.json')))
}
}
def setup() {
verifier = new ProviderVerifier()
}
def cleanup() {
// cleanup provider state
// ie. db.truncateAllTables()
}
def cleanupSpec() {
// cleanup provider
}
@Unroll
def "Provider Pact - With Consumer #consumer"() {
expect:
verifyConsumerPact(consumer) instanceof VerificationResult.Ok
where:
consumer << serviceProvider.consumers
}
private VerificationResult verifyConsumerPact(ConsumerInfo consumer) {
verifier.initialiseReporters(serviceProvider)
def result = verifier.runVerificationForConsumer([:], serviceProvider, consumer)
if (result instanceof VerificationResult.Failed) {
verifier.displayFailures([result])
}
result
}
}
```
Artifact provider
Group au.com.dius.pact
Version 4.1.33
Last update 12. January 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature quot dropwizardconfiguration static host setport under possibly number grabs project each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription https fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts github unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer should framework process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol fixture adheres verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first dius clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 7
Dependencies commons-io, httpclient, model, pactbroker, matchers, support, kotlin-result,
There are maybe transitive dependencies!
Group au.com.dius.pact
Version 4.1.33
Last update 12. January 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature quot dropwizardconfiguration static host setport under possibly number grabs project each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription https fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts github unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer should framework process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol fixture adheres verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first dius clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 7
Dependencies commons-io, httpclient, model, pactbroker, matchers, support, kotlin-result,
There are maybe transitive dependencies!
provider from group au.com.dius.pact (version 4.3.3)
Pact provider
=============
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 final TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(
TestDropwizardApplication, 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 = DefaultPactReader.INSTANCE.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<>()
VerificationResult result = verifier.verifyResponseFromProvider(serviceProvider, interaction,
interaction.getDescription(), failures, client)
// normally assert all good, but in this example it will fail
assertThat(failures, is(instanceOf(VerificationResult.Failed)))
verifier.displayFailures(result)
}
private ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) {
ProviderVerifier verifier = new ProviderVerifier()
verifier.initialiseReporters(provider)
verifier.reportVerificationForConsumer(consumer, provider, new UrlSource('http://example.example'))
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.
Again the provider service is a DropWizard application, and is using the DropwizardAppRule to startup the service.
This example runs all interactions using spocks Unroll feature
```groovy
class ReadmeExamplePactJVMProviderSpockSpec extends Specification {
@ClassRule @Shared
TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(TestDropwizardApplication,
ResourceHelpers.resourceFilePath('dropwizard/test-config.yaml'))
@Shared
ProviderInfo serviceProvider
ProviderVerifier verifier
def setupSpec() {
serviceProvider = new ProviderInfo('Dropwizard App')
serviceProvider.protocol = 'http'
serviceProvider.host = 'localhost'
serviceProvider.port = 8080
serviceProvider.path = '/'
serviceProvider.hasPactWith('zoo_app') { consumer ->
consumer.pactSource = new FileSource(new File(ResourceHelpers.resourceFilePath('pacts/zoo_app-animal_service.json')))
}
}
def setup() {
verifier = new ProviderVerifier()
}
def cleanup() {
// cleanup provider state
// ie. db.truncateAllTables()
}
def cleanupSpec() {
// cleanup provider
}
@Unroll
def "Provider Pact - With Consumer #consumer"() {
expect:
verifyConsumerPact(consumer) instanceof VerificationResult.Ok
where:
consumer << serviceProvider.consumers
}
private VerificationResult verifyConsumerPact(ConsumerInfo consumer) {
verifier.initialiseReporters(serviceProvider)
def result = verifier.runVerificationForConsumer([:], serviceProvider, consumer)
if (result instanceof VerificationResult.Failed) {
verifier.displayFailures([result])
}
result
}
}
```
Artifact provider
Group au.com.dius.pact
Version 4.3.3
Last update 06. January 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature dropwizardconfiguration quot static host setport under possibly number grabs each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer framework should process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol adheres fixture verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 6
Dependencies model, matchers, support, pactbroker, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
Group au.com.dius.pact
Version 4.3.3
Last update 06. January 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature dropwizardconfiguration quot static host setport under possibly number grabs each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer framework should process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol adheres fixture verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 6
Dependencies model, matchers, support, pactbroker, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
provider from group au.com.dius.pact (version 4.2.18)
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 final TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(
TestDropwizardApplication, 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 = DefaultPactReader.INSTANCE.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<>()
VerificationResult result = verifier.verifyResponseFromProvider(serviceProvider, interaction,
interaction.getDescription(), failures, client)
// normally assert all good, but in this example it will fail
assertThat(failures, is(instanceOf(VerificationResult.Failed)))
verifier.displayFailures(result)
}
private ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) {
ProviderVerifier verifier = new ProviderVerifier()
verifier.initialiseReporters(provider)
verifier.reportVerificationForConsumer(consumer, provider, new UrlSource('http://example.example'))
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.
Again the provider service is a DropWizard application, and is using the DropwizardAppRule to startup the service.
This example runs all interactions using spocks Unroll feature
```groovy
class ReadmeExamplePactJVMProviderSpockSpec extends Specification {
@ClassRule @Shared
TestRule startServiceRule = new DropwizardAppRule<DropwizardConfiguration>(TestDropwizardApplication,
ResourceHelpers.resourceFilePath('dropwizard/test-config.yaml'))
@Shared
ProviderInfo serviceProvider
ProviderVerifier verifier
def setupSpec() {
serviceProvider = new ProviderInfo('Dropwizard App')
serviceProvider.protocol = 'http'
serviceProvider.host = 'localhost'
serviceProvider.port = 8080
serviceProvider.path = '/'
serviceProvider.hasPactWith('zoo_app') { consumer ->
consumer.pactSource = new FileSource(new File(ResourceHelpers.resourceFilePath('pacts/zoo_app-animal_service.json')))
}
}
def setup() {
verifier = new ProviderVerifier()
}
def cleanup() {
// cleanup provider state
// ie. db.truncateAllTables()
}
def cleanupSpec() {
// cleanup provider
}
@Unroll
def "Provider Pact - With Consumer #consumer"() {
expect:
verifyConsumerPact(consumer) instanceof VerificationResult.Ok
where:
consumer << serviceProvider.consumers
}
private VerificationResult verifyConsumerPact(ConsumerInfo consumer) {
verifier.initialiseReporters(serviceProvider)
def result = verifier.runVerificationForConsumer([:], serviceProvider, consumer)
if (result instanceof VerificationResult.Failed) {
verifier.displayFailures([result])
}
result
}
}
```
Artifact provider
Group au.com.dius.pact
Version 4.2.18
Last update 06. January 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature quot dropwizardconfiguration static host setport under possibly number grabs project each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription https fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts github unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer should framework process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol fixture adheres verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first dius clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 8
Dependencies commons-io, httpclient, model, pactbroker, matchers, support, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
Group au.com.dius.pact
Version 4.2.18
Last update 06. January 2022
Tags: cleanup using getdescription assertthat dropwizard setpath feature quot dropwizardconfiguration static host setport under possibly number grabs project each automate resourcefilepath yaml parameterized serviceprovider before data readmeexamplepactjvmproviderjunittest resourcehelpers instances running executed setupspec could reportinteractiondescription https fire getpactsource string library assert getname runs public libraries beforeclass dropwizardapprule client tool good consumer localhost setname testdropwizardapplication basic instance requestresponseinteraction shared haspactwith that isempty hamcrest against reportstateforinteraction getresource example result grab providerverifier testrule bindings matchers tostring testconsumerpact readmeexamplepactjvmproviderspockspec mocking startservicerule json setupprovider generally verifyresponsefromprovider interactions httpclientfactory setpactsource functionality protocol separate provides 8080 provider junit statechangeurl there service provided core server pacts github unroll they test verifier initialisereporters expect fail file only config final services groovy again interaction spock startup cleanupspec many setupverifier verification http will providerinfo port failed truncatealltables build providerstate private normally runconsumerpacts displayfailures urlsource failures post responsible loadpact return void verificationresult true sethost reportverificationforconsumer should framework process sending consumerinfo statename warning pactsource defaultpactreader filesource getproviderstates where tools providerclient authored instruct apos required test_consumer verifyconsumerpact solved extends classrule consumers class enter pact usable instanceof this setprotocol fixture adheres verifying specific have state from object setup path application with spocks zoo_app opportunity runverificationforconsumer maps specification uses animal_service hashmap their first dius clients
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 8
Dependencies commons-io, httpclient, model, pactbroker, matchers, support, classgraph, kotlin-result-jvm,
There are maybe transitive dependencies!
Page 8 from 15 (items total 145)