Questions tagged [pact-jvm]

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.

JVM implementation of the consumer driven contract library pact.

From the Ruby Pact website:

Define a pact between service consumers and providers, enabling "consumer driven contract" testing.

Pact provides an RSpec DSL for service consumers to define the HTTP requests they will make to a service provider and the HTTP responses they expect back. These expectations are used in the consumers specs to provide a mock service provider. The interactions are recorded, and played back in the service provider specs to ensure the service provider actually does provide the response the consumer expects.

This allows testing of both sides of an integration point using fast unit tests.

This gem is inspired by the concept of "Consumer driven contracts". See http://martinfowler.com/articles/consumerDrivenContracts.html for more information.

Read Getting started with Pact for more information on how to get going.

Source: https://github.com/DiUS/pact-jvm/

109 questions
0
votes
1 answer

Pact-jvm - Validate string values inside array with regex

I have this array structure: { Array1 : ["A","B","C"], Array2: ["D","E","F"] } And I was validated it like this: array("array1") .string("A") .string("B") .string("C") .closeArray() array("array2") .string("D") .string("E") …
Pedro Henrique
  • 609
  • 2
  • 9
  • 26
0
votes
2 answers

Persistence of data in each iteration of PactVerify in the provider

What is the best way to perform a test of contracts, when the endpoint of the provider performs a persistence of data? For example, the registration of a client. Should I consider the rollback of the data in the pipeline?
0
votes
1 answer

Unable to publish the 'Last Verified' status in PACT Broker

For microservices contract tests, am using PACT with gradle 4.4 and here is my build.gradle: buildscript { repositories { mavenCentral() } dependencies { classpath 'au.com.dius:pact-jvm-provider-gradle_2.12:3.5.22' } } apply plugin:…
Sai
  • 309
  • 1
  • 4
  • 15
0
votes
1 answer

How to represent responses with heterogenous arrays in pact-jvm

I'm having trouble figuring out how to represent arrays with structurally different objects in an array in pact contracts. From pact-spec-v3 It would also be required to define whether the matchers should be combined with logical AND (all…
madhukar93
  • 507
  • 5
  • 23
0
votes
1 answer

Pact does not send provider-verification result to pact broker if junit 5 test fails

I have created a REST-service with spring. Now I want to use pact and junit 5 to test the consumer-provider-communication. I have already a running pact-broker (from https://github.com/jaimeniswonger/pact-broker-openshift). The consumer-test works…
0
votes
2 answers

Pacts: Matching rule for non-empty map (or a field which is not null) needed

I need help with writing my consumer Pacts using pact-jvm (https://github.com/DiUS/pact-jvm). My problem is I have a field which is a list (an array) of maps. Each map can have elements of different types (strings or sub-maps),…
Patrycja K
  • 731
  • 7
  • 14
0
votes
1 answer

How to iteratively create Pact files in pact jvm

So I have a json file that has some request and response data, and what I want to accomplish is iterate through this data and create a pact file that uses each request and response. So at the moment I am using a parameterized test in junit to kinda…
0
votes
1 answer

PactRunner ignores @DefaultRequestValues

I'm trying to test my first Pact file, and I'm stuck on setting headers for the request made to the producer. I'm trying to get a 404 when a request is made to a user API with an invalid userId, as defined in the following Pact file: { "consumer":…
Aydin
  • 311
  • 4
  • 15
0
votes
1 answer

Using regex in pactdsl request body

I want my pact server to return a custom response when making a POST call with Header Content-Type: application/x-www-form-urlencoded. However, the body of the POST call is not always the same, only a prefix remains constant. For example, It has…
Dan Bmd
  • 35
  • 9
0
votes
0 answers

Will pact specification v.4 solve #401 and when will it be released/supported in pact-jvm

We're using pact-jvm and due to bug #401 we cannot use the eachKeyMappedToAnArrayLike for sub objects which is a real problem for us currently. I followed the comments in the issue and ended up in the pact v.4 specification that proposed a change to…
Joel Andersson
  • 239
  • 2
  • 7
0
votes
1 answer

pact-jvm testing multi tier authorization

I want to test my authorization-service via pact-jvm. In my request I'm sending a html-body via post, including some metadata to verify the user - including his username and which is also sent in the header where I use Http Basic Auth. I add the…
KnechtRootrecht
  • 493
  • 1
  • 4
  • 18
0
votes
1 answer

pact-jvm create pact manually by hand

I'm exploring the chance to use pact-jvm with a client and provider that already exist and that are working productively. Currently I try to create a pact file per hand and verify it for the provider. I wonder if this even makes sense. I fear maybe…
KnechtRootrecht
  • 493
  • 1
  • 4
  • 18
0
votes
1 answer

Unable to verify https endpoint with pact-jvm-provider-maven_2.11 in pact broker

This is my pom snippet for service providers StoreSite https
JINESH A
  • 1
  • 2
0
votes
2 answers

Pact-jvm java noob questions

I have a few noob questions about Pact JVM (Java); If the providers json structure response is already known (for example by querying the api with Postman) ,is it possible to convert Postman json body automatically into a pact contract file without…
zombieboy
  • 116
  • 1
  • 10
0
votes
1 answer

How to set regex matchers on PactDslJsonBody in consumer pact version 3.5.3

When upgraded pact.consumer.version to 3.5.3, I am not able to create regex matcher on PactDslJsonBody. Below is code with version 3.2.8: PactDslJsonBody requestBody = createJSONPact(requestBodyJSON, new…
Shilpi
  • 39
  • 5