DOC

au.com.dius : pact-jvm-consumer-groovy-v3_2.10

Maven & Gradle

Sep 17, 2015
1k stars

pact-jvm-consumer-groovy-v3_2.10 · pact-jvm-consumer-groovy-v3 =========================== Groovy DSL for Pact JVM implementing V3 specification changes. ##Dependency The library is available on maven central using: * group-id = `au.com.dius` * artifact-id = `pact-jvm-consumer-groovy-v3_2.11` * version-id = `2.2.x` or `3.0.x` ##Usage Add the `pact-jvm-consumer-groovy-v3` library to your test class path. This provides a `PactMessageBuilder` class for you to use to define your pacts. If you are using gradle for your build, add it to your `build.gradle`: dependencies { testCompile 'au.com.dius:pact-jvm-consumer-groovy-v3_2.11:2.2.12' } ## Consumer test for a message consumer The `PactMessageBuilder` class provides a DSL for defining your message expectations. It works in much the same way as the `PactBuilder` class for Request-Response interactions. ### Step 1 - define the message expectations Create a test that uses the `PactMessageBuilder` to define a message expectation, and then call `run`. This will invoke the given closure with a message for each one defined in the pact. ```groovy def eventStream = new PactMessageBuilder().call { serviceConsumer 'messageConsumer' hasPactWith 'messageProducer' given 'order with id 10000004 exists' expectsToReceive 'an order confirmation message' withMetaData(type: 'OrderConfirmed') // Can define any key-value pairs here withContent(contentType: 'application/json') { type 'OrderConfirmed' audit { userCode 'messageService' } origin 'message-service' referenceId '10000004-2' timeSent: '2015-07-22T10:14:28+00:00' value { orderId '10000004' value '10.000000' fee '10.00' gst '15.00' } } } ``` ### Step 2 - call your message handler with the generated messages This example tests a message handler that gets messages from a Kafka topic. In this case the Pact message is wrapped as a Kafka `MessageAndMetadata`. ```groovy eventStream.run { Message message -> messageHandler.handleMessage(new MessageAndMetadata('topic', 1, new kafka.message.Message(message.contentsAsBytes()), 0, null, valueDecoder)) } ``` ### Step 3 - validate that the message was handled correctly ```groovy def order = orderRepository.getOrder('10000004') assert order.status == 'confirmed' assert order.value == 10.0 ``` ### Step 4 - Publish the pact file If the test was successful, a pact file would have been produced with the message from step 1.

Table Of Contents

Latest Version

Download au.com.dius : pact-jvm-consumer-groovy-v3_2.10 Javadoc & API Documentation - Latest Versions:

All Versions

Download au.com.dius : pact-jvm-consumer-groovy-v3_2.10 Javadoc & API Documentation - All Versions:

Version Size Javadoc Updated
2.2.x

How to open Javadoc JAR file in web browser

  1. Rename the file pact-jvm-consumer-groovy-v3_2.10-2.2.15-javadoc.jar to pact-jvm-consumer-groovy-v3_2.10-2.2.15-javadoc.zip
  2. Use your favourite unzip tool (WinRAR / WinZIP) to extract it, now you have a folder pact-jvm-consumer-groovy-v3_2.10-2.2.15-javadoc
  3. Double click index.html will open the index page on your default web browser.

How to generate Javadoc from a source JAR?

Running the command javadoc:

javadoc --ignore-source-errors -encoding UTF-8 -sourcepath "pact-jvm-consumer-groovy-v3_2.10-2.2.15-sources.jar" -d "pact-jvm-consumer-groovy-v3_2.10-2.2.15-javadoc" -subpackages 

Advertisement

Dependencies from Group

Apr 29, 2020
31 usages
1k stars
Nov 04, 2018
27 usages
1k stars
Nov 04, 2018
18 usages
1k stars
Apr 29, 2020
13 usages
1k stars
Apr 29, 2020
12 usages
1k stars

Discover Dependencies

May 27, 2016
13 usages
231 stars
Aug 07, 2015
124 stars
Aug 03, 2015
20 stars
Aug 03, 2015
20 stars
Aug 09, 2015
0 stars
May 23, 2016
3 usages
36 stars
May 23, 2016
5 usages
36 stars
May 31, 2016
706 stars