Versions of artifact au.com.dius:pact-jvm-consumer-groovy_2.10

pact-jvm-consumer-groovy_2.10

pact-jvm-consumer-groovy ========================= Groovy DSL for Pact JVM ##Dependency The library is available on maven central using: * group-id = `au.com.dius` * artifact-id = `pact-jvm-consumer-groovy_2.11` * version-id = `2.4.x` or `3.2.x` ##Usage Add the `pact-jvm-consumer-groovy` library to your test class path. This provides a `PactBuilder` class for you to use to define your pacts. For a full example, have a look at the example JUnit `ExampleGroovyConsumerPactTest`. If you are using gradle for your build, add it to your `build.gradle`: dependencies { testCompile 'au.com.dius:pact-jvm-consumer-groovy_2.11:3.2.14' } Then create an instance of the `PactBuilder` in your test. ```groovy @Test void "A service consumer side of a pact goes a little something like this"() { def alice_service = new PactBuilder() // Create a new PactBuilder alice_service { serviceConsumer "Consumer" // Define the service consumer by name hasPactWith "Alice Service" // Define the service provider that it has a pact with port 1234 // The port number for the service. It is optional, leave it out to // to use a random one given('there is some good mallory') // defines a provider state. It is optional. uponReceiving('a retrieve Mallory request') // upon_receiving starts a new interaction withAttributes(method: 'get', path: '/mallory') // define the request, a GET request to '/mallory' willRespondWith( // define the response we want returned status: 200, headers: ['Content-Type': 'text/html'], body: '"That is some good Mallory."' ) } // Execute the run method to have the mock server run. // It takes a closure to execute your requests and returns a Pact VerificationResult. VerificationResult result = alice_service.run() { def client = new RESTClient('http://localhost:1234/') def alice_response = client.get(path: '/mallory') assert alice_response.status == 200 assert alice_response.contentType == 'text/html' def data = alice_response.data.text() assert data == '"That is some good Mallory."' } assert result == PactVerified$.MODULE$ // This means it is all good in weird Scala speak. } ``` After running this test, the following pact file is produced: { "provider" : { "name" : "Alice Service" }, "consumer" : { "name" : "Consumer" }, "interactions" : [ { "provider_state" : "there is some good mallory", "description" : "a retrieve Mallory request", "request" : { "method" : "get", "path" : "/mallory", "requestMatchers" : { } }, "response" : { "status" : 200, "headers" : { "Content-Type" : "text/html" }, "body" : "That is some good Mallory.", "responseMatchers" : { } } } ] } ### DSL Methods #### serviceConsumer(String consumer) This names the service consumer for the pact. #### hasPactWith(String provider) This names the service provider for the pact. #### port(int port) Sets the port that the mock server will run on. If not supplied, a random port will be used. #### given(String providerState) Defines a state that the provider needs to be in for the request to succeed. For more info, see https://github.com/realestate-com-au/pact/wiki/Provider-states #### uponReceiving(String requestDescription) Starts the definition of a of a pact interaction. #### withAttributes(Map requestData) Defines the request for the interaction. The request data map can contain the following: | key | Description | Default Value

Artifact Version Name Latest uploaded at
2.4.18 pact-jvm-consumer-groovy_2.10 2016-12-30 01:38:29 UTC
2.4.17 pact-jvm-consumer-groovy_2.10 2016-10-22 06:52:27 UTC
2.4.16 pact-jvm-consumer-groovy_2.10 2016-10-01 21:29:26 UTC
2.4.15 pact-jvm-consumer-groovy_2.10 2016-08-23 12:45:59 UTC
2.4.14 pact-jvm-consumer-groovy_2.10 2016-08-07 03:31:32 UTC
2.4.13 pact-jvm-consumer-groovy_2.10 2016-07-31 05:01:19 UTC
2.4.12 pact-jvm-consumer-groovy_2.10 2016-07-15 02:49:34 UTC
2.4.11 pact-jvm-consumer-groovy_2.10 2016-07-06 05:06:26 UTC
2.4.10 pact-jvm-consumer-groovy_2.10 2016-06-17 23:07:22 UTC
2.4.9 pact-jvm-consumer-groovy_2.10 2016-05-04 02:33:26 UTC
2.4.8 pact-jvm-consumer-groovy_2.10 2016-03-29 02:16:45 UTC
2.4.7 pact-jvm-consumer-groovy_2.10 2016-03-25 00:40:52 UTC
2.4.6 pact-jvm-consumer-groovy_2.10 2016-02-19 23:20:40 UTC
2.4.5 pact-jvm-consumer-groovy_2.10 2016-02-11 04:30:22 UTC
2.4.4 pact-jvm-consumer-groovy_2.10 2016-01-20 23:40:31 UTC
2.4.3 pact-jvm-consumer-groovy_2.10 2016-01-17 02:52:34 UTC
2.4.2 pact-jvm-consumer-groovy_2.10 2015-12-12 22:02:37 UTC
2.4.1 pact-jvm-consumer-groovy_2.10 2015-11-28 06:29:54 UTC
2.4.0 pact-jvm-consumer-groovy_2.10 2015-11-22 04:01:01 UTC
2.3.3 pact-jvm-consumer-groovy_2.10 2015-11-14 06:32:07 UTC
2.3.2 pact-jvm-consumer-groovy_2.10 2015-10-24 01:10:00 UTC
2.3.1 pact-jvm-consumer-groovy_2.10 2015-10-20 08:54:51 UTC
2.3.0 pact-jvm-consumer-groovy_2.10 2015-10-06 10:15:29 UTC
2.2.15 pact-jvm-consumer-groovy_2.10 2015-09-17 10:06:00 UTC
2.2.14 pact-jvm-consumer-groovy_2.10 2015-09-07 10:07:07 UTC
2.2.13 pact-jvm-consumer-groovy_2.10 2015-08-29 05:21:07 UTC
2.2.12 pact-jvm-consumer-groovy_2.10 2015-08-09 07:14:43 UTC
2.2.11 pact-jvm-consumer-groovy_2.10 2015-08-02 04:45:11 UTC
2.2.10 pact-jvm-consumer-groovy_2.10 2015-07-25 06:08:50 UTC
2.2.9 pact-jvm-consumer-groovy_2.10 2015-07-13 09:10:03 UTC