bethskurrie
2018-03-24 03:39
has joined #pact-jvm

andrewcfitzgerald
2018-03-26 02:45
has joined #pact-jvm

mboudreau
2018-03-26 10:39
has joined #pact-jvm

uglyog
2018-04-03 23:39
has joined #pact-jvm

bethskurrie
2018-05-02 04:58
/github subscribe dius/pact-jvm releases

bethskurrie
2018-05-02 04:58
/github unsubscribe dius/pact-jvm deployments commits public

sgleadow
2018-05-09 07:07
has joined #pact-jvm

abubics
2018-05-09 07:11
has joined #pact-jvm

brentbarker9
2018-05-09 20:56
has joined #pact-jvm

brentbarker9
2018-05-15 23:31
I'm looking at https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-junit#example-of-http-test specifically the `toStateWithData(Map data)` method. When and what kind of data is that map filled with?

brentbarker9
2018-05-15 23:31
Trying to debug that I get a empty collection


rgshah781988
2018-05-16 07:25
has joined #pact-jvm

james.hogarth
2018-05-16 09:21
has joined #pact-jvm

james.hogarth
2018-05-16 09:21
So I've been following the JVM workshop (https://github.com/DiUS/pact-workshop-jvm) but the provider isn't pushing verification back to the broker. I have my own (unauthenticated) broker which is working fine with the JS workshop and the JVM consumer is pushing to it fine. The provider pact test passes so I know it can contact teh broker, it just doesn't publish the verification. Any ideas what I am missing in the example code? A provider version property not set perhaps? I'm at a loss


brentbarker9
2018-05-16 15:12
is that what you are looking for?

james.hogarth
2018-05-16 15:54
@brentbarker9 I found that which is why I thought about version ... but the JVM workshop implies it should be publishing the verification (like the JS one does) but it clearly isn't working as described

uglyog
2018-05-16 23:39
@james.hogarth are you using the gradle build, or are you using something else?

james.hogarth
2018-05-17 08:05
@uglyog I'm following what the workshop states ... honestly I'm a little confused with that project which part(s) of pact-jvm are being used ... I see gradle, junit and spring behaviour defined in the relevant code. I've opened an issue because it doesn't work like Step13 claims it should and it behaves differently to the JS workshop, with the lack of pact verification publication https://github.com/DiUS/pact-workshop-jvm/issues/9

rgshah781988
2018-05-18 10:16
pact jvm is having multiple option, which is confussing

thomas.heilbronner
2018-05-21 09:24
has joined #pact-jvm

minhdoan
2018-05-21 10:08
has joined #pact-jvm

minhdoan
2018-05-21 10:09
Hi team, i am buidling a Pact record with the response contains: { "Id": 35345786, "DATA_TYPE": { "EntityTypeName": "STRING", } } or { "Id": 35345786, "DATA_TYPE": null I used the pact-jvm-consumer-junit_2.12:3.5.16 and it seems the or() method, e.g: or("DATA_TYPE", null, PM.nullValue(), PM.stringType()) does not work in this case Could you please help to instruct me how to build it? Many thanks!

abhilash.hanumanth
2018-05-21 11:23
has joined #pact-jvm

abhilash.hanumanth
2018-05-21 11:23
@minhdoan

rollertone
2018-05-21 13:35
has joined #pact-jvm

uglyog
2018-05-21 23:06
@minhdoan The OR constructs currently work at the attribute level, because that is what the matchers are applied to.

uglyog
2018-05-21 23:07
It would probably be better for you to have two different test cases, one with the value set and one with a null.

uglyog
2018-05-21 23:13
@abhilash.hanumanth I'm not sure I understand your issue. Do you have an array at the root level?

minhdoan
2018-05-22 02:45
@uglyog Thanks for your suggestion but in my test the mixing is mandatory validation point. So another solution??, e.g: maybe the record with a pair of name/value: "DATA_TYPE": {}/null, the value type is optional and ignored in the created record?

abhilash.hanumanth
2018-05-22 03:17
@uglyog, @minhdoan: Here is my Json array body: ``` [ { "appName": "Analytics", "class": "framework.BootstrapModule", "eventTimestamp": 1524504793160, "host": "localhost", "logLevel": "INFO", "message": "message123", "nodeName": "All-In-One", "source": "logs/analytics-agent.log", "sourceType": "analytics-demo-log", "threadName": "main", "tierName": "AppTier" }, { "appName": "Analytics", "class": "AgentEventServiceClientModule", "eventTimestamp": 1524504794121, "host": "localhost", "logLevel": "INFO", "message": "message456", "nodeName": "All-In-One", "source": "logs/analytics-agent.log", "sourceType": "analytics-demo-log", "threadName": "main", "tierName": "AppTier" } ] ```

abhilash.hanumanth
2018-05-22 03:19
i want to construct pact DSL for the above json body

minhdoan
2018-05-22 03:29
@abhilash.hanumanth the pact builder:

minhdoan
2018-05-22 03:29
.body(new PactDslJsonArray() .object() .stringValue("appName", "Analytics") .stringValue("class", "framework.BootstrapModule") .stringValue("message", "message123") .closeObject() .object() .stringValue("appName", "Analytics") .stringValue("class", "framework.BootstrapModule") .stringValue("message", "message456") .closeObject() ).toPact(); }

minhdoan
2018-05-22 03:29
and the record:

minhdoan
2018-05-22 03:29
"body": [ { "appName": "Analytics", "message": "message123", "class": "framework.BootstrapModule" }, { "appName": "Analytics", "message": "message456", "class": "framework.BootstrapModule" } ]

minhdoan
2018-05-22 03:29
is it fine?


minhdoan
2018-05-22 04:02
but for or(JsonBody, null)

uglyog
2018-05-22 04:21
The problem with using or, is that you are only testing one branch. Wouldn't you want to know your interface works with both an actual value and a missing one? This would require two test cases.

minhdoan
2018-05-22 04:24
@uglyog i think i have just found a workaround by using: .or("DATA_TYPE", null, PM.nullValue(), PM.includesStr("EntityTypeName"), PM.includesStr("STRING"))

minhdoan
2018-05-22 04:25
As i said, because the test uses the type-cast so the actual response may contains both a map (json) or null

minhdoan
2018-05-22 04:26
If we divide to 2 cases, it also fails because if the first only check the null, pactVerify will fail for the value with "DATA_TYPE": { "EntityTypeName": "STRING", } }

minhdoan
2018-05-22 04:26
and vice versa.

minhdoan
2018-05-22 04:27
Could you please help to show me how to divide into 2 test cases and approach to create respective pact records for them?

vinod.baradwaj
2018-05-22 05:54
has joined #pact-jvm

abhilash.hanumanth
2018-05-22 06:45
it worked. Thanks MinhDoan

minhdoan
2018-05-22 06:48
welcome @abhilash.hanumanth

uglyog
2018-05-22 06:58
@minhdoan I would have a pact file with two interactions, one that has the object value and one that has the null value. For the consumer test, this is just having two different tests.

uglyog
2018-05-22 06:59
For verifying the provider, you will need a mechanism (hopefully controlled via provider states) that will return the correct value for the correct interaction in the pact file.

minhdoan
2018-05-22 07:01
yes, i am working on provider test and the actual response is already fixed, could not be controlled via provider states so i think i must stick with the above workaround

scott.osborne1
2018-05-22 18:22
has joined #pact-jvm

minhdoan
2018-05-23 03:06
I have a question with Pact verification logging mechanism. What is the common logging library used? And how i configure it? Thanks!

uglyog
2018-05-23 04:29
It's all based on SLF4J, so you will need to configure an implementation for your project. Logback is good if you are not using something else.

shekharsp27
2018-05-23 05:19
has joined #pact-jvm

avinash.eediga
2018-05-23 05:56
has joined #pact-jvm

minhdoan
2018-05-23 06:53
Thanks @uglyog so much! I will investigate the SLF4J

gopinathlangote11
2018-05-23 13:31
has joined #pact-jvm

paulswilliams
2018-05-23 20:03
has joined #pact-jvm

paulswilliams
2018-05-24 06:20
Hi all.

paulswilliams
2018-05-24 07:13
Hi @abubics

abubics
2018-05-24 07:14
howdy :slightly_smiling_face:

paulswilliams
2018-05-24 07:15
So, I?m currently spiking Consumer Contract Driven Testing for a new project where we need to separate consumer and provider development. I?ve had a good look through the documentation, and kind of understand how I would use Pact to do the consumer testing if they were JUnit style tests.

paulswilliams
2018-05-24 07:16
However, in our project, we?d like to use Cucumber-JVM with a Pact build mock to Acceptance Test the whole client.

paulswilliams
2018-05-24 07:18
I?m just having a play with the DSL as I obviously can?t use the Junit test helpers.

paulswilliams
2018-05-24 07:19
I?ve a couple of issues with the API?s, and wonder if I?m approaching this sensibly, or using ?internal? methods..

paulswilliams
2018-05-24 07:22
The first issue I have is that mock `MockHttpServer.kt::mockServer()` takes in config, but also a pact. Does this mean I can?t instantiate a MockServer that could support multiple Pacts? Ideally, I?d like to setup one or two MockServers, grab the URLs, and then bring up our Spring Boot application injecting these URLS, and run a few ATs against it.

paulswilliams
2018-05-24 07:25
Secondly, the example documentation (https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-consumer-junit) suggests using `runAndWritePact` which takes in the test function, but in our case, again, I?d like to start a mockserver, inject a handle to it?s url, and then drive several selenium -> consumer -> mockServer http chains. Once these asynchronous actions are complete, then I could verify against the mock server. Am I out of luck for these kind of interactions, or just keep looking through the APIs. I?m concerned that I?ll start digging deeper and deeper into the internals that are likely to change?

abubics
2018-05-24 08:12
Basically, the mock server is brought up per test (and shut down after each)

abubics
2018-05-24 08:13
There is a standalone mock server you can run, in a separate process, but that's a completely different testing approach

abubics
2018-05-24 08:15
Pact's sweet spot is unit testing API clients, so the more code you cover, the lower the ratio of its job is being done :)

abubics
2018-05-24 08:18
Pact won't verify behaviour, so you'd probably find that driving stuff through the UI will hit problems with any non-elementary interactions

paulswilliams
2018-05-24 08:51
Understood. The difficulty with our project is that the consuming website is required to have very little logic - that should all be pushed down to the provider. Thus really, all we need to test is that UI interactions will result in the appropriate collaboration with the provider.

paulswilliams
2018-05-24 08:52
The strategy would be to use Pact provider tests to ensure the invocation / shape of results, and exception codes are appropriate. Then detailed testing of the provider would be via other test automation.

paulswilliams
2018-05-24 08:53
It seems a waste to use Pact for the unit testing of our consumers client classes, and then code further fake providers for the Acceptance Tests :confused:

paulswilliams
2018-05-24 09:04
Oh, that sounds like a potentially better fit :confused: Any pointers to documentation for that? It?s kinda what I originally thought Pact would be.

paulswilliams
2018-05-24 09:59
You?re talking about https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-server in that case? Presumably here, we could start the standalone server, run ATs against the real provider, and it would record Pacts. We could then rerun ATs against it in ?stub? mode, but couldn?t verify against it? Just verify that the client still worked against the stub? Then we?d have the Pacts that would allow us to write the provider tests?

paulswilliams
2018-05-24 10:34
So I I can see that pact-jvm-server can be used to record pacts from real interactions between consumer and provider. Can this also be used to run a mocked provider for consumer tests? I can't see this in the documentation? There doesn't appear to be end points for pact uploads, nor a pact folder to allow the server to receive pacts?

vinod.baradwaj
2018-05-24 11:20

vinod.baradwaj
2018-05-24 11:21
i am not able to import `au.com.dius.pact.consumer.exampleclients.ConsumerClient`

vinod.baradwaj
2018-05-24 11:21
i have added pact jvm concumer dependency, ``` <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-junit_2.12</artifactId> <version>3.5.16</version> </dependency> ```

vinod.baradwaj
2018-05-24 11:21
what am i missing in this ?

vinod.baradwaj
2018-05-24 11:28
should i have to build my own client ?

gopinathlangote11
2018-05-24 11:28
@vinod.baradwaj Are you(maven) able to download the dependancy?

vinod.baradwaj
2018-05-24 11:28
yeah i am able to download dependency from maven repository

gopinathlangote11
2018-05-24 12:50
@vinod.baradwaj : ``` <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-junit_2.12</artifactId> <version>3.5.16</version> </dependency> ``` Here with artifact id `pact-jvm-consumer-junit_2.12` version `3.5.16` is not available. I changed it to `pact-jvm-consumer-junit_2.11` & it was working fine for me.

gopinathlangote11
2018-05-24 12:50
I referred `https://repo1.maven.org/maven2/au/com/dius/` this url to see all artifacts & their versions.


vinod.baradwaj
2018-05-24 12:53
this one has 3.5.16

gopinathlangote11
2018-05-24 12:56
Interesting

paulswilliams
2018-05-24 14:52
Is there a standalone jvm server to support mocking for the consumer tests? Is this where I should use https://github.com/pact-foundation/pact-mock_service ?

abubics
2018-05-24 23:23
What?s your strategy for automating acceptance tests?

abubics
2018-05-24 23:25
I would usually champion screen-driver tests that pass through as few layers as possible (especially not out to network), because more layers = more flaky, especially once you get out of process

abubics
2018-05-24 23:26
Even in Android, my UI tests only test behaviour, and hit API client stubs, in-process, never making it to a network call :slightly_smiling_face:

abubics
2018-05-24 23:28
because acceptance tests usually consist of performing an action, and then verifying that a change happened, I?m not sure how Pact could help . . . but if you have a different approach, I?m excited to hear about it :smile:

abubics
2018-05-24 23:30
This is the base page describing the mock and stub services: https://github.com/pact-foundation/pact-mock_service

abubics
2018-05-24 23:31
but it still might be tricky to use for behaviour

uglyog
2018-05-24 23:54
pact-jvm-server runs the mock server, which uses the pact files to pretend to be the provider.

uglyog
2018-05-24 23:57
That class is in the test code, so is not in the published jar file. Just copy it and use it to create your own. But you should be using your own actual client code.

uglyog
2018-05-25 00:00
You should be able to use any of the standalone mock severs. There are 3 that I know about: https://github.com/pact-foundation/pact-mock_service, https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-server or https://github.com/pact-foundation/pact-stub-server. The later one is different as it does not verify the requests, just returns the matching response.

vinod.baradwaj
2018-05-25 04:57
yeah, understood. I have created my own client..

shirren
2018-05-25 07:19
has joined #pact-jvm

shirren
2018-05-25 07:36
Hi all! I am new to Pact. We have successfully authored some contracts which we successfully validate via pactFile but when we try to use a pact broker via a pactUrl we keep getting a 401 error. Our configuration looks like follows. Any help would be greatly appreciated;

shirren
2018-05-25 07:36
```<serviceProviders> <serviceProvider> <name>xyz</name> <protocol>http</protocol> <host>localhost</host> <port>8080</port> <path>/</path> <pactBroker> <url>https://test.pact.dius.com.au</url> <authentication> <username>${env.PACT_BROKER_USER}</username> <password>${env.PACT_BROKER_PASSWORD}</password> </authentication> </pactBroker> <consumers> <consumer> <name>jsclient</name> <pactUrl>https://test.pact.dius.com.au/pacts/provider/xyz/consumer/abc/latest</pactUrl> </consumer> </consumers> </serviceProvider> </serviceProviders>```

shirren
2018-05-25 07:38
Note that we are using version 3.5.16 of pact-jvm-provider-maven_2.12

shekharsp27
2018-05-25 11:10
Hi Shirren, are you able to login to "https://test.pact.dius.com.au" through browser?

paulswilliams
2018-05-25 13:50
So, I?ve followed advise and am now using Pact to integration test my consumer?s client objects, and provider?s controllers. It doing so, I?m struggling to get a provider verification working: My Spring Boot Tests: ```@RunWith(SpringRestPactRunner.class) @Provider("simple-auth-api") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @PactFolder("/Users/will/src/simple/web/target/pacts") public class AuthControllerTest { @MockBean AuthService authService; @TestTarget public final Target target = new HttpTarget(8081); @State("test login") public void returnSuccessfulLogin() { when(authService.login("paul", "secret")).thenReturn(new User(123, "paul", "Paul", "Williams")); } }``` with my controller ```@RestController public class AuthController { private final AuthService authService; @Autowired public AuthController(AuthService authService) { this.authService = authService; } @GetMapping(value = "/login", produces = MediaType.APPLICATION_JSON_VALUE) public User login(@RequestParam(value="username", required = false) String username, @RequestParam(value="password", required = false) String password) { return authService.login(username, password); } } ``` should, to my belief pass, but fails with ``` returns a response which has status code 200 (OK) includes headers "Content-Type" with value "application/json;charset=UTF-8" (FAILED) has a matching body (FAILED) Failures: 0) successful login returns a response which has a matching body comparison -> Expected a response type of 'application/json' but the actual type was 'text/plain' 1) successful login returns a response which includes headers "Content-Type" with value "application/json;charset=UTF-8" Expected a header 'Content-Type' but was missing java.lang.AssertionError: 0 - Expected a response type of 'application/json' but the actual type was 'text/plain' 1 - Expected a header 'Content-Type' but was missing```

abubics
2018-05-27 01:06
If you `curl` that endpoint, does it have a `Content-Type` header?

shirren
2018-05-27 09:42
Hi @shekharsp27 yes, I am also able to retrieve the contract via a curl request using basic auth. The maven plugin has no issues publishing, just seem to have trouble retrieving a contract with basic auth. Looking at the plugin code it should work so a bit confused as to why it does not. Have you used maven plugin the way we have?

ashish.dubey91
2018-05-27 19:02
has joined #pact-jvm

ashish.dubey91
2018-05-27 19:03
hi guys. I have a question around testing a contract in a consumer for a particular provider state

ashish.dubey91
2018-05-27 19:04
I mean. I've defined 2 states with the same URL

ashish.dubey91
2018-05-27 19:05
in my consumer tests, I'd like to specify which provider state, before sending request for that URL and verifying the response

paulswilliams
2018-05-27 20:39
@abubics it did from Safari: it was parameter related. I stripped them off, tests went green, and then I re-added them using he dsls rather than manually specifying url?params and tests still pass :+1:

uglyog
2018-05-27 23:54
Use two different tests for this. There is no way to let the mock server know which response to return.

shekharsp27
2018-05-28 05:14
Hi @shirren, I am using maven plugin to verify pacts from pact broker, however in my case the pact broker is running as localhost. I'll try by setting basic auth & will update if that works for me

ashish.dubey91
2018-05-28 05:22
okay. makes sense. I saw it in some example. guess I'll have to use that way. thanks

shirren
2018-05-28 05:44
Cool, thanks for that

abhilash.hanumanth
2018-05-28 14:05
Did anyone implement PACT for kakfa message queue consumer and provider ?

uglyog
2018-05-28 22:50
Yes @abhilash.hanumanth that was how the V3 message pact format came about

abhilash.hanumanth
2018-05-29 05:35
@uglyog: I dont see an example for provider test using pact jvm. Can you please look at my simple kakfa application with simple consumer and producer with a simple message here : https://stackoverflow.com/questions/50569251/pact-jvm-for-message-queues-can-someone-provide-sample-provider-test-for-kafka

abhilash.hanumanth
2018-05-29 10:48
@uglyog: In this blog, this is provider test: ``` class ConfirmationKafkaMessageBuilderTest { @PactVerifyProvider('an order confirmation message') String verifyMessageForOrder() { Order order = new Order() order.setId(10000004) order.setExchange('ASX') order.setSecurityCode('CBA') order.setPrice(BigDecimal.TEN) order.setUnits(15) order.setGst(15.0) order.setFees(BigDecimal.TEN) def message = new ConfirmationKafkaMessageBuilder() .withOrder(order) .build() JsonOutput.toJson(message) } } ``` Can you please tell me what is exactly `ConfirmationKafkaMessageBuilder` ? Is this actual class in kafka producer in source code which publishes message to topic ?

abhilash.hanumanth
2018-05-29 12:57
Here is consumer Test code : ``` package com.appd.contracts; import java.util.HashMap; import java.util.Map; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import au.com.dius.pact.consumer.MessagePactBuilder; import au.com.dius.pact.consumer.MessagePactProviderRule; import au.com.dius.pact.consumer.Pact; import au.com.dius.pact.consumer.dsl.PactDslJsonBody; import au.com.dius.pact.consumer.PactVerification; import au.com.dius.pact.model.v3.messaging.MessagePact; public class ExampleMessageConsumerTest { @Rule public MessagePactProviderRule mockProvider = new MessagePactProviderRule(this); private byte[] currentMessage; @Pact(provider = "SimpleProvider", consumer = "SimpleConsumer") public MessagePact createPact(MessagePactBuilder builder) { PactDslJsonBody body = new PactDslJsonBody(); body.stringValue("10", "100"); Map<String, String> metadata = new HashMap<>(); metadata.put("contentType", "application/json"); return builder.given("SomeProviderState") .expectsToReceive("a test message") .withMetadata(metadata) .withContent(body) .toPact(); } @Test @PactVerification({"test_provider", "SomeProviderState"}) public void test() throws Exception { Assert.assertNotNull(new String(currentMessage)); } public void setMessage(byte[] messageContents) { currentMessage = messageContents; } } ```

abhilash.hanumanth
2018-05-29 12:57
Can someone tell me how to write provider test for above consumer test ?

gnewitt
2018-05-29 22:48
has joined #pact-jvm

uglyog
2018-05-29 23:25
ConfirmationKafkaMessageBuilder is a class that I wrote that constructs the objects that will become the message. It is nothing special, just implements the builder pattern.

abhilash.hanumanth
2018-05-30 04:18
In ConfirmationKafkaMessageBuilder class, do you actually call the Producer class to construct the message ?

abhilash.hanumanth
2018-05-30 04:20
@uglyog: Lets say this is the sample kafka application which has simple producer and consumer : https://stackoverflow.com/questions/50569251/pact-jvm-for-message-queues-can-someone-provide-sample-provider-test-for-kafka. Can you pls tell me if the below consumer test is correct ? ``` package com.appd.contracts; import java.util.HashMap; import java.util.Map; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import au.com.dius.pact.consumer.MessagePactBuilder; import au.com.dius.pact.consumer.MessagePactProviderRule; import au.com.dius.pact.consumer.Pact; import au.com.dius.pact.consumer.dsl.PactDslJsonBody; import au.com.dius.pact.consumer.PactVerification; import au.com.dius.pact.model.v3.messaging.MessagePact; public class ExampleMessageConsumerTest { @Rule public MessagePactProviderRule mockProvider = new MessagePactProviderRule(this); private byte[] currentMessage; @Pact(provider = "SimpleProvider", consumer = "SimpleConsumer") public MessagePact createPact(MessagePactBuilder builder) { PactDslJsonBody body = new PactDslJsonBody(); body.stringValue("10", "100"); Map<String, String> metadata = new HashMap<>(); metadata.put("contentType", "application/json"); return builder.given("SomeProviderState") .expectsToReceive("a test message") .withMetadata(metadata) .withContent(body) .toPact(); } @Test @PactVerification({"test_provider", "SomeProviderState"}) public void test() throws Exception { Assert.assertNotNull(new String(currentMessage)); } public void setMessage(byte[] messageContents) { currentMessage = messageContents; } } ```

shekharsp27
2018-05-30 06:30
Hi Abhilash, Yes, on message provider side your test method has to create message and need to publish the message to queue which is configured for testing. PACT will pick up the test method by checking @PactVerifyProvider("This string should match with the string in description string in pact file") and your test method needs to retrieve message which is published and has to return that message. Pact will automatically search for test method which is annotated with @PactVerifyProvider("") and will match the message returned by test method & the message consumer is expecting (which is present in pact file). As in above example (test) function "ConfirmationKafkaMessageBuilder" is must be publishing the message & retrieving message as well

hstene
2018-06-02 13:08
has joined #pact-jvm

ashish.dubey91
2018-06-03 13:35
hey guys, is it possible to write PactDslJsonBody fragments and reuse them in contracts? I'll give an example - I have a product detail API which responds with a product details in a JSON and then there is a list of products endpoint which sends the list of product detail objects. is it possible to define product detail JSON body and reuse it for validating the product list array?

uglyog
2018-06-03 23:46
It should be possible, the only issue is the DSL does not have any way to attach a fragment at some point in the body.

abubics
2018-06-04 00:24
I?m doing some things like that in Kotlin . . . you should be able to do it similarly in Java, just more verbose :stuck_out_tongue:

abubics
2018-06-04 00:25
``` open class PactBase : StringSpec() { val token = "test_token" val builder: PactDslWithProvider = ConsumerPactBuilder .consumer("[REDACTED] Android") .hasPactWith("[REDACTED] BFF") val authToken = "valid_token" val requestHeaders = mapOf("Authorization" to "Bearer $authToken") val responseHeaders = mapOf("Content-Type" to "application/json;charset=utf-8") fun verify(pact: RequestResponsePact, func: [REDACTED]Connector.() -> Unit) { val config = MockProviderConfig.createDefault() val result = runConsumerTest(pact, config, object : PactTestRun { override fun run(mockServer: MockServer) { build[REDACTED]Client(mockServer.getUrl(), { authToken }).func() } }) result shouldBe PactVerificationResult.Ok } } ```

abubics
2018-06-04 00:25
``` class PactTransferTests : PactBase() { init { "makes a transfer and receives a receipt" { val pact = builder .given("a member with some accounts") .uponReceiving("a request to transfer funds between accounts").run { headers(requestHeaders) method("POST") body(LambdaDsl.newJsonBody { with(it) { stringType("toAccountNumber", "S02-01") numberType("amount", BigDecimal("100.00")) } }.build()) path("/member/12345/[REDACTED]") } .willRespondWith().run { status(201) headers(responseHeaders) body(LambdaDsl.newJsonBody { with(it) { stringType("receiptNumber", "receipt-no-123456789") stringType("date", "2018-05-30") stringValue("fromAccount", "abc") stringValue("toAccount", "def") numberValue("amount", 100) } }.build()) } .toPact() verify(pact) { makePaymentTransfer( CreateTransferRequest( sessionToken = token, userId = "12345", from = "abc", to = "def", amount = BigDecimal("100.00") ) ) shouldBe Response.Success( TransferReceipt( number = "receipt-no-123456789", date = "2018-05-30", from = "abc", to = "def", amount = BigDecimal("100.00") ) ) } } } } ```

abubics
2018-06-04 00:26
@ashish.dubey91 The `body()` parameter is an object, so you can create it anywhere and reuse it anywhere else

hstene
2018-06-04 04:56
I am using the `SpringRestPactRunner` but I am not sure how i provide which version of my application which is running the verification. The broker only says version `0.0.0` but I would like it to get the version from the gradle.properties-file in my project. Anyone know how I do that?

hstene
2018-06-04 04:56
``` @Provider(?customer?) @IgnoreNoPactsToVerify @PactBroker(host = ?localhost?, port = ?3000?) @RunWith(SpringRestPactRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ContractVerificationTest { @Autowired CustomerRepository customerRepository; @TestTarget public final Target target = new SpringBootHttpTarget(); @State({?default?, ?extra?}) public void toDefaultState() { System.out.println(?Now service in default state?); } @State(?Customer with ssn(71039012345) exists.?) public void getCustomerPactTest() { customerRepository.add(Customer.builder().name(?Roger Antonsen?).socialSecurityNumber(?71039012345").build()); } @State(?Customer with socialSecurityNumber(71039012345) exists.?) public void getCustomerPactTest2_0() { customerRepository.add(Customer.builder().name(?Roger Antonsen?).socialSecurityNumber(?71039012345").build()); } } ```

uglyog
2018-06-04 04:58
It uses a Java system property by default: `pact.provider.version`

hstene
2018-06-04 05:00
How do I link the gradle.properties value to that system property :thinking_face: Got any ideas?

uglyog
2018-06-04 05:00
In the test task config

hstene
2018-06-04 05:01
Ah, ofc

uglyog
2018-06-04 05:01
``` test { systemProperty 'pact.provider.version', project.version } ```

uglyog
2018-06-04 05:01
Something like that

hstene
2018-06-04 05:04
``` test { systemProperties['pact.provider.version'] = project.version } ```

hstene
2018-06-04 05:04
Works fine. Thank you :slightly_smiling_face:

vinod.baradwaj
2018-06-04 06:40
when i try to run `mvn pact:verify` i am getting the following error, ``` Unable to parse configuration of mojo au.com.dius:pact-jvm-provider-maven_2.12:3.5.11:verify for parameter pactDirectory: Cannot find 'pactDirectory' in class au.com.dius.pact.provider.maven.Provider ``` these are my build configs, ``` <plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven_2.12</artifactId> <version>3.5.11</version> <configuration> <serviceProviders> <!-- You can define as many as you need, but each must have a unique name --> <serviceProvider> <name>flex-master</name> <requestFilter> request.addHeader('Authorization', 'Basic *') </requestFilter> <!-- All the provider properties are optional, and have sensible defaults (shown below) --> <protocol>https</protocol> <host>master.qa1.product.net</host> <pactDirectory>pacts/flex-enterprise</pactDirectory> </serviceProvider> </serviceProviders> </configuration> </plugin> ```

uglyog
2018-06-04 06:42
It needs to be `pactFileDirectory`

vinod.baradwaj
2018-06-04 06:44
thank you... :slightly_smiling_face:

ashish.dubey91
2018-06-04 10:01
thanks @abubics

ashish.dubey91
2018-06-04 10:15
hey. I'm trying to do this check in my contract ``` .minArrayLike("objects", 2) .object() .integerType("type", 21) .closeObject() .closeArray() ```

ashish.dubey91
2018-06-04 10:16
what I'd additionally want is - I can check for existence of another object in the array of this type ``` .object() .integerType("type", 20) .closeObject() ```

ashish.dubey91
2018-06-04 10:17
I can't chain minArrayLike. Ideally I'd want something that checks for inclusion of the example objects in the array

abubics
2018-06-04 23:44
checking the content like that sounds more like a behaviour thing, probably better suited to a unit test

abubics
2018-06-04 23:45
Pact is more for ensuring the shape of the response, not so much the content

mboudreau
2018-06-05 00:23
however, if the value of the content needs to be 20 or 21 because it relates to the shape of the response (like an error code). In that case, I'd probably get a separate interaction specifically for that case.

mboudreau
2018-06-05 00:24
that being said, `integerType("type")` should be more than enough

abubics
2018-06-05 01:06
Yeah, if you?re trying to verify those numbers, you could regex it. But if you?re trying to verify something more sophisticated, maybe don?t do it with Pact :slightly_smiling_face:

abubics
2018-06-05 01:09
@ashish.dubey91 Can you describe the data shape and situation you want to test, rather than just the issues you?re having with the DSL?

ashish.dubey91
2018-06-05 02:07
@abubics I want to test the presence of two types of widgets in the response.

ashish.dubey91
2018-06-05 02:08
the data shape remains the same, but the value of `type` is different

mboudreau
2018-06-05 02:24
@ashish.dubey91 again, the pact test is all about contracts, which is all about structure, not about specifics. You can use the contract to validate that both mock results pass the pact test, then in your unit test, also make sure that 20 and 21 is there as well

mboudreau
2018-06-05 02:25
or you just make 2 different pact interactions for each one

ashish.dubey91
2018-06-05 02:32
technically, the structure of the inner keys can change as well based on the value of type

ashish.dubey91
2018-06-05 02:35
I can make 2 interactions, but I'll essentially be checking the value in both interactions because that value is also part of the contract for certain widget types

mboudreau
2018-06-05 02:37
yeah, think you're going to have to do that then if it changes based on the value

ashish.dubey91
2018-06-05 02:45
which is what I think could have been better if I could chain `minArrayLike` or some other DSL method I could use to achieve this in single interaction

mboudreau
2018-06-05 03:00
yeah, but makes your contract very broad

mboudreau
2018-06-05 03:00
Pact doesn't do this out of the box

ashish.dubey91
2018-06-05 03:20
yeah in a few cases, my contract is indeed a bit broad

vinod.baradwaj
2018-06-06 13:46
i have created this interaction, ```@Pact(provider = "flex-authorisation-service", consumer = "flex-publishindexer-service") public RequestResponsePact createPact(PactDslWithProvider builder) { Map<String, String> headers = new HashMap(); headers.put("Content-Type", "application/vnd.nativ.mio.v1+json"); return builder .given("There is a request to get details of a Job") .uponReceiving("Returns details of the authorisation for the user") .path("/api/filter/5") .query("action=EDIT") .body("{\"objects\":[{\n" + " \"objectId\":1,\n" + " \"accountId\":4,\n" + " \"ownerId\":5,\n" + " \"workspaceId\":1,\n" + " \"typeName\":\"collection\",\n" + " \"privateGroup\":false\n" + "}]}") .method("POST") .willRespondWith() .status(200) .headers(headers) .body("[\n" + " 10908\n" + "]").toPact(); }``` is it possible for me to add matcher for payload body ?


abubics
2018-06-07 00:43
If you have to use Java, it?s quite verbose, but the JSON body DSL exists :slightly_smiling_face:

vinod.baradwaj
2018-06-07 07:42
what if i have a complex body with lot of objects in it ? can i make use of json object mapper and will this DSL make use of it ?

dervis4
2018-06-07 08:26
has joined #pact-jvm

abubics
2018-06-07 10:37
I don't think so (but I don't know much about objectmapper).

abubics
2018-06-07 10:38
If the body has a well-defined structure, and relatively static schema, its complexity shouldn't be a significant issue.

abubics
2018-06-07 10:40
If the content (or schema) is deterministic, based on a known state, you won't have any problems.

vinod.baradwaj
2018-06-08 05:53
thanks @abubics :slightly_smiling_face:

vinod.baradwaj
2018-06-08 07:10
i have request payload something like this, ```{"objects":[{ "objectId":10908, "accountId":10122, "ownerId":10214, "workspaceId":10121, "typeName":"collection", "privateGroup":false }]}```


minhdoan
2018-06-08 08:25
Hi @uglyog and team,

minhdoan
2018-06-08 08:27
I want to create a record to test the request: /odata/CHAIR?$filter=CREATED_BY/FIRST_NAME eq 'LIMS'&$orderby=Id asc

vinod.baradwaj
2018-06-08 08:29
got it.. :+1:

minhdoan
2018-06-08 08:29
With the code as below:

minhdoan
2018-06-08 08:29
.path("/odata/CHAIR") .query("$filter=CREATED_BY/CI_FIRST_NAME eq 'LIMS'&$orderby=Id asc")

minhdoan
2018-06-08 08:31
The record on broker has value:

minhdoan
2018-06-08 08:31
{ "method": "GET", "path": "/odata/CHAIR", "query": "$filter=CREATED_BY%2F_FIRST_NAME+eq+%27LIMS%27&$orderby=Id+asc" }

minhdoan
2018-06-08 08:32
and if i run pactVerify the record, a error code 400 is received

minhdoan
2018-06-08 08:32
{ "error": { "code": "1001", "message": "The types 'Edm.Boolean' and 'Edm.String' are not compatible." } }

minhdoan
2018-06-08 08:32
I think it is a known issue with "+" in the request

minhdoan
2018-06-08 08:33
but i have tried with .path("/odata/CHAIR") .encodedQuery("$filter=CREATED_BY%2FCI_FIRST_NAME%20eq%20%27LIMS%27&$orderby=Id%27asc")

minhdoan
2018-06-08 08:35
and the record is

minhdoan
2018-06-08 08:35
{ "method": "GET", "path": "/odata/CHAIR", "query": "$filter=CREATED_BY%252FIRST_NAME%2520eq%2520%2527LIMS%2527&$orderby=Id%2520asc" }

minhdoan
2018-06-08 08:36
so the pactverify has same error code

minhdoan
2018-06-08 08:36
so any solution on it?

minhdoan
2018-06-08 08:36
Many thanks team!

mr.matt.r.long
2018-06-08 13:45
has joined #pact-jvm

mr.matt.r.long
2018-06-08 14:18
Hi all, I'm having an issue publishing our provider verification, using pact-jvm-provider-spring. The broker details are set in the broker annotation within the test class: `@PactBroker(host = "${pactBrokerHost}", port = "443")` which is successfully pulling the Pact files, but after verification I'm getting the message `Skipping publishing verification results for source ...`. Originally I didn't have the pact.provider.version sys variable set, this is now set by maven surefire plugin

mr.matt.r.long
2018-06-08 14:18
Any help greatly appreciated

mr.matt.r.long
2018-06-08 15:30
Interestingly after downgrading to 3.5.16 the verification was successfully published.

uglyog
2018-06-09 07:41
Thanks for raising the issue. It should not be encoding the space as a +, but as %20

uglyog
2018-06-09 07:43
In that case could you raise an issue? It must be a regression.

daniel.delatorrebabi
2018-06-10 11:22
has joined #pact-jvm

daniel.delatorrebabi
2018-06-10 11:34
Hello guys, I am having some issues when I try to execute gradlew pactVerify from my provider. (editado) My jetty server starts correctly but the process gets stuck when it is executing pact:pact-spring-provider:startProvider (editado) it seems that it never goes to my pactbroker server to verify the pact

daniel.delatorrebabi
2018-06-10 11:46
any idea about this?

daniel.delatorrebabi
2018-06-10 11:48
when I run the tests via junit with intellij the tests are executed correctly and the pact is verified in the pactbroker, but I could not do it with gradle pactVerify

uglyog
2018-06-11 00:53
@daniel.delatorrebabi pactVerify is for verifying a separate running provider. If you are verifying with a JUnit test, it will run as part of the test phase (`gradle test`)

matt
2018-06-11 01:40
has joined #pact-jvm

minhdoan
2018-06-11 02:26
@uglyog The link to the issue here, could you please help to change issue type to bug if it is reasonable? And any plan to fix it? Many thanks!

uglyog
2018-06-11 02:27
sure, I'm looking at some defects today, I'll see if I can sort it out for you

minhdoan
2018-06-11 06:43
:+1::skin-tone-3:

daniel.delatorrebabi
2018-06-11 06:48
Hello uglyog, thanks so much for your response. If I use gradlew test the pact is verified in the pactbroker but the version of my provider is not pushed. Is this behaviour expected?


uglyog
2018-06-11 06:52
Can you provide the version of Pact-JVM you are using?

minhdoan
2018-06-11 06:55
I am using 'au.com.dius:pact-jvm-consumer-junit_2.11:3.5.9' for consumer side test

minhdoan
2018-06-11 06:55
Hope it help

daniel.delatorrebabi
2018-06-11 06:57
thanks so much!

uglyog
2018-06-11 06:57
Just saw your comment on the the issue. Try upgrade to version 3.5.13 or later

daniel.delatorrebabi
2018-06-11 06:57
you helped me a lot!

minhdoan
2018-06-11 06:59
ok, let me try

minhdoan
2018-06-11 07:11
i upgraded to testCompile 'au.com.dius:pact-jvm-consumer-junit_2.11:3.5.17'

minhdoan
2018-06-11 07:11
but the issue still happens

minhdoan
2018-06-11 07:42
And the Broker version is x-pact-broker-version: 2.19.2

minhdoan
2018-06-11 07:42
hope it help

mr.matt.r.long
2018-06-11 09:13
Sure, will log in github today

abhilash.hanumanth
2018-06-11 11:51
can someone point me to example of ```new PactDslJsonBody().and(String name, Object value, MatchingRule... rules)``` ?

abhilash.hanumanth
2018-06-11 11:51
I want to understand how to write MatchingRules


rgshah781988
2018-06-12 04:30
@abhilash.hanumanth

abhilash.hanumanth
2018-06-12 13:49
I have an array of strings of variable length which is expected in response body. For example : ```{ "Conditions":[ "conditionA", "conditionB", "conditionC" ] }``` How do I use stringType() or stringMatcher() for generalizing while creating pact using LambdaDsl with minArrayEachLike() ?

drhansen
2018-06-12 19:27
has joined #pact-jvm

mmonson
2018-06-12 20:02
has joined #pact-jvm


abubics
2018-06-13 02:02
If that doesn?t help, can you be more specific about what you?re having trouble with?

uglyog
2018-06-13 02:02
I think the question is about the java 8 DSL


abubics
2018-06-13 02:02
oh right

abubics
2018-06-13 02:04
I answered a similar query 9 days ago, but I only have Kotlin code samples


abhilash.hanumanth
2018-06-13 02:29
Hi @uglyog: This is creating a 2D array like this : ``` "Conditions": [ [ "foo" ] ] ```

uglyog
2018-06-13 02:30
Have a look at the other tests in that class, there probably is one similar to what you need

abhilash.hanumanth
2018-06-13 03:18
Hi @uglyog : ``` @Test public void testStringArray() { /* [ "Foo", "Bar", "x" ] */ // Old DSL final String pactDslJson = new PactDslJsonArray("", "", null, false) .string("Foo") .stringType("Bar") .stringMatcher("[a-z]", "x") .getBody().toString(); // Lambda DSL final PactDslJsonArray actualPactDsl = new PactDslJsonArray("", "", null, false); final LambdaDslJsonArray array = new LambdaDslJsonArray(actualPactDsl); array .stringValue("Foo") .stringType("Bar") .stringMatcher("[a-z]", "x") .build(); String actualJson = actualPactDsl.getBody().toString(); assertThat(actualJson, is(pactDslJson)); } ``` Above test has the same array example I am looking for but each element is being constructed using LambdaDsl. But in my case, the array which is expected in response is of variable length. So, I am looking to generalize the array construction using LambdaDsl.

abhilash.hanumanth
2018-06-13 03:18
This is my actual array inside an object : ``` { "excludedPackages": [ "name=java,description=Core Java Libraries,system=true", "name=javax,description=Java Extension/J2EE Libraries,system=true", "name=com.sun,description=Sun Reference Implementations/JDK Core Classes,system=true", "name=sun,description=Sun Reference Implementations/JDK Core Classes,system=true", "name=org,description=Common Open Source Libraries like Apache's,system=true", "name=com.bea,description=BEA Core Classes,system=true", "name=com.weblogic,description=Weblogic Server Core Classes,system=true", "name=weblogic,description=Weblogic Server Core Classes,system=true" ] } ```

uglyog
2018-06-13 03:48
Sorry, there is no example for this. But it should not be too hard to work out.

minhdoan
2018-06-13 04:18
I have added comment in the ticket https://github.com/DiUS/pact-jvm/issues/693

minhdoan
2018-06-13 04:18
Please help me on it! Many thanks in advance!

abhilash.hanumanth
2018-06-13 05:59
@uglyog: There is no implementation for such example in eachLike(), minArrayLike(), maxArrayLike() methods

uglyog
2018-06-13 06:02
Hmm, you are correct. There is only support for arrays of objects. Can you raise an issue for this?

abhilash.hanumanth
2018-06-13 06:02
sure

abubics
2018-06-13 07:39
Maybe a misdirection, but having data structures encoded inside strings in JSON is probably a smell :stuck_out_tongue:

abubics
2018-06-13 07:39
if those were broken out to objects, they?d be less brittle, and not incur nested encoding penalties

minhdoan
2018-06-13 07:43
Hi guys, anyone has experience with encoding request URL as the ticket https://github.com/DiUS/pact-jvm/issues/693

minhdoan
2018-06-13 07:43
I am facing stuck and really need your help! Thanks!

minhdoan
2018-06-14 10:18
Hi guys,

minhdoan
2018-06-14 10:19
i want to create a request with an invalid correlationid value in request header

minhdoan
2018-06-14 10:19
the script in @Test method is

minhdoan
2018-06-14 10:19
HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); headers.set(CORRELATION_ID_HEADER_FIELD, INVALID_CORRELATION_ID); HttpEntity request = new HttpEntity<>(null, headers); try { new RestTemplate().exchange(provider.getUrl() + GET_ENTITY, HttpMethod.GET, request, String.class);

minhdoan
2018-06-14 10:20
but i don't know why the pact response creation always fails with error

minhdoan
2018-06-14 10:20
17:16:11.773 [Thread-9] ERROR au.com.dius.pact.consumer.BaseMockServer - Failed to generate response groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object The current character read is 'i' with an int value of 105 Unable to determine the current character, it is not a string, number, array, or object line number 1 index number 0 is not valid for correlationId

thadir
2018-06-17 20:02
has joined #pact-jvm

minhdoan
2018-06-18 03:56
Hi team, anyonehas experience to build Pact record for batch requests?

minhdoan
2018-06-18 03:58
I am doing it but i do not know exactly the type response body should be initialized: PactDslRootValue, PactDslJsonBody, PactDslResponse etc

minhdoan
2018-06-18 04:00
The actual response i received in Postman is:

minhdoan
2018-06-18 04:00
--batch_b8c933bd-2f58-4432-b8dc-ad8280d928b1 Content-Type: application/http Content-Transfer-Encoding: binary HTTP/1.1 200 OK OData-Version: 4.0 Content-Type: application/json;odata.metadata=minimal Content-Length: 328 {"@odata.context":"http://localhost/odata/$metadata#CHAIR/$entity","EntityTypeName":"CHAIR","Id":17368336,} --batch_b8c933bd-2f58-4432-b8dc-ad8280d928b1--

minhdoan
2018-06-18 04:00
the content-type is: multipart/mixed; boundary=batch_b8c933bd-2f58-4432-b8dc-ad8280d928b1

abubics
2018-06-18 04:00
let?s keep it in a thread :slightly_smiling_face:

minhdoan
2018-06-18 04:00
Ok, thanks Boris

abubics
2018-06-18 04:00
it?s a good idea if you can put ``` around the code bits, too

minhdoan
2018-06-18 04:01
:+1:

minhdoan
2018-06-18 04:02
I assume the response body is text so i built the body with ```.body(PactDslRootValue.stringMatcher("--batch_[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}--", "--batch_b8c933bd-2f58-4432-b8dc-ad8280d928b1--"))```

abubics
2018-06-18 04:02
multipart shouldn?t really affect the reconstructed payload

abubics
2018-06-18 04:02
but it affects what is sent over the wire :thinking_face:



abubics
2018-06-18 04:04
if that doesn?t get you far enough, come back and ask again :slightly_smiling_face:

minhdoan
2018-06-18 04:04
Okie, let me try

uglyog
2018-06-18 04:04
Only file uploads are supported at the moment

minhdoan
2018-06-18 04:04
many thanks Boris!


minhdoan
2018-06-18 04:05
@uglyog Do you mean in my example, the body checking has not supported yet, right?

uglyog
2018-06-18 04:06
The DSL only has a `fileUpload` method, which sets up a multipart request.

uglyog
2018-06-18 04:07
You might want to look at that method to see what it is doing

uglyog
2018-06-18 04:08
Actually, the method is `withFileUpload`, and it might work for you as you only have one part

minhdoan
2018-06-18 04:13
Thank you so much! I try it now!

minhdoan
2018-06-18 04:25
Sorry but i am not sure that my case is similar with the File Upload

minhdoan
2018-06-18 04:26
I only want to build response body of a batch request with basic get entity part

minhdoan
2018-06-18 04:26
```Content-Type: multipart/mixed; boundary=batch_b8c933bd-2f58-4432-b8dc-ad8280d928b1```

minhdoan
2018-06-18 04:27
Is withFileUpload utilized in this case as well?

minhdoan
2018-06-18 04:37
My main purpose is build the response body as the line:

minhdoan
2018-06-18 04:37
```willRespondWith(status: 201, body: 'file uploaded ok', headers: ['Content-Type': 'text/plain'])```

minhdoan
2018-06-18 04:38
I received the raw response as:

minhdoan
2018-06-18 04:38
```--batch_b8c933bd-2f58-4432-b8dc-ad8280d928b1 Content-Type: application/http Content-Transfer-Encoding: binary HTTP/1.1 200 OK OData-Version: 4.0 Content-Type: application/json;odata.metadata=minimal Content-Length: 328 {"@odata.context":"http://localhost/odata/$metadata#CHAIR/$entity","EntityTypeName":"CHAIR","Id":17368336,} --batch_b8c933bd-2f58-4432-b8dc-ad8280d928b1--```

minhdoan
2018-06-18 04:38
But it seems not to be string type

uglyog
2018-06-18 04:49
Do you mean that your response body is a multipart body?

minhdoan
2018-06-18 04:57
@uglyog yes, i meant that

uglyog
2018-06-18 04:59
Oh, yeah, multipart bodies are only supported with requests.

uglyog
2018-06-18 05:02
Pact won't understand the batch response content types, so it won't be able to match it


minhdoan
2018-06-18 05:04
Yes, i need this info because i am not sure about the pact implementation

minhdoan
2018-06-18 05:04
Will there plan to support it? And i will add the info to the ticket?

uglyog
2018-06-18 05:05
If you add the information to the ticket, then it won't get lost, because I doubt anyone will refer back to slack

uglyog
2018-06-18 05:05
That way when that ticket is worked on, we will know to also support batch responses

minhdoan
2018-06-18 05:10
(y)

minhdoan
2018-06-18 05:10
I am adding, many thanks for your guide!

vinod.baradwaj
2018-06-18 13:19
i am not able to create separate interactions for endpoint with different id's. for eg i have an endpoints like this `/api/collections/10900` and `/api/collections/10908` i cant use matchers/regex because i need to provide different response for both the requests. Is there someway i can have multiple interactions added in same pact file for different id's in the endpoint ?

rgshah781988
2018-06-18 13:38
Is it POST call then possible via different body.

rgshah781988
2018-06-18 13:39
If it is GET call then sorry.

vinod.baradwaj
2018-06-18 13:39
i need for get

vinod.baradwaj
2018-06-18 13:39
:disappointed:

drhansen
2018-06-18 18:26
I am setting up pact as a provider in Java. I am seeing quite a few examples around the web of how to do it but they all differ quite a bit. Does someone have a guide or clear example that they prefer (set up and to run a test)? We have a spring boot application and are using gradle.

tlane
2018-06-18 18:42
has joined #pact-jvm

uglyog
2018-06-18 23:14
Are you looking to write a consumer test, or verify the provider?

kra
2018-06-19 20:39
has joined #pact-jvm

kra
2018-06-19 20:40
Hi @here:slightly_smiling_face: I am pretty new to pact and currently troubleshooting my provider test (Spring Boot, Junit5): When I start my test I get: request Failed - Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect What am I missing? ` @SpringBootTest @Provider("GoalProvider") @PactFolder("pacts") @ExtendWith({ SpringExtension.class }) class GoalProviderPactTest { @Autowired GoalRepository goalRepository; @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @State("default") public void toDefaultState() { // Prepare service before interaction that require "default" state goalRepository.saveAndFlush(goal); } } `

kra
2018-06-19 20:53
Am I right that I should start my service with (SpringExtension) instead of mocking it with wiremock (like in most samples)?

uglyog
2018-06-19 23:22
The problem with examples is they are just test examples and there is no real service to start

minhdoan
2018-06-20 03:26
@abubics @uglyog Morning and nice day!

minhdoan
2018-06-20 03:27
I have raised an ticket for Batch request supporting. Please help to take a look and provide your ideas! https://github.com/DiUS/pact-jvm/issues/709

minhdoan
2018-06-20 03:27
Many thanks!

kra
2018-06-20 05:41
ok so my assumption to start my whole service is correct?

kra
2018-06-20 05:53
any idea what I am doing wrong that I get the conncetion refused error?

uglyog
2018-06-20 05:55
Not starting the service, or it's running on a different port?

kra
2018-06-20 05:58
let me check

kra
2018-06-20 05:59
could i set the port to which the pact requests are sent?

uglyog
2018-06-20 06:05
Yes, you should be able to inject the port, and then set the port when you define the target

kra
2018-06-20 06:15
my tomcat ist starting on 8099

kra
2018-06-20 06:15
however, The error message still says 8080

kra
2018-06-20 06:15
i do this: HttpTestTarget target = new HttpTestTarget("localhost",8099); context.setTarget(target); context.verifyInteraction();

kra
2018-06-20 06:33
the target seems to have no impact

kra
2018-06-20 06:33
when i set the port to 8080, it workds

kra
2018-06-20 12:53
Hi. Is there any sample of how to upload pact files/communication in general to a pact-broker in a java unit test?

kra
2018-06-20 12:53
I know that there is a @PactBroker annotation but have no other references

uglyog
2018-06-21 00:27
You can use either the Maven or Gradle plugin to publish the pacts files

shekharsp27
2018-06-21 12:53
Does the pact verify process has the ability to wait until provider application gets up & running. In case of using webhook feature from pact-broker

uglyog
2018-06-21 23:20
No, but it does support you providing a start provider step in which you could do the wait (in Gradle). In Maven, you could setup a pre-verification step using the standard Maven phases.

shekharsp27
2018-06-22 06:44
Thanks

santoshtrip
2018-06-26 01:19
has joined #pact-jvm

can
2018-07-02 12:04
has joined #pact-jvm

minhdoan
2018-07-04 06:55
Does anyone has experience with requests with space(s) in resource path or query options?

minhdoan
2018-07-04 06:55
Could you please help me on it?

mboudreau
2018-07-04 07:03
all spaces should be html encoded to `%20`

uglyog
2018-07-05 02:21
@paisrikanth can you provide the Gradle version, Pact version and any logs

paisrikanth
2018-07-05 02:21
has joined #pact-jvm

paisrikanth
2018-07-05 02:25
gradle version is 3.3

uglyog
2018-07-05 02:25
Also the java version

paisrikanth
2018-07-05 02:26
java is 1.8

paisrikanth
2018-07-05 02:26
logs

paisrikanth
2018-07-05 02:30
pact version - au.com.dius:pact-jvm-provider-gradle_2.11:3.5.0

uglyog
2018-07-05 02:31
Are there any java hprof files (in the form like `java_pid12345.hprof`) in your current working directory?

paisrikanth
2018-07-05 02:32
no

uglyog
2018-07-05 02:34
and what does running `./gradlew --status` give?


uglyog
2018-07-05 02:37
Your Gradle daemons are definitely not happy. Can you try with a later version of Pact-JVM. Latest is `au.com.dius:pact-jvm-provider-gradle_2.12:3.5.19`

paisrikanth
2018-07-05 02:38
I have this in my build.gradle file and running the command ./gradlew pactPublish

paisrikanth
2018-07-05 02:38
updating the version

paisrikanth
2018-07-05 02:49
gradle is still syncing :disappointed:

paisrikanth
2018-07-05 02:51
i still get the same error

uglyog
2018-07-05 02:52
hmm, ok, are you able to try with a different version of Gradle? 4.8.1 is the latest.

paisrikanth
2018-07-05 02:53
let me try that

paisrikanth
2018-07-05 02:55
is the build.gradle snippet i posted earlier correct >?

uglyog
2018-07-05 02:56
yes, that is ok

uglyog
2018-07-05 02:57
apart from `pactBrokerUrl = 'my-url'`, but I assume that will be your proper URL

paisrikanth
2018-07-05 02:57
yes

paisrikanth
2018-07-05 03:02
does the gradle 4.8.1 work with android studio 2.3.3

uglyog
2018-07-05 03:05
It should be ok, but you'll have to give it a try

paisrikanth
2018-07-05 03:11
trying it

paisrikanth
2018-07-05 03:18
@uglyog - I'm trying this on the local machine, should this be a problem ?

paisrikanth
2018-07-05 03:18
I just want to make sure the local pacts are uploading before I integrate this with Jenkins

uglyog
2018-07-05 03:21
Should not be a problem, but I have no idea why your Gradle agents are hanging

paisrikanth
2018-07-05 04:22
no luck with the gradle

paisrikanth
2018-07-05 04:22
4.8.1

paisrikanth
2018-07-05 04:22
:disappointed:

paisrikanth
2018-07-05 04:23
very strange not sure y the gradle crashes

uglyog
2018-07-05 04:23
Bummer

uglyog
2018-07-05 04:24
Ok, try running with `-d` to enable debug logging, but you will get a *lot* of output

uglyog
2018-07-05 04:25
You can also try without the daemon (`--no-daemon `)

ssn899
2018-07-05 05:02
has joined #pact-jvm

paisrikanth
2018-07-06 01:24
@uglyog I got it working

uglyog
2018-07-06 01:25
Yay! What was the issue?

paisrikanth
2018-07-06 01:25
code in the gradle file was required if version 2.1 and above the classpath dependency was killing it

uglyog
2018-07-06 01:26
oh, wow! That's good to know. I'll update the docs about that

paisrikanth
2018-07-06 01:26
also it works only with 3.2.11

paisrikanth
2018-07-06 01:26
the latest version crashes

uglyog
2018-07-06 01:27
Is that Gradle or pact-jvm version?

paisrikanth
2018-07-06 01:27
pact-jvm version

uglyog
2018-07-06 01:27
Can you provide your previous snippet with the build classpath?

paisrikanth
2018-07-06 01:28
this one worked for me where as the latest version is 3.5.19 which crashes

uglyog
2018-07-06 01:29
With Gradle 3.3?

paisrikanth
2018-07-06 01:29
yes

paisrikanth
2018-07-06 01:29
i haven't tested with latest gradle for pact-jvm version 3.5.19

uglyog
2018-07-06 01:30
Can you raise an issue for this at https://github.com/DiUS/pact-jvm

paisrikanth
2018-07-06 01:30
sure


paisrikanth
2018-07-06 01:31
the maven cannot find this

minhdoan
2018-07-06 12:02
Hi Michel! This is my issue i faced with the spaces in URL


minhdoan
2018-07-06 12:03
I have tried to downgraded the gradle to 4.7 and pactJvmVersion to "3.5.18", both consumer side and provider side.

minhdoan
2018-07-06 12:04
But the issue with + in url sent to provider still exists.

minhdoan
2018-07-06 12:05
@mboudreau Could you please help me on it? It blocks me some weeks :disappointed:. I think it is a basic feature so maybe my configuration is not correct or something like that.

minhdoan
2018-07-06 12:07
Have you tried with a record with spaces in URL? Could you please share me the basic script to resolve the issue?

minhdoan
2018-07-06 12:07
Many thanksssss again!

yamad
2018-07-07 11:16
has joined #pact-jvm

gaurav
2018-07-07 18:30
has joined #pact-jvm


steve.cook
2018-07-08 10:21
has joined #pact-jvm

paisrikanth
2018-07-09 06:19
@uglyog is there a document or an example on how to publish the pacts to the broker from the CI - Jenkins build

uglyog
2018-07-09 09:03
It's the same, nothing special about running from a Jenkins build

gaurav
2018-07-09 15:43
Is there no release: `3.5.19` for `pact-jvm-provider_2.11`? I see `pact-jvm-provider_2.12:3.5.19` in maven repository but can?t find `pact-jvm-provider_2.11:3.5.19`.. :confused:

paisrikanth
2018-07-10 01:31
@uglyog currently i'm do the command ./gradlew pactPublish to upload the files

paisrikanth
2018-07-10 01:32
I want this to run as task.. ex when I run the ciDev it should call the task and upload the files

uglyog
2018-07-10 08:58
let me check for you ...

paulswilliams
2018-07-10 09:12
Regarding this defect, my colleague has simplified the exemplar, and offered a work around fix that further sheds light on the root cause:

paulswilliams
2018-07-10 09:12
Adding ```@BeforeEach public void pause() throws InterruptedException { Thread.sleep(5000L); }``` around tests allows a green run on `master` but not ```@BeforeEach public void pause() throws InterruptedException { Thread.sleep(4500L); }```

uglyog
2018-07-10 09:59
I have re-released the missing jars

uglyog
2018-07-10 10:01
when you say "run as task", what do you mean? Is this a Jenkins thing?

gaurav
2018-07-10 11:55
Thanks @uglyog.. I still don?t see 3.5.19 in maven repository: https://mvnrepository.com/artifact/au.com.dius/pact-jvm-provider_2.11

uglyog
2018-07-10 12:22
It will be a few hours before the indexes are updated

gaurav
2018-07-10 12:49
great! Thanks.

paisrikanth
2018-07-11 00:31
yes Jenkins

paisrikanth
2018-07-11 04:10
@uglyog I get this error FAILED! 409 Conflict - This is the first time a pact has been published for

paisrikanth
2018-07-11 04:53
Quick question ex - my pact directory is "/workspace/app/pact-contracts/" and pact-contracts has two subfolders which has the json files Does the pactPublish all the files under the folder and sub-folders ??

sjani
2018-07-11 05:37
has joined #pact-jvm

uglyog
2018-07-11 09:20
The 409 conflict is because the consumer or provider name is similar to an existing one

uglyog
2018-07-11 09:20
I don't think it will pick up sub-folders

gaurav
2018-07-12 00:13
Its there. :thumbsup:

vinod.baradwaj
2018-07-12 08:34
anyone using https://github.com/warmuuh/pactbroker-maven-plugin this plugin to upload and download pacts from broker ?

vinod.baradwaj
2018-07-12 08:35
when i try to download using the above plugin i get the following error ``` com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 14 at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1505) at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1386) at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:531) at com.google.gson.stream.JsonReader.peek(JsonReader.java:414) at com.google.gson.JsonParser.parse(JsonParser.java:60) ... 27 more```

ssn899
2018-07-12 14:09
I did and it also did not work out well. Pact-provider-maven allows testing pacts from a broker (not downloading) https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-maven#verifying-pact-files-from-a-pact-broker

minhdoan
2018-07-13 03:15
Hi team, anyone has experience with request with space(s) in URL, when executing pactVerify the space should encoded to %20, unfortunately the '+'. I am stuck and don't know how to fix https://github.com/DiUS/pact-jvm/issues/693 Could you please help on it? Many thanks in advance!

vinod.baradwaj
2018-07-13 03:37
okay, let me try with this. Thank you :slightly_smiling_face:

minhdoan
2018-07-13 08:25
Hi team, i am executing pact provider test, the pact-jvm-provider-gradle library is used. My test suite contains 4 test cases (provider MULTI_USERS_PROVIDER has 4 consumers). My system requires login first so we must add an authorization header to each request as below: pact { // Configure the Pact verification log reports { defaultReports() // adds the standard console output json // report in json format } serviceProviders { MULTI_USERS_PROVIDER { requestFilter = { req -> // Add an authorization header to each request // because of our system needs login first with credential: user:password req.addHeader('Authorization', 'Basic dXNlcjpwYXNzd29yZA==') } protocol = providerScheme host = providerHost port = providerPort path = providerScheme + "://" + providerHost + ":" + providerPort + "/webservice" hasPactsFromPactBroker(pactBrokerScheme + "://" + pactBrokerHost + ":" + pactBrokerPort) } } } But in the test suite, there is one test case must use other user , instead of user:password. So i try to use the stateChange for this one: pact { serviceProviders { MULTI_USERS_PROVIDER { requestFilter = { req -> // Add an authorization header to each request // because of our system needs login first with credential: user:password req.addHeader('Authorization', 'Basic dXNlcjpwYXNzd29yZA==') } hasPactWith('AnotherUser_Consumer') { stateChangeUsesBody = false // defaults to true pactSource = url('http://pact-broker-local-repo.net/provider/MULTI_USERS_PROVIDER/consumer/AnotherUser_Consumer/latest') stateChangeRequestFilter = { req -> // Add an authorization header to each request // another:password req.addHeader('Authorization', 'Basic YW5vdGhlcjpwYXNzd29yZA==') } protocol = providerScheme host = providerHost port = providerPort path = providerScheme + "://" + providerHost + ":" + providerPort + "/webservice" hasPactsFromPactBroker(pactBrokerScheme + "://" + pactBrokerHost + ":" + pactBrokerPort) } } } But it seems the credential is not overwritten for specific test case. Anyone has experience on this stuff? Could you please help?

abhilash.hanumanth
2018-07-13 13:36
how do we know the latest version of pact-jvm ?

uglyog
2018-07-15 02:55
@bethskurrie I got the generator working with values returned from the provider state callback


bethskurrie
2018-07-15 21:28
Nice!

minhdoan
2018-07-16 11:48
Hi team, i have a provider with 10 consumers so there are 10 pact records on Broker. And 7 test cases use the default authorization credential, and remaining 3 cases use distinct ones. So i must add requestFilter for each as below code: `'PERMISSION_PROVIDER {` ` requestFilter = { req ->` ` // Add an authorization header to each request` ` // because of our system needs login first` ` //default credential is: superuser:123456` ` req.addHeader('Authorization', 'Basic c3VwZXJ1c2VyOjEyMzQ1Ng==')` ` }` ` protocol = schemeProperty` ` host = hostProperty` ` port = portProperty` ` hasPactsFromPactBroker(brokerScheme + "://" + brokerHost + ":" + brokerPort)` ` // Consumer 1 need the credential: test001:123456` ` hasPactWith('Consumer_1') {` ` pactSource = url('http://localhost/pacts/provider/PERMISSION_PROVIDER/consumer/Consumer_1/latest')` ` requestFilter = { req ->` ` // Add an authorization header to each request` ` // because of our system needs login first` ` // with cre: test001:123456` ` req.addHeader('Authorization', 'Basic dGVzdDAwMToxMjM0NTY=')` ` }` ` }` ` // Consumer 2 need the credential: test002:123456` ` hasPactWith('Consumer_2') {` ` pactSource = url('http://localhost/pacts/provider/PERMISSION_PROVIDER/consumer/Consumer_2/latest')` ` requestFilter = { req ->` ` // Add an authorization header to each request` ` // because of our system needs login first` ` // with cre: test002:123456` ` req.addHeader('Authorization', 'Basic dGVzdDAwMjoxMjM0NTY=')` ` }` ` }` ` ` ` // Consumer 3 need the credential: test003:123456` ` hasPactWith('Consumer_3') {` ` pactSource = url('http://localhost/pacts/provider/PERMISSION_PROVIDER/consumer/Consumer_3/latest')` ` requestFilter = { req ->` ` // Add an authorization header to each request` ` // because of our system needs login first` ` // with cre: test003:123456` ` req.addHeader('Authorization', 'Basic dGVzdDAwMzoxMjM0NTY=')` ` }` ` }` ` }` And i want to ensure that each request will have correct Authorization header info when pactVerify is executed, but i tried with: `gradle pactverify [--info | --debug | -i]` But no option show the Authorization information. Could you please help on it? Many thanks!

dominic.jones
2018-07-17 07:54
has joined #pact-jvm

minhdoan
2018-07-18 04:45
@team Could you please help on it? How do i retrieve detailed information about the request sent to provider when executing pactVerify?

msc.consults
2018-07-18 13:41
has joined #pact-jvm

abhilash.hanumanth
2018-07-20 14:41
I dont think there is a way to intercept the request in provider tests. I am intercepting the request by forwarding the request to provider via proxy. If you know, please let me know

kaushalye
2018-07-23 05:05
has joined #pact-jvm

kaushalye
2018-07-23 05:06
Thanks @uglyog

uglyog
2018-07-23 05:08
The classpath should be the compiled class files

uglyog
2018-07-23 05:09
Can you turn on printing stack traces?

kaushalye
2018-07-23 05:09
<pact.showStacktrace>true</pact.showStacktrace> ?

kaushalye
2018-07-23 05:09
It's already on


kaushalye
2018-07-23 05:12
:point_up: is the trace @uglyog

uglyog
2018-07-23 05:14
It must be a regression. Can you raise a defect for it?


minhdoan
2018-07-23 06:46
I want to build a response with Json format as below: {"value":[ { "attribute": "att1", "url": "/att1" }, { "attribute": "att2", "url": "/att2", "type": "Chemistry" }, { "attribute": "att3", "url": "/att3", "type": "Construction" } ] } I have tried with pact consumer code: .body(new PactDslJsonBody() .minArrayLike("value", 2,2) .object() .stringType("url", "/att1") .stringType("attribute", "att1") .closeObject() .object() .stringType("url", "/att2") .stringType("attribute", "/att2") .stringType("kind", "Chemistry") .closeObject()) But the object() method must have a name: `throw new UnsupportedOperationException("use the object(String name) form");` If using another approach as: .body(new PactDslJsonBody() .array("value") .object() .stringType("url", "/att1") .stringType("attribute", "att1") .closeObject() .object() .stringType("url", "/att2") .stringType("attribute", "/att2") .stringType("kind", "Chemistry") .closeObject()) The format is right, but the actual response body contains more than 3 elements (this is unknown number depends on the test system) in "value" array so verification fails. Could you please help to confirm that the format to build a response as example, whether it is supported in pact V3 or i must wait for the V4? Many thanks and nice day, team!

uglyog
2018-07-23 11:40
`.minArrayLike` automatically starts an object definition, so you don't need the next `.object()` call

uglyog
2018-07-23 11:41
The idea would be to do something like:

uglyog
2018-07-23 11:41
``` .minArrayLike("value", 2,2) .stringType("url", "/att1") .stringType("attribute", "att1") .stringType("kind", "Chemistry") .closeObject() ```

minhdoan
2018-07-23 11:49
@uglyog Thanks, Ron! Because i want to create a "value" array with two different format elements: ``` {"value":[ { "attribute": "att1", "url": "/att1" }, { "attribute": "att2", "url": "/att2", "type": "Chemistry" }]}``` Is it feasible? Or PactDslJsonBody has not supported that type yet?

uglyog
2018-07-23 11:51
The idea with the `Like` matchers is to setup one example that should be like all the elements in the array. It doesn't have a way to define different items in the array.

minhdoan
2018-07-23 12:01
Any enhancement in the future for it? I often face this type in realistic

kaushalye
2018-07-23 23:13
@uglyog I believe with ANNOTATED_METHOD, we do not have to separately run a pact mock service

uglyog
2018-07-23 23:41
Correct, it will call the method directly

kaushalye
2018-07-23 23:50
Thanks. I've raised an issue. (See above). BTW, I am planning to use the pact-jvm-provider-spring as an alternative. Still prefer the maven plugin as it provides a cleaner mechanism. :slightly_smiling_face:

arne.zelasko
2018-07-24 07:02
has joined #pact-jvm

djrimokbp
2018-07-24 10:41
has joined #pact-jvm

ng.viet.quynh
2018-07-24 11:03
has joined #pact-jvm

djrimokbp
2018-07-24 11:59
anyone knows if MockMvcTarget works with controllers using jersey annotations?

uglyog
2018-07-24 22:31
Only if MockMvc works with controllers using jersey annotations. MockMvcTarget just delegates to MockMvc

sguisado
2018-07-25 10:55
has joined #pact-jvm

minhdoan
2018-07-25 11:04
I am writing a pact record for url: http://localhost:8080, so code is as below: ``` return builder .given("Server root URL") .uponReceiving("An request at server root) .path("") .method(HttpMethod.GET.name()) ``` But when run @Test method to create the pact record, failure happens with log: ``` au.com.dius.pact.consumer.PactMismatchesException: The following mismatched requests occurred: Unexpected Request: method: GET path: / query: [:] headers: [Accept:text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2, Connection:keep-alive, Host:localhost:8080, User-agent:Java/1.8.0_161] matchers: MatchingRules(rules={}) generators: Generators(categories={}) at au.com.dius.pact.consumer.junit.JUnitTestSupport.validateMockServerResult(JUnitTestSupport.kt:41) at au.com.dius.pact.consumer.BaseProviderRule.validateResult(BaseProviderRule.java:164) at au.com.dius.pact.consumer.BaseProviderRule$1.evaluate(BaseProviderRule.java:81) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:106) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) ``` I am using **au.com.dius:pact-jvm-consumer-junit_2.11:3.5.19** Could you please help to clarify why the path value could not be set to empty ("")? Many thanks!

antonello
2018-07-25 15:47
has joined #pact-jvm

niedra91
2018-07-26 07:46
has joined #pact-jvm

uglyog
2018-07-26 09:06
The path is not empty, it is coming in as `/`

dipjyotimetia
2018-07-27 04:11
has joined #pact-jvm

dipjyotimetia
2018-07-27 04:12
@here can anyone help me hoy to get started with pact jvm

uglyog
2018-07-27 04:53
@dipjyotimetia start with http://docs.pact.io and then the readmes at https://github.com/DiUS/pact-jvm

mark.bridgett
2018-07-30 12:19
has joined #pact-jvm

mark.bridgett
2018-07-30 12:19
Reposting here: Hey there. Anyone know how I can get my Java provider tests to output the full provider response? I'm trying to debug a failed test and would like to see what my service is sending back that is failing. All I have to go on at the moment is this output which doesn't help much : $.some_property -> [{mismatch=Expected List() to have minimum 1, diff=}]

mark.bridgett
2018-07-30 12:20
I'm guessing it might be an environment variable i need to pass to maven or something. Not a Java dev so none of this stuff is obvious to me (Node.js here)

matt.fellows
2018-07-30 12:51
has joined #pact-jvm

antonello
2018-07-30 14:16
I am interested in the answer as well!

imran.khan2
2018-07-31 07:22
has joined #pact-jvm

imran.khan2
2018-07-31 08:15
Hey folks

imran.khan2
2018-07-31 08:15
I'm trying to run my pact provider tests in CI tool

imran.khan2
2018-07-31 08:16
I'd like it to publish verification resultd to the pact broker

imran.khan2
2018-07-31 08:17
Unfortunately at the moment it publishes the snapshot version (I'm using gradle)

imran.khan2
2018-07-31 08:17
How do I publish in CI with the release version, given verifications seem to only be published during the test phase

imran.khan2
2018-07-31 08:18
?

uglyog
2018-07-31 09:24
Enabling debug level logging will output quite a bit

uglyog
2018-07-31 09:26
You can override the version with configuration in the gradle build file. Check the docs on the github project.

nabrosimova
2018-07-31 17:59
has joined #pact-jvm

nabrosimova
2018-07-31 18:00
Hi, I am trying to figure . out how to use pact_jvm with ruby to do file upload

nabrosimova
2018-07-31 18:01
are there anyone how have used Pact_jvm and ruby got it?

shashidesai
2018-07-31 18:35
has joined #pact-jvm

uglyog
2018-07-31 22:38
Are you trying to test a ruby app with pact-Jvm ? Is this on the consumer or provider side?

nabrosimova
2018-07-31 22:41
both consumer and prover are written in ruby. i need to do file upload api call. and idk how i can do that with pact testing

balthasarbiedermann
2018-08-01 18:31
has joined #pact-jvm

balthasarbiedermann
2018-08-01 18:31
Hi all, is there currently already a Kotlin-specific integration for Pact?

balthasarbiedermann
2018-08-01 18:36
I'm currently playing a bit building a Kotlin-idomatic DSL for Pact. Currently it looks like this: ``` pact { given("serverState") uponReceiving("receivingDescription") with("/foo/bar") { method("PUT") body("{\"name\": \"harry\"}") headers("Authorization", "Bearer sfdlgsl") } willRespondWith { status(200) headers(mapOf("Foo" to "Bar")) } } ```

balthasarbiedermann
2018-08-01 18:39
Is there already something similar?

balthasarbiedermann
2018-08-01 18:39
Feedback is welcome

tushar.gavhane
2018-08-02 04:10
has joined #pact-jvm

abubics
2018-08-02 04:38
I can get close to that with the Java 8 pact consumer

abubics
2018-08-02 04:38
but no, there?s no Kotlin DSL

abubics
2018-08-02 04:40
I keep a base class for pact tests: ``` open class PactBase : StringSpec() { val builder: PactDslWithProvider = ConsumerPactBuilder .consumer("Sample Android App") .hasPactWith("Sample API") private val authToken = "valid_token" val getToken = { authToken } val authHeaders = mapOf("Authorization" to "Bearer $authToken") val contentTypeHeaders = mapOf("Content-Type" to "application/json;charset=utf-8") fun verify(pact: RequestResponsePact, func: ClientConnector.() -> Unit) { val config = MockProviderConfig.createDefault() val result = runConsumerTest(pact, config, object : PactTestRun { override fun run(mockServer: MockServer) { buildClient(mockServer.getUrl(), getToken).func() } }) result shouldBe PactVerificationResult.Ok } } ```

abubics
2018-08-02 04:41
and use it like this: ``` class PactAccountTests : PactBase() { init { "fetches Accounts and converts them to AccountReferences" { val pact = builder .given("a member with some accounts") .uponReceiving("a request for the list of accounts").run { headers(authHeaders) method("GET") path("/member/12345/account") } .willRespondWith().run { headers(contentTypeHeaders) status(200) body(newJsonBody { container -> with(container) { minArrayLike("accounts", 1) { with(it) { stringType("id", "123456") stringType("name", "Test Account 1") stringMatcher("type", "savings|loan", "savings") numberType("availableBalance", 5) numberType("currentBalance", 5.67) } } } }.build()) } .toPact() verify(pact) { fetchAccountList( AccountsRequest( userId = "12345" ) ) shouldBe Response.Success( listOf( AccountReference( id = "123456", type = AccountType.Savings, name = "Access Account TestOne", availableBalance = BigDecimal("5.00"), currentBalance = BigDecimal("5.67") ) ) ) } } ... ```

abubics
2018-08-02 04:42
so you can see it?s a little clunky, but quite close to your example :slightly_smiling_face:

balthasarbiedermann
2018-08-02 07:22
@abubics Thanks for the info and feedback. I like your approach using `run {}`

abubics
2018-08-02 07:22
np :slightly_smiling_face: I?d love to have a native DSL, but I don?t have bandwidth to build it myself :sweat_smile:

balthasarbiedermann
2018-08-02 07:22
Would you use a Kotlin DSL or prefer the `run{}` approach?

abubics
2018-08-02 07:24
`run {}` is ok, but I think it?s avoidable with sugar

abubics
2018-08-02 07:24
and other bits are much worse, like `body(newJsonBody { container -> with(container) {`

balthasarbiedermann
2018-08-02 07:24
That would be the next thing I want to look in

abubics
2018-08-02 07:25
yeah, the object creation dsl in junit8 is ok for java, I guess, but still very boilerplatey in Kotlin :slightly_smiling_face:

abubics
2018-08-02 07:25
it?s certainly better than the plain junit one, which has hard-to-see structure

balthasarbiedermann
2018-08-02 07:26
I'm not sure if I want to keep the fluent approach with the cascading dots in the ConsumerPactBuilder DSL. It does not look so clean and "DSL-like" for me, but provides some compile-time safety

balthasarbiedermann
2018-08-02 07:26
I don't know if I can provide the same safety with the DSL at compile time

abubics
2018-08-02 07:37
the problems I had with it being fluent are more around the different types returned along the pipeline

abubics
2018-08-02 07:37
for example, it changes from `PactDslRequestWithoutPath` to `WithPath`

abubics
2018-08-02 07:38
and all the helpers kinda wanna have parity across them, for ease of use

abubics
2018-08-02 07:38
passing blocks with a `Foo.() -> Bar` type helps avoid the fluent leading dots, though :slightly_smiling_face:

abubics
2018-08-02 07:40
like, I have these helpers for my UI tests: ``` private fun <T : Robot> withRobot(robot: T, func: T.() -> Unit) = robot.apply { isCorrectScreen() func() } fun accounts(func: AccountsRobot.() -> Unit) = withRobot(AccountsRobot(), func) ```

abubics
2018-08-02 07:41
so you still get type safety, but also cleaner code :ok_hand:

abubics
2018-08-02 07:41
oh, maybe I should add the usage sample :stuck_out_tongue: but it *is* like the `run {}` example

abubics
2018-08-02 07:42
e.g. ``` @Test fun transferConfirmTest() { pay { tapTransfer() } nextScreenPayTo { enterAmount("0.88") tapNext() } nextScreenConfirm { verifyAccountDetailsVisible( id = "456", name = "Test One" ) verifyAccountDetailsVisible( id = "987", name = "Test Four" ) verifyAmountVisible("$0.67") tapConfirm() } } ```

balthasarbiedermann
2018-08-02 08:34
Do you use `infix` to get rid of the dots between the function calls? E.g. in `nextScreenPayTo`?


abubics
2018-08-02 08:48
``` infix fun nextScreenPay(func: PayFromToRobot.() -> Unit) = pay(func) ```

balthasarbiedermann
2018-08-02 11:03
I restructured the DSL. This is my new structure idea: ``` kPact { consumer withName "consumer" andProvider "provider" havePact { given providerIsInState "state1" then { whenever receiving "request1" withPath "/path" and { headers("Authorization", "Bearer sfghfsdh") } willRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } whenever receiving "request2" withPath "/path" and { headers("Authorization", "Bearer sfghfsdh") } willRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } } given providerIsInState "state2" then { whenever receiving "request1" withPath "/path" and { headers("Authorization", "Bearer sfghfsdh") } willRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } whenever receiving "request2" withPath "/path" and { headers("Authorization", "Bearer sfghfsdh") } willRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } } } } ```

abubics
2018-08-02 11:21
It's probably a good idea to stick to the same vocabulary where possible, such as `uponReceiving`

abubics
2018-08-02 11:24
I would keep kPact as just pact, because it will probably be in a separate package for import :)

abubics
2018-08-02 11:25
And where you have multiple consecutive infix keywords (e.g. `consumer withName`)... Do they facilitate other mechanisms?

abubics
2018-08-02 11:26
(basically, I'd prefer things to be autocompleteable intuitively... `whenever` doesn't give me much idea what to expect :sweat_smile:)

abubics
2018-08-02 11:27
You could also look to gradle for dsl ideas... But they have several conventions that can be confusing, so be careful ;D)

abubics
2018-08-02 11:29
Looking forward to your body dsl ideas too :D

abubics
2018-08-02 11:29
And, of course, I'm not the only Kotlin Pact user, so don't take my feedback exclusively :P

balthasarbiedermann
2018-08-02 12:09
Naming is a good point. I like the "given..when(ever)..then" schema (I've changed the syntax and the keywords again). But I agree, that consistency is important. Probably you are right and I should ask for more feedback to find a consensus

balthasarbiedermann
2018-08-02 12:10
`consumer withName` and the other similar things are not consecutive infixes. `consumer` is a `val` with the infix function `withName`

balthasarbiedermann
2018-08-02 12:13
auto-completion works with the auto-completion shortcut in IntelliJ also with infix calls. But to let the IDE automatically give you the hint, you should not use the infix notation. I've added shorter non-infix functions for that use-case:

balthasarbiedermann
2018-08-02 12:14
With infix: ``` kPact { consumer withName "consumer" andProvider "provider" havePact { given providerIsInState "state1" then { whenever receiving "request1" withPath "/path" and { headers("Authorization", "Bearer sfghfsdh") } thenRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } whenever receiving "request2" withPath "/path" thenRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } } given providerIsInState "state2" then { whenever receiving "request1" withPath "/path" and { headers("Authorization", "Bearer sfghfsdh") } thenRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } whenever receiving "request2" withPath "/path" thenRespondWith KPact.EmptyResponse } } } ```

balthasarbiedermann
2018-08-02 12:15
Without infix: ``` kPact { consumer("consumer").hasPactWith("provider") { given("state1") { whenever("request1").withPath("/path") { headers("Authorization", "Bearer sfghfsdh") } thenRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } whenever("request1").withPath("/path") .thenRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } } given("state2") { whenever("request1").withPath("/path") { headers("Authorization", "Bearer sfghfsdh") } thenRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } whenever("request1").withPath("/path") .thenRespondWith(KPact.EmptyResponse) } } } ```

balthasarbiedermann
2018-08-02 12:15
The user can use both

balthasarbiedermann
2018-08-02 12:19
What do you think, how to reach as many as possible people to get feedback? Should I open an issue and show the idea of the syntax? Or should I directly open an PR?

balthasarbiedermann
2018-08-02 12:21
The Kotlin DSL evolved. The current state allows a infix syntax and an infix-free syntax. With infix: ``` kPact { consumer withName "consumer" andProvider "provider" havePact { given providerIsInState "state1" then { whenever receiving "request1" withPath "/path" and { headers("Authorization", "Bearer sfghfsdh") } thenRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } whenever receiving "request2" withPath "/path" thenRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } } given providerIsInState "state2" then { whenever receiving "request1" withPath "/path" and { headers("Authorization", "Bearer sfghfsdh") } thenRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } whenever receiving "request2" withPath "/path" thenRespondWith KPact.EmptyResponse } } } ``` Without infix: ``` kPact { consumer("consumer").hasPactWith("provider") { given("state1") { whenever("request1").withPath("/path") { headers("Authorization", "Bearer sfghfsdh") } thenRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } whenever("request1").withPath("/path") .thenRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } } given("state2") { whenever("request1").withPath("/path") { headers("Authorization", "Bearer sfghfsdh") } thenRespondWith { body("body") headers(mapOf("Authorization" to "Bearer sfghfsdh")) } whenever("request1").withPath("/path") .thenRespondWith(KPact.EmptyResponse) } } } ``` Thanks to @abubics for the already provided feedback. One question: Should the typical Pact terminology be used (e.g. `uponReceiving` and `willRespondWith`)? I also like the BDD-like "`given`..`when`(`ever`)..`then`" rhythm. *Feedback is more than welcome.*

matt.fellows
2018-08-02 21:15
I'd refuse an issue as an enhancement request so that it can be done truly in the open. These conversations are great though

uglyog
2018-08-02 23:01
`uponReceiving` and `willRespondWith` is just the current DSL, it should not be mandatory if you can find a better way

uglyog
2018-08-02 23:01
Looks really good to me

abubics
2018-08-03 00:44
I like keeping the existing DSL (or both), unless the new vocab is markedly better :slightly_smiling_face: it helps people switch languages when working from examples. Kotlin has an issue with BDD because `when` is a keyword :stuck_out_tongue:

abubics
2018-08-03 00:46
The non-infix `whenever` damages dsl readability, especially when rendered in the broker :slightly_smiling_face: because `uponReceiving` and `whenever` don?t have the same function in English

abubics
2018-08-03 00:50
I love the direction, though :smile:

cparrish
2018-08-03 18:43
has joined #pact-jvm

tcanascimento
2018-08-07 14:28
has joined #pact-jvm

conallbennett
2018-08-07 22:12
has joined #pact-jvm

antonello
2018-08-08 16:57
I have noticed that when I run the only provider test that we have for now, it takes a long time to publish the verification results. ``` Running com.foo.MyPactTest 2018-08-08 17:25:29,109 aprovider INFO [StandaloneMockMvcBuilder$StaticRequestMappingHandlerMapping] Mapped "{[/endpoint],methods=[GET]}" onto public com.foo.ChannelOutput com.foo.Controller.amethod() 2018-08-08 17:25:29,109 aprovider INFO [StandaloneMockMvcBuilder$StaticRequestMappingHandlerMapping] Mapped "{[/endpoint/venue/{venueId}],methods=[GET]}" onto public com.foo.ChannelOutput com.foo.Controller.amethodForVenueId(java.lang.Long) 2018-08-08 17:25:29,110 aprovider INFO [StandaloneMockMvcBuilder$StaticRequestMappingHandlerMapping] Mapped "{[/endpoint/{channelCode}],methods=[GET]}" onto public com.foo.ChannelOutput com.foo.Controller.amethodByChannelCode(com.foo.ChannelCode) 2018-08-08 17:25:29,127 aprovider INFO [RequestMappingHandlerAdapter] Looking for @ControllerAdvice: org.springframework.test.web.servlet.setup.StubWebApplicationContext@1603a2a1 2018-08-08 17:25:29,132 aprovider INFO [MockServletContext] Initializing Spring FrameworkServlet '' 2018-08-08 17:25:29,132 aprovider INFO [TestDispatcherServlet] FrameworkServlet '': initialization started 2018-08-08 17:25:29,134 aprovider INFO [TestDispatcherServlet] FrameworkServlet '': initialization completed in 2 ms Verifying a pact between aconsumer and aprovider Given ........ has a matching body (OK) 2018-08-08 17:26:09,393 aprovider INFO [ProviderVerifier] Published verification result of 'true' for consumer 'Consumer(name=aconsumer)' Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 40.517 sec - in com.foo.MyPactTest ``` Time elapsed 40s, most of which seem to spent publishing the results. It seems far too much time.

kurst03
2018-08-09 00:29
has joined #pact-jvm

uglyog
2018-08-09 08:48
@antonello Wow, that is long. It is just doing a post request to the broker, it shouldn't take that long.

antonello
2018-08-09 08:48
I wonder what it is?

antonello
2018-08-09 08:49
Would there be any interesting TRACE or DEBUG level logging worth enabling?

uglyog
2018-08-09 08:50
Definitely. If you enable debug logging for the Apache HTTP client, you should see the actual request being made.

gaurav
2018-08-11 08:09
Hello all, I am evaluating mockMvc in a spring project. I have a scenario where a contract expects 404 for certain request. For that request, provider service throws an exception with 404 status: `throw new MyException("Unable to execute the request", 404)` and pact test fails with following:

gaurav
2018-08-11 08:09
I would expect pact test not to fail.

uglyog
2018-08-11 08:09
If the code under test throws an exception, you need to handle it.

gaurav
2018-08-11 08:09
how can I handle this?

gaurav
2018-08-11 08:10
Thats a stateless test. :confused:

gaurav
2018-08-11 08:10
so don?t know where to catch that exception.

uglyog
2018-08-11 08:10
Oh, in the provider test. Bummer.

gaurav
2018-08-11 08:12
Anything that can be done? otherwise will have to add state in consumer tests. And probably will be able to catch exception in method that implements state?

uglyog
2018-08-11 08:14
The spring exception handlers should be handling that. You might just have to configure the MockMvc to handle the exception

gaurav
2018-08-11 08:16
spring exception handlers do that when application is running.. Not sure how mockMvc will handle them. will look into that. mockMvc is bit new to me :slightly_smiling_face: Thanks a lot.

gaurav
2018-08-11 08:51
got it.. just needed to add a Controlleradvice that was handling exceptions globally. :slightly_smiling_face:

gaurav
2018-08-13 06:49
In mockmvc example at https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-spring, There is a comment: `We cannot autowire this as we're not using (and don't want to use) a Spring test runner.` I am just being bit curious about why using spring test runner is a bad choice. :slightly_smiling_face:

lindblad.n
2018-08-13 07:30
has joined #pact-jvm

lindblad.n
2018-08-13 08:27
Hi! Posting here, as I?m not sure where this issue occurs - if it?s a Pact Broker configuration thing, a maven plugin bug, or an expected behavior. I?m trying to use the `pact-jvm-provider-maven_2.12` plugin to connect to a Pact Broker, but it seems the base URL is being changed somewhere which causes the execution of `mvn:verify` to fail. The issue is that I?m specifying ?https://<base_url>/<rest_of_path>?, but it?s being changed to ?http://<base_url>:443/<rest_of_path>? and doesn?t seem to follow redirects... Maven plugin settings: ``` <plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven_2.12</artifactId> <version>3.5.20</version> <!--mvn pact:verify--> <configuration> <serviceProviders> <serviceProvider> <name>a</name> <pactBroker> <url>https://pact.somecompany.net/</url> <serverId>pact-broker</serverId> <!-- This must match the server id in the maven settings --> </pactBroker> </serviceProvider> </serviceProviders> <pactBrokerUrl/> <!-- To suppress the warning --> </configuration> </plugin> ``` Execution results: ``` service-a git:(master) ? mvn pact:verify [INFO] Scanning for projects... [INFO] [INFO] ---------------< com.somecompany.a:service-a >--------------- [INFO] Building service-a 1.0.3 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- pact-jvm-provider-maven_2.12:3.5.20:verify (default-cli) @ service-a --- Verifying a pact between b and a [from Pact Broker http://pact.somecompany.net:443/pacts/provider/a/consumer/b/version/1.0.0-SNAPSHOT] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.120 s [INFO] Finished at: 2018-08-13T09:37:42+02:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal au.com.dius:pact-jvm-provider-maven_2.12:3.5.20:verify (default-cli) on project service-a: Execution default-cli of goal au.com.dius:pact-jvm-provider-maven_2.12:3.5.20:verify failed: Request to path 'http://pact.somecompany.net:443/pacts/provider/a/consumer/b/version/1.0.0-SNAPSHOT' failed with response 'HTTP/1.1 400 Bad Request' -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException ```

lindblad.n
2018-08-13 08:30
Publishing to the same server with `pact-jvm-provider-maven_2.12` and the same server url and serverId settings works fine, and it looks like the plugin is finding pacts between the services, only failing to fetch the files

uglyog
2018-08-13 08:33
That comments comes from the days before the Pact spring runner, and it is referring to the default spring runner

lindblad.n
2018-08-13 08:34
Relevant parts of Stacktrace: ``` Caused by: au.com.dius.pact.pactbroker.RequestFailedException: Request to path 'http://pact.somecompany.net:443/pacts/provider/a/consumer/b/version/1.0.0-SNAPSHOT' failed with response 'HTTP/1.1 400 Bad Request' at au.com.dius.pact.pactbroker.HalClientBase$getJson$1.invoke (HalClient.kt:227) at au.com.dius.pact.pactbroker.HalClientBase$getJson$1.invoke (HalClient.kt:126) at au.com.dius.pact.provider.broker.com.github.kittinunf.result.Result$Companion.of (Result.kt:110) at au.com.dius.pact.pactbroker.HalClientBase.getJson (HalClient.kt:211) at au.com.dius.pact.pactbroker.HalClientBase.fetch (HalClient.kt:202) at au.com.dius.pact.pactbroker.HalClientBase.fetch (HalClient.kt:197) at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod (IndyInterface.java:232) at au.com.dius.pact.provider.broker.PactBrokerClient.fetchPact (PactBrokerClient.groovy:121) at au.com.dius.pact.model.PactReaderKt.loadPactFromUrl (PactReader.kt:32) at au.com.dius.pact.model.PactReader.loadFile (PactReader.groovy:189) at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod (IndyInterface.java:232) at au.com.dius.pact.model.PactReader.loadPact (PactReader.groovy:28) at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod (IndyInterface.java:232) at au.com.dius.pact.provider.ProviderVerifier.loadPactFileForConsumer (ProviderVerifier.groovy:115) at au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer (ProviderVerifier.groovy:79) at au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer (ProviderVerifier.groovy) ```

uglyog
2018-08-13 08:38
The URL used to fetch the pact file is the one it would have got from the broker, so it is either your broker not configured correctly, or a proxy in front of it that is doing that

lindblad.n
2018-08-13 08:39
Ok, so the broker sends back the ?base url? used to fetch the files? Thanks a lot, and sorry if i cluttered up the channel


amitojduggal
2018-08-13 15:07
has joined #pact-jvm

gaurav
2018-08-14 01:03
I see.. thanks.

gaurav
2018-08-14 02:59
I am getting error while running provider test: `Expected 'application/json;charset=utf-8' to match 'application/json;charset=UTF-8'` On consumer side, I see following in pact file: ```{ "match": "regex", "regex": "application/json;charset=UTF-8" }``` And on producer side, content type is produced as: `produces = "application/json;charset=UTF-8"` I can get around this by changing UTF-8 => utf-8 on consumer side or by defining a regex to match both lower and upper case on consumer side. However because as per RFC2045, content type value should be case insensitive, do you think it should be handled by pact (don?t match case for content-type value)? https://tools.ietf.org/html/rfc2045#page-12

paul.davies
2018-08-14 04:19
has joined #pact-jvm

paul.davies
2018-08-14 04:20
Hi all, I'm pretty new to Pact and have checked the Stack Overflow but no luck with my problem. I'm having an issue with a Date query parameter which is handled by a DateTime argument resolver at runtime. When debugging my application I can hit the endpoint with this command: GET http://localhost:9090/plan/master/active?from_start_date=2018-08-01T22:00:00.000Z and I can see the date has been correctly interpreted, however when I run my Pact Provider test, which has this in the Pact contract:

paul.davies
2018-08-14 04:20
The date comes through as null

paul.davies
2018-08-14 04:21
My endpoint

paul.davies
2018-08-14 04:22
Any assistance would be most welcome. Thanks!

paul.davies
2018-08-14 04:23
OptionalDateTimeParam

paul.davies
2018-08-14 04:23
OptionalDateTimeArgumentResolver

antonello
2018-08-14 12:49
Is there a built-in way of skipping the publishing pacts when using the the maven plugin? I?m asking because I wouldn?t want to publish pacts when running `mvn verify` locally (unless I actually decide to)

amitojduggal
2018-08-14 13:10
i usually do it this way, specify this as part of provider plugin config ```<configuration> <pact.showStacktrace>true</pact.showStacktrace> <pact.verifier.publishResults>${pact.verifier.publishResults}</pact.verifier.publishResults> </configuration>```

amitojduggal
2018-08-14 13:10
and then override it using a property in maven

amitojduggal
2018-08-14 13:11
``` <pact.verifier.publishResults>false</pact.verifier.publishResults>```

amitojduggal
2018-08-14 13:11
and then from the console you can mvn pact:verify -Dpact.verifier.publishResults=true

amitojduggal
2018-08-14 13:12
or false, as you may like

antonello
2018-08-14 13:20
@amitojduggal That is to publish verification results

antonello
2018-08-14 13:20
I am talking about publishing pacts

antonello
2018-08-14 13:25
There does not seem to be an equivalent property to skip the `pact:publish` goal.

gaurav
2018-08-14 13:35
@antonello `mvn pact:verify` is done on provider side to verify pacts and `mvn pact:publish` is done on consumer side after pacts are generated by consumer tests e.g. unit tests. So you run your consumer tests in usual way e.g. `mvn clean test` which runs tests and pact files are generated during tests. They won?t be published to pact broker unless you do `mvn pact:publish`

antonello
2018-08-14 13:42
@gaurav we publish the pacts as part of the mvn `verify` phase.

antonello
2018-08-14 13:44
Perhaps we shouldn?t do that.

gaurav
2018-08-14 13:51
yeah.. remove that if you don?t want to publish pacts on each run. Its better to publish pacts only when tests look fine.. otherwise, depending on setup, it might make provider tests fragile. I run `pact:publish` as a separate step.

antonello
2018-08-14 13:51
well, on CI you always want to publish them

antonello
2018-08-14 13:51
we don?t use `pact-jvm-provider-maven_2.12` to do provider verification by the way

gaurav
2018-08-14 13:53
yes, on CI: if tests look good -> publish pacts in next step. thats how I do.

antonello
2018-08-14 14:00
that is what we implicitly do, as you don?t get to the maven verify phase if the test phase failed

antonello
2018-08-14 14:01
the issue is that once you?ve bound the pact:publish goal to the verify phase, you can?t easily skip it.

antonello
2018-08-14 14:09
There is an easy workaround, which is to set phase to none, but I was just wondering if you could skip it in any other way, although it seems there isn?t.

antonello
2018-08-14 14:11
Something that @uglyog should be able to confirm.

gaurav
2018-08-14 14:31
I do it in simple way (don?t bind pact:publish to verify phase): step 1: Run tests | step 2: `mvn pact:publish`. step 2 won?t be executed if step 1 fails in CI. Simple. No issues.

uglyog
2018-08-14 22:32
Is there a reason you are matching the content type explicitly? Pact-JVM will check the content type matches, because it needs it to know how to parse the body

uglyog
2018-08-14 22:35
Debug logs will help

uglyog
2018-08-14 22:39
Yeah, I never conceived someone wanting to invoke the publish task and have it do nothing :smile:

uglyog
2018-08-14 22:39
There is no don't publish option.

paul.davies
2018-08-14 23:50
Thanks @uglyog will attach now. Not sure how much use these will be but it's the console output from running my pact test.

paul.davies
2018-08-14 23:58
Hi all, Is there something special i need to do for java.util.Date query values? If I switch the controller parameter to a String and then perform the conversion to a date later on, my Pact provider test will work fine. This will be a big refactor to do this so will be a 'last resort' option. Could this be done via a ValueResolver within the MockMvcTarget by any chance? An example of how this is done would be most welcome. Thanks in advance.

paul.davies
2018-08-15 02:09
No drama. A colleague of mine worked it out. As we have some custom configuration within our SpringBoot application we needed to run the test via a SpringRestPactRunner combined with SpringBootTest. Also we needed to use an HttpTarget rather than the MockMvcTarget so that the pact test is pointed towards the application booted by the SpringBootTest. Thanks for offering to help @uglyog!

nick
2018-08-16 03:18
has joined #pact-jvm

rrosa
2018-08-17 09:25
has joined #pact-jvm

kristine.jetzke
2018-08-18 18:35
has joined #pact-jvm

kristine.jetzke
2018-08-18 20:28
Hi, I?m using pact junit to publish my contracts to the broker. I noticed that the broker detects a contract change every time I upgrade to a new version of pact-jvm. I assume it?s because the pact contains the pact-jvm version. Is that correct? Is there a specific reason that the version needs to be included in the pact file? If not I would file a PR and remove it.

uglyog
2018-08-19 02:42
It's for diagnostic purposes, so when someone submits a pact file with an issue, we know what created it. Maybe a better option would have the broker ignore the metadata, or to have an option to strip it out when publishing

kristine.jetzke
2018-08-19 14:23
Yes, I would also prefer if the broker would ignore the metadata. I can prepare a PR for that. Do you know if the pact spec version (which is also part of the metadata) needs to be included?

kristine.jetzke
2018-08-20 18:32
Might have been fixed already according to this: https://github.com/pact-foundation/pact_broker/issues/147 I will check again after I have upgraded the broker

kristine.jetzke
2018-08-20 18:40
I need to set `base_equality_only_on_content_that_affects_verification_results` to true in the config.

komalahluwalia06
2018-08-23 07:23
has joined #pact-jvm

rsaccoll
2018-08-27 13:27
has joined #pact-jvm

abhilash.hanumanth
2018-08-28 11:23
Did anyone face this problem in provider tests ?

uglyog
2018-08-28 11:59
Check the version of Scala that you are running with.

abhilash.hanumanth
2018-08-28 12:32
@uglyog: I am using gradle pact-jvm

abhilash.hanumanth
2018-08-28 12:34
```contractTestImplementation (group:'au.com.dius', name:'pact-jvm-provider-junit_2.12', version:'3.5.16', transitive: true)```

abhilash.hanumanth
2018-08-28 14:30
Guys someone please help me

abhilash.hanumanth
2018-08-28 14:30
I am not getting anything because of above error

abhilash.hanumanth
2018-08-28 14:31
which scala libraries I should use for PACT. I didnt define anything explicitly. I am using latest pact-jvm

abubics
2018-08-29 00:34
Your messages were between 10:30pm and 12:30am here :slightly_smiling_face: most of the contributors are asleep or not working at that time

ashish.dubey91
2018-08-29 03:26
cross-posting from #general: I'm noticing an issue in my CI setup with pact involving the hosted pact broker. here is how it is - with pact-jvm and gradle plugin I'm pushing my pacts with the branch name as the tag (edited) when I fetch the pacts from this url `/pacts/provider/API/consumer/android/latest/dev` I get the latest pact published from *any* branch rather than specifically `dev` branch always because of this my provider build fails because of unstable contracts pushed in feature branches of the consumer

ashish.dubey91
2018-08-29 03:26
does anybody know what could be wrong here?

uglyog
2018-08-29 03:35
What other libraries are you using? Make sure that all rely on Scala 2.12

abubics
2018-08-29 03:36
what does the `pact {}` block look like in your `build.gradle`?

abhilash.hanumanth
2018-08-29 04:39
ok ok :slightly_smiling_face: Please help me Boris

ashish.dubey91
2018-08-29 04:41
``` pact { publish { pactDirectory = 'xxxxx/target/pacts' pactBrokerUsername = 'xxxxxxx' pactBrokerPassword = 'xxxxxxx' pactBrokerUrl = 'https://xxxx.pact.dius.com.au' tags = ["${branchName}"] version = appVersionName } } ```

abubics
2018-08-29 05:25
that's in the consumer, how about the provider's `build.gradle`?

abubics
2018-08-29 05:29
I haven't seen this error before, I don't have any quick fixes

abubics
2018-08-29 05:30
additionally, I haven't used the `contractTestImplementation` DSL either :upside_down_face:

abubics
2018-08-29 05:32
If @uglyog's hopeful direction is right, you could try changing `_2.12` to other Scala versions, and see if it changes your errors

abubics
2018-08-29 05:33
if you can't work it out like that, the best way to get help is to make a simple public repo that reproduces your issue, so someone can help work through your code

ashish.dubey91
2018-08-29 05:39
I'm running provider verification using python-pact's pact-verifier


abubics
2018-08-29 05:44
that's not a #pact-jvm question, then :slightly_smiling_face:

abubics
2018-08-29 05:45
I haven't done any Pact stuff with Python, sorry

abubics
2018-08-29 05:45
good luck ^_^

ashish.dubey91
2018-08-29 05:52
Okay this seemed to me pact-jvm and pact broker issue because even if I fetch `/pacts/provider/API/consumer/android/latest/dev` which should reflect only the pact pushed from the `dev` branch

ashish.dubey91
2018-08-29 05:53
but when I fetch it I receive the pact pushed from differen tbranch

ashish.dubey91
2018-08-29 05:53
so I guess it's less of a pact-verifier issue

ashish.dubey91
2018-08-29 05:55
does it make sense?

abhilash.hanumanth
2018-08-29 06:48
Can you please tell me what all scala libs are used in pact so that i will force to use those libraries of scala 2.12 in my gradle for contract tests

abubics
2018-08-29 07:22
I'm not sure if that's how tags work in the ReST API . . . your expectation might be right

abubics
2018-08-29 07:22
but I just use the gradle plugin, and I never see what endpoint it uses :slightly_smiling_face: so I can't really tell you

ashish.dubey91
2018-08-29 07:57
okay. I got this from the documentation of pact broker

ashish.dubey91
2018-08-29 08:00
according to the documentation it should work like I'm expecting it..either I misunderstood something and there is a bug

ashish.dubey91
2018-08-29 13:38
can we even have different pacts for the same version but different tags?

abubics
2018-08-29 14:18
You can publish different pact payloads with the same version. The version is tagged, so you can't get different tags :)

ashish.dubey91
2018-08-29 14:18
okay I think I got it all wrong

ashish.dubey91
2018-08-29 14:20
this was happening: a ci build on dev branch was pushing a pact with version=4.1 and tag=dev. on a different branch a pact with version=4.1 and tag=feature-something was being published

ashish.dubey91
2018-08-29 14:21
when I fetch latest version with dev, it fetches me version=4.1 which is overwritten by pact from feature-something branch

david.j.smith
2018-08-29 14:30
has joined #pact-jvm

ashish.dubey91
2018-08-29 14:49
thanks for the help @abubics!

mpasumarthy
2018-08-29 16:08
has joined #pact-jvm

uglyog
2018-08-29 22:29
Pact is built with Scala 2.12 (hence the _2.12 in the module names)

abubics
2018-08-30 02:03
no worries :slightly_smiling_face: if you haven't seen it already, there's a "Show latest tags" action in the top-right of the broker landing page UI. That might help consolidate your mental models

madhukar.mishra
2018-08-30 05:41
has joined #pact-jvm

madhukar.mishra
2018-08-30 05:45
Hello, trying to represent an array with different types in pact, haven't been able to find how to model that in pact-jvm. Here are further details https://stackoverflow.com/questions/52089816/how-to-represent-responses-with-heterogenous-arrays-in-pact-jvm

abhilash.hanumanth
2018-08-30 08:20
Thanks @uglyog . It works after forcing scala version to 2.12 in gradle

ibenardetelevis
2018-09-04 07:11
has joined #pact-jvm

thirumal.net
2018-09-06 18:11
has joined #pact-jvm

minhdoan
2018-09-14 09:32
Hi team, i want to run pactVerify (using pact-jvm-provider-gradle 3.5.9) with two providers as below snippet

minhdoan
2018-09-14 09:35
But it seems when any first provider's record failed, it willl stop the pactVerify task. Any configuration to ignore failure and continue remaining tests? Many thanks for your reading and help!

malheur
2018-09-18 08:07
has joined #pact-jvm

malheur
2018-09-18 08:10
Hi all, I'm running CDC test on provider's side and facing the problem: https://stackoverflow.com/questions/52359563/pact-provider-tests-broken-pactverificationtesttemplate-preconditionviolation. What should I do to make the consumer-broker-provider bundle work together. Additionally: the running pact-broker, when I'm opening a contract, displays the warning: "this contract could not be parsed to a v1 or v2 Pact, showing raw content instead". Thanks in advance!

adam
2018-09-19 13:11
has joined #pact-jvm

uglyog
2018-09-23 04:47
I've given an initial answer on SO. The broker only renders V1 or V2 pacts, but Pact-JVM defaults to V3. That is just a rendering issue, they will still work ok with the broker.

yudinagata
2018-09-24 23:21
has joined #pact-jvm

yudinagata
2018-09-24 23:25
hello, I'm trying to validate a pact on the provider side in a junit test, but I'm getting the following error.

abubics
2018-09-25 00:05
as in, `NoSuchMethodError: matchHeaders`?


uglyog
2018-09-25 22:36
Check the version of the Scala libraries in your classpath. Pact-JVM has to run with the same versions of Scala as it has in the JAR names (i.e. if you use pact-jvm-consumer-junit-2.12) it has to use Scala 2.12

yudinagata
2018-09-26 17:38
thank you, that fixed the problem

viktor.nyblom
2018-09-27 07:47
has joined #pact-jvm


uglyog
2018-09-28 01:13
Yeah, it is all @bethskurrie's fault: https://github.com/DiUS/pact-jvm/issues/738

uglyog
2018-09-28 01:18
I have answered the SO question

matt.fellows
2018-09-28 01:31
lol

matt.fellows
2018-09-28 01:31
thx

bethskurrie
2018-09-28 09:13
Lies!

dervis4
2018-10-03 13:47
Hi guys, do you have any idea why my example provider app publishes the verification results automatically? I have set the pact.verifier.publishResults variable through Maven to false, but the results are still being published. Source code: https://github.com/dervism/person-provider

dervis4
2018-10-03 13:51
Getting this in the log: 13:49:31.459 [main] DEBUG au.com.dius.pact.provider.junit5.TestResultAccumulator - All interactions for Pact person-provider-person-consumer are verified 13:49:31.461 [main] DEBUG au.com.dius.pact.pactbroker.HalClientBase - Posting JSON to https://norwegianlga.pact.dius.com.au/pacts/provider/person-provider/consumer/person-consumer/pact-version/df604a7296cab416741e83acca146eeedaea346c/verification-results {"success":true,"providerApplicationVersion":"1.0"} 13:49:32.549 [main] DEBUG au.com.dius.pact.pactbroker.HalClientBase - Got response HTTP/1.1 201 Created

uglyog
2018-10-03 22:14
Are you running the latest version of Pact-JVM?


dervis4
2018-10-04 08:16
I tried running with "mvn clean install -Dpact.verifier.publishResults=false" but it still publishes... The same happens in my build server.

fraser.crichton.devel
2018-10-04 23:22
has joined #pact-jvm

arne.zelasko
2018-10-10 09:43
hi , we currently use dropwizard and spring boot for creating microservices. some om my colleagues has the idea to use spring boot contract instead of pact-jvm. is it possible to use spring boot contract and pact-jvm togerther, so that for an example the consumer is a dropwizard service which uses pact and the provider is a spring boot service which uses spring cloud contract or the other way around ?

uglyog
2018-10-10 09:44
I believe spring cloud contract supports pacts files, so it may be possible

arne.zelasko
2018-10-10 09:48
okay maybe i look there in the documentation

dagarwal
2018-10-10 11:04
has joined #pact-jvm

alejandro.exequiel.ca
2018-10-17 19:46
has joined #pact-jvm

avi.pardu.nash3
2018-10-21 23:31
has joined #pact-jvm

inbox
2018-10-23 23:34
has joined #pact-jvm

kanohen
2018-10-24 08:25
has joined #pact-jvm

kanohen
2018-10-24 08:39
Hello guys, Please, I have a pact test on my producer. The producer is a Gradle spring project. I have added the pact test to a pact directory in my test folder. When I run ./gradlew test --info, every test in the test folder runs except the pact test. For some reason Gradle isn't aware of that test. However , when I run it locally, without using Gradle, it works fine. Is there some configuration I need to add to my build file to notify Gradle of the pact folder?

nishantv12
2018-10-24 08:50
has joined #pact-jvm

nishantv12
2018-10-24 08:55
Hi all, I am writing my first pact provider test in my organization for a Spring Boot API . We have a pact broker setup which requires SSL. I am not able to find an option for specifying the trust-store in annotation. Do i need to use maven plugin along with the pact-jvm-provider-spring library?

abubics
2018-10-24 10:32
Ssl isn't part of the interface contact, just the transport. You don't need to assert anything, just use http in the tests :)

abubics
2018-10-24 10:45
Also, can y'all add an avatar, or whatever? It's hard to follow when everyone has the same default icons...

abubics
2018-10-24 10:46
What does "run it locally, without using Gradle" mean? Like, from your IDE?

kanohen
2018-10-24 11:13
I mean when I use the runner

kanohen
2018-10-24 11:13
It works but when I use the Gradle --test, the test is skipped.

kanohen
2018-10-24 11:20
Also, I am not getting notification anytime someone replies to my posts/replies from slack. So I have to check back to see if a reply has been dropped. No push notification.

nishantv12
2018-10-24 11:21
Thanks for the response. But I am talking about the SSL for pact broker and not the API under test. The pact broker has been setup in such a way that it requires SSL connection. But your reply made me realise that the particular section i was referring to in maven plugin is for providers and not broker. So I just want to know if I can specify truststore while connecting to broker

uglyog
2018-10-24 11:49
Not sure what you mean by "I use the runner". Do you mean the PactRunner used with the `@RunWith` annotation?

uglyog
2018-10-24 11:53
If it is regular SSL it will work. If you require MASSL, then I don't think that will work. You can add the certificates to the JVM truststore if you are using self-signed certificates.

kanohen
2018-10-24 12:18
@uglyog yes.

kanohen
2018-10-24 12:33
Oh @uglyog I think your answer is NO. What I mean is when you write a test, next to the test method or class, you can run that particular set of classes or methods. There is functionality that says 'run the tests' kind of. That works fine. The problem is when I try to run the tests in a build plan e.g using Gradle with my jenkins/bamboo plan, the test fails. So far I have added the @TestTemplate which causes the test to he seen but now I have to write a method for the @TestTemplate method. I now ask what the @PactVerifyProvider do? Does it verify if the provider obeys the contract?

nishantv12
2018-10-24 12:55
@uglyog thanks. I added the required certificates to the JVM truststore and it worked for me. I guess that's the only way

kanohen
2018-10-24 12:59
Ok, getting even closer to the problem. Gradle is only going to run a test if it finds the @Test or @TestTemplate annotations. I really don't need this as I just run the test with Gradle when I don't have @Test or @TestTemplate annotations. Is there a way to force Gradle to run a pact test even if it doesn't have those annotations?

alex
2018-10-24 15:37
has joined #pact-jvm

inbox
2018-10-24 16:55
Looking to use PACT-JVM to validate Kafka events. Are there any examples around. Ideally Spring Boot . Kotlin . ?

abubics
2018-10-24 23:51
There is definitely some amount of support for messaging (e.g. Kafka, SQS, etc), but I personally don't know where good examples are. Maybe this is a starting point? https://github.com/pact-foundation/pact-message-demo

abubics
2018-10-24 23:53
Or maybe @tom.hombergs's own blog post? https://reflectoring.io/cdc-pact-messages/

abubics
2018-10-24 23:55
I've never tried to verify a provider in a unit-testing style, so I can't really help with that.


uglyog
2018-10-25 00:27
You have to use the test annotations. It's the only way to indicate your class is a test. Otherwise it's just a class and the test runner will ignore it

tom.hombergs
2018-10-25 03:14
has joined #pact-jvm

kanohen
2018-10-25 16:31
When I run on on my intellij IDE it does verify the contract is obeyed. The issue is when I then try to run it with Gradle, it fails. I added this plugin called springbootutility and now I can see it hitting the test when I run ./gradlew pactVerify

kanohen
2018-10-25 16:36
The only issue is I needed a way to start my spring project , verify the pact and then shut or terminate the task again. This was what the plugin was supposed to do and it is but I think I am not setting things up properly. When I remove the start provider task and terminate provider task, it does calls my test class and tries to verify the pact except it fails because my spring project isn't started. Error localhost:8080 connection failed is returned. However, when I add the startProvider(bootRun), the app is started on localhost:8080 but the pact task is then not called because my application runs infinitely. I read it is because bootRun task extends the standard Gradle javaExec task, which is not able to run in the background. It was then suggested that one should try the springbootutility.

inbox
2018-10-25 16:55
@abubics thanks for the shares yesterday

uglyog
2018-10-25 21:27
ah, I see. `./gradlew pactVerify` doesn't run tests. It verifies the pact files itself. If springbootutility works, use it. I have also used the spawn plugin to run the app in the background (it won't work on windows)

anfalsiddiqui
2018-10-29 21:16
has joined #pact-jvm

anfalsiddiqui
2018-10-29 21:20
Hello! We have been running into an issue in IntelliJ with pact-jvm. When we add the maven dependency, intellij is able to properly import the library, but is unable to run _anything_. It isn't showing any errors, but no tests, classes files, etc. can be run; the run button greys out. Has anyone encountered this issue before?

anfalsiddiqui
2018-10-29 21:21
Here are the dependencies we are adding

abubics
2018-10-30 00:19
What kind of app are you building?

abubics
2018-10-30 00:19
(I haven't seen that type of issue before)

kristine.jetzke
2018-10-30 07:18
We encountered it a while ago. I think we ?solved? it by upgrading the kotlin plugin

anfalsiddiqui
2018-10-30 17:51
Thanks @kristine.jetzke, that seems to have done the trick!

borsuk.artem034
2018-10-31 13:59
has joined #pact-jvm

borsuk.artem034
2018-11-02 13:41
Hi, can I use Pact with SQS message broker?

uglyog
2018-11-02 23:11
@borsuk.artem034 you can using message pacts. Have a read through https://dius.com.au/2017/09/22/contract-testing-serverless-and-asynchronous-applications/

joscha.alisch
2018-11-03 16:26
has joined #pact-jvm

joscha.alisch
2018-11-03 16:34
Hi there :slightly_smiling_face: Just started using pact-jvm-junit and I'm a bit confused on how to verify multiple interactions on the consumer side. It seems like it is necessary to test all the interactions in a *single* unit test annotated with `@PactVerification`. When trying to separate the calls to the mock-server into multiple tests I get `au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: ... ` on all of them. Having a single test of course is fine for all the examples I've encountered in tutorials where there are only a small amount of interactions. However once you have more than that, the test gets very long and hard to understand. Is there any way of splitting them up?

joscha.alisch
2018-11-03 16:36
I've also tried a different route of defining multiple pacts - but then it seems impossible to use the same consumer-name for all of them, as the pact-json file just gets overwritten by the last of the pacts.

uglyog
2018-11-03 21:40
You can use multiple test classes. The pact files will be merged together, but you must ensure that each test has a unique description for the interaction.

uglyog
2018-11-03 21:43
The one caveat is the mock server will check every request it receives, so you need to define all the expeceted interactions. If you leave any out, you will get a failure about non-received requests.

joscha.alisch
2018-11-03 21:52
> The pact files will be merged together Indeed they do. I must have had the same description when testing this earlier - thanks @uglyog :unicorn_face:

iryna.feuerst
2018-11-05 13:14
has joined #pact-jvm

borsuk.artem034
2018-11-05 14:31
and I got error

jbbarquero
2018-11-05 20:14
has joined #pact-jvm

jbbarquero
2018-11-05 20:17
Hello, message repeated from the general channel, but my issue is about publishing to a pact broker using the maven plugin in a JVM application (Java)

jbbarquero
2018-11-05 20:18
Is it possible to specify a trustore for publishing pact files into a Pact Broker with HTTPS with certificates issued by a custom CA? I don?t find the option at https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-maven#publishing-pact-files-to-a-pact-broker

xcq1.defy
2018-11-06 09:28
has joined #pact-jvm

iryna.feuerst
2018-11-06 16:55
Hi everyone! I?m using the ConsumerPactBuilder in my Java Consumer application. I would like to define a request parameter (like /my/path?my_param=example_value). I assume that I should use the query-method of the ConsumerPactBuilder.PactDslWithProvider.PactDslWithState.PactDslRequestWithoutPath. I cannot find a simple documentation about how properly to pass in the part ?my_param=example_value?. Could anybody help me with that or point to the right documentation?

iryna.feuerst
2018-11-06 17:01
Oh, I can just pass it as it is to query(?my_param=example_value?). That was too simple to be evident :slightly_smiling_face: . Sorry for disruption

jonas.natten
2018-11-15 08:17
has joined #pact-jvm

cosmin.mogos
2018-11-29 11:02
has joined #pact-jvm

ruben.perezg
2018-11-29 14:57
has joined #pact-jvm

andrew.nicholson
2018-12-03 18:01
has joined #pact-jvm

andrew.nicholson
2018-12-03 18:44
Hello - I am trying to figure out how to use the jvm-consumer-junit library to define a matcher that is an array of arrays, where: * the outer array has at least 1 element * the inner arrays all have at least 1 element * the inner array entries are strings the closest thing that I have is: ``` .eachArrayWithMinLike("outerArray", 1) .stringType("exampleString") .closeArray() ``` but the inner array doesn't seem to have an 'at-least-one' matcher....can someone provide some advice?

andrew.nicholson
2018-12-03 18:47
I have also tried: ``` .eachArrayWithMinLike("outerArray", 1) .minArrayLike(1, PactDslJsonRootValue.stringType("exampleString")) .closeArray() .closeArray() ``` but then I end up with an extra level of nesting

uma.shanker
2018-12-06 16:25
has joined #pact-jvm

sthan
2018-12-07 18:36
has joined #pact-jvm

mpasumarthy
2018-12-11 03:37
Hi, Could someone guide/help me... I have followed the steps mentioned in https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-spring#example-of-mockmvc-test I'm using pact-jvm-provider-maven_2.12 version 3.6.0 plugin to verify the results. Junit is running fine, but I am seeing the below issue when I run mvn pact:verify goal..

mpasumarthy
2018-12-11 06:08
I am not able to publish results back to pact broker, could you guide me how to set "pact.provider.version" and publish the results

abubics
2018-12-11 06:23
If there's someone in here using maven . . . I think most people use gradle (and I'm not sure what the maven integration looks like)

uglyog
2018-12-11 07:29
@mpasumarthy You can use the `-D` parameter to Maven, i.e. `mvn -Dpact.provider.version=1.0.0 pact:verify` or you can use the configuration section of the Pact Maven plugin. See https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-maven#plugin-properties

antonello
2018-12-11 10:15
When is it likely that we?ll get a new release of `pact-jvm`? Wondering when we could get https://github.com/DiUS/pact-jvm/pull/828 in :slightly_smiling_face:

joaquin.delgado
2018-12-11 14:04
has joined #pact-jvm

joaquin.delgado
2018-12-11 14:39
Hi! I'm trying to implement the definition of an array of n elements via lambda DSL: "componentsIds": [ "A1" ] or "componentsIds": [ "A1", ... "An" ] so far I've tried: (LambdaDslObject) category.eachLike("componentsIds", modelOptionIdsArray -> modelOptionIdsArray.stringType()); and (LambdaDslObject) category.eachKeyLike("componentsIds", modelOptionIdsArray -> modelOptionIdsArray.stringType()); and (LambdaDslObject) category.eachArrayLike("modelOptionIds", modelOptionIdsArray -> modelOptionIdsArray.eachLike(a -> a.stringType()); But none of them are parsed. Only the fixed .array("componentsIds", modelOptionIdsArray -> modelOptionIdsArray.stringType()); is working. Anyone has a lead on how to do this?

mpasumarthy
2018-12-11 17:12
Thanks..it worked but i added this to sure-fire maven plugin...

uglyog
2018-12-11 21:21
I'll push out a release this weekend, probably on Sunday

uglyog
2018-12-11 21:30
@joaquin.delgado looks there is no implementation for eachLike with an array of primitives. The DSL is expecting an object in the array. Can you raise an issue for this?

joaquin.delgado
2018-12-12 06:36
sure thing!

james.carman
2018-12-13 02:19
has joined #pact-jvm

rworcest
2018-12-14 01:07
has joined #pact-jvm

rworcest
2018-12-14 16:28
3.5.14 of pact-jvm-provider-junit_2.12 and pact-jvm-consumer-junit_2.12 I'm trying to setup pact in a middle layer (a BFF): APK - pact file - BFF - pact file - backend How can I make a junit test that is both a @Provider and has @PactProviderRuleMk2? Doing the obvious thing runs the provider test normally but ignores the @Pact method. Do I need junit 5? Do I need to do something weird to use multiple test runners or junit rules?

rworcest
2018-12-14 17:31
Or maybe there's some other annotations for a test that's both a provider and consumer. I read https://docs.pact.io/best_practices/provider#stub-calls-to-downstream-systems which had no information and the linked gist which seemed to be about how to mock out part of the code by hand without using a pact file

rworcest
2018-12-14 17:43
https://docs.pact.io/getting_started/provider_states says that states can be used to stub a downstream system (no further details). https://stackoverflow.com/questions/46183190/pact-using-provider-state shows how to use state but it seems like a hack to parse the pact file here since I want this for all states and shouldn't have to parse/validate pact files myself (even with builders)

rworcest
2018-12-14 17:50
The junit and junit5 versions of ContractTest in pact-jvm shows a provider stubbing a backend by hand rather than by using a pact file

uglyog
2018-12-14 22:59
@rworcest are you trying to test the entire chain from the first BFF to the end service in one test? Pact is design to test one interaction at a time.

rworcest
2018-12-15 00:02
@uglyog I suppose it is 2 interactions but it isn't the entire chain since what the backend calls isn't involved (there are more than 3 layers). But how am I supposed to test the APK to BFF interaction while having a realistic stub of my backend except by using the second pact file? If the backend updates the BFF to backend pact file how can the APK to BFF stubs be kept in sync to make sure the APK doesn't become broken?

rworcest
2018-12-15 00:48
You made it sound like it isn't possible to have a junit test that is both a provider and consumer. Is there any way to make pact work for my BFF? We're looking to replace our in house library which is based on VCR so a solution that isn't great may still be better than what we have now.

uglyog
2018-12-15 07:18
There are a few ways of mocking a service using a pact file. Have a look at something like https://github.com/pact-foundation/pact-stub-server

rworcest
2018-12-15 15:19
Thanks for the info but in order to run all tests on a build server I'll need each test to specify the stubbing required. I found https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider#an-example-of-running-provider-verification-with-junit and while I don't understand everything it is doing it looks like the junit test is parsing the pact file. Is there any way I can feed a list of RequestResponseInteraction to an internal class that is used by PactProviderRuleMk2 to create a mock service?

ruben.perezg
2018-12-17 08:03
Hi! I have a question regarding `pact-jvm`, and I am not sure if this is the right place for it. If it?s not, excuse me, and please let me know how should I do it :slightly_smiling_face: We are starting a _PoC_ with Pact in our java ecosystem, and I have started with consumer tests. I have a few of them, and they execute successfully when they are run in an isolated way (just one test at a time). But when I try to execute all the tests together (all of them are located in the same test class), then only the first one executed succeeds, and the rest fail with a `Connection refused` exception (_java.net.ConnectException_). My client is implemented using _OpenFeign_, and I?m using `pact-jvm-consumer-junit5_2.12-3.6.0` and `pact-jvm-consumer_2.12-3.6.0` . And these are the annotations that I have in my test class: ``` @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "productMs") ``` Probably this is a beginner mistake, but I?m quite stuck with it?

uglyog
2018-12-17 08:22
@ruben.perezg try using a random port for each test. Your HTTP client may be caching the connections. Each test gets a new mock server, so if the client has cached the connection, it will be stale for the later tests

ruben.perezg
2018-12-17 08:52
How could I do that?

ruben.perezg
2018-12-17 08:53
In each test I?m using an annotation like this: `@PactTestFor(pactMethod = "createProductPact")` If I?m not specifying the port, shouldn?t it be random?

uglyog
2018-12-17 10:22
Yes. How are you setting the port on the http client?

uglyog
2018-12-17 10:24
You can, but you'll have to write the code to do that yourself. That is basically what the junit test module does for you.

ruben.perezg
2018-12-17 10:26
using `mockServer.getUrl()` directly

ruben.perezg
2018-12-17 10:27
with the _MockServer mockServer_ parameter of the test method

uglyog
2018-12-17 10:31
And you are not setting a port in the test?

ruben.perezg
2018-12-17 10:34
what do you mean by that? AFAIK, with the annotation `@PactTestFor`, there will be a random port assigned if you don?t choose one. That?s what I am assuming, whether that?s true or not :slightly_smiling_face: And I?m using that to create the client for the tests


ruben.perezg
2018-12-17 10:35
> The @PactTestFor annotation allows you to control the mock server in the same way as the JUnit 4 PactProviderRule. It allows you to set the hostname to bind to (default is localhost) and the port (default is to use a random port). You can also set the Pact specification version to use (default is V3).

ruben.perezg
2018-12-17 10:49
and I can confirm now (I have tested it now) that each test method is getting a different port in my case

ruben.perezg
2018-12-17 10:50
but the port used by my http client somehow is always the same? So it looks like I?m doing something wrong creating my client :man-shrugging:

ruben.perezg
2018-12-17 13:59
I?m gonna dig deeper in my client issue, but I would like to change the approach a bit. I think it would be better overall if I could use the same port for all my test methods inside a given class. If I wanted to use the same port for all the tests in my test class, how should I do it? AFAIK, I need to use the `@PactTestFor` annotation in each test method, so I can specify what `fragment` I?m gonna use in that specific test. But doing that, I get a random port for each one? Is there a way for me to use the same port in every test method of a given class?

nishantv12
2018-12-17 14:40
Hi. I am new to pact testing and trying to understand the best practices when writing pacts for Consumer and Provider which are two different teams and do not share database. Do we need to agree on the existence of valid data at both ends? This doesn't sound right to me. But in case when consumer calls the provider with some query parameters as well as header parameters which should also be returned in the response, is providing provider state and then parse it to create an appropriate mocked state the best way?

erik.moller
2018-12-17 15:23
has joined #pact-jvm

erik.moller
2018-12-17 15:27
Hi, we using Pact at my company and got a question from a team that sending http delete message with a request body and couldn't get the provider test to work..after a bit of investigation I realized that it wasn't possible with the current http apache client library, the org.apache.http.client.methods.HttpDelete does not support body....what is your thoughts there?

rworcest
2018-12-17 17:06
I'd rather minimize duplicating library code. The way that a consumer test uses @PactProviderRuleMk2 didn't work for my provider test. Is there a way a provider test can use @PactProviderRuleMk2? If not what classes can I use?

rworcest
2018-12-17 17:37
(Technically it's @Rule with a new PactProviderRuleMk2 since PactProviderRuleMk2 isn't an annotation).

uglyog
2018-12-17 21:32
You can specify the same port, use the `port` attribute on the `@PactTestFor` annotation

uglyog
2018-12-17 21:34
You can put the annotation on both the class level and method level. It will use what's specified at the method level and default to the class level.

uglyog
2018-12-17 21:36
Some HTTP methods generally don't support bodies. You'll have to check the HTTP RFC on the DELETE method, but I would expect that if the Apache HTTP client is not sending the body then that is probably the case.

uglyog
2018-12-17 21:39
That's the best way we could find to solve this problem. If you have a better idea, we would love to hear it. But I believe that teams collaborating on integration points is the best way to build integrated systems.

erik.moller
2018-12-17 22:43
I saw for example Elastic Search Client, created their own delete with a body, and also we are using spring framework as our backend/provider which supports a body for delete...so it's little different depending on which library/framwork you are using. But, I think pact should actually send the delete with body and then let the provider test decide if that is valid or not

erik.moller
2018-12-17 22:48
`` private static class HttpDelete extends HttpEntityEnclosingRequestBase { public HttpDelete(URI uri) { super(); setURI(uri); } @Override public String getMethod() { return "DELETE"; } } ``

erik.moller
2018-12-17 22:51
This "formatted" code is from Spring Web Client, I could create a PR for it?

erik.moller
2018-12-17 22:55
The scenario now is: - No problem pushing a delete request with a body to p-broker - The test runs no problem, the request gets sent to the http-target, but the body is not included and the test fails with error code 400, that is also very hard for a user to actually understand that the reason was because the body in the request was omitted,

erik.moller
2018-12-17 22:56
Either way I think it should be some change, add support for body in delete or else fail earlier in the chain

ruben.perezg
2018-12-18 07:25
After struggling yesterday with a few things, I will try to post here what I found: - We thought about using the same port for all test methods because of performance reasons: the first request of our client library (OpenFeign) takes forever, so we didn?t want that to happen for every request? But we have found a workaround for that, so we don?t need that anymore. - Our client was _indeed_ catching different things (connections, configuration) under the hood, even though it was hard to find. - I know that setting a hardcoded value for the port at the class level will make all the test methods use that port. - What I don?t know is how can we use *the same random port* in every test, so that it can run in any local machine and in our CI environments without the flakyness of trying to use an already in use port. If that?s possible, could you let me know how to do that? I?m still not sure if that?s the way to go or not, because it looks like there is a new wiremock ?instance? under the hood for every test method anyway? (not sure about that)

uglyog
2018-12-18 08:58
You could do that in code. By default if you provide a port of 0, the OS will assign a port from the available ports. You could open a port in the setup, then close the connection, and then use that for all the tests. But you won't be able to set that port for the mock server without extending the PactConsumerTestExt class.

uglyog
2018-12-18 09:02
The connection details are created in a "before" handler using a `ProviderInfo` class. If `PactConsumerTestExt` was extended to allow that object to be injected, you could inject it into a "beforeEach" method and set the port to a random one.

uglyog
2018-12-18 09:06
By using the same random assigned port for each test may still be an issue. For more info, have a look at this issue: https://github.com/DiUS/pact-jvm/issues/342#issuecomment-258594453

nishantv12
2018-12-18 09:28
good to know thanks

nishantv12
2018-12-18 09:44
When running provider tests do we usually mock the database repository or set up a database instance and mock data for the test? I like the idea of mocking as it brings it closer to unit test. But wanted to know the practices in general

ruben.perezg
2018-12-18 11:09
Thank you very much for all your help @uglyog :slightly_smiling_face:

james.carman
2018-12-18 14:09
I?m using mocking

james.carman
2018-12-18 14:09
you?re only trying to test the contract, so it really doesn?t matter where the data comes from

james.carman
2018-12-18 14:09
makes setting up @State very simple (just train the mock)

rworcest
2018-12-18 19:32
Here's a small code sample of what I'm trying to do (this doesn't work). Ideally this would create the pact file BFF_Locator-Foundational.json, use that file as a stub service, and run the provider test. What's the minimum amount of coding I'll need to get this to work? Maybe a different Target implementation? I can also provide the APK-BFF_Locator.json pact file which is what the provider is testing against but I didn't think it was relevant.

nishantv12
2018-12-20 15:48
Thanks for the response. I did the same. But I found several examples online where at the provider end they just start the real API with real database in place or pointing to an environment. I believe pact tests should be as close as possible to unit tests

james.carman
2018-12-20 18:22
I?m with you and I believe I?ve had folks give me the same advice here on slack. I?m certainly not the expert, though.

nishantv12
2018-12-21 08:40
From one of the consumers we are getting a pact file with query string as a map ```"query": { "?`queryParamKey": [ "valuex%3Avaluey%3Avaluez%2Cvaluea%3Avalueb%3valuec" ] }``` At the provider side this is not getting parsed with the error `groovy.lang.MissingMethodException: No signature of method: static au.com.dius.pact.model.PactReader.queryStringToMap() is applicable for argument types: (groovy.json.internal.LazyMap)`

nishantv12
2018-12-21 08:41
I am using pact-jvm version 3.5.16 at the provider end

guidopio.mariotti10_d
2018-12-29 23:44
has joined #pact-jvm

nishantv12
2018-12-31 10:16
Hi, I believe my query was lost in the holidays. But would really appreciate any information regarding this issue.

uglyog
2018-12-31 23:18
That is not a valid query parameter. It should not start with the ```?` ```

uglyog
2018-12-31 23:18
It also should not cause that failure

nishantv12
2019-01-01 09:56
thanks. but the query params being provided as a map is a valid syntax?

rworcest
2019-01-01 16:20
https://stackoverflow.com/questions/53978159/how-to-start-a-mock-server-in-my-providerservice-and-call-a-webservice links to https://docs.pact.io/best_practices/provider#only-stub-layers-beneath-where-contents-of-the-request-body-are-extracted which states "If you do need to stub something (eg. a downstream system), make sure that you only stub the code that gets executed after the contents of the request body have been extracted and validated." Is there any way I can get pact to stub the downstream system and validate it?

uglyog
2019-01-01 23:44
yes, V3 format pact files use a map for query parameters

nishantv12
2019-01-02 12:06
oh ok thanks. i will check the specification for any further such details.

nishantv12
2019-01-02 12:28
so I removed the `?` symbol before query param and tried to run the provider tests. However I am still getting the same error `groovy.lang.MissingMethodException: No signature of method: static au.com.dius.pact.model.PactReader.queryStringToMap() is applicable for argument types: (groovy.json.internal.LazyMap)` If I upgrade the *pact-jvm-provider-spring* version from *3.5.16* to *3.6.1* in order to match with the version used by the consumer, I am getting this error- `java.lang.NoClassDefFoundError: au/com/dius/pact/provider/spring/SpringEnvironmentResolver` eventhough the required dependencies are available in my classpath.

rworcest
2019-01-02 14:33
@uglyog have you had a chance to look at the above code? What are your thoughts on my situation?

nishantv12
2019-01-03 15:17
looks like there was a dependency for pact_jvm_provider_jnuit 3.5.16 specified in some other dependency. Had to use <exclusions> in my pom to exclude any other pact dependency and prevent dependency conflicts with 3.6.1

uglyog
2019-01-04 05:04
@rworcest You can use a mock/stub server for test. These are servers that can return fixture responses so your integration works.

uglyog
2019-01-04 05:05
You can use wiremock in Java, but there are other examples.

vinod.baradwaj
2019-01-04 06:11
is it possible to add `pact-jvm-provider` tests using `testng` ?

rworcest
2019-01-04 16:05
I am not familiar with wiremock but that is something we could look into. Two quick questions: 1. Does that provide a way to stub responses based on the existing pact files? I didn't find anything like that (wiremock-pact-generator appears to be the other way around). 2. Alternatively what classes can I use (possibly from the junit test module) to get pact to stub the service within my Provider test?

thomas.scheuchzer
2019-01-05 10:18
has joined #pact-jvm

nishantv12
2019-01-09 12:16
is this the right channel to ask questions for *scala-pact* or is there a different dedicated channel?

mboudreau
2019-01-09 23:00
yep. We don't have a lot of scala requests, so it doesn't deserve it's own channel just yet :slightly_smiling_face:

jonas.natten
2019-01-10 09:18
There is a #pact-scala-itv channel, but it isn't very active

nishantv12
2019-01-10 16:07
ok then i will probably ask the question here.

rworcest
2019-01-10 16:29
I talked with someone about pact and it seems I misunderstood the scope and intention of pact. I was hoping to use pact to replace a library which is based indirectly on VCR (https://github.com/vcr/vcr). The library we are currently using we call the AST framework. AST tests are run over the entire project's code base whereas Pact is only for API verification (and should not run implementation code). The pact doc https://github.com/pact-foundation/pact-ruby/wiki/FAQ#how-does-pact-differ-from-vcr doesn't mention that pact doesn't run as much of the code base compared to vcr (assuming the java versions act the same as the ruby ones) which is either good or bad depending on use case. @uglyog thanks for your time. I'll figure out what to do from here.

abubics
2019-01-10 22:19
You're right that that's not the intended scope :slightly_smiling_face: but VCR can also test as much or as little of your code as you like. It just depends what you stub in your tests.

gbivins4
2019-01-12 00:24
has joined #pact-jvm

nishantv12
2019-01-15 10:14
Just wanted to inform that `protocol` for *pactbroker* doesn't seem to work even with version *3.5.24* in *pact-jvm-provider-spring*. I had to use `scheme` to make it work.

antonello
2019-01-15 13:48
I have split the provider tests for a given consumer/provider into different classes, one class per endpoint under test (let?s say 2), and therefore splitting the various `@State` methods into 2 classes. However, when the provider tests run, each of the 2 provider test classes tries to verify all interactions defined in the pact. Naturally, some fail because not all `@State` methods are defined in each class. The only way to get around it is by having a `@PactFilter` in each class, with only the states you are implementing in said class. This, however, seems a bit odd, as you end up repeating ?magic strings? in more than one place. Is there any other way of doing this that I?m not seeing?

nishantv12
2019-01-15 15:25
Can't think of a way but if the tests are getting this big then I would probably treat each endpoint as a different provider within the same service

slack1977
2019-01-17 14:19
has joined #pact-jvm

galvinshane
2019-01-18 11:47
has joined #pact-jvm

uma.shanker
2019-01-22 12:24
Can someone provide guide/reference/sample for simple consumer and provider test over kafka message queue?

nishantv12
2019-01-28 10:09
I have a high level question around testing SSL related contracts between microservices. These requirements are "contracts" because you need to agree on this in order to get the services talk to each other. If you think about it these contracts are actually provider driven and not consumer driven. So I am not sure if CDD or Pacts can actually help. Or can they? I wanted to understand how do people generally test that.

matt.fellows
2019-01-29 05:25
This is possibly a good question for #general, but I usually don?t test SSL as part of contract tests. They aren?t related to the payload, and this kind of testing is unlikely to pick up any useful bugs (if people are just testing local/self-signed certs I don?t think it proves anything you can?t test easily with other means)

matt.fellows
2019-01-29 05:25
that being said, people ask for it enough, and we have support for it (mostly) across the toolchain

dagarwal
2019-01-29 12:04
~Hello guys , when i add pact matching with term here on path withRequest: { method: ?GET?, path: term({ matcher: ?/api/assets/[0-9]+?, generate: ?/api/assets/10006? }), }, ( I am getting 404 when i try to load the data on UI :disappointed: ) .Without adding matcher it just works fine for me . Any suggestions on what went wrong and how to achieve it ?~

vicenzo
2019-01-29 22:42
has joined #pact-jvm

vicenzo
2019-01-29 22:45
Anyone around to help me figure out a problem I have with my provider?

vicenzo
2019-01-29 22:46
On my `build.gradle` I?ve added: ```plugins { id "au.com.dius.pact" version "3.6.1" } subProjects { apply plugin: 'au.com.dius.pact' testCompile 'au.com.dius:pact-jvm-provider-gradle_2.12:3.6.1' }```

vicenzo
2019-01-29 22:47
on one of the subprojects (the one I should have a pact with) ```#build.gradle pact { serviceProviders { 'sentinel-judge' { hasPactsFromPactBroker('http://d1lrubypactappdev1.local/') } } } ```

claudia.cordes.de
2019-01-30 13:27
has joined #pact-jvm

vicenzo
2019-01-30 23:17
No one have any idea how to fix my problem?

abubics
2019-01-31 02:07
Looks like this is the relevant bit out of that stack trace: ``` Caused by: java.lang.NoSuchMethodError: org.codehaus.groovy.runtime.DefaultGroovyMethods.collect(Ljava/lang/Iterable;Lgroovy/lang/Closure;)Ljava/util/List; at au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer(ProviderVerifier.groovy:60) at au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer(ProviderVerifier.groovy) at au.com.dius.pact.provider.ProviderVerifier.verifyProvider(ProviderVerifier.groovy:36) at au.com.dius.pact.provider.gradle.PactVerificationTask.verifyPact(PactVerificationTask.groovy:40) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) ... ```

vicenzo
2019-01-31 06:01
wonder of this is a bug with pact or my project being dumb :/

abubics
2019-01-31 07:37
Yeah, I haven't used 3.6.1, so I couldn't tell you :slightly_smiling_face:

abubics
2019-01-31 07:38
Also not sure about your combination of `plugins` and `subprojects` blocks . . . I can't tell if there's anything wrong with it, I haven't tried that combo before

vicenzo
2019-01-31 14:49
it looks like it works, but I've been reading more about it and I will change to the dependency format

vicenzo
2019-01-31 16:44
any suggested version to fall bacl to?

vicenzo
2019-01-31 19:01
FYI bumped down to 3.5.14 and it works

gopinathlangote11
2019-02-01 13:09
Any plan for implementing `pact-jvm-kotin `?

james.carman
2019-02-01 22:20
you can?t use the regular one from Kotlin?

james.carman
2019-02-01 22:24
or are you looking for a nicer DSL that Kotlin may be able to provide?

uglyog
2019-02-03 00:54
I'll have a look

uglyog
2019-02-03 03:25
It's a bug with Groovy `@CompileStatic` in the verifier. I have removed the annotation.

gopinathlangote11
2019-02-04 14:11
Yes. I can use but it will be nice, if there is nicer Kotlin build in support available

abubics
2019-02-05 00:25
Yeah, @gopinathlangote11 & @james.carman, until someone feels like putting effort into a nicer DSL for Kotlin, the junit-java8 DSL is the least bad to use :slightly_smiling_face:

abubics
2019-02-05 00:26
With a liberal dosing of Kotlin sugar, you can make it quite legible, e.g.


gopinathlangote11
2019-02-05 09:03
@abubics I agree. We can use java-8 till then. If we start with adding kotlin dsl, people can add to it later

keetron
2019-02-05 10:38
has joined #pact-jvm

keetron
2019-02-05 10:38
I am trying to have my pact files written someplace else than `/target/pact`, we will have a pact broker in a few weeks but want to do some POC before that and I cannot find how to do this

keetron
2019-02-05 10:39
My inability to find how does not mean it is not there, just that I cannot locate the correct documentation...

dipeshlpatel
2019-02-05 11:22
has joined #pact-jvm

jlopespereira
2019-02-05 14:12
has joined #pact-jvm

james.carman
2019-02-05 16:43
is there a flag to use on the maven plugin to tell it to skip publishing the pact files to the broker?

james.carman
2019-02-05 16:43
I know I?ve seen it before, but can?t find it now.

abubics
2019-02-05 23:36
There's an option in the gradle plugin to change the output directory . . . let me find it

abubics
2019-02-05 23:39
```systemProperty 'pact.rootDir', "$buildDir/pacts"```

abubics
2019-02-05 23:39
So, a system property called `pact.rootDir`, and set it to whatever path you like :slightly_smiling_face:

keetron
2019-02-06 08:03
that is what I was looking for, thanks

keetron
2019-02-06 08:04
I also discovered this information is in the Readme, but only after cloning the jvm code and doing a search on the default location

keetron
2019-02-06 08:31
I am now working on my first provider / consumer combination, and ran into something

keetron
2019-02-06 08:32
the `@State` annotation basically should set the state for whatever possible contract can come in? Or does it need to fit a certain explicit contract?

james.carman
2019-02-06 11:31
@keetron the @State annotation is intended to set up a pre-determined, specific state or perhaps provide a template (via the Map parameter) for a specific type of state. I wouldn?t consider that a ?set up any state you want? type facility.

james.carman
2019-02-06 11:34
Basically, keep it reasonable and controlled

keetron
2019-02-06 11:35
ok, thank you. Right now I am struggling with getting the service to run at all using JUnit5, but I will keep you updated.

james.carman
2019-02-06 13:22
I?m on junit4. What sort of issues are you facing?

keetron
2019-02-06 13:42
oh, nothing with pact, but local setup and running of the service

keetron
2019-02-06 13:43
`@Rule` was removed from JUnit5, I have troubles migrating

dipeshlpatel
2019-02-06 21:03
Hello everyone, I am new to PACT and was wondering if someone can point out if there is any video series which i can follow or attend PACT workshop in London to gain better understanding to implement using JAVA. Referred the link below but i guess step by step docs/video that is what i need ; https://github.com/DiUS/pact-workshop-jvm

jlopespereira
2019-02-07 10:07
Hi everyone, I wanted to ask something about Pact. We are using contract testing already for our integration tests but we wanted to see if we could re-use the contracts to build a mocked server of the provider to be used in our component testing. Is this something that someone has tried to do? I was wondering if there would a way to initialize this mocked server at the beginning of our component tests

gopinathlangote11
2019-02-07 14:26
I have tried this way

gopinathlangote11
2019-02-07 14:27
Let me know in specific if i can help you :slightly_smiling_face:

vicenzo
2019-02-07 21:13
glad to be able to submit a bug report on the wrong place :) but glad that it was fixed

keetron
2019-02-08 08:11
I would say you?d like to avoid using pact tests for functional verification

petro.turovskyy
2019-02-09 18:51
has joined #pact-jvm

jlopespereira
2019-02-11 14:02
@keetron you mean, not using the contracts from the pact tests to build a mocked server to use it on our component testing?

keetron
2019-02-11 14:06
Well, the thing is that pact is designed to show technical implementation regression when it occurs.

keetron
2019-02-11 14:06
On the pact page it explicitly points out that testing API functionality is to be avoided

keetron
2019-02-11 14:07
and I would imagine that using your pact files as some sort of API definition would make it tempting to extend the pact test itself outside of the scope of the intention

jlopespereira
2019-02-11 14:07
Yes, exactly

jlopespereira
2019-02-11 14:07
That was my idea

jlopespereira
2019-02-11 14:07
See if I could take advantage of it

jlopespereira
2019-02-11 14:08
But if it's not recommended or if people tried that and it didn't work, I might avoid doing it

keetron
2019-02-11 14:11
If you separate the mock?s technical implementation (that you build using pact contracts) from the functional data (your actual tests) and not put the functional data in the contracts, I think it would work

keetron
2019-02-11 14:11
if you build it generic, it might not even be a bad idea :wink:

jlopespereira
2019-02-11 15:18
I'll try that :slightly_smiling_face: Thanks @keetron!

keetron
2019-02-12 11:49
For some reason, the pact consumer generated contract does not contain the headers that are send by the consumer. Did I do a setting wrong?

james.carman
2019-02-12 12:05
What does your pact definition look like?

keetron
2019-02-12 12:13
you mean the json?

keetron
2019-02-12 12:15
or the java?

gopinathlangote11
2019-02-12 12:18
Where are your setting consumer headers?

keetron
2019-02-12 12:30
I am under the impression the consumer header was captured by the pact provider stub, but appears not?

keetron
2019-02-12 12:31
and I tried setting up checks on consumer headers but could not figure out where

james.carman
2019-02-12 12:32
You need to declare it in your pact

james.carman
2019-02-12 12:32
It doesn?t ?record? it while talking to the stubbed service

james.carman
2019-02-12 12:33
The pact is created by the DSL


keetron
2019-02-12 12:34
can you point me to a syntax source for java? or an example?

keetron
2019-02-12 12:34
on how to set consumer headers?

keetron
2019-02-12 12:35
after which I would happily RTFM :wink:

james.carman
2019-02-12 12:44
Here?s one of my examples: ``` @Pact(provider = PROVIDER, consumer = CONSUMER) public RequestResponsePact createNoNameFragment(PactDslWithProvider builder) { return builder .uponReceiving("Hello") .path("/hello") .method("POST") .matchHeader("Content-Type", "application/json") .body(newJsonBody(o -> o.stringValue("name", "Pact") ).build()) .willRespondWith() .status(200) .matchHeader("Content-Type", "application/json") .body(newJsonBody(o -> o .stringType("greeting", "Hello, Pact!") ).build()) .toPact(); } ```

james.carman
2019-02-12 12:44
notice the matchHeader

james.carman
2019-02-12 12:46
The cool thing is that the pact framework will keep you honest. For example, if you add ```matchHeader("foo", "bar")```, but you don?t send a ?foo? header, it will throw an AssertionError

keetron
2019-02-12 12:53
yeah, I wanted to implement that but was not aware it is called `matchHeader`

keetron
2019-02-12 12:53
awesome! Thank you!

keetron
2019-02-12 12:53
Now I can close this story, it was being a pain

keetron
2019-02-12 13:00
weirdly tho, the `matchHeader` is actually causing an error 500

keetron
2019-02-12 13:00
in my consumer

keetron
2019-02-12 13:01
while I would expect it to be just for checking consumer headers and not influencing consumer behavior?

keetron
2019-02-12 13:06
oh, I was doing something wrong myself

sam
2019-02-13 17:43
has joined #pact-jvm

mail
2019-02-20 11:05
has joined #pact-jvm

vicenzo
2019-02-22 19:48
Good mornjng

vicenzo
2019-02-22 19:48
i am a little dumb folded by the error being generated by the verifier on the provider

vicenzo
2019-02-22 19:48
could someone try and help me please?

vicenzo
2019-02-22 19:49
the value is the same and it is still failing?

james.carman
2019-02-22 20:19
perhaps one is a string and one is a number?

vicenzo
2019-02-22 20:59
no :/

vicenzo
2019-02-22 20:59
when I change a key to string on the client the provider expected a '0' but got 0

vicenzo
2019-02-22 21:05
could it be that those numbers on java are big decimals?

vicenzo
2019-02-22 21:45
fixed it by generating the response on the client with marchers

damien.castelltort
2019-02-26 17:28
has joined #pact-jvm

dagarwal
2019-03-06 17:14
Hi , I am using my contract test like this on consumer side describe(?Getting available action for publish?, () => { before(() => { return provider.addInteraction({ given: ?GET call?, uponReceiving: ?Get available action?, withRequest: { method: ?GET?, path: ?/api/actions%3Fcontext%3Dtype%3Btype%3Dpublish%3BassetIds%3D10212? }, willRespondWith: { status: 200, headers: { ?Content-Type?: ?application/json? }, body: actions } }); }); it(?Get available actions for publish?, () => { return request.get(`http://localhost:${PORT}/api/actions%3Fcontext%3Dtype%3Btype%3Dpublish%3BassetIds%3D10212`) .set({ ?Accept?: ?application/json? }).then((response) => { return expect(Promise.resolve(response.status)).to.eventually.equals(200); }).catch(err => { console.log(?Error in available actions?, err); }); }); }); and its generating the json correctly ,Data under body part is exactly the same what i see on hitting api on provider side But validation is failing since when it is matching, order is changed .I can see all those values present even while verification is done but no order is followed To make it simple : at provider side /api/user1 { id :1, name: abc } { id:2, name:xyz } and i add exactly same data at consumer side But when provider verification happens it is not following the order and compares id 1 with some other id 2 What am i missing here ?

abubics
2019-03-06 23:39
what is in `actions`? it probably needs flexible matchers, if the body doesn't use them already

dagarwal
2019-03-07 11:30
it looks like this


dagarwal
2019-03-07 11:30
@abubics

dagarwal
2019-03-07 11:34
@matt.fellows can you suggest something

aidamanna
2019-03-07 14:39
has joined #pact-jvm

abubics
2019-03-07 23:23
so, it seems like you're using `like()` wrong

abubics
2019-03-07 23:24
as far as I remember, it only takes one object to describe the shape, but you're passing several objects of the same shape as separate parameters

abubics
2019-03-07 23:25
btw, what timezone are you in? we seems to always respond 12 hours apart :stuck_out_tongue:

matt.fellows
2019-03-07 23:27
Looks like the UK, maybe

dagarwal
2019-03-08 09:18
yes UK :stuck_out_tongue_winking_eye:

dagarwal
2019-03-08 09:20
but then how else can i add matchers if i want to pass multiple objects ?

msc.consults
2019-03-09 11:06
Hi everyone, I've written a pact contract test in groovy for a negative scenario (i.e. I make a `POST` request that's invalid and expect a `400` status to return. This all works fine, however a pact file isn't generated to record this expectation? When I write a happy path contract scenario (where I'm expecting a status of `200`, this will then generate the pact file. Is there something I'm doing wrong? I have ``` then: assert result instanceof PactVerificationResult.Error` ``` which asserts fine

msc.consults
2019-03-09 13:09
All resolved now, many thanks! ^^

james.carman
2019-03-09 13:43
What was it?

timepasstimepass1234
2019-03-11 12:02
has joined #pact-jvm

timepasstimepass1234
2019-03-11 12:03
Hi All,

timepasstimepass1234
2019-03-11 12:03
My controller call is returning result in DeferredResult format. MockMvcTarget returns the result without waiting for async process. How to add async option to pact through PactDslWithProvider builder in java?

abubics
2019-03-11 22:48
What are you trying to test? The interaction is pretty unclear from that huge payload :slightly_smiling_face:

abubics
2019-03-11 22:49
if your response is meant to have a list of objects, e.g. ```[ {...}, {...}, ... ]``` then you probably want `eachLike`

abubics
2019-03-11 22:50
but also remember that Pact isn't for verifying specific content, it's more fo verifying the shape of the data

pltran875
2019-03-11 23:46
has joined #pact-jvm

pltran875
2019-03-12 00:03
Has anyone used the pact-jvm-provider-gradle before? I am getting Could not find method hasPactsFromPactBroker() when trying to publish to broker on a pactVerify

abubics
2019-03-12 04:14
"Every used before" is maybe not specific enough :wink: I haven't used it in about 9 months

abubics
2019-03-12 04:14
(but it was working then :P)

luca.ippolito
2019-03-12 08:30
has joined #pact-jvm

luca.ippolito
2019-03-12 09:59
Hi there! I've got a question regarding the execution order of provider states, couldn't find anything elsewhere about this. So, let's assume in a contract are the following states configured for a testcase: "providerStates": [ { "name": "service has student", "params": { "id": 1, "firstName": "John", "lastName": "Doe" } }, { "name": "student has grade", "params": { "subject": "Mathematics", "grade": "A" } } ] The expected result by the consumer for this testcase would be "student": { "id": 2, "firstName": "John", "lastName": "Doe", "grades": [ { "subject": "Mathematics", "grade": "A" } ] } When executing this testcase as a provider, I noticed that the execution order of the provider states is reversed, so instead of executing the provider states in this order on the provider side: 1. service has student 2. student has grade The states are getting executed like this: 1. student has grade 2. service has student Can anyone explain me, why the execution order is inverted? Because of that, on the provider side we are implementing something like a "reverse builder pattern" to setup the object that needs to be returned. What would be a better approach on this? I know, a possible answer would be "just use one provider state instead", but I would like to allow multiple consumers to use the same states and they should be able to create their own expected result value, so my key requirement is the usage of multiple paramterized states. Another possible solution would be to tell the consumer that he should invert the order of the provider states on his side, but that does not make that much sense to me. I think, it is more logical to set the provider states like this: .given("service has student", studentParameters).given("student has grade", gradeParameters) instead of setting the states up like this: .given("student has grade", gradeParameters).given("service has student", studentParameters) Thanks in advance for your feedback!

uglyog
2019-03-13 02:20
@luca.ippolito the provider states are keyed by name, so the other would probably be executed based on JVM hash order. But I would recommend to not have your provider states dependent on the order they are executed.

msc.consults
2019-03-13 07:56
@james.carman I was incorrectly using the DSL and not catching the RestClientResponseException that was thrown, its then within the handled exception that I can carry-out my assertions followed by asserting that the PactVerifcationResult is ok >>> James Carman [1:43 PM] What was it?

luca.ippolito
2019-03-13 07:57
@uglyog What do you mean by "keyed by name" I've implemented some states that are only logging their state name to test this, example: @State("A") public void a() { log.debug("A"); } So the following configuration: Verifying a pact between blueadit-fulfillment and blueadit-devices-subscriber-inventory Given A Given B Given C orderTest Results in this execution order: 2019-03-13 08:44:10.355 DEBUG (main) C 2019-03-13 08:44:10.356 DEBUG (main) B 2019-03-13 08:44:10.356 DEBUG (main) A While this configuration: Verifying a pact between blueadit-fulfillment and blueadit-devices-subscriber-inventory Given C Given A Given B orderTest Results in this execution order: 2019-03-13 08:40:17.077 DEBUG (main) B 2019-03-13 08:40:17.078 DEBUG (main) A 2019-03-13 08:40:17.078 DEBUG (main) C I cannot see any keying by name there as you mentioned in your comment earlier. Else I would expect the same order of execution for both tests. Also you mentioned that you wouldn't recommend dependent states. So do you know how i would solve a problem like i described in my first post? Let's say I've got a student object that is expected by the consumer looking like this: { "id": 0, "firstName": "string", "lastName": "string", "grades": [ { "subject": "string", "grade": "string" } ] } Possible that would be a valid usecase for different consumers would be: Example 1: {} Example 2: { "id": 1, "firstName": "John", "lastName": "Doe", "grades": [ { "subject": "Mathematics", "grade": "A" } ] } Example 3: { "id": 2, "firstName": "Johnas", "lastName": "Keller", "grades": [ { "subject": "Mathematics", "grade": "C" }, { "subject": "Geography", "grade": "B" } ] } As far as i know until now, to reduce code duplication and avoid hard coded data, i need multiple states that are using parameters and are dependent to each other, so for each example the states would look something like this (params in brackets would be transmitted as a parameter map and not as part of the name of the state: Example 1: actually no states needed Example 2: "service has student" (params: id = 1, firstName = "John", lastName = "Doe"), "student has grade" (subject = "Mathematics", grade = "A") Example 3: "service has student" (params: id = 2, firstName = "Johnas", lastName = "Keller"), "student has grade" (subject = "Mathematics", grade = "C"), "student has grade" (subject = "Geography", grade = "B") What would be the best approach on this in your oppinion?

james.carman
2019-03-13 11:36
Ahhh, good to know. Thanks for sharing.

alisdaircole
2019-03-13 16:39
has joined #pact-jvm

abubics
2019-03-13 22:53
Not here to help with this specific problem, but you could make your posts easier to digest for people with some formatting :slightly_smiling_face: there's a tiny little tooltip in Slack when you start typing:

luca.ippolito
2019-03-14 07:20
@abubics Thanks, did not know about this

ghandour.jihad
2019-03-14 08:34
has joined #pact-jvm

ghandour.jihad
2019-03-14 11:03
Wrong thread

pltran875
2019-03-14 12:40
Does the pact-jvm-provider-gradle alway expects a running provider for the pactVerify task. I know that starting a provider with stubbing seems to be the most common appropriate. Are there other ways supported like invoking annotated test methods?

luca.ippolito
2019-03-14 13:18
@ghandour.jihad which thread then? I've already been told that this does not belong to #general and was referred to this thread

ghandour.jihad
2019-03-14 13:41
@luca.ippolito, I wrote something here, then edited it by saying wrong thread, I meant "I used the wrong thread" sorry for that :slightly_smiling_face: I reposted my question on the right thread, and now will edit again the message to clarify what I meant

ghandour.jihad
2019-03-14 13:42
apparently I can't double edit a comment. Anyway, it is just that what I previously wrote is on the wrong thread, sorry again

abubics
2019-03-14 23:35
(fyi, you can edit as many times as you like, but there's a time limit)

luca.ippolito
2019-03-15 06:30
@uglyog any input regarding my question?

ghandour.jihad
2019-03-15 13:32
From a consumer test I generated the below json using .stringType since I only care that I have strings and not their actual value: "response": { "status": 200, "headers": { "Content-Type": "application/json;charset=UTF-8" }, "body": [ { "name": "bob", "familyName": "winston" }, { "name": "bob", "familyName": "winston" } ], "matchingRules": { "$.body[0].name": { "match": "type" }, "$.body[0].familyName": { "match": "type" } } } When I place it inside the provider, it is failing due to: Failures: 0) Validating the response content returns a response which has a matching body $.1.name-> Expected 'bob' but received 'Jhon' Apparently PACT is comparing the value and not just the type as indicated in the machingRules Am I missing something? or is there a bug in the matchingRules?

ghandour.jihad
2019-03-15 13:36
Well Apparently there is indeed a bug. in the consumer test, I had .setNumberExamples(2); that should have generated "matchingRules": { "$.body[0].name": { "match": "type" }, "$.body[0].familyName": { "match": "type" }, "$.body[1].name": { "match": "type" }, "$.body[1].familyName": { "match": "type" } } and not just body[0] How can someone report a bug?

ghandour.jihad
2019-03-15 13:57
or it should have added "matchingRules": { "$.body[*].name": { "match": "type" }, "$.body[*].familyName": { "match": "type" } }

uglyog
2019-03-15 22:20
I don?t know why your provider states are executing in that particular order. I assumed it was iterating over a hash map. I still don?t think it is a good idea to have states dependent on each other. There is no guarantee on the order of execution.

luca.ippolito
2019-03-17 08:46
@uglyog how would you design the states than?

uglyog
2019-03-17 20:34
I?d make them to not be dependent on each other. Takes more effort, but makes for much less brittle testing.

dagarwal
2019-03-18 09:51
I was passing multiple data and it was behaving weirdly .So i have reduced the content and its working fine now :slightly_smiling_face:

luca.ippolito
2019-03-18 11:46
@uglyog Can you give me some examples of providerstates and possible parameters you would provide with a state?

sumanthbharan
2019-03-20 08:41
has joined #pact-jvm

sumanthbharan
2019-03-20 09:00
Hi everyone, I want to ask a question related to modifying the request before provider verification. Is it possible to modify the parameter value in the body for post request? The wiki here(https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-junit#modifying-the-requests-before-they-are-sent-version-323245) provides an option but org.apache.http.HttpRequest allows us to modify the header but not the body. This is my relevant pact information: ```"request": { "method": "POST", "path": "/testApi", "headers": { "Content-Type": "application/json" }, "body": { "fileName": { "s3ObjectKey": "1649a6d0-4aee-11e9-8646-d663bd873d93" } }, "matchingRules": { "body": { "$['fileName'].s3ObjectKey": { "matchers": [ { "match": "regex", "regex": "([a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12})" } ] } } } },``` I would like to modify the s3ObjectKey as it is generated.

paras.vora
2019-03-27 08:30
has joined #pact-jvm

paras.vora
2019-03-27 08:35
@here hello, I have a scenarios where there is an auth token(valid for only 3 mins) required for any request to be addressed.


paras.vora
2019-03-27 08:38
However, I see the auth token is been hardcoded in the code. As I mentioned, the token will expire after 3 mins.

paras.vora
2019-03-27 08:39
Hence, seems this wont be a prominent solution to my case.

paras.vora
2019-03-27 08:39
Could anyone please help in this regard?

paras.vora
2019-03-27 08:45
Also, is there any working sample code repo which would help for using the below code, ```pact { serviceProviders { provider1 { requestFilter = { req -> // Add an authorization header to each request req.addHeader('Authorization', 'OAUTH eyJhbGciOiJSUzI1NiIsImN0eSI6ImFw...') } hasPactWith('consumer1') { pactFile = file('path/to/provider1-consumer1-pact.json') } } } }```

paras.vora
2019-03-27 08:46
As, I am unsure how & where to place it.

abubics
2019-03-27 11:12
There are a few fundamental issues...

abubics
2019-03-27 11:13
1. You don't want chained test cases (doing auth is one, using the same token for other requests is other test cases)

abubics
2019-03-27 11:14
2. Auth isn't the user value feature, it's just a thing you need, as a cross-cutting concern (with indirect user value)

abubics
2019-03-27 11:15
Pact is developing some auth features, but this seems like something you can solve with state

gopinathlangote11
2019-03-27 11:28
@paras.vora https://github.com/gopinath-langote/Pact-JVM-Implementation checkout this :slightly_smiling_face:

gopinathlangote11
2019-03-27 11:28
might help you

paras.vora
2019-03-27 11:31
Thank you @gopinathlangote11 will check & revert.

paras.vora
2019-03-28 04:57
In the repo you shared, could you please help in pointing the reference of bearer token....?

uma.shanker
2019-03-28 15:03
Hi Guys, Getting this error when adding dependencies : `Could not find org.jetbrains.kotlin:kotlin-stdlib-jre8:1.3.21.` Required by: ` project :backend:application > au.com.dius:pact-jvm-consumer-junit_2.11:3.5.0` ` project :backend:application > au.com.dius:pact-jvm-provider-junit_2.11:3.5.0` `project :backend:application > au.com.dius:pact-jvm-consumer-junit_2.11:3.5.0 > au.com.dius:pact-jvm-consumer_2.11:3.5.0` `project :backend:application > au.com.dius:pact-jvm-provider-junit_2.11:3.5.0 > au.com.dius:pact-jvm-provider_2.11:3.5.0` ` project :backend:application > au.com.dius:pact-jvm-consumer-junit_2.11:3.5.0 > au.com.dius:pact-jvm-consumer_2.11:3.5.0 > au.com.dius:pact-jvm-model:3.5.0` `project :backend:application > au.com.dius:pact-jvm-consumer-junit_2.11:3.5.0 > au.com.dius:pact-jvm-consumer_2.11:3.5.0 > au.com.dius:pact-jvm-matchers_2.11:3.5.0`

uma.shanker
2019-03-28 15:04
Please help me on it I am using ` kotlinVersion = '1.3.21'` `springBootVersion = '2.1.3.RELEASE'`

uglyog
2019-03-30 01:45
org.jetbrains.kotlin:kotlin-stdlib-jre8 was dropped with Kotlin 1.3.x. Use a later version of Pact JVM or use Kotlin 1.2.71

uma.shanker
2019-04-01 08:55
Thanks @uglyog but I think I am using the latest version of pact jvm which is 3.5.x. If it is not, do you know what is the latest version of pact jvm? can you please point me there.

uma.shanker
2019-04-01 09:46
Thanks @uglyog by using 3.5.24 fixed the issue. thank you so much.

skirankumars31
2019-04-01 10:44
has joined #pact-jvm

ghandour.jihad
2019-04-04 06:54
Hello fellow jvm Pacters :slightly_smiling_face:, is there a bug in eachKeyLike? In the body response I will have something like the below, where both SERVICE_NAME_PORT and 12345 can change. "ports": { "SERVICE_NAME_PORT": "12345" } I used in the consumer test: .object("ports") .eachKeyLike("SERVICE_NAME_PORT",PactDslJsonRootValue.stringType()) .closeObject() which generated a pact "body": [ { "ports": { "SERVICE_NAME_PORT": "string" }, } ], "matchingRules": { "$.body[0].ports.*": { "match": "type" } } Yet the provider tests are failing with 0) test returns a response which has a matching body $.0.ports -> Expected SERVICE_NAME_PORT='string' but was missing Diff: { - "SERVICE_NAME_PORT": "string" + "MY_SERVICE_NAME_PORT": "10001" } Any idea how can I do it?

uglyog
2019-04-04 08:32
What version of pact-Jvm are you using?

ghandour.jihad
2019-04-04 08:57
<dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit_2.12</artifactId> <version>3.6.1</version> </dependency>

ghandour.jihad
2019-04-04 09:13
(tried 3.6.3 now that you asked, and still I have the same problem on provider side)

ghandour.jihad
2019-04-04 09:41
@uglyog I did a dichotomy, The issue is coming from 3.5.22 since it exists there while the issue doesn't exist on 3.5.21

andyharkinsqa
2019-04-04 14:54
has joined #pact-jvm

uglyog
2019-04-04 20:50
Can you raise an issue for this?

ghandour.jihad
2019-04-05 08:09
Done thanks!

paras.vora
2019-04-05 10:31
@matt.fellows Can I get the access to the `Provider` invoked server in my provider test file?

matt.fellows
2019-04-05 11:58
What does this mean, sorry?

matt.fellows
2019-04-05 11:59
What do you want to do?

paras.vora
2019-04-05 12:03
The provider test invokes the provider service, I need to do some manipulations in the invoked running service before the provider test runs.

paras.vora
2019-04-05 12:04
``` package com.appdirect.itg.invoice.template.configuration.contract; import org.junit.Before; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import au.com.dius.pact.provider.junit.Provider; import au.com.dius.pact.provider.junit.State; import au.com.dius.pact.provider.junit.loader.PactBroker; import au.com.dius.pact.provider.junit.target.Target; import au.com.dius.pact.provider.junit.target.TestTarget; import au.com.dius.pact.provider.spring.SpringRestPactRunner; import au.com.dius.pact.provider.spring.target.SpringBootHttpTarget; @RunWith(SpringRestPactRunner.class) @Provider("itg") @PactBroker(failIfNoPactsFound = false) @Category(ContractTest.class) @ContextConfiguration(classes = InvoiceTemplateConfigurationApplication.class) @SpringBootTest( classes = {InvoiceTemplateConfigurationApplication.class,TestJwtConfiguration.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"spring.profiles.active=test", "spring.main.web-application-type=reactive","spring.main.allow-bean-definition-overriding=true"} ) public class ProviderTest { @TestTarget public final Target target = new SpringBootHttpTarget(); @Before public void setup() { System.out.println(); } @State("Return template Tokens as json") public void getTemplateTokens() { } @State("Validate the Json") public void validateTemplateJson() { } @State("Return active template Json for Invoice in Base64 encoded") public void getActiveTemplateJsonForInvoice() { } } ```

paras.vora
2019-04-05 12:06
Need to do some manipulation with the invoked server in the setup block.

matt.fellows
2019-04-05 20:03
@uglyog?

matt.fellows
2019-04-05 20:05
I'd have thought given you're in the spring context you can do whatever you need using spring framework

uglyog
2019-04-07 23:27
That what the provider states are for. You can inject any spring bean into the test

sam
2019-04-08 21:24
Looking for some advice... I'm creating a Pact for an endpoint that is a POST with form urlencoded params. Is there a way to generally specify the params expected (ex: a param called "foo" that's a string) like I can do JSON response body?

sam
2019-04-08 21:25
Right now I have something like this `body("requestId=1234&start=1262300400", ContentType.APPLICATION_FORM_URLENCODED)`

sam
2019-04-08 21:26
but I was hoping to be more general with the values passed in, and just declare the param name and type

uglyog
2019-04-08 23:34
No, there is no current support for specifying individual parameters. But it should be easy to implement.

nschmuter
2019-04-09 13:11
has joined #pact-jvm

ghandour.jihad
2019-04-10 07:14
Please let me know if I should raise an issue: I am using <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-junit_2.12</artifactId> <version>3.5.11</version> </dependency> In my consumer tests I use: MockProviderConfig config = MockProviderConfig.createDefault(); PactVerificationResult pactVerificationResult = runConsumerTest(pact, config, mockServer -> { List<URI> response = new ProviderClient(new ProviderConfig(mockServer.getUrl())); assertEquals(1,response.size()); }); assertEquals(PactVerificationResult.Ok.INSTANCE, pactVerificationResult); When this fails, the output is polluted: java.lang.AssertionError: Expected :au.com.dius.pact.consumer.PactVerificationResult$Ok@4044fb95> but was:<Error(error=java.lang.AssertionError: expected:<1 Actual :2>, mockServerState=au.com.dius.pact.consumer.PactVerificationResult$Ok@4044fb95)

uglyog
2019-04-10 09:15
@ghandour.jihad why are you using version 3.5.11?

uglyog
2019-04-10 09:17
But I guess your assertion is failing: `assertEquals(1,response.size());` -> `AssertionError: expected:<1 Actual :2`

uglyog
2019-04-10 09:18
I.e., your response has size 2, not 1

ghandour.jihad
2019-04-10 09:58
(I upgraded to 3.6.3 now and it aswell has the same problem)

ghandour.jihad
2019-04-10 09:59
indeed this is the assertion that is failing, I intended to make it fail, so that I see how will the result be outputed in the Intellij console

ghandour.jihad
2019-04-10 10:00
problem is I get java.lang.AssertionError: Expected :au.com.dius.pact.consumer.PactVerificationResult$Ok@2ceb80a1> but was:<Error(error=java.lang.AssertionError: expected:<1 Actual :2>, mockServerState=au.com.dius.pact.consumer.PactVerificationResult$Ok@2ceb80a1) While I was expecting for something more neat like java.lang.AssertionError: Expected :1 Actual :2

ghandour.jihad
2019-04-12 16:04
Kind reminder on this :slightly_smiling_face: @uglyog, do you think I should open an issue?

uglyog
2019-04-13 03:56
No, it is not an issue. It is working as intended. The assertion error is getting caught by the pact framework and being wrapped in a Error and then re-thrown.

jadedevin13
2019-04-19 09:08
has joined #pact-jvm

alexei
2019-04-23 09:59
has joined #pact-jvm

alexei
2019-04-23 10:02
Hi, where do I put consumer version with gradle publishing pact on pact broker? I haven?t found it in documentation yet. gradle project.version is being used, but there is also a case with one build uploading pacts for different consumers, what are the ways to differentiate?

alexei
2019-04-23 10:06
I also missing documenation about how to version the provider for the broker verfication (Junit5, gradle)?.

alexei
2019-04-23 11:11
Update. Found this one: For pacts that are loaded from a Pact Broker, the results of running the verification can be published back to the broker against the URL for the pact. You will be able to see the result on the Pact Broker home screen. You need to set the version of the provider that is verified using the **pact.provider.version system property**. To enable publishing of results, set the property pact.verifier.publishResults to true [version 3.5.18+].

mvpatel1982
2019-04-24 06:47
has joined #pact-jvm

alexei
2019-04-24 13:53
it is just version like in> ``` pact { publish { pactDirectory = 'build/pact-files' // defaults to $buildDir/pacts pactBrokerUrl = url pactBrokerUsername = pactBrokerUser pactBrokerPassword = pactBrokerPwd version="${project.version}-${getGitHashForLastCommit()}" } ```` but possibly not mentioned in README

uglyog
2019-04-25 04:20
It uses the version property from the project by default, which can be overwritten as you have done

alexei
2019-04-25 07:58
Another question. @uglyog Suppose i have the same request which delivers different responses depending on state. Example: State=normal /find/book/1 returns json response State=empty db /find/book/1 returns 404 How do I test it in consumer? In this example my mock server returns as if in "normal", didn't find a way to switch between states on consumer side.

uglyog
2019-04-25 08:00
The consumer test would have 2 different test cases which define the expected response and the provider state

alexei
2019-04-25 08:00
Do you have a link to example?

alexei
2019-04-25 08:01
https://github.com/DiUS/pact-jvm/blob/master/pact-jvm-consumer-junit/README.md#using-the-base-consumerpacttest Here are two states with just one test, unclear how to define states in tests...

uglyog
2019-04-25 08:02
No, you use one state per test. The two interactions then go into the same pact file

alexei
2019-04-25 08:04
So it is probably doable if there are two different paths for each test. But if the path is the same?

alexei
2019-04-25 08:04
(Using junit5)

uglyog
2019-04-25 08:05
The path doesn't matter. Each test gets it's own mock server which knows how to behave based on the expected interactions.

alexei
2019-04-25 08:07
``` @Test void test(MockServer mockServer) throws IOException { HttpResponse httpResponse = Request.Get(mockServer.getUrl() + "/articles.json").execute().returnResponse(); assertThat(httpResponse.getStatusLine().getStatusCode(), is(equalTo(200))); }```

alexei
2019-04-25 08:08
How do I configure the right state for the mock? The pact find is okay, but I cant find the way to test the second state for consumer.

alexei
2019-04-25 08:10
Let's imagine, the same url/articles.json return 200 (as above) or 404.

uglyog
2019-04-25 08:12
The states are not used on the consumer test. The mock server uses the defined response for the test. So you setup one pact fragment with a 200 response and provider state "article exists" and one with 404 response and "article does not exist". Then you have two tests, one which uses the first fragment and the other the second.

alexei
2019-04-25 08:13
But it doesn't work if the "request" part of both fragments is the same)

alexei
2019-04-25 08:14
It works if first fragment /article/1, the second fragment /article/1984

alexei
2019-04-25 08:15
But not for the same /article request, because mock always answers with one and the same response

uglyog
2019-04-25 08:15
the first test will get a mock server that returns a 200 response from `/articles.json` and the second test will get a new mock server that returns a 404 to that URL

alexei
2019-04-25 08:16
As if mockServer.useState(String ...) is missing

uglyog
2019-04-25 08:16
Might be easier if I just write the test for you :smile:

alexei
2019-04-25 08:20
``` @Test void test(MockServer mockServer) throws IOException { HttpResponse httpResponse = Request.Get(mockServer.getUrl() + "/articles.json").execute().returnResponse(); assertThat(httpResponse.getStatusLine().getStatusCode(), is(equalTo(404))); }``` Just like this??


alexei
2019-04-25 10:11
It must be properly bound some how, it cannot work this way without binding test to fragement

alexei
2019-04-25 10:15
Thanks! I solved it the same way on the plane)) I had the interaction in one method, then there is no way to differentiate. That is from README example

pltran875
2019-04-26 09:16
Anyone knows if there is a Gradle equivalent of the can-i-deploy functionality?

gopinathlangote11
2019-04-26 12:10
Here, anyone using pact maven plugin with S3 to store contract files? As currently `pact-jvm-provider-maven` do not support AWS S3 to store/retrieve the contracts files? @maintainer any plans to support the same? If you feel it is useful, I don?t mind submitting PR :slightly_smiling_face:

uglyog
2019-04-28 05:55
There is support for loading pacts from S3. Publishing would just mean copying the pact files, so there is no need to create a pact plugin for that. Just use the AWS cli.

gopinathlangote11
2019-04-28 11:30
@uglyog Thanks for the response. About loading pact from s3, is there support in `pact-jvm-provider-maven`, I was not able to find the same. Could you share the link to document if I am missing something

richard.jones
2019-04-29 00:07
has joined #pact-jvm

uglyog
2019-04-29 00:58
Just checked, and it only works for 3.5.x and not for the maven plugin. It works by using an S3 URL S3://...

richard.jones
2019-04-29 04:10
Hi folks, I?ve just confirmed that the latest pact-jvm (3.6.5) generates a `"min": 0` when `.arrayEachLike()` is used, but believe it should be defaulting to `"min": 1` given that?s the recommendation as detailed https://docs.pact.io/faq#why-is-there-no-support-for-specifying-optional-attributes (the ruby and python implementations treat an EachLike minimum of 0 as an error).

uglyog
2019-04-29 08:47
That's correct. `arrayEachLike` generates `"min": 0` while `minArrayLike(n)` generates `"min": n`

gopinathlangote11
2019-04-29 09:09
How to handle auth for S3 url?

gopinathlangote11
2019-04-29 09:10
& Can we add native support for maven plugin

uglyog
2019-04-29 09:11
Please raise an issue or create a PR for it at https://github.com/DiUS/pact-jvm

gopinathlangote11
2019-04-29 09:21
@uglyog I have already created issue for the same https://github.com/DiUS/pact-jvm/issues/875

gopinathlangote11
2019-04-29 09:21
I can propose more details there!

jonathan.ruckwood
2019-04-29 11:52
has joined #pact-jvm

richard.jones
2019-04-29 22:20
@uglyog I believe it should generate a default min of 0, otherwise the generated pacts are not valid (certainly they break the broker, which only handles the valid case of min > 0)

uglyog
2019-04-29 22:23
Then that issue is with the broker. There is nothing invalid about having min=0, it is a valid use case.

richard.jones
2019-04-29 22:24
I believe you and @bethskurrie need to discuss that further then :slightly_smiling_face:

richard.jones
2019-04-29 22:24
Per https://docs.pact.io/faq#why-is-there-no-support-for-specifying-optional-attributes ?The same goes for specifying an array with length 0 or more. If all your provider verification data returned 0 length arrays, all your verification tests would pass without you ever having validated the contents of the array. This is why you can only specify an array with minimum length 1 OR a zero length array.?

uglyog
2019-04-30 08:05
@bethskurrie what have you done?

christophe
2019-05-01 16:08
has joined #pact-jvm

noel.yap_slack.pact.i
2019-05-08 16:43
has joined #pact-jvm

james.hattersley-dyke
2019-05-24 07:34
has joined #pact-jvm

james.hattersley-dyke
2019-05-24 07:36
Hi, can anyone point me at some examples of converting a PactMessage class to a JSON string? I can generate the Pact, but when I try invoke my message handler, I get validation / deserialisation errors - We're using a message handler that just accepts the string of the raw message

james.hattersley-dyke
2019-05-24 07:41
``` messageStream.run { Message message -> def json = JsonOutput.toJson(message.contentsAsBytes()) productSubscriber.handleEvent(json) ``` assertion not shown here, but i've tried multiple variations on this, the `handle` method takes a string parameter of the actual message

james.hattersley-dyke
2019-05-24 07:53
it's ok I got this... wasn't clear from the docs, that for a java n00b like me you can just do `new String(message.contentsAsBytes())`

james.hattersley-dyke
2019-05-24 07:53
might be worth throwing that on at the end :slightly_smiling_face:

uglyog
2019-05-24 08:56
You can also do something like `message.getContents().valueAsString()`

james.hattersley-dyke
2019-05-24 09:27
ah right, that's good to know. I'm just getting to grips with Java / Groovy et al

james.hattersley-dyke
2019-05-24 13:56
Anyone know what to do with this? ``` could not create Vfs.Dir from url. ignoring the exception and continuing org.reflections.ReflectionsException: could not create Vfs.Dir from url, no matching UrlType was found [file:/C:/Code/product-command/build/classes/groovy/main] either use fromURL(final URL url, final List<UrlType> urlTypes) or use the static setDefaultURLTypes(final List<UrlType> urlTypes) or addDefaultURLTypes(UrlType urlType) with your specialized UrlType. ```

james.hattersley-dyke
2019-05-24 14:07
``` serviceProviders { 'selling-product-command' { verificationType = 'ANNOTATED_METHOD' packagesToScan = ['com.companyname.sellingproductcommand.*'] hasPactsFromPactBroker(brokerUrl, authentication: ['Bearer', brokerToken]) } } ```

james.hattersley-dyke
2019-05-24 14:46
This is when trying to use the message verification in the pact-jvm-provider-gradle, been stuck on it a while now, not sure there's much I can affect

diandra
2019-05-28 00:21
has joined #pact-jvm

simone.dicola
2019-05-28 08:33
has joined #pact-jvm

simone.dicola
2019-05-28 08:33
Morning all

simone.dicola
2019-05-28 08:34
I have created the following test

simone.dicola
2019-05-28 08:35
But when I run gradlew test

simone.dicola
2019-05-28 08:35
I am not able to generate the pact

simone.dicola
2019-05-28 08:35
Sure I am missing something :slightly_smiling_face:

simone.dicola
2019-05-28 08:35
for instance runConsumerTest

simone.dicola
2019-05-28 08:35
anyone can shed some light ?

simone.dicola
2019-05-28 08:48
import static au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest;

simone.dicola
2019-05-28 09:14
is there anyone here?

abubics
2019-05-28 23:41
It's morning here now :slightly_smiling_face:


abubics
2019-05-28 23:45
but it depends what style of testing you want to work with :slightly_smiling_face:

abubics
2019-05-28 23:46
I think, if you set up the provider manually (as in your example), and build a pact object (as you have, via `.toPact()`), you will need to manually call `runConsumerTest(pact, config, (mockServer, context) -> { ... })`


simone.dicola
2019-05-30 10:09
Thanks @abubics

russell.blandamer
2019-05-30 10:44
has joined #pact-jvm

simone.dicola
2019-05-30 12:11
sorted :slightly_smiling_face:

antonello
2019-06-03 22:42
Hi! It?s me again. Is it possible to split provider verification tests for a single provider into different classes (for example to have a separate class for each endpoint) without having to resort to using @PactFilter annotations? @PactFilter works a treat, but it also means that when a consumer adds a new interaction to an existing pact, given that the provider is filtering, the verification succeeds even if the new interaction hasn?t been verified.

richard.jones
2019-06-03 23:03
Hi folks, I just wanted to note that a lot of the links (like pact-jvm-consumer-specs2, pact-jvm-consumer-junit, ?) on https://github.com/DiUS/pact-jvm are broken. I?m trying to find docs on the JVM API :slightly_smiling_face: (specifically, how is tagging of pacts done? if the JVM impl doesn?t submit pacts to the broker, then ignore my question :smile: )

uglyog
2019-06-04 00:14
@richard.jones use the v3.6.x branch until I can correct the links.

richard.jones
2019-06-04 00:26
okie, thanks!

uglyog
2019-06-04 00:39
There is no current way to only validate a subset of the interactions without using @PactFilter. Can you raise an issue for this at the github project?

antonello
2019-06-04 07:04
Thank @uglyog. I don?t really want to validate a subset of interactions though. I would either like to have the ability of sharing various @State across more than one class without having to using @PactFilter or the ability to know if any interactions defined in our pacts haven?t been verified.

antonello
2019-06-04 07:30
I thought this (https://github.com/DiUS/pact-jvm/issues/522) would address our issue, but we?re using the SpringRestPactRunner.

alessio.paciello
2019-06-04 08:44
has joined #pact-jvm

ben
2019-06-04 11:14
has joined #pact-jvm

rob.clarken
2019-06-04 22:47
has joined #pact-jvm

antonello
2019-06-05 06:23
@uglyog @bethskurrie Reading your comments on the issue above, the expected behaviour should be that if you use @PactFilter and only verify a subset of interactions in a pact, the verification should fail if all defined interactions are not verified. Am I understanding it correctly? And would that be the case for the SpringRestPactRunner?

uglyog
2019-06-05 06:27
At the moment, it won't fail the build (it generates a test per interaction), but will not publish the verification result back to the broker unless all the interactions where verified

antonello
2019-06-05 06:35
Gotcha. We thought we were seeing something different but it?s possible we just go confused by the pact broker indicating the pact has been verified, but it?s possible that it was verified by a feature branch. We will retest what we thought we saw, but I?m sure it behaves as expected (as in as you say above).

alessio.paciello
2019-06-05 09:15
Hello! Any hint on enabling DEBUG logging level on `pact-jvm-provider-junit` ?

uglyog
2019-06-05 09:20
Use any SLF4J logging library. logback is one such. It will enable debug level by default

alessio.paciello
2019-06-05 10:14
thanks! Actually the problem was that `logback-test.xml` wasn't picked up

antonello
2019-06-05 16:57
@uglyog Sadly we have been able to demonstrate the problem. I?ve raised an issue: https://github.com/DiUS/pact-jvm/issues/889 I am not providing a working example because it?s incredibly easy to reproduce, but let me know if you need any further clarification.

antonello
2019-06-06 08:15
By the way, any idea of when v4 will be released? Just wondering what we should target if we wanted to fix the issue above, or whether we should aim to fix it both.

uglyog
2019-06-06 08:16
Lots of re-factoring happening. The beta versions are available. Once it is stable the beta will be dropped

uglyog
2019-06-06 08:17
Fix it in master. If needed we can backport it to 3.6.x

steveland
2019-06-06 15:11
has joined #pact-jvm

antonello
2019-06-06 17:57
@uglyog We turned it around quite quickly thanks to @alessio.paciello! :-) If you?re ok with it, I think we may want it on 3.6.x. Also, we were wondering if we should also fail the test run.

hboddupalli
2019-06-07 21:34
has joined #pact-jvm

sgleadow
2019-06-10 23:09
@sgleadow has left the channel

iamtarasshevchenko
2019-06-12 11:23
has joined #pact-jvm

thomas.scheuchzer2
2019-06-12 13:23
has joined #pact-jvm

thomas.scheuchzer2
2019-06-12 13:25
Hi. Does anybody mind if we migrate some groovy classes to kotlin on the v4 branch?

uglyog
2019-06-12 22:46
That was the whole point of the V4 refactor :smile: But it is now merged to master

gerwin.vaatstra
2019-06-13 07:09
has joined #pact-jvm

vivek.125
2019-06-13 19:46
has joined #pact-jvm

vivek.125
2019-06-13 19:46
hi, how can i get the request reponse logs when running a provider?

vivek.125
2019-06-13 20:00
@uglyog

uglyog
2019-06-13 22:13
Set you log level to debug

cjadav
2019-06-14 05:42
has joined #pact-jvm

cjadav
2019-06-14 12:22
Hi i have this body in consumer tests ```PactDslJsonBody response = new PactDslJsonBody() //.numberType("id") //.id("id") .id() //.numberValue("id", 1) .stringType("clientId") .stringType("clientSecret") .stringValue("applicationName","flex-publish-service") .stringValue("description","abc")``` after creating json it is giving 500 errors for post call, i am facing problem with id. if i use .id("id",10L) it worked but i want id to be random and will be ignored in provider verification

gerwin.vaatstra
2019-06-17 07:32
I had an issue (resolved it by specifying the contract differently) but I wonder if it is a bug. I had this contract that resulted in the matchingrule in the body of "$.payload$.bestandsid" (double $): PactDslJsonBody body = new PactDslJsonBody(); body.object("headers") .stringValue("bestandstype", "dpc") .stringValue("Content-Type", "application/json") .closeObject(); payload = new PactDslJsonBody(); payload.stringValue("bestandstype", "dpc") .stringValue("bestandsid", EXAMPLE_DPC_FILE_NAME) .closeObject(); body.object("payload", payload); The issue here is that when I use a PactDslJsonBody as DslPart in 'body.object("payload", payload)', I get the extra $ Second thing I noticed is that the error message isn't mentioning the extra $: 0) A message notifying a newly available foo file generates a message which has a matching body $.payload.bestandsid -> Expected 'string' but received '20190219_foo_20190124.txt'

drambhia
2019-06-17 15:27
has joined #pact-jvm

james.hattersley-dyke
2019-06-17 15:27
Hi, just wondering if anyone has any advice really... I've got a provider that spits out a large amount of json, I'm feeling lazy and can't be doing with specifying each field (some of the information is repeated), however my message consumer only consumes fully formed messages... is there a way to 'reuse' the message generation code? In my consumer tests I'm instanciating a message subscriber and pushing the generated JSON through that class... ``` given: "Product Command produces the following message" def messageStream = new PactMessageBuilder().call { serviceConsumer 'web-cmd' hasPactWith 'product-command' given 'the service can accept incoming messages' expectsToReceive 'a fully formed product message' withContent { .... } when: "a message is received" messageStream.run { def s = new String(it.contentsAsBytes()) productSubscriber.handleEvent(s) } then: "the valid message is persisted to the database" 1 * ProductDAO.save(_ as DynamoDB) >> { it.id == '12344323' } ``` Am I doing this right? Is there any easier way?

anddreiu
2019-06-17 15:51
has joined #pact-jvm

uglyog
2019-06-17 23:14
@james.hattersley-dyke not sure what you asking. Do you want to use the message provider code to generate the message for the consumer test?

abubics
2019-06-18 00:51
Hello! is `4.0.0-beta.1` a good version to use? Or is it not-so-stable?

uglyog
2019-06-18 00:53
It is usable in the sense that it should work. It is unstable in the sense that there is a big re-factor going on, so all the classes and method signatures may change before 4.0.0

uglyog
2019-06-18 00:54
That looks like an error. What version are you using?

abubics
2019-06-18 00:56
I see. I think I'll go with 3.6.x then :ok_hand:

abubics
2019-06-18 01:02
(oh, and thanks :pray: )

agarwalatrisha1212
2019-06-18 03:18
has joined #pact-jvm

abubics
2019-06-18 06:27
for JVM providers, is there any recommendation or rationale around choosing to verify with gradle vs junit? or just personal preference?

uglyog
2019-06-18 06:30
With JUnit you can have more focused tests, and can mock out collaborators that aren't important

uglyog
2019-06-18 06:31
For instance a service that calls out to another service

abubics
2019-06-18 06:32
right . . . I do that with the gradle verify anyway . . . :thinking_face:

abubics
2019-06-18 06:32
I mean, I've never used the junit verify, so I was wondering how the experience is :slightly_smiling_face:

uglyog
2019-06-18 06:33
Apart from the JUnit bit, I prefer it

abubics
2019-06-18 06:34
welp, I'm in a kotlin codebase with Spek set up (non-junit) so I suppose I have fewer choices :upside_down_face:

uglyog
2019-06-18 06:36
I've done it with Spock as well, just required more test code to be written when the JUnit has annotations to do a lot of that

cjadav
2019-06-18 06:47
Hi Guys, any resolution for this?

uglyog
2019-06-18 06:51
What error do you get?

cjadav
2019-06-18 06:55
```===> Received request: Request { method: "POST", path: "/api/authentication/applications", query: None, headers: Some({"Connection": "keep-alive", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36", "X-App-Registration-Key": "Ld61vMw2jKLBNClekKCkSSshETpX0pUl4S0YpJwPvWBpO4sB", "Cache-Control": "no-cache", "Host": "localhost:18101", "Accept": "*/*", "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate, br", "Accept-Language": "en-IN,en;q=0.9,hi-IN;q=0.8,hi;q=0.7,en-GB;q=0.6,en-US;q=0.5", "Content-Length": "71", "Postman-Token": "d4556f1d-12a8-c22c-e577-f8ce74ebb613", "Origin": ""}), body: Present([123, 10, 32, 32, 34, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 78, 97, 109, 101, 34, 58, 32, 34, 102, 108, 101, 120, 45, 112, 117, 98, 108, 105, 115, 104, 45, 115, 101, 114, 118, 105, 99, 101, 34, 44, 10, 32, 32, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 32, 34, 97, 98, 99, 34, 10, 125]), matching_rules: MatchingRules { rules: {} }, generators: Generators { categories: {} } } 06:54:23 [INFO] body: '{ "applicationName": "ftest, "description": "abc" }' 06:54:23 [INFO] comparing to expected request: Request { method: "POST", path: "/api/authentication/applications", query: None, headers: Some({"X-App-Registration-Key": "Ld61vMw2jKLBNClekKCkSSshETpX0pUl4S0YpJwPvWBpO4sB", "Content-Type": "application/json"}), body: Present([123, 34, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 78, 97, 109, 101, 34, 58, 34, 102, 108, 101, 120, 45, 112, 117, 98, 108, 105, 115, 104, 45, 115, 101, 114, 118, 105, 99, 101, 34, 44, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 34, 115, 116, 114, 105, 110, 103, 34, 125]), matching_rules: MatchingRules { rules: {"body": Category { name: "body", rules: {"$.description": RuleList { rules: [Type], rule_logic: And }} }} }, generators: Generators { categories: {BODY: {"$.description": RandomString(20)}} } } token = Root body_cursor = Object({"applicationName": String("flex-publish-service"), "clientId": String("string"), "clientSecret": String("string"), "description": String("abc"), "id": Number(1234567890)}) token = Field("id") body_cursor = Object({"applicationName": String("abc"), "clientId": String("string"), "clientSecret": String("string"), "description": String("abc"), "id": Number(1234567890)}) thread '<unnamed>' panicked at 'Rng.gen_range called with low >= high', /home/ronald/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.4.2/src/lib.rs:519:9 note: Run with `RUST_BACKTRACE=1` for a backtrace.```

uglyog
2019-06-18 06:58
> `thread '<unnamed>' panicked at 'Rng.gen_range called with low >= high'`

uglyog
2019-06-18 07:00
Looks like the verification panicked, can you raise on issue at https://github.com/pact-foundation/pact-reference



gerwin.vaatstra
2019-06-18 08:15
At the consumer I use pact-jvm-consumer-junit_2.12 - Version 3.6.2 pact-jvm-consumer-java8_2.12 - Version 3.6.2 I believe I also tried 3.6.7 earlier but also had the issue there


james.hattersley-dyke
2019-06-18 08:30
Hi, I'm saying is there a way to reuse some of the message generation code? And if I'm doing it right asserting that the generated message can still be processed?

james.hattersley-dyke
2019-06-18 10:19
I suppose I could not assert the generated message is handled correctly and just use it to generate the contract? That feels a little risky though

james.hattersley-dyke
2019-06-18 10:34
do you write verbose tests or just enough to generate a contract?

james.hattersley-dyke
2019-06-18 10:36
anyone else want to weigh in on this thread?

gerwin.vaatstra
2019-06-18 10:40
Not really. If you have a lot of JSON and your consumer needs it all, I would say it pays to do the effort. You could also wonder why your consumer needs it all of course. I would go for 1 contract + captures JSONs for the other scenario's and use them on your service

gerwin.vaatstra
2019-06-18 10:41
And if you go the way of "let's generate" then you actually say "whatever it generates is what I expect"

james.hattersley-dyke
2019-06-18 11:10
cool, I was thinking of going all out an generating the entire message then scaling back as we understand more of what's mandatory data. Right now, everything is....

gerwin.vaatstra
2019-06-18 12:21
Instead of scaling down, start with what you need because then you end up with the correct contract instead of checking more than needed

james.hattersley-dyke
2019-06-18 13:46
does anyone know if it's possible to generate matchers for this JSON ``` "standards": { "STANDARD_NAME_2": ["STANDARD_VALUE_2", "STANDARD_VALUE_1"], "STANDARD_NAME_1": ["STANDARD_VALUE_1"] }, ```

james.hattersley-dyke
2019-06-18 13:51
answered my own question - just incase you're interested ``` standards { keyLike 'STANDARD_NAME', eachLike(2, string('STANDARD_VALUE')) } ```

uglyog
2019-06-18 23:49
Looks like a defect. Can you raise an issue for it?

abubics
2019-06-19 00:38
howdy, just setting up a gradle verify, following instructions on https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-gradle#using-a-state-change-url, but getting an unexpected error: ``` > Cannot cast object 'UrlSource(url=http://localhost:8080/pact-state-change, pact=null)' with class 'au.com.dius.pact.model.UrlSource' to class 'java.net.URL' ``` My gradle file looks like ``` pact { serviceProviders { 'app-api' { startProviderTask = startProvider terminateProviderTask = stopProvider hasPactWith('app-ui') { pactSource = file('pacts/app-ui-app-api.json') stateChangeUrl = url('http://localhost:8080/pact-state-change') } } } } ``` Any ideas?

uglyog
2019-06-19 00:38
Oh, damn

uglyog
2019-06-19 00:39
Issue please

abubics
2019-06-19 00:39
oh no

abubics
2019-06-19 00:41
Is there an issue template?


abubics
2019-06-19 00:49
there you go :slightly_smiling_face: cheers~*

abubics
2019-06-19 00:49
lmk if you need more detail, of course

abubics
2019-06-19 01:45
another problem I'm (surprisingly) having . . . most of the time, Pact is failing to hit my provider instance: ``` Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused) ``` but when I `curl` it manually, it's giving the expected responses. The log output shows that it's waited for the provider to finish starting up (using `com.wiredforcode.gradle.spawn.SpawnProcessTask`). I've never seen this before, just wondering if anyone else has. And it has worked a couple of times out of >20 attempts, hinting at a race condition maybe?

uglyog
2019-06-19 01:46
Is it a springboot app?

uglyog
2019-06-19 01:48
I remember the spawn task can wait for some log output to appear. It seems like a race condition that the spawn task has returned because the process is running, but the socket may not have been opened yet

abubics
2019-06-19 01:52
it's a ktor app, and the output indicates that it's really ready, although that could be inaccurate ``` 2019-06-19 11:41:12.659 [main] INFO Application - Responding at http://0.0.0.0:8080 2019-06-19 11:41:12.660 [main] TRACE Application - Application started: io.ktor.application.Application@a68df9 java -jar /Users/.../app-api/build/libs/app-api-0.0.1-SNAPSHOT.jar is ready. ```

abubics
2019-06-19 01:53
I'll check the docs for `SpawnProcessTask` to see if I can delay it after finding the `ready` line

abubics
2019-06-19 02:52
settling for ``` startProvider.doLast { Thread.sleep(100) } ``` but sad about it :cry:


abubics
2019-06-19 07:12
Found the fix, but leaving the issue open until the docs are fixed :slightly_smiling_face:

vetisanvasile
2019-06-19 07:36
has joined #pact-jvm

vetisanvasile
2019-06-19 07:44
Hello guys, I tried to setup logging for pact tests (pact-jvm-provider) with logback and everything seems to work ok. But when I try to use log4j I don't see any info realted to pact classes e.g DEBUG a.c.d.p.p.j.loader.PactBrokerLoader, DEBUG a.c.d.pact.matchers.MatcherExecutor but I see a lot of http logging. Is there incompatibility between pact-jvm and log4j?

uglyog
2019-06-19 07:45
Pact-JVM uses SLF4J. If you want to use log4j, you need to also use a SL4FJ adapter for log4j

james.reynolds
2019-06-19 15:06
has joined #pact-jvm

james.carman
2019-06-19 16:48
We tried upgrading to pact-jvm 3.6.8 and we started getting: ``` groovy.lang.MissingMethodException: No signature of method: java.math.BigDecimal.toInt() is applicable for argument types: () values: [] Possible solutions: print(java.io.PrintWriter), print(java.lang.Object), toLong(), round(), trunc(), round(java.math.MathContext) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70) at org.codehaus.groovy.vmplugin.v7.IndyGuardsFiltersAndSignatures.unwrap(IndyGuardsFiltersAndSignatures.java:175) at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234) at au.com.dius.pact.model.Response$_fromMap_closure1.doCall(Response.groovy:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041) ... ```

james.carman
2019-06-19 16:51
We are a Spring Boot project and Spring Boot is pinning (via dependencyManagement) Groovy to 2.5.7.

james.carman
2019-06-19 16:56
Looks like pact-jvm uses 2.5.6 in its dependencies, so that shouldn?t be an issue

james.carman
2019-06-19 18:41
Same! :slightly_smiling_face:

james.reynolds
2019-06-19 20:02
Hello! I?m working on setting up my first Pact test in a springboot app. I?m using v`4.0.0-beta.1` and modeling my work after the example here: https://github.com/DiUS/pact-jvm/tree/master/consumer/pact-jvm-consumer-junit I noticed the `ConsumerClient` class isn?t found in the jar. I assume it?s the same that?s used in this test too: https://github.com/DiUS/pact-jvm/blob/master/consumer/pact-jvm-consumer-junit/src/test/java/au/com/dius/pact/consumer/pactproviderrule/PactProviderTest.java#L7 Am I following the wrong example for a JDK 11/Pact 4.0 setup?

uglyog
2019-06-19 23:03
`ConsumerClient` is just an example class and is in the test classpath, you should be using your own classes instead.

oswald.quek
2019-06-21 11:46
has joined #pact-jvm

codrut.gusoi
2019-06-21 13:54
has joined #pact-jvm

shefeeque85
2019-06-22 18:55
has joined #pact-jvm

mui_ume
2019-06-23 09:34
has joined #pact-jvm

jemmawells
2019-06-25 11:46
has joined #pact-jvm

jemmawells
2019-06-25 11:59
Hiya, looking for some guidance! We are currently writing some Providers side tests to verify a Pact File that we have successfully pushed to our Pact Broker. We're currently having issues with basic authentication when trying to access the Pact Broker during the test. We know our username and password are correct - they work without issue in a GET request and a curl. We're just not able to successfully authenticate using the annotations. We're using J Unit 5, and our @PactBroker annotation looks like the above

jemmawells
2019-06-25 11:59
Are there any known issues around this currently?

jemmawells
2019-06-25 12:00
Otherwise, any suggestions on things to try would be greatly received!

carolyn.biggar
2019-06-25 12:04
has joined #pact-jvm

james.carman
2019-06-25 12:15
What?s the error?

carolyn.biggar
2019-06-25 12:40
We're being redirected to our SSO webpage ie getting back html instead of the PACT broker json response. We've just used Charles to intercept what's being sent when we run the test and can see that no Authorization is being set. If you use Bearer on the other hand, you _can_ see the Autherization being set: ```@PactBroker(host = "http://our-broker.net", scheme = "https", port = "443", authentication = PactBrokerAuth(scheme = "Basic", username = "my-bearer-token", password = ""))``` (unfortuately we don't have a bearer token!) This seems to the last comment on this issue, https://github.com/DiUS/pact-jvm/issues/881#issuecomment-494286204 where the commenter mentions that basic auth no longer works - is that a known thing?

alessandrobuggin
2019-06-25 14:40
has joined #pact-jvm

james.hattersley-dyke
2019-06-25 14:41
hi, is there a way to prevent the pact gradle plugin pinging the broker on build? Our broker is locked down heavily right now by IP's in a security group - it means each dev is having to add their IP to the group... or they cannot build locally.... is there a way around this?

james.hattersley-dyke
2019-06-25 15:00
I'm guessing the above ^ relates to this: > NOTE: Currently the pacts are fetched from the broker during the configuration phase of the build. This means that if the broker is not available, you will not be able to run any Gradle tasks. This should be fixed in a forth coming release.

james.hattersley-dyke
2019-06-25 15:01
has this been addressed in v4.x?

cjadav
2019-06-28 13:34
i have ```return builder .given("There is a request to get details of a Job") .uponReceiving("Returns details of the not authorised user " + NOT_AUTHORISED_USER_ID) .headers(headers) .matchPath("/api/filter/[0-9]+") .body(body) .method("POST") .willRespondWith() .status(200) .headers(headers) .body("[]").toPact();``` .matchPath method which creates path like `"path": "/api/filter/13"` but when we run provider verification it tries to do post call of `"path": "/api/filter/13"` and failing as 13 is not available. question is how can we do matchers at provider side to ignore that particular id

uglyog
2019-06-29 01:22
what are you using on the provider side?

uglyog
2019-06-29 01:25
But you should use provider states to setup the correct data so that ID is valid. You can also use `matchPath(String pathRegex, String path)` to use a particular ID

cjadav
2019-07-01 05:48
We are using below code at provider side ```@RunWith(PactRunner.class) @Provider(PactConstants.PACT_PROVIDER_NAME_) @PactBroker(host = PactConstants.PACT_BROKER_URL_, port = PactConstants.PACT_BROKER_PORT_, protocol = PactConstants.PACT_BROKER_PROTOCOL_) @Slf4j public class ProviderVerification { static List<Integer> objectIds = new ArrayList<Integer>(); @TestTarget public final Target target = new HttpTarget(PactConstants.TARGET_PROTOCOL_, PactConstants.TARGET_DOMAIN_, PactConstants.TARGET_PORT_); @BeforeClass public static void before() throws Exception { System.setProperty("pact.verifier.publishResults", "true"); System.setProperty("pact.provider.version", getProviderVersion()); System.out.println("Version " + getProviderVersion()); } public static String getProviderVersion() { MavenXpp3Reader reader = new MavenXpp3Reader(); try { Model model = reader.read(new FileReader("pom.xml")); return model.getParent().getVersion(); } catch (XmlPullParserException | IOException ex) { throw new RuntimeException("Error while reading POM File..."); } } @State("There is a request to get details of a Job") @Test public void testObjectsEndpoint() { http://log.info("Verifying pact provider for xyz Service"); System.out.println("Verifying pact provider for xyz Service..."); } @AfterClass public static void after(){ System.clearProperty("pact.verifier.publishResults"); System.clearProperty("providerVersion"); } }```

cjadav
2019-07-01 05:49
every time id would be different so if i use `matchPath(String pathRegex, String path)` then too it will fail

uglyog
2019-07-01 05:54
No, it will use second parameter when making the request. The ID won't change.

cjadav
2019-07-01 05:57
true but how can lets say if i use `.matchPath("/api/filter/[0-9]+","/api/filter/6",)` it will request `"/api/filter/6"` like this but my problem is that 6 might not be there at provider side so first i need to create user having id 6 and then verify the contract so how can i do this?

uglyog
2019-07-01 05:58
Use a provider state that sets up user with id 6

cjadav
2019-07-01 06:01
ok. Thanks. Do we have any example for this? sorry but i am newbie in pact

cjadav
2019-07-01 06:05
also one problem i am seeing here is that i need to create a user in provider state but as id is auto-generated, i might get 7 instead of 6 and again it will fail

uglyog
2019-07-01 06:06
`testObjectsEndpoint` is an example. It get's called when that state needs to be setup. You can create another, or rename that one (`There is a request to get details of a Job` doesn't sound useful)

cjadav
2019-07-01 06:11
Got it. Thanks. However verification will fail if generated id is 7, right?

uglyog
2019-07-01 06:12
Can you not have a user created with the correct ID?

cjadav
2019-07-01 06:12
id is auto-generated, i dont have control on it.

cjadav
2019-07-01 06:14
so at provider side sudo login would be 1. create a user in state setup 2. have this id 3. pass this in contract request /api/filter/<id> thats why i am searching a way to change pact request and pass new id

uglyog
2019-07-01 06:27
There is a new feature that allows that, but it is not documentated


cjadav
2019-07-01 06:39
is there any link for that one?

uglyog
2019-07-01 06:47
No, it's undocumented. But it allows you to pass values from the provider state callback and use them with a generator

uglyog
2019-07-01 06:47
Not sure if there are any examples either

uglyog
2019-07-01 06:50
The method is `pathFromProviderState` instead of `matchPath`

cjadav
2019-07-01 06:52
Thanks. Let me google `pathFromProviderState`

uglyog
2019-07-01 06:53
if you use `pathFromProviderState("/api/filter/${id}", "/api/filter/1")` then have your provider state method return a Map with the `id`, it will use that

uglyog
2019-07-01 06:53
You have to use the latest version of Pact-JVM

cjadav
2019-07-01 06:54
at consumer side?

uglyog
2019-07-01 06:55
Both sides

cjadav
2019-07-01 06:56
latest of `pact-jvm-consumer-junit` and `pact-jvm-provider-maven` right?

uglyog
2019-07-01 06:58
Yes. Hopefully it will work with `pact-jvm-provider-maven`, it hasn't been tested yet


cjadav
2019-07-01 06:58
let me try it

nick_horne_90
2019-07-01 09:59
has joined #pact-jvm

nick_horne_90
2019-07-01 09:59
Hi, I am trying to write a Pact-Verifying unit test for the consumer in Java. Should I only have one test per class? I have noticed that if I have multiple tests in the class some of them fail unless I add a sleep before running my client assertions.


nick_horne_90
2019-07-01 11:03
For the above im using junit 4 and my test looks like this. When I add more Pact / PactVerification pairs (more tests) then the second one seems to fail consistently unless I add a sleep. ```@RunWith(SpringRunner.class) @SpringBootTest(properties = {}) public class ConsumerPactVerificationTest { @Rule public PactProviderRuleMk2 stubProvider = new PactProviderRuleMk2("customerServiceProvider", "localhost", 8888, this); @Autowired private AddressClient addressClient; @Pact(provider = "test") public RequestResponsePact getAddresses(PactDslWithProvider builder) { return builder .given("a collection of 2 addresses") .uponReceiving("a request to the address collection resource") .path("/addresses/") .method("GET") .willRespondWith() .status(200) .body("...", "application/hal+json") .toPact(); } @Test @PactVerification(fragment = "getAddresses") public void verifyAddressCollectionPact() { assertThat(addressClient.getAddresses())... } }```

dennis.woditsch
2019-07-01 11:42
has joined #pact-jvm

dennis.woditsch
2019-07-01 11:51
Hi, I'm currently struggling with parts of the provider. We have a pact defined with a hardcoded DateTime as part of the request body. In our service we have a constraint that this has to be in the future. How can we handle this? I found something like a `@TargetRequestFilter` to modify incoming request but this seems not to work with the `SpringRestPactRunner`. Any guidance here how to handle this? Is this something we have to "fix" in our pact file or does the producer actually has to take care to modify the date to be something in the future (maybe current date + 1hour)?

cjadav
2019-07-01 12:14
I have code like ``` PactDslJsonBody body = new PactDslJsonBody() .stringValue("action","VIEW") .array("objectIds") .id(1L) .closeArray() .minArrayLike("objects",1) .id("objectId") .id("accountId") .id("ownerId") .id("workspaceId") .stringType("typeName","ASSET") .booleanValue("privateGroup", true) .booleanValue("privateCollection", true) .closeArray() .asBody();``` but after using ```<artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.0-beta.3</version>``` it is generating json like ```{ "method": "POST", "path": "/api/filter/4", "headers": { "Content-Type": "application/json" }, "body": { "objects": [ { "accountId": { "value": "1234567890" }, "privateCollection": true, "typeName": "ASSET", "privateGroup": true, "ownerId": { "value": "1234567890" }, "objectId": { "value": "1234567890" }, "workspaceId": { "value": "1234567890" } } ], "action": "VIEW", "objectIds": [ { "value": "1" } ] } }``` however when i used 3.x it was generating ```{"objects":[{"accountId":4,"privateCollection":true,"typeName":"ASSET","privateGroup":true,"ownerId":5,"objectId":1,"workspaceId":3}],"action":"VIEW","objectIds":[1]}```. with 4.x version json provider verification is failing and giving ``` Returns details of the not authorised user 5 returns a response which has a matching body=BodyComparisonResult(mismatches={$=[BodyMismatch(expected=[], actual={"errorMessage":"JSON parse error: Can not deserialize instance of java.lang.Long out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.Long out of START_OBJECT token\n ```

uglyog
2019-07-01 23:56
I'm currently work on date expressions, so you can define a date as `now + 1 hour`. But it is still a work in progress. `@TargetRequestFilter` should work with `SpringRestPactRunner`, if not, that is a defect.

uglyog
2019-07-01 23:58
@cjadav could you raise a defect for that?

karlboyle
2019-07-02 15:30
has joined #pact-jvm

karlboyle
2019-07-02 15:33
Hey, just learning Pact for Jvm. I?m struggling to understand how it verifies in Maven? I can understand in junit, download pact from broker and run against a mocked instance of the app in code. But I don?t see in maven where you can spin up an instance of the app to test the pact verify against?

karlboyle
2019-07-02 15:34
Or is provider side testing with maven only for deployed/already running instances, not for dynamically spinning up your mocked instance local. Hopefully I?m making sense :)

antonello
2019-07-02 15:39
Yes, as far as I understand the maven plugin on the provider verification is only for deployed/already running instances

jdesouza
2019-07-02 17:38
has joined #pact-jvm

abubics
2019-07-03 05:42
Who uses Maven? :troll:

abubics
2019-07-03 05:43
basically, there are 2 strategies for doing JVM provider verifications: the gradle plugin way, and the junit way

abubics
2019-07-03 05:43
I can't comment on mvn, since I've never used it, but I haven't heard of a Maven version of the Gradle plugin . . . probably @uglyog would have advice there

abubics
2019-07-03 05:44
@karlboyle The way you're describing sounds like the gradle plugin workflow :slightly_smiling_face:

uglyog
2019-07-03 05:50
Maven plugin works nearly identically to the Gradle one (just in a Maven way)

karlboyle
2019-07-03 05:59
Thanks guys company requirement for Maven :zany_face:, @uglyog nearly identical - just doesn't spin up an instance? :)

uglyog
2019-07-03 06:02
Yeah, you'll need to do that using other Maven plugins. If you bind it to the integration test phase, you could use the pre- and post- phases to start and stop your app

karlboyle
2019-07-03 06:09
Ahhhh okay I'll play about later today! Thanks!

karlboyle
2019-07-03 06:17
Out of interest which is the preferred approach, provider tests in build tool or test lib. Test one seems better to me personally, just curious. Work asking about maven option hence my enquiry :)

abubics
2019-07-03 06:22
We had a little chat about this not long ago :slightly_smiling_face:

karlboyle
2019-07-03 06:36
Found it! Thanks @abubics !

cjadav
2019-07-03 08:42
Will do

sandhyarani.gabbi
2019-07-03 16:07
has joined #pact-jvm

dennis.woditsch
2019-07-05 09:09
Thanks @uglyog for your answer. This date expression would be enormously useful for us. But I guess in the meantime we have to somehow modify the date on the provider side. I tried to create a simple code snippet to show our setup. @RunWith(SpringRestPactRunner.class) @Provider("MyService") @PactBroker(host = "pact-broker.k8s.dev.XX") @ContextConfiguration(classes = { IntegrationTestWebMvcConfig.class }) @WebAppConfiguration public class PactProviderTest { @TestTarget public final MockMvcTarget target = new MockMvcTarget(); @Autowired private WebApplicationContext webApplicationContext; @Autowired private MyMock myMock; private MockMvc mockMvc; @Before public void setup() { mockMvc = webAppContextSetup(webApplicationContext) .apply(springSecurity()) .alwaysDo(log()) .defaultRequest(get("/") .servletPath("/rest")) .addFilter(new ExceptionResolverFilter(), "/*") .build(); target.setMockMvc(mockMvc); SecurityContextHolder.getContext().setAuthentication(new MockAuthentication(ORGANIZER_KEY, OAUTH_TOKEN, ORGANIZER)); } @After public void tearDown() throws Exception { myMock.reset(); } @State("default") public void blaCanBeCreated() { myMock.doUsefulSetup(); } @TargetRequestFilter public void exampleRequestFilter(HttpRequest request) { // I NEVER GET TO REACH THIS POINT } } ```

kiran.kumar.sukumar
2019-07-05 14:04
has joined #pact-jvm

kiran.kumar.sukumar
2019-07-05 14:06
Hi, How do i send a query parameter in provider side thats been set to a matcher on the consumer side e?

uglyog
2019-07-06 04:44
@kiran.kumar.sukumar when you specified the matcher on the consumer side, you can give an example value. That will be used to populate the query parameter when verifying the provider.

uglyog
2019-07-06 04:59
@dennis.woditsch `@TargetRequestFilter` will not work with `MockMvcTarget`, because there is never a real request with MockMVC. Use the `SpringBootHttpTarget` or `HttpTarget`.

uglyog
2019-07-07 08:13
3.6.11 has been released with support for date and time expressions

skirankumars31
2019-07-07 16:20
I have done that but it looks like the provide will not be able to set the exact value in provider state. The query value needs to be set to a different value when running the test. Is that possible ?

dennis.woditsch
2019-07-08 08:05
Thank you!

florian.nagel
2019-07-08 08:26
has joined #pact-jvm

dennis.woditsch
2019-07-08 08:54
This is exactly what I need. But somehow I guess I'm missing something. So I have this code in my DSLPart `body.datetimeExpression("scheduledStartTime", "today + 1 hour", "yyyy-MM-dd'T'HH:mm:ss.S'Z'");` But this is printing `"scheduledStartTime" -> "2000-01-31T14:00:00.0Z"`. What am I doing wrong here?

uglyog
2019-07-08 09:05
In the consumer test?

dennis.woditsch
2019-07-08 09:05
yes

uglyog
2019-07-08 09:07
The expressions are only used when verifying the provider side for the request.

dennis.woditsch
2019-07-08 09:12
Sure. I updated the consumer side with this datetimeExpression, updated the pact file and on provider side when I execute my tests they still get `"scheduledStartTime":"2000-01-31T14:00:00.0Z",` Dependency was also updated on the provider side

dennis.woditsch
2019-07-08 09:48
```"body": { "subject": "Meet Now", "scheduledStartTime": "2000-01-31T14:00:00.0Z", "meetingType": "scheduled" }, "matchingRules": { "body": { "$.scheduledStartTime": { "matchers": [ { "match": "timestamp", "timestamp": "yyyy-MM-dd'T'HH:mm:ss.S'Z'" } ], "combine": "AND" } } }, "generators": { "body": { "$.scheduledStartTime": { "type": "DateTime", "format": "yyyy-MM-dd'T'HH:mm:ss.S'Z'", "expression": "today + 1 hour" } }```

dennis.woditsch
2019-07-08 09:49
looks correct in the pact file. But somehow it is still wrong on the provider side

ruben.perezg
2019-07-08 11:29
Hi! I'm working trying to reach `Pact Nirvana` :slightly_smiling_face: [1], and currently trying to define our Tagging policy (for the _pact_, _consumer_ and _provider_) [2], pushing the verification results back to the broker, and also using the `can-i-deploy` tool to be sure about deploying newer versions of my services. I've found that the _gradle plugin_ [3] is able to execute the `pactVerify` task, specifying the providerName and where the Pact Broker is. But what I'm not seeing is how to connect that with my already existing tests that use either a `RestPactRunner` (JUnit 4) or a `SpringExtension`(JUnit 5). Looks like it expects that I "start up" my provider somehow [4], but I would like to use my already existing tests... Am I missing anything here? 1 -> https://docs.pact.io/best_practices/pact_nirvana 2 -> https://docs.pact.io/getting_started/versioning_in_the_pact_broker 3 -> https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-gradle 4 -> https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-gradle#starting-and-shutting-down-your-provider

uglyog
2019-07-08 23:52
If you are running your provider verification as JUnit tests, you don't need to use the Gradle pactVerify task. If you are using Springboot, you can use the Springboot test annotations to start the provider in the JUnit test.

asite.mshah
2019-07-09 06:05
has joined #pact-jvm

ruben.perezg
2019-07-09 06:13
I hace both scenarios: - Some as "unit tests" in the provider, using mockMVC. - Some with SpringBoot, using SpringBootTest to start the provider. But what I don't have is the results of the verification published back in the Broker. That's why I thought I needed to use the `pactVerify`... but maybe I'm wrong :smile: . Could you point me in the right direction? I think I'm missing something here, but I haven't been able to really get it with the documentation I've read


ruben.perezg
2019-07-09 08:39
ahhh, ok, I thought I had to do that in addition to using the `pactVerify` task. Thank you @uglyog :slightly_smiling_face:

uglyog
2019-07-09 23:21
Ok, can you raise an issue for that?

ruben.perezg
2019-07-10 09:04
@uglyog I still have problems... :sweat_smile: You shared the link of the `pact-jvm-provider-junit`, but I'm using `pact-jvm-provider-junit5`. I don't see anything about any JVM system property there [1]. I have tried to set it anyway with the _gradle_ execution, and haven't worked: - `./gradlew myTestTasks -Dpact.verifier.publishResults=true` I don't see any error trying to send the verification results as could be seen here [2]. I don't know how to set the `provider version` either... Could you help me with this again? :slightly_smiling_face: 1 -> https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-junit5 2 -> https://github.com/DiUS/pact-jvm/issues/738

uglyog
2019-07-10 09:14
Can you enable debug level logs? You?ll see a message as to why it is not publishing the results.

ruben.perezg
2019-07-10 09:18
`-d`? I have, but haven't seen anything

ruben.perezg
2019-07-10 09:19
do you want me to share it?

uglyog
2019-07-10 09:19
No, you need it enabled when your tests run. The easiest way is to add logback to your test class path.

uglyog
2019-07-10 09:21
Which makes me think the property needs to be set on the test task.

ruben.perezg
2019-07-10 09:21
:thinking_face:

ruben.perezg
2019-07-10 09:34
you mean adding: ``` doFirst { System.setProperty("pact.verifier.publishResults", "true") }```

ruben.perezg
2019-07-10 09:34
inside my custom test task definition?

ruben.perezg
2019-07-10 09:35
or adding `pact.verifier.publishResults=true` in the `gradle.properties`

ruben.perezg
2019-07-10 09:36
(I have tried both, but it´s not working...)

ghandour.jihad
2019-07-10 10:20
Hello awesome pacters in https://docs.pact.io/how_pact_works I found in the "expected request" ==> (this is always present for synchronous interactions like HTTP requests, but not required for asynchronous interactions like message queues) I am interested in the second part of it... does that mean that pact works for direct java calls, that are not REST calls?

uglyog
2019-07-10 23:50
You'll need to get the debug level logs to see what is going on

uglyog
2019-07-10 23:52
If you are asking if pact could be used to test interactions between Java classes, then yes, as long as they pass JSON in string format between them

ghandour.jihad
2019-07-11 07:47
Thank you!

nick_horne_90
2019-07-11 10:20
Hey, I am writing my consumer pact, how can I set the content type if I am using `.body(DslPart)` ?

nick_horne_90
2019-07-11 10:21
It seems to set the content-type to `application/json; charset=UTF-8` but I want to set it to something else

nick_horne_90
2019-07-11 10:22
The methods with a content type don't take in the DslPart

ruben.perezg
2019-07-12 07:19
I will work on this next week, thank you very much :slightly_smiling_face:

vetisanvasile
2019-07-12 15:14
Hi all I would like to ask a question related to pact broker. I am using pact-jvm-provider-junit_2.12 (version 3.6.10) I have a provider service called "wProviderService" and two service consumers ("pConsumerOne" and "tConsumerTwo") I have defined a parameter -Dpact.broker.tags=latest in my tests My test class looks like this: @RunWith(PactRunner.class) @Provider("wProviderService") @Consumer("pConsumerOne") @PactBroker(scheme = "${pact.broker.scheme}", host = "${pact.broker.host}", tags = "${pact.broker.tags}", authentication = @PactBrokerAuth(username = "${pact.broker.user}", password = "${pact.broker.pass}")) public class PactWProviderTest{ // some dummy and uninteresting implementation } When I execute my class I notice that pact files are fetched for both consumer services not only for consumer service that I specified [@Consumer("pConsumerOne")]. Is this behaviour intended? Console output: 2019-07-12 17:58:01 [main] DEBUG a.c.d.p.p.j.loader.PactBrokerLoader ? Loading pacts from pact broker for provider "wProviderService" and tag latest 2019-07-12 17:58:01 [main] DEBUG a.c.d.pact.pactbroker.HalClientBase ? Fetching: / 2019-07-12 17:58:02 [main] DEBUG a.c.d.pact.pactbroker.HalClientBase ? Fetching: https://mypactBroker.com/pacts/provider/wProviderService/latest 2019-07-12 17:58:02 [main] DEBUG a.c.d.pact.pactbroker.HalClientBase ? Fetching: https://mypactBroker.com/pacts/provider/wProviderService/consumer/pConsumerOne/version/0.0.5-SNAPSHOT 2019-07-12 17:58:03 [main] DEBUG a.c.d.pact.pactbroker.HalClientBase ? Fetching: https://mypactBroker.com/pacts/provider/wProviderService/consumer/tConsumerTwo/version/0.0.3-1123334445

uglyog
2019-07-14 08:37
It should only be executing the pact for the one consumer. Can you confirm this?

vetisanvasile
2019-07-15 05:47
@uglyog, is this message related to the question from friday?


vetisanvasile
2019-07-15 06:10
Yes, I can confirm this it downloads pact files from other consumers too

vetisanvasile
2019-07-15 06:12
Should I create an ticket for this on https://github.com/DiUS/pact-jvm/issues?

uglyog
2019-07-15 06:59
Is it only downloading them, or is it also verifying them?

vetisanvasile
2019-07-15 06:59
just downloading them

uglyog
2019-07-15 07:00
That?s ok then

vetisanvasile
2019-07-15 07:01
~would you like to post a question on pact-jvm issues so that other users that stumble on this to have an answer?~

ruben.perezg
2019-07-16 10:02
```09:59:32.131 [Test worker] WARN a.c.d.p.p.j.TestResultAccumulator - Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')```

ruben.perezg
2019-07-16 10:03
Now I know that I haven't been able to set the property correctly

ruben.perezg
2019-07-16 10:07
I've tried: - `-Dpact.verifier.publishResults=true` in the gradle command execution - `System.setProperty("pact.verifier.publishResults", "true")` inside our custom gradle test task Where should I set that property?

ruben.perezg
2019-07-16 10:09
The only way I've managed to set that property successfully has been setting that directly in my java tests (inside a `BeforeAll` method): I guess there should be a better way of doing this... but I haven't been able to find it

ruben.perezg
2019-07-16 10:26
Now, finally, I've been able to set it in our gradle task. The problem was that our custom gradle task was a task of type `Test`, so I needed to set the property like this, as stated here [1]: ```// set a system property for the test JVM(s) systemProperty 'some.prop', 'value'``` - https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html

ruben.perezg
2019-07-16 10:28
@uglyog do you think there is anything that I could improving in the documentation, so that it helps preventing other people from doing the same mistake? Or it is just because of my _"gradle ignorance"_ :laughing:

mui_ume
2019-07-16 10:31
Hi I?m new to the pact test on the provider side I need some simple example On java using spring and junit as framework Thanks

uglyog
2019-07-16 13:01
Anything you can do will help


mui_ume
2019-07-16 13:59
I saw this test snippet code for the login at the provider ```package xxx.platform.service.identitymanager; import xxx.platform.service.identitymanager.controller.IdentityController; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; @RunWith(SpringRunner.class) @WebMvcTest(IdentityController.class) public class IdentityControllerTest { @Autowired private MockMvc mvc; // Login Test Cases @Test public void logInUserSuccess() { //404 expected } @Test public void logInUserNotFound() { //404 expected } ```

mui_ume
2019-07-16 14:06
I did the consumer side setup for the login. my consumer is in JS. but I still trying to figure out how to add on the provider?

mui_ume
2019-07-16 14:07
above is the pact file generated by the pact test run at consumer side

mui_ume
2019-07-16 14:08
how can I replace with pact test? thanks

pavani.polakala
2019-07-16 21:52
has joined #pact-jvm

pavani.polakala
2019-07-16 21:59
Hi all. I'm new to Pact. I have configured pact on android project and tried running a sample test. But it's failing always. I'm getting this error : `java.lang.IllegalArgumentException: Could not locate ResponseBody converter for class java.lang.String` Can someone help me understand the issue?

pavani.polakala
2019-07-16 22:02
This is my request `{` ` "method": "GET",` ` "path": "/hello_world/"` `}` This is my response `{` ` "status": 200,` ` "body": "Hello World"` `}`

pavani.polakala
2019-07-16 22:03
Any help would be appreciated.

uglyog
2019-07-16 23:53
@pavani.polakala That is not anything to do with Pact. `ResponseBody converter` must be something from the android libraries you are using.


pavani.polakala
2019-07-17 00:00
Thanks @uglyog

florian.nagel
2019-07-17 09:10
I am analysing Consumer-driven contract tests in the scope of my bachelor thesis and I was wondering if it would (technically) be possible for the Gradle plugin to listen (and maybe trigger an event) to a Kafka topic. This way the pact framework would behave just like in the synchronous way and would actually trigger the event. This would make it easier for Pact integration in testing. I'd be glad for any input on this and am open to discussion on how to best incorporate pact testing (i.e. CDCs) in an asynchronous environment, preferably Kafka.

florian.nagel
2019-07-17 09:11
I suppose this could also go into #general as well. I can post this again if the mods think it is suited for #general

sabil.beladri
2019-07-17 14:11
has joined #pact-jvm

pavani.polakala
2019-07-17 18:19
@uglyog How to include tag in the publishing task in JVM?

pavani.polakala
2019-07-17 18:22
Got it.

uglyog
2019-07-18 00:04
I think this is a good topic for general. But back to the Gradle plugin, the reason why we kept things agnostic to queues otherwise the pact libraries would have to know about every queue available.

denis.ducansel
2019-07-18 09:30
has joined #pact-jvm

sabil.beladri
2019-07-18 14:10
Hi! First of all kudos to Pact foundation for providing such powerful tools. Glad to be using pact over the last year, it makes a huge difference and leap forward within my organization. I have questions specific to pact-jvm-provider-spring: I'm using MockMvcTarget and upon running pact validation I get these errors: * comparison -> Expected a response type of 'application/json' but the actual type was 'text/plain' * Expected a header 'Content-Type' but was missing Any suggestion/hint? Thanks for keeping me posted if so!

pavani.polakala
2019-07-18 14:44
@uglyog Pact file is always generated in target/pacts. I want it to be generated in build directory. I used following to change it 1. `System.setProperty(PactConsumerConfig.pactRootDir(), "build/pacts");` 2.`ext { pactDirectory = "$buildDir/pacts" }` But its not working. When I did debug, I found this in MockHttpServer.kt which overrided my values. `fun pactDirectory() = System.getProperty("pact.rootDir", "target/pacts")!!`

pavani.polakala
2019-07-18 14:46
Any idea on how to change the directory?

abubics
2019-07-19 00:25
I think you probably want ``` System.setProperty("pact.rootDir", "build/pacts"); ```

abubics
2019-07-19 00:25
the second argument to `System.getProperty` is the fallback, if the property isn't set

matt.fellows
2019-07-19 05:40
@matektchorek let?s continue your discussion in a thread here (to avoid polluting general)

matektchorek
2019-07-19 05:40
has joined #pact-jvm


matt.fellows
2019-07-19 05:41
Carry on here?

matt.fellows
2019-07-19 05:41
(I have to head to a meeting?)

matektchorek
2019-07-19 06:02
is there a possibility to mock server with my own jar file instead?

guidopio.mariotti10_d
2019-07-19 07:30
Hi, is there anyone that can look into https://github.com/DiUS/pact-jvm/issues/903#issuecomment-512142413? I think the gradle plugin was compiled with Java 12

tchorek.mateusz
2019-07-20 09:19
has joined #pact-jvm

guidopio.mariotti10_d
2019-07-21 06:40
Can anyone spot what is wrong in the timestamp format? ``` expected="2000-01-31T14:00:00.000+01:00", actual="2019-07-21T08:38:12.087+02:00", mismatch=Expected "2019-07-21T08:38:12.087+02:00" to match a timestamp of 'YYYY-MM-DD'T'HH:mm:ss.SSSZZZ': Unable to parse the date: 2019-07-21T08:38:12.087+02:00 ``` My guess is on the `SSSZZZ` but I?m not able to figure out what is wrong

uglyog
2019-07-21 07:01
Use `XXX` instead of `ZZZ`

uglyog
2019-07-21 07:04
I just double checked the Java docs, and `ZZZ` does not accept the zone offset with a colon. It expects `+0200` form

guidopio.mariotti10_d
2019-07-21 07:22
It doesn?t seem to make a difference. It still produces the same example date but with the same error too

guidopio.mariotti10_d
2019-07-21 07:22
Do you know which class is used for the validation? I wanted to debug this but I?m having an hard time finding the right class in the provider library

mui_ume
2019-07-22 06:16
Hi, what should I put at @Provider("pricing") for my use case?

mui_ume
2019-07-22 06:16
pricing is to be replaced with ?

mui_ume
2019-07-22 06:17
Also I have setup my own pact broker at https://pact.shared.frigg.li/

mui_ume
2019-07-22 06:17
@PactBroker(protocol = "https", host = "${pactBrokerHost}", port = "443", authentication = @PactBrokerAuth(username = "${pactBrokerUser}", password = "${pactBrokerPassword}"))

mui_ume
2019-07-22 06:19
can I just use this: ```@PactBroker("https://pact.shared.frigg.li/")```

mui_ume
2019-07-22 06:20
I guess the "pricing" should replaced with my provider name?

mui_ume
2019-07-22 06:21
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)

mui_ume
2019-07-22 06:21
I do not understand what is this WebEnvironment.DEFINED_PORT

mui_ume
2019-07-22 06:48
is there any simpler example to add the pact test code for the provider. I do not understand those @State annotation as seen in this github example: https://github.com/DiUS/pact-jvm/blob/master/provider/pact-jvm-provider-junit/src/test/java/au/com/dius/pact/provider/junit/ArticlesContractTest.java

mui_ume
2019-07-22 06:48
I only want to verify this provider's response: ```{ "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "authToken": "eyJraWQiOiJVdEI4c0hhYnk0aXBLNlwvQTZnaHBkRFFqRU9tdlptSnZZQTJpNFwvM2w3UmM9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiIyMTVhMGVhZS00ZjkwLTRlODItOWY4Zi1lNzhlOTdkMzcyODAiLCJldmVudF9pZCI6IjQxMjA3MjQwLWI2NGEtNDYxNi1iOGFiLTJkYzNiZjY4YWEwNCIsInRva2VuX3VzZSI6ImFjY2VzcyIsInNjb3BlIjoiYXdzLmNvZ25pdG8uc2lnbmluLnVzZXIuYWRtaW4iLCJhdXRoX3RpbWUiOjE1NjEwOTUwMDYsImlzcyI6Imh0dHBzOlwvXC9jb2duaXRvLWlkcC51cy1lYXN0LTIuYW1hem9uYXdzLmNvbVwvdXMtZWFzdC0yX2EzbE5SRU5QMSIsImV4cCI6MTU2MTA5ODYwNiwiaWF0IjoxNTYxMDk1MDA2LCJqdGkiOiJlNGFiNTI0Ny1hZjgwLTQ1MmUtOTcwMS01YjQ4OTY1ZTcwZDgiLCJjbGllbnRfaWQiOiI2Z2xwbmRxb2s2YWhua3M2dGFnNXQ5cGMwZyIsInVzZXJuYW1lIjoicWFAdGVsZXBhdGh5LmFpIn0.icFT50MVM-xhAPIu76H9XwIeNHhbe6_d3LcAv1qDQcRp1xabxpgzntgaEvyUnaTwFFJzkU2flfIrT_Y8TCeeFFqMFrMkpS9GadVtraxpOtNhMwxrwUz6bbz8iMHFxSxcIi0Ar3y06RLoRkp3C4gXf7eL8JXsTI9IB56TK7idvUmUcbN_322UPsAU98l3XFjdQEkMo3Fnqyrr41ftWBH876E2KB4g79Q73AL_s0j7mRmXjGswu8-pFiyPcIrDZKz35RSEpdWYLoRyW8rDnYU6YqWM-ncXEczBKlBKk6ggxMOK_qcTc7HYBty9c16zOn-33hxLCxG6pOtg5vLD3L0Tqw", "clientInfo": { "clientId": "0662923d-b187-4879-866a-3f053178426a" } } }```

florian.nagel
2019-07-22 08:24
I get timeouts when using the 4.x version with both the gradle plugin and the jUnit 5 runner. Gradle `pactVerify` works fine with 3.6.12 but fails to work with 4.0.0-beta.4 or 4.0.0-beta.3. I have written a class to be used by the gradle test and a class to be used with jUnit 5. I really don't know what to do. When jUnit5 is used it proceeds to `context.verifyIntegration()` and then times out, or to be more specific has an exception because the heap space is exceeded. When used with the gradle plugin there is a timeout as well, but it says `Expiring Daemon because JVM Tenured space is exhausted`. You could say "just use the gradle plugin" as it works fine, but I need an EmbeddedKafkaBroker which needs spring class annotations and I can only do that with the junit5 support. When I use the older version (3.6.x) of the jUnit5 runner it doesn't recognize any pact syntax/classes in my test class. As you see I'm running into multiple walls. Any help is appreciated. I'll post my source code on request.

florian.nagel
2019-07-22 12:59
Same project as above, different issue: My project is using an embeddedKafka with spring. When I use `pact-jvm-provider-junit5_2.12:3.5.24` everything's fine on pact side. But the context of the spring project won't load. As soon as I add the line ```implementation 'org.scala-lang:scala-library:2.11.8'``` in the gradle build file the pact test throws the following error message `java.lang.NoSuchMethodError: com.typesafe.scalalogging.StrictLogging.$init$(Lcom/typesafe/scalalogging/StrictLogging;)V` I can add the stacktrace if you want. When using `pact-jvm-provider-junit5_2.12:3.6.12` I get the following error: `java.lang.NoSuchMethodError: com.typesafe.scalalogging.StrictLogging.$init$(Lcom/typesafe/scalalogging/StrictLogging;)V` I have the feeling that this all has to do with a scala version mismatch but I am unable to figure this out unfortunately. Any help is appreciated.

florian.nagel
2019-07-22 13:00
So to clarify the original thread, both, the gradle plugin and the jUnit5 runner time out when using version `4.0.0-beta.4`

igordezky
2019-07-22 17:55
has joined #pact-jvm

uglyog
2019-07-22 22:22
What jvm version are you using?

mui_ume
2019-07-23 04:42
Hi here is my provider pact test code: ```package package xxx.xxx.platform.service.identitymanager.pact; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import javax.ws.rs.ext.Provider; @RunWith(SpringRestPactRunner.class) @Provider("Platform Services") @PactFolder("pacts") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class LoginProviderPactTest { @TestTarget public final Target target = new SpringBootHttpTarget(); } ```

mui_ume
2019-07-23 04:44
I got a compilation error ```[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:testCompile (default-testCompile) on project identity-manager: Compilation failure [ERROR] /Users/core-develop/platform/service/identity-manager/src/test/java/xxx/xxxx/platform/service/identitymanager/pact/LoginProviderPactTest.java:[1,8] <identifier> expected```

mui_ume
2019-07-23 04:44
what did I miss?

mui_ume
2019-07-23 04:46
in my pact json, I have a few request/response endpoints with the same URL, how do I write my provider pact test for one of the request/response endpoint?

mui_ume
2019-07-23 04:46
the github examples are not cleared to me how I should write the provider pact test code.

mui_ume
2019-07-23 04:48
basically, I just want to verify this response at the pact file ``` { "description": "authToken and clientInfo clientId", "request": { "method": "POST", "path": "/api/identity-manager/v2/login", "headers": { "Accept": "*/*", "Content-Type": "application/json" }, "body": { "clientInfo": { "clientId": null }, "pass": "xxxxxx!", "tenantId": "xxx", "userId": "xxx@xxxx" }, "matchingRules": { "$.body": { "match": "type" } } }, "response": { "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "authToken": "eyJraWQiOiJVdEI4c0hhYnk0aXBLNlwvQTZnaHBkRFFqRU9tdlptSnZZQTJpNFwvM2w3UmM9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiIyMTVhMGVhZS00ZjkwLTRlODItOWY4Zi1lNzhlOTdkMzcyODAiLCJldmVudF9pZCI6IjQxMjA3MjQwLWI2NGEtNDYxNi1iOGFiLTJkYzNiZjY4YWEwNCIsInRva2VuX3VzZSI6ImFjY2VzcyIsInNjb3BlIjoiYXdzLmNvZ25pdG8uc2lnbmluLnVzZXIuYWRtaW4iLCJhdXRoX3RpbWUiOjE1NjEwOTUwMDYsImlzcyI6Imh0dHBzOlwvXC9jb2duaXRvLWlkcC51cy1lYXN0LTIuYW1hem9uYXdzLmNvbVwvdXMtZWFzdC0yX2EzbE5SRU5QMSIsImV4cCI6MTU2MTA5ODYwNiwiaWF0IjoxNTYxMDk1MDA2LCJqdGkiOiJlNGFiNTI0Ny1hZjgwLTQ1MmUtOTcwMS01YjQ4OTY1ZTcwZDgiLCJjbGllbnRfaWQiOiI2Z2xwbmRxb2s2YWhua3M2dGFnNXQ5cGMwZyIsInVzZXJuYW1lIjoicWFAdGVsZXBhdGh5LmFpIn0.icFT50MVM-xhAPIu76H9XwIeNHhbe6_d3LcAv1qDQcRp1xabxpgzntgaEvyUnaTwFFJzkU2flfIrT_Y8TCeeFFqMFrMkpS9GadVtraxpOtNhMwxrwUz6bbz8iMHFxSxcIi0Ar3y06RLoRkp3C4gXf7eL8JXsTI9IB56TK7idvUmUcbN_322UPsAU98l3XFjdQEkMo3Fnqyrr41ftWBH876E2KB4g79Q73AL_s0j7mRmXjGswu8-pFiyPcIrDZKz35RSEpdWYLoRyW8rDnYU6YqWM-ncXEczBKlBKk6ggxMOK_qcTc7HYBty9c16zOn-33hxLCxG6pOtg5vLD3L0Tqw", "clientInfo": { "clientId": "0662923d-b187-4879-866a-3f053178426a" } }, "matchingRules": { "$.body": { "match": "type" } } } } ],```

guidopio.mariotti10_d
2019-07-23 07:43
I tried parsing that date with that format using a `FastDateFormat` instance and no exceptions are thrown. Is it the matcher using something else?

uglyog
2019-07-23 08:27
What version of Pact-JVM are you using?


florian.nagel
2019-07-23 10:12
Should be 1.8, not at my work laptop at the moment. So I can't check. Thanks for the quick reply! I'll let you know as soon as I had a chance to check @uglyog

guidopio.mariotti10_d
2019-07-23 12:07
4.0.0-beta.4. I?ll try to debug it and let you know what is the problem

guidopio.mariotti10_d
2019-07-23 14:06
ok, all of a sudden now the timestamp matching works. I found that the only problem was when milliseconds is 0 and jackson serialization removes it

oswald.quek
2019-07-23 15:51
.

oswald.quek
2019-07-23 15:53
is it because you have `package package xxx...`?

uglyog
2019-07-23 23:00
Ah, yeah, the JVM date time formats don?t support any optional fields which can be annoying. Especially the milliseconds field.

mui_ume
2019-07-24 01:42
thanks I fixed that, but my test still fail not due to pact...

mui_ume
2019-07-24 07:16
I have this build error when build pact test java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultReactiveBootstrapConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.vault.config.VaultReactiveBootstrapConfiguration$$EnhancerBySpringCGLIB$$34b3cdf1]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: reactor/ipc/netty/http/client/HttpClientOptions$Builder Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.vault.config.VaultReactiveBootstrapConfiguration$$EnhancerBySpringCGLIB$$34b3cdf1]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: reactor/ipc/netty/http/client/HttpClientOptions$Builder Caused by: java.lang.NoClassDefFoundError: reactor/ipc/netty/http/client/HttpClientOptions$Builder Caused by: java.lang.ClassNotFoundException: reactor.ipc.netty.http.client.HttpClientOptions$Builder

florian.nagel
2019-07-24 07:16
@uglyog It is indeed version 1.8 Just checked

uglyog
2019-07-24 07:17
@mui_ume you must be missing a dependency -> `java.lang.ClassNotFoundException: reactor.ipc.netty.http.client.HttpClientOptions$Builder`

uglyog
2019-07-24 07:18
This is not anything to do with Pact

florian.nagel
2019-07-24 07:24
Yeah. That's what I thought. Would still be nice to have the same ease of access as with the REST protocol. So for example just defining the kafka topic Pact should listen on and then reading that out. Would be awesome, but I totally get your point.

florian.nagel
2019-07-24 07:33
I think I have found the reason for the timeout. I get lots of errors regarding the file system. That I can't open certain files. Apparently Pact is searching each and every file in my gradle user cache. Version 4.0.0-beta.3 and up don't print those errors to the console and, as there are lots of them, the heap space is exceeded. When using version 4.0.0-beta.1 it works because every error is printed to the console. Still annoying as hell, but at least the pact verification works. I still have no idea why I get all the errors. This is the error message I get. Might have nothing to do with Pact, but you never know ```org.reflections.ReflectionsException: could not create class object from file com/ibm/icu/impl/data/icudt61b/zone/en_001.res``` Imagine this message with a whole stacktrace for *a lot* of files. I'm looking into it as we speak, but I thought I'd let you guys know anyway

florian.nagel
2019-07-24 07:42
That's the complete stacktrace, in case someone needs it.

florian.nagel
2019-07-24 07:49
My uninformed guess is that it has to do with the method annotation scanner of pact. Somehow it is looking into *all* files and not just looking for the annotated method in the same class. This is using `jUnit` btw

mui_ume
2019-07-24 09:16
ok got it, fixed by adding the dependencies...

mui_ume
2019-07-24 10:11
my provider pact test is failing, it is not reading from the pact file

mui_ume
2019-07-24 10:12
I put the pact file at ~/src/test/resources/pacts/mypact.json

mui_ume
2019-07-24 10:14
my pact java class file is at ~/src/test/java/xx/xxx/xxx/xxx/xxx/pact/ProviderPactTest.java

mui_ume
2019-07-24 10:14
@PactFolder("pacts")

florian.nagel
2019-07-24 10:33
I had the exact same problem. Which version of pact are you using? For me it worked when I specified it as a PactUrl. ```@PactUrl(urls = {"D:\\src\\test\\resources\\pacts\\pact.json"})``` This is not a good fix of course, but it is a workaround if you want to test your provider tests quick and dirty. Let me know if you've got it to work with the `@PactFolder` annotation. @mui_ume


mui_ume
2019-07-24 12:42
to add to the pom.xml

mui_ume
2019-07-24 12:42
```<plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.0</version> <configuration> <serviceProviders> <!-- You can define as many as you need, but each must have a unique name --> <serviceProvider> <name>Platform Services</name> <!-- All the provider properties are optional, and have sensible defaults (shown below) --> <pactFileDirectory>/Users/tohlaymui/Desktop/ai.telepathy.core-develop/platform/service/identity-manager/src/test/resources/pacts </pactFileDirectory> </serviceProvider> </serviceProviders> </configuration> </plugin>```

mui_ume
2019-07-24 12:43
but I got [ERROR] Errors: [ERROR] ProviderPactTest.initializationError » Exactly one pact source should be set

florian.nagel
2019-07-24 12:43
Ah okay. I thought you were working with the method annotations of jUnit for example

mui_ume
2019-07-24 12:47
my pact broker is setup at https://pact.shared.frigg.li/

mui_ume
2019-07-24 12:47
how can I specify to point to this?

mui_ume
2019-07-24 13:19
question: the endpoint in my json file is "path": "/api/identity-manager/v2/login",

mui_ume
2019-07-24 13:19
so I need to bring up this endpoint for pact test to pass?

sandhyarani.gabbi
2019-07-24 19:28
Hi, I have a scenario where a date field on the provider side is expecting the date to be in future and within 40 days from the current date. If I am setting the value on consumer side as currenttime + 5 mins but the verification is failing(with error "date must be in future") as it is done after 24 hours. How do I deal with this scenario?

uglyog
2019-07-24 23:16
Yes, your service needs to be running

uglyog
2019-07-24 23:17
Back to the path problem, with Gradle it works relative to the resources folder. It must be something Maven is doing different.


uglyog
2019-07-24 23:19
What are you using to set currenttime + 5 mins ? Is that what is going into the pact file?

mui_ume
2019-07-25 05:17
ok, I have added this to my pom.xml ``` <plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.0</version> <configuration> <serviceProviders> <serviceProvider> <name>spring-boot-maven-provider</name> <pactFileDirectory>src/test/resources/pacts</pactFileDirectory> </serviceProvider> </serviceProviders> </configuration> </plugin>```

mui_ume
2019-07-25 05:18
when I run mvn test I got this ```[ERROR] Failures: [ERROR] ProviderPactTest.UI Client - authToken and clientInfo clientId 0 - expected status of 200 but was 404 1 - BodyComparisonResult(mismatches={$=[BodyMismatch(expected={"authToken":"eyJraWQiOiJVdEI4c0hhYnk0aXBLNlwvQTZnaHBkRFFqRU9tdlptSnZZQTJpNFwvM2w3UmM9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiIyMTVhMGVhZ....```

mui_ume
2019-07-25 05:18
does it mean it has read the pact file but it could not pass due to the endpoint services not up and running?

uglyog
2019-07-25 05:20
No, it made the request, but got a 404 response instead of the expected 200

mui_ume
2019-07-25 08:30
my request ``` "request": { "method": "POST", "path": "/api/identity-manager/v2/login", "headers": { "Accept": "*/*", "Content-Type": "application/json"```

mui_ume
2019-07-25 08:30
is it that I got to specify the local host url?

mui_ume
2019-07-25 08:31
I saw this from the log file ```Fetching config from server at : http://localhost:8888```

uglyog
2019-07-25 08:33
You need to tell pact where your server is running. You can do that in the maven config. It will default to 8080 otherwise


sandhyarani.gabbi
2019-07-25 08:39
I am setting it manually and yes it is going into the pact file and verification passes if it is done within 5 mins and fails when verified after 5 mins

mui_ume
2019-07-25 08:40
I add these lines to the nearest pom.xml ``` <plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.0</version> <configuration> <serviceProviders> <serviceProvider> <name>spring-boot-maven-provider</name> <pactFileDirectory>src/test/resources/pacts</pactFileDirectory> </serviceProvider> <serviceProvider> <name>Platform Services</name> <protocol>http</protocol> <host>localhost</host> <port>8888</oport> <path>/</path> </serviceProvider> </serviceProviders> </configuration> </plugin>```

uglyog
2019-07-25 08:42
Add the port to the first serviceProvider

mui_ume
2019-07-25 08:43
is the serviceProvider the name of my Provider "Platform Services"? or "identity-manager"?

mui_ume
2019-07-25 08:44
my pact file : ``` "consumer": { "name": "UI Client" }, "provider": { "name": "Platform Services" }, "interactions": [...```

mui_ume
2019-07-25 08:48
my pom.xml: ``` <plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.0</version> <configuration> <serviceProviders> <serviceProvider> <name>spring-boot-maven-provider</name> <protocol>http</protocol> <host>localhost</host> <port>8888</port> <path>/</path> <pactFileDirectory>src/test/resources/pacts</pactFileDirectory> </serviceProvider> </serviceProviders> </configuration> </plugin>```

mui_ume
2019-07-25 08:48
not sure if this is correct but my test still failed with status 404

uglyog
2019-07-25 08:48
"Platform Services"

mui_ume
2019-07-25 08:49
okay

uglyog
2019-07-25 08:49
Is it running on that port? What do you get if you make that request with curl or postman?

mui_ume
2019-07-25 08:49
I replaced with <name>spring-boot-maven-provider</name> with <name>Platform Services</name>

mui_ume
2019-07-25 08:53
if I used the extra url and endpoint on postman, I got status 200 and the response ```{ "authToken": "eyJraWQiOiJVdEI4c0hhYnk0aXBLNlwvQTZnaHBkRFFqRU9tdlptSnZZQTJpNFwvM2w3UmM9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJhM2FiMzZiYy0wZGM1LTQxNzctOGIwMC02NzQ4ZDFiOWVjN2EiLCJjb2duaXRvOmdyb3VwcyI6WyJyb290Il0sImV2ZW50X2lkIjoiZmY4Y2JkZWQtNjQ3MS00YWMxLWExZWMtZTI3NGQ0NDhhYWFlIiwidG9rZW5fdXNlIjoiYWNjZXNzIiwic2NvcGUiOiJhd3MuY29nbml0by5zaWduaW4udXNlci5hZG1pbiIsImF1dGhfdGltZSI6MTU2NDA0MDU0MSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMi5hbWF6b25hd3MuY29tXC91cy1lYXN0LTJfYTNsTlJFTlAxIiwiZXhwIjoxNTY0MDQ0MTQxLCJpYXQiOjE1NjQwNDA1NDEsImp0aSI6IjI2ZDk1MzYxLTU0OTUtNDA0My05YWZmLTQyYjQ3NjFmNGU1MCIsImNsaWVudF9pZCI6IjZnbHBuZHFvazZhaG5rczZ0YWc1dDlwYzBnIiwidXNlcm5hbWUiOiJsYXltdWkudG9oQHRlbGVwYXRoeS5haSJ9.MINll4bAg5gzQf4Jf4f4p1N6iyLQoiBkJLMYXEaJU4fdjWYEKpZi_45ZHYHp0yr9SiMnWqW97AEJR9orE1190F45STSjy8ApsMjNcH6b7m1UajbE9WWhfXC3kicD2JRvKlptazIpCllH8Jal-XU9XtpZ7fUmkUWFlk9e5FtJ-6yoU639PkeYzjtwPK9jwPPzOr1paxqxwcnJmofUhj1HoELsBjzoXOJANUMq0GYaOCKrd3i-o9gBNBtVY3Wa4b9u-V2HkG9hAh3e-R7Fck78vIJgVg0xsdPmyPR6daCz1Abkcu1VPfpvcpu3Lt92xMB1KdTrUxVQ9rvYBvWHSshgVA", "clientInfo": { "clientId": "dafbbd50-b2d7-442f-941b-40269be61ac9" } }```

mui_ume
2019-07-25 08:54
I will try with that local host and port

mui_ume
2019-07-25 08:57
it didn't work

mui_ume
2019-07-25 09:07
I just realised the identity-manager is not up and running, thus the pact test fail

jgluck
2019-07-25 17:20
has joined #pact-jvm

jgluck
2019-07-25 17:39
Okay, I'm here after a few hours of confusion. Disclaimer: I'm a very experienced developer but I'm rusty with Java and have limited experience with SpringBoot. I have some Spring experience, but again, it's rusty. I have experience implementing pact in Ruby. I (think I am/intend to on) using SpringBoot 1.5 Java 8 Pact 3.6.11 (because we can't use beta versions of software here) JUnit4 Pact Broker Maven I have implemented to consumer side of pact for a POC I am doing. I am now attempting to implement the provider side My provider class looks like this ``` import au.com.dius.pact.provider.junit.Provider; import au.com.dius.pact.provider.junit.State; import au.com.dius.pact.provider.junit.loader.PactBroker; import au.com.dius.pact.provider.junit.target.Target; import au.com.dius.pact.provider.junit.target.TestTarget; import au.com.dius.pact.provider.spring.SpringRestPactRunner; import au.com.dius.pact.provider.spring.target.SpringBootHttpTarget; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; @RunWith(SpringRestPactRunner.class) @PactBroker( host = "localhost", port ="9292") @Provider("legal-agreement-service") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) public class AgreementTypeResourceProviderStatesTest { @TestTarget public final SpringBootHttpTarget target = new SpringBootHttpTarget(); } ``` My pom plugin config looks like this ``` <plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven_2.12</artifactId> <version>3.6.11</version> <configuration> <serviceProviders> <serviceProvider> <pactBrokerUrl>http://localhost:9292</pactBrokerUrl> <name>legal-agreement-service</name> <protocol>http</protocol> <host>localhost</host> </serviceProvider> </serviceProviders> </configuration> </plugin> ```

jgluck
2019-07-25 17:40
When I run `mvn test-compile pact:verify` I Get the following error ``` Verifying a pact between borrower and legal-agreement-service [from Pact Broker http://localhost:9292/pacts/provider/legal-agreement-service/consumer/borrower/version/163.0-SNAPSHOT] Given test GET WARNING: State Change ignored as there is no stateChange URL GET REQUEST Jul 25, 2019 10:33:34 AM org.apache.http.impl.execchain.RetryExec execute INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http://localhost:8080: The target server failed to respond Jul 25, 2019 10:33:34 AM org.apache.http.impl.execchain.RetryExec execute INFO: Retrying request to {}->http://localhost:8080 Jul 25, 2019 10:33:34 AM org.apache.http.impl.execchain.RetryExec execute INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http://localhost:8080: The target server failed to respond Jul 25, 2019 10:33:34 AM org.apache.http.impl.execchain.RetryExec execute INFO: Retrying request to {}->http://localhost:8080 Jul 25, 2019 10:33:34 AM org.apache.http.impl.execchain.RetryExec execute INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http://localhost:8080: The target server failed to respond Jul 25, 2019 10:33:34 AM org.apache.http.impl.execchain.RetryExec execute INFO: Retrying request to {}->http://localhost:8080 Request Failed - localhost:8080 failed to respond [WARNING] Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true') Failures: 0) Verifying a pact between borrower and legal-agreement-service - GET REQUEST Given test GET localhost:8080 failed to respond [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:24 min [INFO] Finished at: 2019-07-25T10:33:34-07:00 [INFO] Final Memory: 78M/244M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal au.com.dius:pact-jvm-provider-maven_2.12:3.6.11:verify (default-cli) on project legal-agreements-server-pact: There were 1 pact failures -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException ``` I've tried numerous things but I'm just stabbing in the dark. I'm unable to find anything documented examples that are specific to my stack. I'm wondering if anyone can either point me to some docs that are known to be good, or help me work out the kinks. I'm trying to figure out if I'm having a port problem or a mock target setup problem. Also note that our implementation is not a strict SpringBoot implementation in that they aren't using @Service or @SpringBootApplication annotations. But I'm not sure that is even what the problem is. At this point, I'd simply like to prove to myself that I can get a minimal setup to work. Any takers?

jgluck
2019-07-25 21:06
Correction. I appear to be using SpringBoot 1.25

jgluck
2019-07-25 22:43
So that means that part of my problem is that I can't use @LocalServerPort. Instead, I'm attempting to use ``` @Value("${local.server.port}") private int port;```

uglyog
2019-07-25 22:51
@jgluck can you check what port your app is running on? Also, it looks like you have both a unit test and are using the maven plugin.

uglyog
2019-07-25 22:51
You normally only need to do one of the other


uglyog
2019-07-25 22:52
I have working example projects, but they will be springboot 2

jgluck
2019-07-25 22:53
I'd like the test to start the app

jgluck
2019-07-25 22:53
If you have a working example, I'd love to see it

jgluck
2019-07-25 22:53
So in other words, I use the plugin if the app is already running?


jgluck
2019-07-25 22:56
Yeah, also kotlin.

jgluck
2019-07-25 22:57
Oh, hmmm, so if I want to use the mojo, I can only use it with already running app?

uglyog
2019-07-25 22:57
Yes, you'll have to use maven plugins to start and stop the app, or some other mechanism

uglyog
2019-07-25 22:58
I think the recommended way would be to bind the Maven Mojo to the integration test phase and then you can use the pre-.post- phases to start and stop the app

uglyog
2019-07-25 22:58
Or you can use a script

jgluck
2019-07-25 23:01
sure that makes sense

jgluck
2019-07-25 23:01
Otherwise I'm just driving it with surefire verify?

jgluck
2019-07-25 23:06
Okay, great. Yes, I was very confused. I get it now, I think

jgluck
2019-07-25 23:08
I think I'm going to skip the mojo and try to use webEnvironment. Wish me luck

uglyog
2019-07-25 23:08
If you're not using the @SpringBootApplication annotation, you'll need to check that the test is bootstrapping the spring context correctly

jgluck
2019-07-25 23:13
Sure, there's some tests in here I can use for reference. Makes it a little more challenging. Of course, some of our project are using CDC so we're going to try to encourage teams to upgrade by letting them know they can use the pact broker on existing contract tests if the upgrade to SpringBoot 2.0, as it is my understanding that the broker is supported in SpringBoot 2.0

jgluck
2019-07-25 23:17
So do I remove the plugin entirely? Or do I use it to set the location of the broker?

uglyog
2019-07-25 23:18
The broker details can be driven with annotations, no need for the plugin

hvgiitr
2019-07-26 04:18
has joined #pact-jvm

au443479
2019-07-26 05:58
has joined #pact-jvm

guidopio.mariotti10_d
2019-07-26 07:55
Hi, I?m having a problem when trying to publish the verification results using the gradle plugin, version `4.0.0-beta.4`. The function `publishingResultsDisabled()` always returns true even if the property is correctly set. The image is me trying to debug this issue. Any guess on what I might be doing wrong?

uglyog
2019-07-26 08:35
How are you running the tests?

guidopio.mariotti10_d
2019-07-26 08:42
I?m running the following task `./gradlew :varkyrie:pactVerify -Dpact.verifier.publishResults=true`. `valkyrie` is a module in my project

uglyog
2019-07-26 08:52
Hmm, that looks all ok

uglyog
2019-07-26 08:53
Are you able to run it with version 3.6.12?

guidopio.mariotti10_d
2019-07-26 08:59

sandhyarani.gabbi
2019-07-26 14:06
@matt.fellows @uglyog Can someone please help me with this

florian.nagel
2019-07-26 14:48
@uglyog If you have any input it'd be very much appreciated

jgluck
2019-07-26 22:24
By any chance, will someone confirm what the lowest version of SpringBoot I need in order to run the spring pact provider without conflicts? My project is currently using 1.2.5 which I understand is very very old. It appears to me that even the oldest versions of pact require a minimum Spring Boot version of 1.5.14 (and yes I realize 1.x will be EOL in two weeks). I'd like confirmation partly as ammunition for convincing my boss that we need to upgrade our base dependency package.

uglyog
2019-07-27 02:38
When using the Gradle plugin, you need to use `-P` instead of `-D`. Must be because the plugin runs as part of the main Gradle process.

uglyog
2019-07-27 02:46
The pact-jvm-provider-spring is currently built against spring-boot-starter-test 1.5.16.RELEASE. But it comes down to the version of spring-test that is transitively used. For older versions of Springboot, if they so not work you could just use the Gradle or Maven plugin to run the verification.

uglyog
2019-07-27 02:51
You could try build that module against Springboot 1.2.5. The main classes used are: - org.springframework.beans.BeanUtils - org.springframework.test.context.TestContextManager - org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks - org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks - org.springframework.test.context.support.DependencyInjectionTestExecutionListener - org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener - org.springframework.test.context.support.DirtiesContextTestExecutionListener - org.springframework.test.context.web.ServletTestExecutionListener - org.springframework.core.env.Environment If those classes haven't changed much, then it may work

uglyog
2019-07-27 03:48
There is a new feature in Pact-JVM you can use. Have a read through https://blog.pactflow.io/dealing-with-relative-dates-in-contract-tests/

florian.nagel
2019-07-29 07:21
I am still having this issue. If anyone has any input I'd be very grateful

guidopio.mariotti10_d
2019-07-29 08:10
the `-P` makes `Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')` disappear, however, in the pact broker, the `Last Verified` field is not updated

uglyog
2019-07-29 08:12
If you enable debug level logging, you should see the log entries with the post of the results

guidopio.mariotti10_d
2019-07-29 09:05
actually, I just discovered that when it runs in our pipeline, the `Last Verified` field is properly updated

guidopio.mariotti10_d
2019-07-29 09:05
not sure, however, what is the different with running it locally

guidopio.mariotti10_d
2019-07-29 09:10
found the problem, locally I receive a 307 as response status code, could it be the reason?

deshdeepdivakar
2019-07-30 07:35
has joined #pact-jvm

deshdeepdivakar
2019-07-30 07:35
hi @here can someone please point me to a good provider (Spring + JUnit 5) example. I am a bit confused as all the current JUnit examples are using Wiremock & I have my service running locally as a gradle task. Do I need to have my consumer mocked when verifying provider :thinking_face: Also,`org.junit.platform.commons.util.PreconditionViolationException: No supporting TestTemplateInvocationContextProvider provided an invocation context` getting this error https://github.com/DiUS/pact-jvm/blob/master/provider/pact-jvm-provider-junit5/src/test/java/au/com/dius/pact/provider/junit5/HttpsContractTest.java



sabil.beladri
2019-07-30 08:07
Hi, a question regarding RestPactRunner usage: I have a service provider receiving 2 pacts, each for a different controller I'm facing the issue that if pact is declared for the same provider name, I can't setup each controller separately where my @RunWith(RestPactRunner.class) is declared. So I had to split each pact with a different provider declaration (myServiceProviderControllerA and myServiceProviderControllerB) so that I can setup each controller as needed in a separate class each. Did I miss something on how to avoid this split? Thanks for keeping me posted if so.

uglyog
2019-07-30 08:15
Unfortunately the consumer annotation is applied to the class level so there would be no way to know which pact applies to which test. Is this for a spring boot app?

sabil.beladri
2019-07-30 08:26
yes, it's for a spring boot microservice I'm fine with doing this split for consumer annotation, too bad for the graphs displayed by the broker, since we'll see 2 different providers in this case It would be great to be able multiple controllers within a same class, each pointing to a distinct state. Or not, it may turn into a mess as well. Anyway, as it is, coupling RestPactRunner along with mockMvc and a controller helps us a lot in running solid provider validations, so I can live with that minor issue. Thanks for clarifying this!

william.robson
2019-07-30 09:50
has joined #pact-jvm

uglyog
2019-07-30 23:31
You can raise an issue at the github project to get the consumer annotation applied at the method level

deshdeepdivakar
2019-07-31 03:34
thanks @uglyog for `default` Provider state I don't really need to inject state right?

deshdeepdivakar
2019-07-31 03:38
I am still getting the error `org.junit.platform.commons.util.PreconditionViolationException: No supporting TestTemplateInvocationContextProvider provided an invocation context`

deshdeepdivakar
2019-07-31 03:39
@PactFolder("src/test/target/pacts")

deshdeepdivakar
2019-07-31 03:39
pacts is all there and Provider state is `default`

uglyog
2019-07-31 03:40
Check the provider name against the @Provider annotation

deshdeepdivakar
2019-07-31 03:44
Awesome, thanks! it wasn't matching now good. :raised_hands:

deshdeepdivakar
2019-07-31 03:45
do you reckon this is also due to some miss configuration?`Request Failed - Connect to localhost:8888 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)`

uglyog
2019-07-31 03:49
Is the springboot app running on port 8888?

deshdeepdivakar
2019-07-31 03:56
No, it isn't on 8888. I just copied over from the example and forgot to change. Appreciate all the help!!

deshdeepdivakar
2019-07-31 04:02
I am loving http://Pact.io it's so good :heart:

gerwin.vaatstra
2019-08-01 11:44
I know there is minArrayLike where you can have multiple arrays matching, but it looks for an array that matches. Is there an equivalent for objects? My issue: I have an array with multiple objects (in my case activities in a ride). Not all activities have the same fields. I'll post an constructed simplified example in the Thread (not to spam the room). What I notice is that the generated pact has matchers like: "$[*].activities[2].fieldname" where I would like it to check that there is at least 1 activity object present with the validation on the fields

gerwin.vaatstra
2019-08-01 11:45
Example response: [ { "idNumber": 123, "activityList": [ { "city": "ABC", "actType": "DEPART", "actId": 1, "actDateTime": "2019-08-01T12:00:00Z", "equipment": [ { "field1": "AA", "field2": 1, } ] }, { "city": "NNN", "actType": "PASS", "actId": 2 }, { "city": "XYZ", "actType": "ARRIVE", "actId": 3, "actDateTime": "2019-08-01T12:00:00Z" } ] } ]

gerwin.vaatstra
2019-08-01 11:45
Expected structure: DslPart ritten = newJsonArrayMinLike(1, lambdaDslJsonArray -> { lambdaDslJsonArray.object(RIDE -> { RIDE.numberType("idNumber", 123); RIDE.array("activityList", ACTIVITIES -> { ACTIVITIES.object(ACTIVITY -> { ACTIVITY.stringType("city", "ABC"); ACTIVITY.stringValue("actType", "DEPART"); ACTIVITY.numberValue("actId", 1); ACTIVITY.timestamp("actDateTime", "yyyy-MM-dd'T'HH:mm:ss'Z'", planDatumTijd); ACTIVITY.minArrayLike("equipment", 1, EQUIP -> { EQUIP.stringType("field1", "AO"); EQUIP.numberType("field2", 5); }); }); ACTIVITIES.object(ACTIVITY -> { ACTIVITY.stringType("city", "NNN"); ACTIVITY.stringValue("actType", "DEPART"); ACTIVITY.numberValue("actId", 2); }); ACTIVITIES.object(ACTIVITY -> { ACTIVITY.stringType("city", "XYZ"); ACTIVITY.stringValue("actType", "ARRIVE"); ACTIVITY.numberValue("actId", 3); ACTIVITY.timestamp("actDateTime", "yyyy-MM-dd'T'HH:mm:ss'Z'", planDatumTijd); }); }); }); }).build();

gerwin.vaatstra
2019-08-01 11:56
So what I'd need is 1 array with activities with a variable amount of objects with variable fields :wink:

uglyog
2019-08-01 22:26
Pact doesn?t support polymorphism. What you?ll need to do is have different tests that have a set example and define your contracts based on that

sundakr1
2019-08-02 00:17
has joined #pact-jvm

kapoorvishal23
2019-08-02 12:14
has joined #pact-jvm

pavani.polakala
2019-08-02 21:47
@uglyog I have a general doubt. I have written consumer test cases on Android and generated a pact file. Is provider responsible to write corresponding test cases to verify consumer tests? Does provider test these APIs against actual server and check if the actual response is same as that of consumer expected response?

johngluckjunk
2019-08-03 00:12
has joined #pact-jvm

uglyog
2019-08-03 02:45
Yes, exactly that

chaoscifer
2019-08-03 21:27
has joined #pact-jvm

sundakr1
2019-08-06 09:04
Folks, I have a unique use case to solve and hope this channel can help. We are transitioning to a Microservices architecture. Some of the newer apps are written in Spring-Jaxrs and teams are planning to use Springboot-Jaxrs. Teams that have adopted old Spring-Jaxrs based frameworks want to have pact tested against their provider APIs. The issue, in this case, is I will have to deploy before executing the pact tests. My question is: Is there an alternative? Or should I ask the teams to migrate to Spring boot?

deshdeepdivakar
2019-08-06 11:48
hi @here do we have some examples for `Json-rpc` ?

pbarrientos
2019-08-06 15:17
has joined #pact-jvm

sabil.beladri
2019-08-06 16:14
I finally managed to find a moment to create this issue: https://github.com/DiUS/pact-jvm/issues/919 please let me know in case this is not clear

pavani.polakala
2019-08-07 04:10
@uglyog I'm using regular expressions to match the header values. Following is my code `builder.uponReceiving(DESCRIPTION)` ` .path(PATH)` ` .method(POST_METHOD)` ` .willRespondWith()` ` .status(STATUS_CODE_CREATED)` ` .matchHeader(HEADER_1, "[0-9A-Za-z]+")` ` .toPact();` Matching rule is generate as below in the pact file: `"matchingRules": {` ` "header": {` ` "HEADER_1": {` ` "matchers": [` ` {` ` "match": "regex",` ` "regex": "[0-9A-Za-z]+"` ` }` ` ],` ` "combine": "AND"` ` }` ` }` However, when the provider runs this test case, it is not checking whether the header value is matching the pattern. It is comparing the header value with randomly generated value. How to solve this issue?

deshdeepdivakar
2019-08-07 07:38
hi @uglyog can you please suggest if this isn't look right for `json-rpc`

gerwin.vaatstra
2019-08-07 08:33
I was curious so did searched an example. I did find this matcher in the repo. You could try if that notation works https://github.com/DiUS/pact-jvm/blob/4106422f4b5ade4a63c5662818defc0a71f99473/pact-specification-test/src/main/resources/v2/response/headers/matches%20with%20regex.json

uglyog
2019-08-07 10:07
There is nothing wrong with the matcher. What version are you using?

pavani.polakala
2019-08-07 14:05
I'm using this version - 3.6.11

pavani.polakala
2019-08-07 14:23
@gerwin.vaatstra This json is generated by pact. I can't modify it. I can only specify the regex in my test case.

pavani.polakala
2019-08-07 16:57
@uglyog I tried setting the response body as given below - body(PactDslJsonRootValue.stringType()) But I'm getting expectation not met error : Expected \"\\\"string\\\"\" but got \"3eeeeed3d9ab0bba888c922ea7a3741964039e50\" at $

pavani.polakala
2019-08-07 17:16
I'm wondering if I should write some code on provider side to validate the regex?

pavani.polakala
2019-08-07 19:04
Looks like the matching rules are dropped by provider. The interaction in pact broker is not showing matching rules.

amber.race
2019-08-07 21:47
has joined #pact-jvm

brent.foley
2019-08-07 22:43
has joined #pact-jvm

brent.foley
2019-08-07 23:09
hello. I have basic setup for pact working in java. I am using annotations very similar to this post: https://github.com/DiUS/pact-jvm/issues/815 I have verification results being posted back to broker, but it only works if *all* the tests pass. If I run the tests and have a failure, the results aren't sent to broker. Any idea why that is?

uglyog
2019-08-07 23:26
How are you running the verification on the provider? Also, enabling debug level logs will help.

chaoscifer
2019-08-08 00:36
Hello! Please, for JUnit5 if a put a relative path it would work if this path is outside my test resources? I'm setting up exactly as the examples from gh (but with Kotlin and Gradle 5.5.1) with no success I'm stuck at "No service providers are configured". I think I'm doing something wrong with my sourceSet. Indeed, I would like to read more documentation about JUnit5 pact-jvm-provider notations. Thanks!

uglyog
2019-08-08 00:53
Junit @Folder annotation loads via the classpath, so the resources directory is the easiest to use. But if you add your directories to the classpath that should work

pavani.polakala
2019-08-08 01:09
I'm not sure how it is being done since it is being handled by some one else in our team. I will get back to you on that. But I wanted to know if provider should handle regex explicitly?

uglyog
2019-08-08 01:13
No, the regex should be evaluated by what ever us running the provider validation

chaoscifer
2019-08-08 01:15
Thanks for your reply. Do you think that something like this would work? (assuming that my pact files within src/contractTest/resources/pacts) sourceSets { contractTest{ compileClasspath += blabla runtimeClasspath += blabla resources { srcDir "src/contractTest/resources" } } }

uglyog
2019-08-08 01:17
If it's in the resources already, you don't need that

pavani.polakala
2019-08-08 02:00
Ok. What could be causing this issue? Provider is not considering the regex. It is matching the randomly generated value with actual value.

pavani.polakala
2019-08-08 02:00
Do you have any working example of matchers in java?

uglyog
2019-08-08 02:04
If you use the Gradle, Maven or JUnit to run the verification, the matchers should work.

antstorm
2019-08-08 08:38
has joined #pact-jvm

oswald.quek
2019-08-08 14:59
.

brent.foley
2019-08-08 16:03
Hello, I am not sure if this is a defect or me... My test setup looks like this. If the tests all pass then everything works as you'd expect. Verification results are sent to my pact broker. However, if a test fails, no results get sent to broker. If I remove @SpringBootTest from the class annotations, the failures DO get sent to broker. But by removing that annotation, the @AutoWiring no longer works. So I appear to be stuck

brent.foley
2019-08-08 16:07
I followed the pact-workshop-jvm to get to where I'm at

brent.foley
2019-08-08 16:08
I think my case is just slightly more complex since I'm Autowiring components in my test class and the workshop did not do that

anupamknw
2019-08-08 18:46
has joined #pact-jvm

jgluck
2019-08-08 19:51
Before I tell the developer they have made a mistake, I want to confirm something. I am using SpringBoot 1.5 Java 8 Pact 3.6.11 (because we can't use beta versions of software here) JUnit4 Pact Broker I am able to get a 200 from my provider, but I am having trouble with the Content-Type My provider class looks like so ```@RunWith(SpringRestPactRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @PactBroker( host = "localhost", port = "9292") @Provider("decision-input-repository") public class SomeTest { @LocalServerPort private int port; @TestTarget public final Target target = new SpringBootHttpTarget(); @Autowired private DirController dirController; @MockBean private DirServiceImpl dirServiceImpl; @State("profile upsert") public void decisionInputProfilePost() { } }``` My contract is ``` { "status": 200, "headers": { "Content-Type": "application/json;charset=UTF-8" }, "body": { <bunch of stuff here> } ``` 1. I am seeing this in the logs ``` 12:30:41.421 [main] DEBUG a.c.d.pact.provider.ProviderClient - Response: {statusCode=200, headers={X-Content-Type-Options=[nosniff], X-XSS-Protection=[1; mode=block], Cache-Control=[no-cache, no-store, max-age=0, must-revalidate], Pragma=[no-cache], Expires=[0], X-Frame-Options=[DENY], Content-Length=[0], Date=[Thu, 08 Aug 2019 19:30:41 GMT]}, contentType=application/json; charset=UTF-8, data=} ``` I saw a response to some saying they had misspelled the header but it's not clear to me that it's possible to do that in Spring Boot assuming someone is using the standard annotations and it appears the developer is doing things corrects. 2. Also, I don't know if I'm doing something wrong but I haven't been able to remove the JSON Content-Type. If I don't include it in my `.willRespondWith().headers()`, the expectation still appears when I generate the pact, so it appears Pact always includes this. Is that correct?

jgluck
2019-08-08 22:12
I have just been able to confirm that the service in standalone returns the headers ```curl -i -X POST http://localhost:8080/api/decision-input-repository/v1/profile -H "Content-Type: application/json" -d '{<bunch of stuff here>}' HTTP/1.1 200 X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache Expires: 0 X-Frame-Options: DENY Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked Date: Thu, 08 Aug 2019 22:09:49 GMT```

jgluck
2019-08-08 22:23
Is this a defect?

borsuk.artem034
2019-08-09 08:00
Hello, does pact-jvm-consumer-java8(lambdaDSL) support messaging(MessagePactBuilder)?

pavani.polakala
2019-08-09 13:42
@uglyog I found out that provider is ignoring the matching rules. This is what I found in logs - `Ignoring unsupported matching rules {"Th_jwt"=>{"matchers"=>[{"match"=>"regex", "regex"=>".*"}], "combine"=>"AND"}} for path ['header']` What could be causing this issue?

pavani.polakala
2019-08-09 15:31
It's working after I changed consumer version to V2. Looks like Ruby implementation on provider supports only v2.

jgluck
2019-08-09 22:40
FYI, I have half figured this out. As it turns out, my body has field which takes a value that is JSON, only not exactly. I need to work on formatting this so that it will go into and come out of the database. I'll let you know if I discover any problems

uglyog
2019-08-10 01:57
Does seem like a defect. Please raise an issue for this.

uglyog
2019-08-10 02:04
`contentType` is incorrect, it has to have a hyphen like `content-type`. Case doesn't matter. So you're saying is that the content type header is correct in the Pact file, but it is getting translated during the verification? But the actual service is returning the correct header?

uglyog
2019-08-10 02:06
I'll be surprised if this is an issue with Pact-JVM, because everyone would be having this issue. Can you try version 3.5.25 and see if you have the same issue?

uglyog
2019-08-10 02:08
You should be able to use it in the same way

borsuk.artem034
2019-08-11 11:02
```@Pact(provider = "pro", consumer = "con") public MessagePact createPact(MessagePactBuilder builder) { return builder .expectsToReceive("state") .withMetadata(metadata) .withContent(newJsonBody((s) -> { s.stringValue("foo", "Foo"); s.stringValue("bar", "Bar"); })) .toPact(); }``` Method .withContent expect au.com.dius.pact.consumer.dsl.DslPart not the lambda DSL

uglyog
2019-08-11 23:00
Call `.build()` to return the correct class

borsuk.artem034
2019-08-12 07:04
Thanks you for help, it's works,

jgluck
2019-08-12 15:54
I think this has to do with the embedded JSON. I think this is my problem

neelofer.tamboli
2019-08-13 09:21
has joined #pact-jvm

neelofer.tamboli
2019-08-13 09:24
Hi. We have a provider with 2 consumers. Both consumers use different APIs of the provider. We would like to keep the provider side tests written in separate classes for modularity purposes. Contract test class: ```@RunWith(SpringRestPactRunner.class) @ContextConfiguration(classes = { ProviderApplication.class }) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @PactBroker(failIfNoPactsFound = false) public abstract class ContractTest { }``` Provider side, Consumer 1: ```@Provider("provider-one") @Category({ ContractTest.class }) @IgnoreNoPactsToVerify public class ProviderConsumer1Test extends ContractTest { @LocalServerPort public int port; @TestTarget public final Target target = new SpringBootHttpTarget(); @Before public void setup() { when(...).thenReturn(Boolean.TRUE); } @TargetRequestFilter public void requestFilter(HttpUriRequest request) { ..... } } ``` And similarly a provider side test for Consumer 2. We are not providing any `state` on the Provider test class because we don't have particular mocking for the states which we have not already covered in the setup. My questions: 1. Would this be a correct approach? 2. When we run provider side test, same state from each consumer is verified against both provider test classes. How can we change that? We want each provider class to verify pacts of only one specific consumer each. Thank you.

borsuk.artem034
2019-08-13 10:08
Hello, can I somehow specify the list of objects through the "eachLike" or someting else? I have many similar objects like: ``` "Attributes":[ { "Type":"type_value", "name":"name_value", "originalName":"name_value" }, { "Type":"type_value", "name":"name_value", "originalName":"name_value" }, .....many same objects ] ``` Trying to use: ``` ...array("Attributes", Attributes -> { Attributes.eachLike(Attributes.object((attribute) -> { attribute.stringMatcher("Type", "type_value"); } )); }); ```

guidopio.mariotti10_d
2019-08-13 13:21
Hi everyone, I?m currently working in integrating pact into a couple of our kotlin microservices and I created a couple of methods to have a more kotlin friendly dsl. I?d like to contribute it back to pact-jvm, is this something that the pact team can be interested in?

uglyog
2019-08-13 23:27
To be honest, the correct approach is what works for you. You can filter the pacts that are verified by the consumer. See https://github.com/DiUS/pact-jvm/blob/master/provider/pact-jvm-provider-junit/README.md#filtering-by-consumer

uglyog
2019-08-13 23:29
`eachLike` works on an array (or list) by specifying that each object in the array must match the provided template.

uglyog
2019-08-13 23:29
Instead of `...array("Attributes", ` you must use the `eashLike` here

uglyog
2019-08-13 23:30
:100:! There are lots of people who have been waiting for a nice Kotlin DSL

guidopio.mariotti10_d
2019-08-14 06:14
cool, I?ll try to open a PR in the next couple of weeks so that we can collect some feedback on it

neelofer.tamboli
2019-08-14 10:08
Thank you

jgluck
2019-08-14 20:12
Is there a sample pom.xml for publishing results to the broker somewhere? In particular, I'm using version 3.6.11 so I'm not sure what syntax is supported in that version. I haven't been able to find a clear single file example and I am confused. They way my implementation works now, I am always asked for a stateChangeURL, but I'm not using a stateChangeURL, so I'm not sure what to provide there.

antonello
2019-08-14 20:20
What are you trying to publish? Pacts or verification results?

antonello
2019-08-14 20:22
Sorry, I should?ve read your message more carefully :slightly_smiling_face:

antonello
2019-08-14 20:27
``` <profile> <id>pact-provider-tests</id> <activation> <activeByDefault>false</activeByDefault> </activation> <properties> <pact.include.categories>PactProviderTests</pact.include.categories> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>${companyName.surefireArgLine} ${jacoco.surefireArgLine}</argLine> <redirectTestOutputToFile>true</redirectTestOutputToFile> <testSourceDirectory>src/test/java</testSourceDirectory> <groups>${pact.include.categories}</groups> <systemPropertyVariables> <pact.provider.version>${pact.pacticipantVersion}</pact.provider.version> <pact.verifier.publishResults>false</pact.verifier.publishResults> <pact.provider.version.trimSnapshot>true</pact.provider.version.trimSnapshot> </systemPropertyVariables> </configuration> </plugin> </plugins> </build> </profile> ```

antonello
2019-08-14 20:28
In this case we have a profile and some filtering done based on junit `@Category`.

antonello
2019-08-14 20:28
you may not want to do that

antonello
2019-08-14 20:34
In short: >For pacts that are loaded from a Pact Broker, the results of running the verification can be published back to the broker against the URL for the pact. You will be able to then see the result on the Pact Broker home screen. > >To turn on the verification publishing, set the system property pact.verifier.publishResults to true in the pact maven plugin, not surefire, configuration. https://github.com/DiUS/pact-jvm/tree/v3.6.x/pact-jvm-provider-maven#publishing-verification-results-to-a-pact-broker-version-354

johngluckjunk
2019-08-15 01:07
Thanks @antonello I'll give that a go when I get some time in a few days

chaoscifer
2019-08-19 14:13
Hello all! Please, I'm trying to run a gradle task with my provider tests (using JUnit). The task runs successfully, but without invoke the tests from my class. I'm using as reference documentation in here: https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-junit And here: https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-junit/src/test Please, am I missing some config or annotation?

uglyog
2019-08-19 20:36
Are you able to post your test?

chaoscifer
2019-08-19 23:27
@uglyog, I just figured out a few minutes ago. The issue was on the following lines on my build.gradle: useJUnitPlatform{ includeEngines 'spek2', 'junit-jupiter' } Thanks!

fil.tmb
2019-08-20 11:02
has joined #pact-jvm

jgluck
2019-08-20 15:32
This worked @antonello. Thanks for the advice

antonello
2019-08-20 15:33
My pleasure!

getsreerag22
2019-08-21 04:25
has joined #pact-jvm

matchehot
2019-08-21 18:29
has joined #pact-jvm

matchehot
2019-08-21 18:29
Hi, has anyone used jvm XmlBodyMatcher to match response body? Looking for example

dglaubman600
2019-08-22 02:27
has joined #pact-jvm

james.hattersley-dyke
2019-08-22 08:13
Morning all, I discovered yesterday the pact-jvm-provider-junit way of doing things... previously I'd just been using pact-jvm-provider-gradle and just calling `pactVerify` what's the advantage / disadvantage of doing it as a junit test? On first glance, it seems like I'm going to have to fully run my CI pipeline to get the verifications to happen whereas I can set up a single CI build job to just call `pactVerify ` using the gradle provider? Is there a recommended approach or are both valid?

abubics
2019-08-22 08:16
@james.hattersley-dyke

james.hattersley-dyke
2019-08-22 08:20
cheers, I've never really needed to do any mocking in the versifications I've done to date so not needed junit etc. This week was the first time we encountered an issue where we needed to start WireMock and then start the Spring app before running `pactVerify`. We tried using the `startAppTask` in the gradle provider but the devs went with the junit provider instead... no issue with that, just wondered if there was a recommended approach? Seems like picking the right tool for the job really?

abubics
2019-08-22 08:26
not really . . . just depends which idiom you prefer to use :slightly_smiling_face:

abubics
2019-08-22 08:26
I like the gradle version, and @uglyog now prefers the junit style

abubics
2019-08-22 08:26
the gradle way, you have to do a bit more setup (with launching the app, and the state change endpoint)

abubics
2019-08-22 08:27
the junit way, more of it is done for you, but you have to use junit :stuck_out_tongue:

james.hattersley-dyke
2019-08-22 08:36
I've been doing a lot with messaging (sqs) systems recently so I've not really needed the JUnit stuff... Might give it a whirl next time...

borsuk.artem034
2019-08-22 09:36
@uglyog sorry for the late answer, had a vacation. But your advice acceptable for json like ``` "Attributes":[ [ "Type":"type_value", "name":"name_value", "originalName":"name_value" ], .....many same objects ] ```

borsuk.artem034
2019-08-22 09:38
but I have one array with many similar objects like: ```"Attributes":[ { "Type":"type_value", "name":"name_value", "originalName":"name_value" }, .....many same objects ] ``` maybe you know how i can describe that using "Like" statement?

uglyog
2019-08-22 22:51
Not many people use XML, so I doubt there would be any examples. Maybe you can be the one to contribute the first one :smile:

sundakr1
2019-08-27 03:49
Tried with Jax-rs endpoint server and jaxrsserverfactorybean. I do not require a springboot app after all. Here is sample code built on top of pact-jvm-workshop.

guidopio.mariotti10_d
2019-08-27 09:22
Hi, is there anyone that was able to run a Provider test with Junit 5 and Spring Webflux? I?m trying using `@WebFluxTest` together with `@LocalServerPort` but I?m not sure it is working properly

guidopio.mariotti10_d
2019-08-27 17:50
or, alternatively, can I avoid the pact provider to execute the http request and just execute the request specification myself?

uglyog
2019-08-27 23:23
You can use the Gradle plugin to run the verification of the provider

kashikar.harsh
2019-08-28 05:19
has joined #pact-jvm

kashikar.harsh
2019-08-28 05:19
Hey All

kashikar.harsh
2019-08-28 05:20
I am looking for some help on provider verification that involves mocking a function call that provider is calling

kashikar.harsh
2019-08-28 05:20
the use case is, my provider gets input, does a little bit transformation and writes the data to service bus

kashikar.harsh
2019-08-28 05:21
obviously I do not want the data to be written to service bus every time I run provider verification and looking for a way to mock this scenario

kashikar.harsh
2019-08-28 05:21
any inputs/help is much appreciated

uglyog
2019-08-28 05:35
User a provider test written with JUnit and mock out the collaborator that writes to the message queue

kashikar.harsh
2019-08-28 05:42
not sure if I could quite understood this, mostly I have written pact in node and there the provider verification is just to call a verify method

kashikar.harsh
2019-08-28 05:43
so assuming we do have more control in provider verification with jvm

kashikar.harsh
2019-08-28 05:43
or perhaps it is there is node as well and I may not have explored it

uglyog
2019-08-28 05:44
Should be able to do that pretty easy in node. Maybe ask in the #pact-js channel

kashikar.harsh
2019-08-28 05:50
Sorry for not being clear, I nee to write this time in java only with junit test framework

kashikar.harsh
2019-08-28 05:50
are there any examples of using mock that I can refer to?

uglyog
2019-08-28 05:52
Are you using springboot?

kashikar.harsh
2019-08-28 05:53
yes

uglyog
2019-08-28 05:57
You can use springboot test annotations and @MockObject to mock out the collaborator. See this for a basic springboot provider test: https://github.com/DiUS/pact-jvm/blob/master/provider/pact-jvm-provider-spring/src/test/groovy/au/com/dius/pact/provider/spring/SpringRunnerWithBeanThatMustBeClosedProperlyTest.groovy

uglyog
2019-08-28 05:58
Sorry, I think the annotation is @MockBean

kashikar.harsh
2019-08-28 06:03
Thanks @uglyog will check this out

guidopio.mariotti10_d
2019-08-28 07:54
I?m actually using the gradle plugin. What I meant was, can I get the request specification so that I can use the `TestWebClient` configured by the `@WebFluxTest` and avoid having to start the entire application? Or do you have any other suggestion on how to run those tests against a webflux application?

guidopio.mariotti10_d
2019-08-28 07:54
To me, this is more a spring boot problem than a pact one, but I haven?t found anything for spring so I?m hoping I can work around this with pact

uglyog
2019-08-28 09:39
I have no idea about webflux, but if @WebFluxTest works similar to the springboot test one, you should be able to use it

guidopio.mariotti10_d
2019-08-28 09:45
unfortunately not, `@WebFluxTest` doesn?t start a server. However, I think I figured out a solution using `@SpringBootTest`. If I find some time, I?ll try to contribute something that works with `@WebFluxTest`

kashikar.harsh
2019-08-28 12:56
another dump question, how do I build the PactDslJsonBody if the method is expecting 3 params , param 1 - byte array, param 2 - This is set to null and param 3 - a custom class object

kashikar.harsh
2019-08-28 13:05
asking because I didn't find a specific byte data type for array

guidopio.mariotti10_d
2019-08-28 13:11
however, using the gradle `pactVerify`, it doesn?t run the `@SpringBootTest` like when you test the messaging part with `verificationType=ANNOTATED_METHOD`. Any workaround this?

uglyog
2019-08-28 22:50
Which method are you referring to?

uglyog
2019-08-28 22:52
`pactVerify` runs the verifications itself, using a running application

kashikar.harsh
2019-08-29 05:28
my provider method that I want to register my pact against

uglyog
2019-08-29 05:32
ok, and what does the request look like that is sent to your app?

kashikar.harsh
2019-08-29 05:33
it calls readbytes on a json string and send it

kashikar.harsh
2019-08-29 05:33
this is about message queue based contract

kashikar.harsh
2019-08-29 05:34
so the provider receives this data, massages it and puts it into another service bus

kashikar.harsh
2019-08-29 05:34
need to validate this provider

uglyog
2019-08-29 05:40
ah, and param1 is the byte array of the JSON

uglyog
2019-08-29 05:43
If you can mock out the call to the other service bus, you can assert that the correct JSON was sent. In your test method call your provider method with the 3 parameters and then check that the downstream got the correct message

kashikar.harsh
2019-08-29 05:44
yes

kashikar.harsh
2019-08-29 05:44
I am trying to call the provider method but stuck while sending the params

kashikar.harsh
2019-08-29 05:45
body .object() .nullValue("paramName") .closeObject(); body .object("paramName") .booleanValue("manual", true) .stringValue("actionType","SomeAction") .closeObject();

kashikar.harsh
2019-08-29 05:45
this is how I constructed for the other 2 params one of which accepts null for this specific case and other accepts an object

kashikar.harsh
2019-08-29 05:46
but couldn't find similar method for constructing a byte [] to pass on to the 1st param

uglyog
2019-08-29 05:47
JSON doesn't have a byte array type. Is the parameter data from a string?

uglyog
2019-08-29 05:47
Or is it an array of numbers?

kashikar.harsh
2019-08-29 05:49
my bad it is json bundled as string and we are using getBytes method on string

kashikar.harsh
2019-08-29 05:52
String alert = StreamUtils.copyToString(is, Charset.forName("UTF-8")) - this is snippet from unit test

kashikar.harsh
2019-08-29 05:52
is - this is pointer to a json file

kashikar.harsh
2019-08-29 05:52
alert will load json from file and finally will be passed on to provider method as alert.getBytes()

uglyog
2019-08-29 05:58
The verification tests work by calling a method and checking the returned value matches the pact. So you need to write your test in a way that you pass the data as required to your method, then get what was passed to the service bus and return that.


uglyog
2019-08-29 05:59
PactDslJsonBody will be used by the consumer test of whatever is processing the message off the service bus

kashikar.harsh
2019-08-29 06:07
provider method is not returning anything here, it is just dumping that into another service bus

kashikar.harsh
2019-08-29 06:07
so for consumer tests, I need not to build PactDslJsonBody is what you are saying?

kashikar.harsh
2019-08-29 06:11
also at this point of time I am trying to write consumer tests,, but the examples are all using PactDslJsonBody

uglyog
2019-08-29 06:11
The consumer test (whatever reads the message from the service bus) will setup the pact via a test, and need to define what the format of the message is.

uglyog
2019-08-29 06:12
Your provider (the what writes to the service bus) needs to use a test like the example above. The test method will have to return the contents of the message.

kashikar.harsh
2019-08-29 06:13
understood, or in case if it is not returning anything, I can atleast ensure it doesn't throw any exception and mock the writing to service bus part

kashikar.harsh
2019-08-29 06:14
Developer may not welcome any changes about returning the value now :disappointed:

kashikar.harsh
2019-08-29 06:14
is there a sample consumer test that doesn't use PactDslJsonBody

uglyog
2019-08-29 06:15
There are a few that use JSON as a string value

uglyog
2019-08-29 06:15
Nothing special, they just provide the string contents

kashikar.harsh
2019-08-29 06:15
ok, let me try

kashikar.harsh
2019-08-29 06:16
thanks a lot @uglyog, will keep you posted on how this goes

guidopio.mariotti10_d
2019-08-29 07:48
yeah, I thought it was making easier to run the tests using junit. At the end, I decided to go with the junit5 tags and the `@PactBroker` annotation

joao
2019-08-29 13:35
has joined #pact-jvm

priyank.shah217
2019-08-30 05:49
has joined #pact-jvm

mui_ume
2019-08-30 08:11
my pom.xml has this ```<plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.0</version> <configuration> <serviceProviders> <serviceProvider> <name>Platform Services</name> <protocol>http</protocol> <host>localhost</host> <port>9319</port> <path>/</path> <pactFileDirectory>src/test/resources/pacts</pactFileDirectory> </serviceProvider> </serviceProviders>```

mui_ume
2019-08-30 08:12
is this the mock pact broker?

kian.leong
2019-08-30 08:16
has joined #pact-jvm

ruben.perezg
2019-08-30 09:07
Hi! :slightly_smiling_face: I have been trying to take a look at the code of `pact-jvm`, to see if I was able to create a PR that would solve this issue: https://github.com/DiUS/pact-jvm/issues/823 I have not found where is the code that handles that from the `pact-jvm`, I would like to see if I could try to implement that somehow (if I can figure out how xD), rather than having to use the workaround proposed in the issue while it's not implemented. Could anyone point me in the right direction, so I can see if I can do something to implement this, or to finally go for trying the workarounds proposed? As far as I see it, it looks like I need to apply those tags to be able to use the `can-i-deploy` tool properly.

brent.foley
2019-08-30 18:41
Hello. Are there examples of pact being used with TestNG framework or is it only supported in junit for java?

nyarasha
2019-08-30 18:54
has joined #pact-jvm

uglyog
2019-08-30 23:29
I haven't seen any example with TestNG.

priyank.shah217
2019-08-31 11:56
I am new to PACT, Have a question: In my consumer side, i am able to generate pact file with json array (2 entries) with some fields. The json contract uploaded to pact-broker successfully. But while running this file against producer, which basically ingest some random data on those json fields (entries may vary, and data could be any random). due to this eventually my contract test failed. returns a response which has status code 200 (OK) has a matching body (FAILED) So now question is i am more interested into json schema, not in content matching. Is there any way to just focus on those part using pact.

priyank.shah217
2019-08-31 12:02
Do i need to set state from provider side in order to get matched response ? (using directly ingesting data into repository)?

priyank.shah217
2019-09-01 04:54
I really done my weekend exercise successfully by implementing pact for one of pet project. https://github.com/priyankshah217/ContractTestingExample.git Nice documentation @bethskurrie @uglyog and whole pact team...

kashikar.harsh
2019-09-01 11:14
Hey all

kashikar.harsh
2019-09-01 11:14
Is there an example of publishing pacts to pact broker using java clients?


kashikar.harsh
2019-09-01 13:52
Thanks @priyank.shah217, couldn't quite locate where you are publishing contracts to broker

kashikar.harsh
2019-09-01 13:52
can you please help me which file I should be referring to

priyank.shah217
2019-09-01 14:28
Refer pom.xml of consumer

kashikar.harsh
2019-09-01 14:42
Thanks, got it

kashikar.harsh
2019-09-01 14:43
Got confused as this is done via mvn plugin, was searching for java code to publish :disappointed:

priyank.shah217
2019-09-03 09:47
i have a question, I am using pact-broker to share contracts.. just wanted to know https://github.com/DiUS/pact-jvm/blob/master/provider/pact-jvm-provider-maven/README.md#2-define-the-pacts-between-your-consumers-and-providers What should be given ?PactUrl? in consumer section?

priyank.shah217
2019-09-03 09:48
here example given for <pactFile>.. what to give if i m sharing contracts over broker?


emils.solmanis
2019-09-03 13:07
has joined #pact-jvm

emils.solmanis
2019-09-03 13:10
hi all, I'm trying to run the provider verifier via Lein and it segfaults, are there particular supported versions of JRE I need, or..? I've tried 8, 11, and 12 to no avail so far

emils.solmanis
2019-09-03 13:13
sorry, it's OpenJDK specifically, and lein 2.9.1

emils.solmanis
2019-09-03 13:29
seems to be Jansi related somehow, can't find anything in open issues ``` Stack: [0x00007f3838765000,0x00007f3838866000], sp=0x00007f3838856bb0, free space=966k Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.so+0x8dab2c] C [libjansi-64-5995465925194073194.so+0x1c2a] Java_org_fusesource_jansi_internal_CLibrary_init+0x10a Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j org.fusesource.jansi.internal.CLibrary.init()V+0 j org.fusesource.jansi.internal.CLibrary.<clinit>()V+21 v ~StubRoutines::call_stub j org.fusesource.jansi.AnsiConsole.wrapOutputStream(Ljava/io/OutputStream;)Ljava/io/OutputStream;+61 j org.fusesource.jansi.AnsiConsole.<clinit>()V+13 v ~StubRoutines::call_stub j au.com.dius.pact.provider.reporters.AnsiConsoleReporter.verifyConsumerFromUrl(Lau/com/dius/pact/core/model/UrlPactSource;Lau/com/dius/pact/provider/IConsumerInfo;)V+12 ```

oswald.quek
2019-09-03 16:05
hello. i'm running a provider test, https://github.com/alphagov/pay-ledger/blob/master/src/test/java/uk/gov/pay/ledger/pact/TransactionsApiContractTest.java. i've set the relevant environment variables:

oswald.quek
2019-09-03 16:05
but when running the test (from intellij), no results are published...

oswald.quek
2019-09-03 16:07
i've put breakpoints at places in the pact classes where the PACT_VERIFIER_PUBLISH_RESULTS env var is being read (e.g. VerificationReporter.kt, ProviderVerifier.kt, TestResultAccumulator.kt) but those breakpoints aren't being hit and results aren't being published

oswald.quek
2019-09-03 16:07
my test passes but there's absolutely no logging about why something isn't being published.

oswald.quek
2019-09-03 16:08
any brainwaves appreciated!

oswald.quek
2019-09-03 16:08
i'm pretty sure i've seen this working locally before

uglyog
2019-09-03 22:54
If publishing the verification was being skipped, there would be an explicit log output stating that

uglyog
2019-09-03 22:54
Can you set the log level to debug?

oswald.quek
2019-09-04 10:09
@uglyog it might be a pact bug. if I remove the `au.com.dius.pact.provider.junit.loader.PactFilter` annotation from my test I see ```{"level":"WARN","logger":"au.com.dius.pact.provider.DefaultTestResultAccumulator","thread":"main","message":"Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')","service-name":"ledger-service","@timestamp":"2019-09-04T10:08:02.709+0000"} ``` otherwise I don't see it

uglyog
2019-09-04 10:23
Ok, raise a defect for that, please.

borsuk.artem034
2019-09-04 14:26
Hello, I have different with order of Json attributes in consmer and provider, and don't understand why verification (matching body) on provider side is failed? For examlpe: Consumer LambdaDsl create json like: ``` { "foo" : "fooValue", "bar": "barValue" } ``` On Provider side when "Pact verify" a matching body is failed and require ``` { "bar": "barValue", "foo" : "fooValue" } ```

borsuk.artem034
2019-09-04 14:36
info from debug: all fields are validated and math the values: ``` 17:28:25.498 [main] DEBUG au.com.dius.pact.core.matchers.JsonBodyMatcher - compareValues: Matcher defined for path [$, 0, foo] 17:28:25.499 [main] DEBUG au.com.dius.pact.core.matchers.MatcherExecutor - comparing "fooValue" with regexp fooValue at [$, 0, id] -> true 17:28:25.499 [main] DEBUG au.com.dius.pact.core.matchers.JsonBodyMatcher - compareValues: Matcher defined for path [$, 0, bar] 17:28:25.499 [main] DEBUG au.com.dius.pact.core.matchers.MatcherExecutor - comparing "barValue" with regexp barValue at [$, 0, bar] -> true has a matching body (FAILED) has matching metadata (OK) ```

borsuk.artem034
2019-09-04 14:59
never mind, I miss one of objects and diff show all different between all of objects in json, not only missed object

oswald.quek
2019-09-04 15:55
before I do, I was wondering whether this is expected behaviour. if we're filtering pacts by provider state we can't be confident all the interactions were successful as not all of them were run so how can a verification result be published?

oswald.quek
2019-09-04 15:58
also i noticed that on one repository in my organisation, the interaction between a consumer and provider was spread out over different test classes (that's why they used the `@PactFilter` over different classes). i think this is probably bad practice as there's no way for the pact runner to know if all the interactions were successful or not

oswald.quek
2019-09-04 17:30
oh, i see others have encountered this problem too https://github.com/DiUS/pact-jvm/issues/522

guillermo.castro
2019-09-05 13:42
has joined #pact-jvm

andreas
2019-09-09 07:14
has joined #pact-jvm

sarajcarbajal
2019-09-13 09:40
has joined #pact-jvm

hstene
2019-09-16 13:25
Good afternoon, I have a problem using provider states. So I am trying to create a Person with an ID that I get from the provider DB. The ID is an Integer on the Person class. *Pact-creation* ``` @Test public void getPersonById() { Integer id = 100; RequestResponsePact pact = ConsumerPactBuilder .consumer("consumer").hasPactWith("national-registry") .given("A person exist") .uponReceiving("Get person by id") .path("/v1/person") .method("GET") .queryParameterFromProviderState("id", "${id}", id.toString()) .willRespondWith() .status(HttpStatus.OK.value()) .body(new PactDslJsonBody() .stringType("ssn") .valueFromProviderState("id", "${id}", id) ) .toPact(); MockProviderConfig config = MockProviderConfig.createDefault(); PactVerificationResult result = runConsumerTest(pact, config, (mockServer, context) -> { NationalRegistryClient nationalRegistryClient = new NationalRegistryClient(new NationalRegistryConfig(mockServer.getUrl())); nationalRegistryClient.getPersonById(id.toString()); }); assertEquals(PactVerificationResult.Ok.INSTANCE, result); } ``` *Pact-verification* ``` @State("A person exist") public Map<String, Object> getPersonByIdPact(Map<String, String> params) { Person person = personRepository.add(new Person(null, "12345611111", "", null)); Map<String, Object> map = new HashMap<>(); map.put("id", person.getId()); return map; } ``` *Error message* ``` java.lang.AssertionError: 0 - $.id -> [{mismatch=Expected '1' but received 1, diff=}] ``` *I dont understand why it says ?Expected ?1?? in quoutes? The id field on the Person class is an Integer. I am forced to pass the `id` as a String in `queryParameterFromProviderState` example. I send the id as an int in `valueFromProviderState` example.* What am I doing wrong here?


lauri.vaeaenaenen
2019-09-16 16:08
has joined #pact-jvm

kiranpatel11
2019-09-16 21:10
has joined #pact-jvm

uglyog
2019-09-16 22:20
Let me have a look for you to find out what is converting it to a string

uglyog
2019-09-17 00:11
Ah, the expression `"${id}"` is a string. Can you raise an issue for that?

uglyog
2019-09-17 00:13
I think we would be able to convert the result of the expression based on the type of the example value

uglyog
2019-09-17 00:13
The other option would be to make it explicit in the expression (`"${id}:integer"`)

bart.schotten
2019-09-17 09:17
has joined #pact-jvm

bart.schotten
2019-09-17 09:20
Hi, I've noticed that Pact-JVM generates a matching rule with the type "number". As far as I can see this is not part of the Pact Specification (only "decimal" and "integer"). Is the spec not up-to-date or is this a problem with Pact-JVM? This currently makes it impossible for other Pact implementations to verify some of the pacts that are generated by Pact-JVM.

uglyog
2019-09-17 09:25
Good pickup. That isn't really needed because it would be the same as just using a type matcher.

bart.schotten
2019-09-17 09:25
Yeah, that was my thinking as well

james.hattersley-dyke
2019-09-17 14:54
Hi, does any one have any examples of using the `startProvider` and `stopProvider` hooks in the pact-jvm-provider-gradle? We've got to the point where out task starts the app, but then `pactVerify` doesn't run, because the `bootRun` command of SpringBoot is hogging the process. Has anyone used the methods documented here: https://github.com/DiUS/pact-jvm/tree/v3.6.x/pact-jvm-provider-gradle#starting-and-shutting-down-your-provider

abubics
2019-09-17 22:30
Yes, I usually use that... When I get in to work, I can debug with you maybe :)

abubics
2019-09-17 22:31
The only time I've had issues with it was when I got the trigger text wrong :P

uglyog
2019-09-17 23:03
I've used the Gradle Spawn plugin to do that. The only problem with it is it will not work on Windows

abubics
2019-09-18 00:21
I probably stole this from you, @uglyog :joy: ``` import com.wiredforcode.gradle.spawn.* task startProvider(type: SpawnProcessTask, dependsOn: 'assemble') { def path = "$buildDir/libs" if (new File(path).exists()) { def jarFiles = new FileNameByRegexFinder().getFileNames(path, /<your-app>.*\.jar/) command "java -jar ${jarFiles[0]}" ready 'Application started' } } startProvider.doLast { Thread.sleep(100) } task stopProvider(type: KillProcessTask) { } ```

uglyog
2019-09-18 00:22
:party_parrot: the whole Internet is built on stolen code

james.hattersley-dyke
2019-09-18 08:08
thanks! This looks like it'll work...

james.hattersley-dyke
2019-09-18 08:10
I'm trying to introduce a standardised way of running verification tasks for our Spring Boot apps. Some people are writing Unit tests using Junit because starting the app was too complex, others are using just `pactVerify` from the gradle plugin,

james.hattersley-dyke
2019-09-18 08:10
I think using `gradle pactVerify` is much cleaner

vhbsouza
2019-09-18 20:45
has joined #pact-jvm

abubics
2019-09-18 23:51
I think the jUnit style is actually cleaner, because it keeps everything in the test sourceSet

abubics
2019-09-18 23:52
but I like the gradle style because it's easy to reason about, and gives confidence on the built jar . . . you have to put in extra stuff to keep the pact state change endpoint & related code out of the prod artifact, though

wongso_a
2019-09-19 07:17
has joined #pact-jvm

dianaszaharia
2019-09-19 10:54
has joined #pact-jvm

kiranpatel11
2019-09-22 23:34
sharing with to pact-jvm

tjones
2019-09-23 00:21
has joined #pact-jvm

kristine.jetzke
2019-09-23 18:54
Hi, I?m trying to upgrade my provider tests to Junit5. They are using spring and I was using ``` @TestTarget public final Target target = new SpringBootHttpTarget(); ``` Is there something similar for Junit5 and Spring?

kristine.jetzke
2019-09-23 18:56
Nevermind, got it to work :wink:

kristine.jetzke
2019-09-23 18:56
``` @LocalServerPort private int port; @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", port)); } ```

simonmeulenbeek
2019-09-24 10:13
has joined #pact-jvm

simonmeulenbeek
2019-09-24 10:14
Hey, is there a way to match an JsonArray holding key-value pairs? The keynames are different everytime.

simonmeulenbeek
2019-09-24 10:26
Nvm, i'm having a brainfart i think

sabil.beladri
2019-09-25 11:34
Hi, a couple of doubts related to provider validation: ? is there a way to pass tag value from command line (using maven in my case), when using something as @PactBroker([...] tags = ["Release"]) ? My idea is here to be able to switch from a tag to another depending on the git branch, I tried to get system property propagated there but constant value is needed so I see no easy way. I also tried removing tag there and use a maven systemPropertyVariables pact.provider.tag for this purpose, but it would only default to latest without considering another value there. ? also trying to reuse example from [1], I was not able to split in separate classes different @State methods related to a same provider, all must go along the class holding @Provider. This can lead to long classes. It would be great to know if: a- it's possible and I ignore it b- it's a dumb idea and makes no sense c- it would be a possible improvement (I'd create an issue then) [1]: https://github.com/DiUS/pact-jvm/blob/master/provider/pact-jvm-provider-spring/src/test/java/au/com/dius/pact/provider/spring/BooksPactProviderTest.java

zoeabryant
2019-09-25 15:21
has joined #pact-jvm

uglyog
2019-09-25 23:03
1. Dynamic tag values is a good idea. Can you raise an issue for that? 2. Moving the provider state callbacks to another class makes sense. Raise an issue please :smile:

george.papas
2019-09-26 05:07
has joined #pact-jvm

s1apped
2019-09-26 06:03
has joined #pact-jvm

s1apped
2019-09-26 06:04
Hi I have some problem with junit provider , pactbroker and gradle. I try to set PactBroker properties in gradle like test{ systemProperty 'pactbroker.tags', 'test' systemProperty 'pactbroker.host', 'url' systemProperty 'pact.provider.version', 'version' systemProperty 'pact.verifier.publishResults', 'true' } I'm getting error : Did not find any pact files for provider This works just fine @PactBroker(host = "url", scheme = "http", tags = {"test"}). Am I missing something?


uglyog
2019-09-26 06:33
You need to add the property as an expression: `@PactBroker(host="${pactbroker.host}", port = "80")`

borsuk.artem034
2019-09-26 07:09
try to add annotation @Consumer("service-name")

german.schnyder
2019-09-26 07:38
has joined #pact-jvm

s1apped
2019-09-26 08:17
looks like my problem is that I'm using SpringRestPactRunner so it works little bit different

dianaszaharia
2019-09-26 08:35
I also ran into both of these issues, it would be great to see them resolved. How I worked around them - dynamic tags - implement a custom Junit extension that dynamically sets the sytem property "tags" based on current branch. It also polls the pact broker for pacts tagged for existing branch, so that if none exist it fallbacks to master (or prod). This was needed because if no pacts exist with the provided tag, the test will fail with `No supporting TestTemplateInvocationContextProvider provided an invocation context` - splitting states in different classes - extract states in different interface classes and have the pact test class implement those

nathan.deamer
2019-09-26 09:41
has joined #pact-jvm

zoeabryant
2019-09-26 11:27
does anyone have an example of a fully working consumer side contract test in clojure that I could reference?

zoeabryant
2019-09-26 11:28
I have a contract test that runs without error, but doesn't seem to generate a pact that I can publish.

zoeabryant
2019-09-26 13:35
never mind it was hidden in the target folder :joy:


nyarasha
2019-09-26 18:09
Hey all, so I'm totally new to pact but have been reading lots of example code and tutorials. So far, I have not been able to get my head around how to create a pact file. I have set up a junit test, and have the DSL defined for our request / response interactions, but am unclear on how to connect those into the Mock Server (which mocks out the provider side of things). Where do I configure and run a Mock for the provider? What I've come up with so far runs, but I get a `Connection Refused` error (since nothing is running on the Mock Server port at `http://localhost:8080`?) ``` MockServer mockServer = new MockServer() { @NotNull @Override public String getUrl() { return "http://localhost"; } @Override public int getPort() { return 8080; } [...] }; ```

uglyog
2019-09-26 23:04
The mock server will automatically be setup by the test framework. You don't need to do anything there. What version of JUnit are you using?

nyarasha
2019-09-27 14:46
Hm okay. I'm using JUnit 5 and the JUnit 5 JVM Consumer `au.com.dius:pact-jvm-consumer-junit5_2.12`

kashikar.harsh
2019-09-28 16:41
Hey all, I was trying to use pact jvm library for java/junit to validate scala provider method has anyone tried this before? I am facing some problem with compiling both maven and sbt, somehow maven doesn't honor dependencies defined in sbt file and throws exception

kashikar.harsh
2019-09-28 19:39
Also, I was trying to run provider verification using the SpringRestPactRunner.class for asyn contract test and getting the below error

kashikar.harsh
2019-09-28 19:40
Can I use this class for asyn contract test? If not, how can I run the message contract in spring

kashikar.harsh
2019-09-28 19:48
Or can someone please pont me to spingboot example of asyn message contract test?

uglyog
2019-09-29 00:03
@kashikar.harsh looks like it is failing because the URL for the Pact Broker is null. How have you configured your Maven POM?

kashikar.harsh
2019-09-29 05:59
Hi @uglyog I have setup the url in @PactBroker(host="<pact_broker_url>", port="443", scheme="https", tags = {"latest"}) in my provider verification class

uglyog
2019-09-29 06:01
The Maven plugin is for running the verification with Maven. If you're using a JUnit test, it will just run as part of the Maven test phase.

uglyog
2019-09-29 06:01
So you can just run `mvn verify`

uglyog
2019-09-29 06:02
Oh, sorry. You did.

uglyog
2019-09-29 06:02
Is `<pact_broker_url>` just a placeholder for the actual pact broker URL?

kashikar.harsh
2019-09-29 06:05
yes

kashikar.harsh
2019-09-29 06:06
but actually you were right, after I pass pact broker url as param, it worked

kashikar.harsh
2019-09-29 06:06
@PactBroker host parameter is not being used

kashikar.harsh
2019-09-29 06:09
After providing the above parameter, it fails to invoke provider verification method and gives below error

uglyog
2019-09-29 06:14
If you enable debug level logs, you should be able to see why that method failed

kashikar.harsh
2019-09-29 06:38
sure, checking that

catrionamcgarvey
2019-09-30 08:34
has joined #pact-jvm

kashikar.harsh
2019-09-30 09:52
Hey @uglyog I am still getting the same error "Failed to invoke provider method '<my-method-name>'"

kashikar.harsh
2019-09-30 09:53
public final Target target = new AmqpTarget(); - is this applicable for springboot as well or do I have to use a different target?

kashikar.harsh
2019-09-30 10:17
Ok, moved on with the previous error by providing package name containing list of singletons, now getting a classpath error

borsuk.artem034
2019-09-30 10:21
class have "public" accesor?

kashikar.harsh
2019-09-30 10:28
Yeah


kashikar.harsh
2019-09-30 10:29
this seems to be the issue, will proceed with creating custom class as suggested in https://reflectoring.io/cdc-pact-messages/

borsuk.artem034
2019-09-30 10:35
do you use junit4?

kashikar.harsh
2019-09-30 10:40
yes

kashikar.harsh
2019-09-30 11:05
Even with the custom class getting the same exception, any suggestions?

kashikar.harsh
2019-09-30 14:11
Sorry to spam, but seems if I try to run goal pact:verify, it doesn't run in spring context (I don't see springboot info)

alex.thayn
2019-09-30 20:45
has joined #pact-jvm

uglyog
2019-10-01 00:04
@kashikar.harsh pact:verify goal knows nothing about Spring. You need to run your verification as a JUnit test with the spring test annotations

uglyog
2019-10-01 00:08
Also, if using Maven you need to enable the system classloader. See https://github.com/DiUS/pact-jvm/issues/763#issuecomment-487890115

kashikar.harsh
2019-10-01 14:46
Hey all I am trying to parameterize pact broker credentials by using variable pactBrokerCredentials as stated in doc https://github.com/ITV/scala-ITV/scala-pact | Added by GitHub however getting an error that pactBrokerCredentials cannot be resolved using SBT 0.13.16 and scalapact 2.2.5

s1apped
2019-10-01 18:46
Hi. Is it possible to run Provider spring parameterized tests?

uglyog
2019-10-01 22:14
@david.j.smith one for you

uglyog
2019-10-01 22:15
Are you asking about JUnit5 parameterized tests?

s1apped
2019-10-02 09:35
I'm using spring and junit4. I have a contract with matcher on field which accepts enum. On Provider side I'm using SpringRestPactRunner and would like to test all the options and I thought if it's possible to use parameterized tests.

nayaksurajr
2019-10-02 16:00
has joined #pact-jvm

s1apped
2019-10-02 18:35
@uglyog lets say I would switch to Junit5 is it possible to use parameterized tests?

uglyog
2019-10-02 21:57
I was just asking to find out what you meant by parameterized tests. I wouldn't use Pact to test combinations of data. I would use a Unit test to test that the different values can be handled, and one test with an invalid value. And then I would create 2 Pact tests, one with valid values and one with invalid values.

hande.sagar
2019-10-03 04:29
has joined #pact-jvm

hande.sagar
2019-10-03 04:32
Hi All , currently I am facing one problem , when trying to publish pact contract for rest provider. This is the mvn Command we are using in our Jenkin pipeline: MVN cmd: mvn pact:verify -P contract-tests,no-asciidoc -Dpactbroker.host=http://kube-pact -Dpact.verifier.publishResults=true -Dpact.provider.version=fc7194df2b341fbada3c7c2fa0f1ef96abe5f59d -Dpact.tag=feature/FMPSU-236-pact-for-phase-3-4 This is the Error we are getting: 1 @PactVerification then " Verification Failed - No annotated methods were found for interaction 'A GET request to retrieve package with id 04398eb4-0f57-4056-b2ea-aa45bf5c4bfd.'. You need to provide a method annotated with @PactVerifyProvider("A GET request to retrieve package with id 04398eb4-0f57-4056-b2ea-aa45bf5c4bfd.") that returns the message contents. " 2. We have added @PactVerifyProvider with method verifyPackage then we got another error ?Verification Failed - Failed to invoke provider method 'verifyPackage'?. If any one has some idea about this issue please revert back to me.

uglyog
2019-10-03 04:36
With Maven you need to enable the system classloader. See https://github.com/DiUS/pact-jvm/issues/763#issuecomment-487890115

uglyog
2019-10-03 04:38
Oh, wait, that is for running tests via Maven


anothonyvong
2019-10-03 14:35
has joined #pact-jvm

hande.sagar
2019-10-04 04:44
still I am getting below error

hande.sagar
2019-10-04 04:44
[INFO] Published verification result of 'Failed(results=[{message=Request to provider method failed with an exception, exception=java.lang.RuntimeException: Failed to invoke provider met hod 'verifyPackage', interactionId=201b9024ecac5921bd9fc6bfc38eb3b39e5d8331}, {message=Request to provider method failed with an exception, exception=java.lang.RuntimeException: Failed t o invoke provider method 'verifyPackage', interactionId=efb912814610bebdbd82728382fff3d0bf7ad799}], description=Request to provider method failed with an exception)' for consumer 'Consum er(name=consignment-planner)'

uglyog
2019-10-04 04:49
Your provider method is throwing an exception.

hande.sagar
2019-10-04 04:57
when I run my pact contract using junit , it works fine , only it gives error when try to publish using mvn:pact verify

uglyog
2019-10-04 05:00
You need to enable debug level logging with Maven so you can see what the exception cause is.

uglyog
2019-10-04 05:01
If the JUnit test works, why do you need to use mvn pact:verify?

hande.sagar
2019-10-04 05:15
I need to use this command in my jenkin job to publish result on pact server

uglyog
2019-10-04 05:17
The provider JUnit test will also publish the result

hande.sagar
2019-10-04 06:33
this is the log trace in details

hande.sagar
2019-10-04 06:33
[DEBUG] Response body: {"providerName":"package-supplier","providerApplicationVersion":"2.0.0","success":false,"verificationDate":"2019-10-04T08:32:04+00:00","testResults":[{"interactionId":"201 b9024ecac5921bd9fc6bfc38eb3b39e5d8331","success":false,"mismatches":[],"exceptions":[{"message":"Failed to invoke provider method 'verifyPackage'","exceptionClass":"java.lang.RuntimeException"}] },{"interactionId":"efb912814610bebdbd82728382fff3d0bf7ad799","success":false,"mismatches":[],"exceptions":[{"message":"Failed to invoke provider method 'verifyPackage'","exceptionClass":"java.l ang.RuntimeException"}]}],"_links":{"self":{"title":"Verification result","name":"Verification result 10500 for Pact between consignment-planner (v507915e528fc3e6fb6155c1583eba4220b775045) and p ackage-supplier","href":"http://kube-pact/pacts/provider/package-supplier/consumer/consignment-planner/pact-version/088b7abe4cfc7786fd34f8ac40e17a66960726d6/verification-results/10500"},"pb:pact -version":{"title":"Pact","name":"Pact between consignment-planner (v507915e528fc3e6fb6155c1583eba4220b775045) and package-supplier","href":"http://kube-pact/pacts/provider/package-supplier/cons umer/consignment-planner/version/507915e528fc3e6fb6155c1583eba4220b775045"},"pb:triggered-webhooks":{"title":"Webhooks triggered by the publication of this verification result","href":"http://ku be-pact/pacts/provider/package-supplier/consumer/consignment-planner/pact-version/088b7abe4cfc7786fd34f8ac40e17a66960726d6/verification-results/10500/triggered-webhooks"}}} [INFO] Published verification result of 'Failed(results=[{message=Request to provider method failed with an exception, exception=java.lang.RuntimeException: Failed to invoke provider method 'ver ifyPackage', interactionId=201b9024ecac5921bd9fc6bfc38eb3b39e5d8331}, {message=Request to provider method failed with an exception, exception=java.lang.RuntimeException: Failed to invoke provide r method 'verifyPackage', interactionId=efb912814610bebdbd82728382fff3d0bf7ad799}], description=Request to provider method failed with an exception)' for consumer 'Consumer(name=consignment-plan ner)'

uglyog
2019-10-04 06:41
If you enable this Java system property `pact.showStacktrace`, it may show you the exception

uglyog
2019-10-04 06:41
But what the log is staying, is that Pact Maven plugin invoked your verifyPackage method which threw a runtime exception.

dhiral.kaniya
2019-10-04 16:36
has joined #pact-jvm

audun.halland
2019-10-07 09:40
has joined #pact-jvm

audun.halland
2019-10-07 10:46
Using pact-jvm-provider-spring (and HttpTarget), I want to verify a HTTP pact that expects a `301 Moved Permanently`. But it fails because it gets `200 Ok`, because it looks like the client actually performed the redirect, which it shouldn?t, because I?m allowed to publish a pact that expects any http status code. Any tips?

s1apped
2019-10-07 11:02
Thanks!

audun.halland
2019-10-07 13:07
I have solved it by using `CustomHttpTarget : HttpTarget`, and then in `fun testInteraction(...)` I copied the body from `HttpTarget::testInteraction` and inserted my own `CustomHttpClientFactory` which can create an apache http client the way I want. But it would have been better if I didn?t have to copy a lot of logic. I suggest `fun getHttpClientFactory()` to be an overridable method in `au.com.dius.pact.provider.junit.target.HttpTarget`.

audun.halland
2019-10-07 13:13
The http client I want is `HttpClients.custom().disableRedirectHandling().build()`

audun.halland
2019-10-07 13:15
It would make sense to me if that was how the default client was created. I consider it a bug the way it behaves now..

sabino_lrs
2019-10-07 16:46
has joined #pact-jvm

s1apped
2019-10-08 12:35
Hi. I have an issue with randomly failing tests with 500 Internal Server Error. I'm using junit4 with SpringRunner. The issues seems to be related to @Rule PactProviderRule but can't really pin point it. I tried to switch on Junit5 and it works without any issues. Any ideas?

hstene
2019-10-08 12:47
Why not just switch to JUnit5?

s1apped
2019-10-08 12:58
@hstene due to services being old and having quite a few junit4 tests and possible dependencies conflicts. Junit4 to 5 migration is last option..

thomas.heilbronner
2019-10-08 13:00
you can run junit4 tests in junit5

thomas.heilbronner
2019-10-08 13:00
no need to change your existing tests

thomas.heilbronner
2019-10-08 13:00
new ones can be written in junit 5

thomas.heilbronner
2019-10-08 13:01
in case you want/have to migrate have a look at https://github.com/junit-pioneer/convert-junit4-to-junit5

hstene
2019-10-08 13:02
^This

thomas.heilbronner
2019-10-08 13:03
there is a long pending PR that adds quite some functionality to the code https://github.com/junit-pioneer/convert-junit4-to-junit5/pull/16

thomas.heilbronner
2019-10-08 13:04
I used this one to migrate junit 4 tests to junit5 for some of my projects

uglyog
2019-10-08 22:17
I agree, that is not desired behaviour in the mock server

uglyog
2019-10-08 22:18
can you provide some logs?

wongso_a
2019-10-09 01:24
Hi, any idea when documentation for Pending pacts (https://docs.pact.io/getting_started/pending) be available? I'm keen to know more about it.

uglyog
2019-10-09 01:28
I haven't had a chance to implement that yet, let alone write any documentation. In fact, I still need to work out how it works :smile:

wongso_a
2019-10-09 01:29
Would you be able to give me high level idea what problem Pending Pacts will solve?

uglyog
2019-10-09 01:30
I think the idea is to not break the providers build when a new consumer is added or a WIP feature is added to a consumer


wongso_a
2019-10-09 01:32
Nice! My client would love that feature. Thank you :slightly_smiling_face:

hstene
2019-10-09 04:59
This is a great idea @uglyog! :smile:

uglyog
2019-10-09 05:00
It's all @bethskurrie, I'm just the messenger

hstene
2019-10-09 05:00
Then :tada: to Beth!

thomas.scheuchzer2
2019-10-09 09:39
Hi. I just upgraded one of my Spring-Boot examples to Pact 4 and now the consumer tests fail in a strange way. I get `Unexpected end of file from server; nested exception is java.net.SocketException: Unexpected end of file from server`

thomas.scheuchzer2
2019-10-09 09:43
I can debug the code down to MockHttpServer line 227 `val bodyContents = exchange.requestBody.readBytes()`. When I evaluate the expression it returns an empty byte array what is fine in a get call. But when steppinng through the code the debugger just disappears on that line without catching any exception and the execution continues with the error in the log. I put the example on gitbug: https://github.com/scheuchzer/cdc-demo-2019-10.git The test consumer project is in the folder weather. Any ideas on what is wrong in my code? It used to work fine with pact 3.6

thomas.scheuchzer2
2019-10-09 14:52
I noticed it is working fine with Java 8 until 3.6.13. 3.6.14 throws java.lang.NoSuchMethodError: kotlin.io.ByteStreamsKt.readBytes(Ljava/io/InputStream;)[B with Java 8. After upgrade to Java 11 the same error as with pact 4.0.0 is thrown

thomas.scheuchzer2
2019-10-09 14:54
btw. 3.6.13 is working fine with Java 11

uglyog
2019-10-09 22:55
@thomas.scheuchzer2 can you raise a github issue for that, please?

ryan.dens
2019-10-10 16:53
has joined #pact-jvm

florian.nagel
2019-10-10 17:13
I have encountered the same exception `java.lang.NoSuchMethodError: kotlin.io.ByteStreamsKt.readBytes(Ljava/io/InputStream;)`. I can't help with the debugging because of time issues, but I'd appreciate updates nonetheless! :smile:

kashikar.harsh
2019-10-11 13:33
Hey All Need some help with springboot pact verification for message contracts

kashikar.harsh
2019-10-11 13:34
If I use runner "PactRunner", it doesn't use spring and runs as normal junit test

kashikar.harsh
2019-10-11 13:34
If I change my runner to "SpringRestPactRunner", it loads with spring, however it complains " Did not find any pact files for provider"

kashikar.harsh
2019-10-11 13:35
I am using pact brokers and have @PactBroker to my provider test class with relevant params like host, port, scheme, tags and hardcoded authentication with @PactBrokerAuth

kashikar.harsh
2019-10-11 13:35
in the debug logs, I do not see any traces of it trying to contact broker

kashikar.harsh
2019-10-11 13:36
Anything I am missing here?

kashikar.harsh
2019-10-11 13:42
I running these tests with mvn verify

ryan.dens
2019-10-11 14:57
Hi! I?m looking to use the pact-jvm maven plugin with pactflow. I?ve successfully published pacts from my consumer to the broker, but the way the HTTP client is configured in `PactProviderMojo` does not seem to allow me to specify the header `Authorization: Bearer <TOKEN>` as required by pactflow. I attempted a workaround using the `createClient` configuration to configure the httpclient to always send the correct authorization header like: ``` <createClient> org.apache.http.impl.client.HttpClients.custom().setDefaultHeaders(java.util.Collections.singletonList(new org.apache.http.message.BasicHeader("Authorization", "Bearer <TOKEN>"))).build() </createClient> ``` but unfortunately the `PactProviderMojo` doesn?t seem to use the `HttpClientFactory` that reads that config to create the http client which accesses the pact broker. Is the community open to a change which would allow the pact-jvm-provider to load pacts from pactflow? The way I imagine implementing it is similar to the gradle plugin, but open to suggestions here of course.

ryan.dens
2019-10-11 15:00
I looked for an open issue on github, but couldn?t find one. If I missed it, let me know!

audun.halland
2019-10-12 00:03
@audun.halland has left the channel

uglyog
2019-10-12 00:44
Hi @kashikar.harsh when switching to the Spring runner, the properties for the proker will be resolved as Spring properties not JVM system properties. Just make sure they are defined in your spring context, using the spring boot config file


kashikar.harsh
2019-10-12 04:08
Thank you @uglyog

kashikar.harsh
2019-10-12 04:08
In this case, can you please guide me how do I pass pactbroker credentials as an argument instead of hard coding them in the properties file?


uglyog
2019-10-12 04:13
But I think the values have to first be in the property file, and then you can override them

kashikar.harsh
2019-10-12 04:14
sure, thank you

kashikar.harsh
2019-10-12 04:49
I tried adding these properties with respective values but it still says did not find any pact files

kashikar.harsh
2019-10-12 04:50
again no traces of it contacting pact broker


uglyog
2019-10-12 05:04
If I run `mvn verify -Dpactbroker.host=http://dius.pact.dius.com.au ....`, I can see it using that value in the logs

uglyog
2019-10-12 05:04
``` 2019-10-12 16:03:32.542 DEBUG 12920 --- [ main] a.c.dius.pact.pactbroker.HalClientBase : Fetching: / 2019-10-12 16:03:33.053 DEBUG 12920 --- [ main] a.c.dius.pact.pactbroker.HalClientBase : Fetching: https://dius.pact.dius.com.au/pacts/provider/spring-boot-maven-provider/latest 2019-10-12 16:03:33.323 DEBUG 12920 --- [ main] a.c.dius.pact.pactbroker.HalClientBase : Fetching: / 2019-10-12 16:03:33.492 DEBUG 12920 --- [ main] a.c.dius.pact.pactbroker.HalClientBase : Fetching: https://dius.pact.dius.com.au/pacts/provider/spring-boot-maven-provider/latest 2019-10-12 16:03:33.560 DEBUG 12920 --- [ main] a.c.d.p.p.junit.loader.PactBrokerLoader : Failed to get provider URL from the pact broker au.com.dius.pact.pactbroker.NotFoundHalResponse: No HAL document found at path 'https://dius.pact.dius.com.au/pacts/provider/spring-boot-maven-provider/latest' ```

kashikar.harsh
2019-10-12 05:13
thanks, using the debug mode, I see now it is contacting pact broker

kashikar.harsh
2019-10-12 05:14
however it generates a url like https://<pact_broker_url>/pacts/provider/<provider_name>/consumer/<consumer_name>/version/1.0.1

kashikar.harsh
2019-10-12 05:14
and then says no pact found for provider

kashikar.harsh
2019-10-12 05:14
But if I access the above url using the same credentials as defined in my application.properties, I see the pact

uglyog
2019-10-12 05:19
Check that your provider name is spelt correctly and has the correct case

kashikar.harsh
2019-10-12 05:20
Yes, I copied the url from debug logs and pasted in browser, it worked all fine

kashikar.harsh
2019-10-12 05:21
provider and consumer names are all lower case, so no casing mismatching involved here

uglyog
2019-10-12 05:22
What version of pact-jvm are you using?

kashikar.harsh
2019-10-12 05:23
4.0.0-beta.5

uglyog
2019-10-12 05:27
Can you use 3.6.14? Looks like there is an issue with that version

uglyog
2019-10-12 05:29
``` <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit_2.12</artifactId> <version>3.6.14</version> </dependency> ```

uglyog
2019-10-12 05:31
BTW, you should not mix major versions (4.0.0-beta.5 and 3.6.13)

kashikar.harsh
2019-10-12 05:31
sure, I just upgraded everything to 4.0.0, let me check

uglyog
2019-10-12 05:37
Actually, upgrading that test project to 4.0.0 works for me

kashikar.harsh
2019-10-12 05:38
unfortunately getting the same error : java.lang.Exception: Did not find any pact files for provider <provider_name>

kashikar.harsh
2019-10-12 05:42
Some findings, it first calls the api to get the latest pact: https://cas-pact-broker.eng.citrite.net/pacts/provider/cas-app-actions/latest

kashikar.harsh
2019-10-12 05:43
this returns list of 3 in pb:pacts

kashikar.harsh
2019-10-12 05:44
sorry it is not list of 3 but just 1

kashikar.harsh
2019-10-12 05:44
but interestingly the provider object in response has name set to "Deprecated"

kashikar.harsh
2019-10-12 05:45
and the actual provider name is appearing in title

uglyog
2019-10-12 05:52
That is the problem, it doesn't match the expected provider name

kashikar.harsh
2019-10-12 05:54
Yep, somebody messed up with the pact version, I just registered pact with incremented version

kashikar.harsh
2019-10-12 05:54
however still it gives the same error

kashikar.harsh
2019-10-12 05:56
"DEPRECATED - please use the pb:provider relation"

kashikar.harsh
2019-10-12 05:57
this is coming in provider name, any idea what is this?

kashikar.harsh
2019-10-12 05:57
I think we are still using the provider property from response of latest which is now deprecated and instead we should use pb:provider property to fetch the pact detaisl

kashikar.harsh
2019-10-12 05:58
makes sense?

uglyog
2019-10-12 05:58
I still don't understand why the provider name has been changed

uglyog
2019-10-12 05:59
What version of the pact-broker are you using? You should see that in the response headers

kashikar.harsh
2019-10-12 06:01
it is not changed,it indicates property provider is deprecated and instead we should be using pb:provider

kashikar.harsh
2019-10-12 06:03
pact broker version: 2.29.0

kashikar.harsh
2019-10-12 06:08
Is this something that I can contribute to?

kashikar.harsh
2019-10-12 06:10
Looks like they will remove non pb relation completely in version 3 of pact broker

uglyog
2019-10-12 06:12
That test project works against my broker, which is 2.38.1. Where is the provider property coming from?

kashikar.harsh
2019-10-12 06:13
As response of this request https://<pactbroker_host>/pacts/provider/cas-app-actions/latest

kashikar.harsh
2019-10-12 06:15
it returns json with these properties self, pb:provider, pb:pacts, provider and pacts

uglyog
2019-10-12 06:18
But the Pact-JVM does not use that relation. It will use `pb:latest-provider-pacts`, and then return all the pacts that are returned

kashikar.harsh
2019-10-12 06:20
I don't see this property in the response of latest api

uglyog
2019-10-12 06:26
Not, what I mean, it will first fetch root (/), then look for the `pb:latest-provider-pacts` relation, and then fetch that. Then fetch the `pacts` relation to get the actual pact. It doesn't use `pb:provider`. You can use the HAL browser to follow the same set of links

kashikar.harsh
2019-10-12 06:28
yes, I can relate this with the logs

uglyog
2019-10-12 06:29
The thing I don't understand is why your broker is returning a pact with the provider name set to that. It means it was published with that name.

kashikar.harsh
2019-10-12 06:31
nope, because I see correct provider name in "pb:provider" propert

kashikar.harsh
2019-10-12 06:31
and the json file I checked also has the correct provider name

kashikar.harsh
2019-10-12 06:33
even in the hal browser I see pb:provider set to correct provider name and not provider

uglyog
2019-10-12 06:34
Then that is not the issue.

kashikar.harsh
2019-10-12 06:36
as you said, it doesn't use pb:provider, which property it uses then?

uglyog
2019-10-12 06:36
When you fetch the JSON from `https://<pact_broker-host>/pacts/provider/cas-app-actions/consumer/sf-action-adapter/version/1.0.3`, what does the provider section have?

uglyog
2019-10-12 06:36
It uses the `pacts` one

kashikar.harsh
2019-10-12 06:37
"provider": { "name": "cas-app-actions" },

uglyog
2019-10-12 06:37
That is correct

kashikar.harsh
2019-10-12 06:37
then we are back to start i.e. Did not find any pact files for provider cas-app-actions

kashikar.harsh
2019-10-12 06:38
what else could be the possible issue?

uglyog
2019-10-12 06:38
Are you able to show the Test class?

kashikar.harsh
2019-10-12 06:38
povider?

kashikar.harsh
2019-10-12 06:38
yes I can

uglyog
2019-10-12 06:38
Yes, the provider test class

kashikar.harsh
2019-10-12 06:39
yep

kashikar.harsh
2019-10-12 06:39
Shall I paste the code here?/

uglyog
2019-10-12 06:42
Sure, or you can use a Gist

uglyog
2019-10-12 06:43
Just beware that this is a public forum

kashikar.harsh
2019-10-12 06:44
no idea what is Gist

kashikar.harsh
2019-10-12 06:45
I will pm you

uglyog
2019-10-12 06:46
It's a Github way of sharing code: https://gist.github.com/

kashikar.harsh
2019-10-12 06:50
PM the source code

uglyog
2019-10-12 06:52
Your test looks ok

kashikar.harsh
2019-10-12 06:53
how to proceed on this?

uglyog
2019-10-12 06:53
Can you try run against our test broker? https://test.pact.dius.com.au: Username: dXfltyFMgNOFZAxr8io9wJ37iUpY42M Password: O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1

uglyog
2019-10-12 06:53
You will need to find a provider name there to use

kashikar.harsh
2019-10-12 06:55
Can I use any provider?

uglyog
2019-10-12 06:56
Sure, it's all test data

kashikar.harsh
2019-10-12 07:00
tried with source_provider_sample provider and it could successfully fetch the pact

uglyog
2019-10-12 07:03
Ok, so it must be something with your broker.

kashikar.harsh
2019-10-12 07:03
so you suggest upgrading pact broker?

uglyog
2019-10-12 07:03
Yeah, upgrading the broker to the latest is always a good idea

kashikar.harsh
2019-10-12 07:03
to 2.38.1 or higher

kashikar.harsh
2019-10-12 07:04
ok, I will check with operations team and let you know

uglyog
2019-10-12 07:04
2.38.1 must be the latest

kashikar.harsh
2019-10-12 07:04
Thank you @uglyog for all your time and efforts, appreciate it

uglyog
2019-10-12 07:05
No prob. If you could provide the pact file from that URL, it would help diagnose why it is being rejected

kashikar.harsh
2019-10-12 08:03
any specific section of pact file?

kashikar.harsh
2019-10-12 08:03
I am afraid I can't share the entire file due to obvious business reasons

wongso_a
2019-10-14 06:57
Hi, is there a way for pact-jvm-provider-maven to run tests with Pact contracts that are tagged with "latest"? When I specify the following: <tags> <tag>latest</tag> <tags> I the the an error saying that there is not Pact found for the provider test. After a bit of debugging I found: [DEBUG] Fetching: http://pactbroker.blah.net/pacts/provider/SomeApi/latest/latest

dianaszaharia
2019-10-14 11:32
Hi! Is there an equivalent for `@IgnoreNoPactsToVerify` for junit 5? I see it's only available in the junit 4 module

kashikar.harsh
2019-10-14 14:56
Hi @uglyog We upgraded the pact broker version to 2.38.1, but are still getting the same result

kashikar.harsh
2019-10-14 14:57
Error: Did not find any pact files...

kashikar.harsh
2019-10-14 14:57
Anything else we can try?

kashikar.harsh
2019-10-14 15:08
I have tried re-registering pact with higher pact version and then running the provider verification, it didn't help

kah.goh
2019-10-14 21:53
has joined #pact-jvm

darragh.grace
2019-10-15 16:01
has joined #pact-jvm

uglyog
2019-10-15 22:57
I have someone else who has the same problem as you. I'm going to see if I can resolve it for them. Hopefully, that will help you as well :smile:

uglyog
2019-10-16 03:02
Their problem was authentication with bearer tokens, which is not the issue you are having. But you could try the latest version 4.0.1

simon.waterhouse
2019-10-16 09:58
has joined #pact-jvm

simon.waterhouse
2019-10-16 10:37
Hi @uglyog I am working with @kashikar.harsh on this. The problem appears in PactRunner.kt. I added some diagnostics to filterPacts at line 128 and found that it was receiving a list of 1 pacts as input and (apparently) returning that 1 pact to caller.

simon.waterhouse
2019-10-16 10:39
However when I looked at the contents of the returned list at line 102 it was empty !!!

simon.waterhouse
2019-10-16 10:41
If I replace the call to filterPacts at line 79 with a call to filterPactsByAnnotation (adding the extra testClass.javaClass parameter) then everything works fine.

simon.waterhouse
2019-10-16 10:42
As a Kotlin novice I am wondering if I am missing something obvious here...is it OK in Kotlin to call an object method (filterPacts) from the constructor?

simon.waterhouse
2019-10-16 10:43
BTW using master branch of pact-jvm sunk a day or 2 back.

hande.sagar
2019-10-16 10:47
If I run junit from eclipse all my pact test cases are passed and also publish results on kube pact server , but I need to do same thing using mvn command . any idea? I tried using command mvn test -DjvmArgs -Dpact.verifier.publishResults=true -X but it gives me some other error and pact test cases failed.

simon.waterhouse
2019-10-16 14:57
Here is the logging enhanced PactRunner,kt and a snippet from the log showing it losing the pact: https://gist.github.com/siwater/5b00fadb788f46200c3f31aac96676e2

simon.waterhouse
2019-10-16 15:08
And here is a working PactRunner.kt and a snippet from the log showing the pact is no longer lost: https://gist.github.com/siwater/4144ce5d8aa1e5a157dd39af745a43bb

uglyog
2019-10-16 22:08
Maven will setup the classpath and system properties differently to Eclipse. How are you executing the tests? JUnit?

uglyog
2019-10-16 23:39
Oh, that's interesting. I'm going to remove that filterPacts

uglyog
2019-10-16 23:40
But I still want to know why this is affecting you and not anyone else

uglyog
2019-10-16 23:42
What JVM version are you using?

uglyog
2019-10-16 23:44
Ah, I've found the problem (I think).

uglyog
2019-10-16 23:45
You're using the SpringRestPactRunner, which filters out everything except http pacts. SpringMessagePactRunner is the one you need to use

uglyog
2019-10-16 23:46
That's why removing the filterPacts method fixes the issue

uglyog
2019-10-16 23:48
I'm going to make that error message more explicit

kashikar.harsh
2019-10-17 05:44
Thanks @uglyog, also if we can add an example of message pact for spring, it will help

kashikar.harsh
2019-10-17 05:44
I was not aware that SpringMessagePactRunner exists, my bad if i have missed any document

kashikar.harsh
2019-10-17 05:51
After changing to SpringMessagePactRunner, it proceed with further verifcation

kashikar.harsh
2019-10-17 05:51
Thanks you @uglyog and @simon.waterhouse

uglyog
2019-10-17 06:26
Sorry, it's not your fault, there is no documentation on that.

simon.waterhouse
2019-10-17 08:29
Good work @uglyog - thanks for the speedy response !!

nathan.deamer
2019-10-17 15:04
Any tips on how to use the pact gradle plugin for pactVerify? I am using gradle5 and trying to start a spring boot app with a profile - but it doesn't seem to be picking up the spring.profiles.active. ``` if ('pactVerify' in gradle.startParameter.taskNames) { startProviderTask = 'startApp' terminateProviderTask = 'stopApp' hasPactsFromPactBroker(System.getenv('PACT_BROKER_URL'), authentication: ['Bearer', System.getenv('PACT_BROKER_TOKEN')]) }``` ```task startAppProcess() { doLast() { ExecutorService es = Executors.newSingleThreadExecutor() es.submit({ project.javaexec { classpath = project.sourceSets.main.runtimeClasspath main = 'com.nathandeamer.Application' args 'spring.profiles.active=test' } } as Callable) } } task startApp(dependsOn: startAppProcess) { doLast { def timeTaken = 0 while (timeTaken < 120) { try { if (Request.Get('http://localhost:8080/actuator/health').execute().returnResponse().getStatusLine().getStatusCode() == 200) { return } } catch (ConnectException ignored) { } timeTaken++ sleep(500) } throw new GradleException('Failed to start app in 1 minute.') } }``` Or is there a better way to do this?

gopinathlangote11
2019-10-17 15:41
Feels like you are trying to make application up before pact verification. wondering why you want to do pact verification against you local env. Why not with stable env?


nathan.deamer
2019-10-17 15:57
1. Start up my provider. 2. Get the PACTs from the pact broker 3. Verify them against running provider.

okereke.ruth
2019-10-17 20:56
has joined #pact-jvm

abubics
2019-10-17 22:54
Some of us use this copypasta between years of codebases :stuck_out_tongue: ``` import com.wiredforcode.gradle.spawn.* task startProvider(type: SpawnProcessTask, dependsOn: 'assemble') { def path = "$buildDir/libs" if (new File(path).exists()) { def jarFiles = new FileNameByRegexFinder().getFileNames(path, /<your-app>.*\.jar/) command "java -jar ${jarFiles[0]}" ready 'Application started' } } startProvider.doLast { Thread.sleep(100) } task stopProvider(type: KillProcessTask) { } ```

abubics
2019-10-17 22:56
@gopinathlangote11 It's totally reasonable to want to run Pact tests on local :slightly_smiling_face: the style I encourage people to write them in is like unit tests for the network interface. I know that's not the only way people use Pact, though.

hstene
2019-10-18 05:34
Boris is right. Why would you *not* want to run it locally? One of the benfits of Pact is that I as a developer can make a code change, verify that my change did not break any dependencies (and if it did; fix them) before I even commit my code. Testing locally on my machine is *ABSOLUTELY* a desired feature, @gopinathlangote11

nathan.deamer
2019-10-18 07:41
Thanks guys. Will let you know how I get on

nathan.deamer
2019-10-18 09:38
Yep, that is working. Now just dealing with spring boot issues not overriding my beans with mocks

jennifer.molis
2019-10-18 16:04
has joined #pact-jvm

uglyog
2019-10-19 22:02
@dianaszaharia because of the way JUnit 5 works, we have not found a way to implement that

uglyog
2019-10-19 22:03
If you don?t provide a tag, it will use latest

roi.otero.morales
2019-10-21 12:53
has joined #pact-jvm

roi.otero.morales
2019-10-21 12:57
Hello Im having a problem when trying to use pact with the `pact-jvm-provider-spring:4.0.1` , I cannot make it able to verify the tests, they are being reported as `verification: result:OK` but they are not being pushed to the PactBroker therefore they are never verified there Im getting the error: `Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')` Im using: ```@SpringBootTest(classes = {Application.class},properties={ "pact.provider.version=0", "pact.verifier.publishResults=true" }, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)``` as well tried with the quotes on true ` "pact.verifier.publishResults='true'"` I have it as well on the application properties: ```pact: verifier: publishResults: 'true' provider: version: 0```

uglyog
2019-10-21 20:52
Which test runner are you using?

roi.otero.morales
2019-10-21 20:56
Hey, i will check it tomorrow but i think the PactRunner, anyways i found a way, its a system property. So in gradle i defined as a system property. Looks like the library is not getting the environment properties, just system ones.

roi.otero.morales
2019-10-21 20:58
I was debugging the pact jvm library and there is a class, i cannot recall the name, in kotlin, that checks for the state of the variable pact.verifier.publishResults, but it checks with System.getProperty() not System.getEnv()

uglyog
2019-10-21 21:13
The base runner only uses JVM system properties. If you use the runner from the spring module, it will use values from the spring context

roi.otero.morales
2019-10-22 08:40
umm well i was using this module: `testCompile 'au.com.dius:pact-jvm-provider-spring:4.0.1'` And only works from the JVM system properties :disappointed:

roi.otero.morales
2019-10-22 08:41
I was using as well the runner `@RunWith(SpringRestPactRunner.class)`

sandhyarani.gabbi
2019-10-22 13:04
Hi Team, StringMatcher and numberType matchers are not allowing "/" or ":" in the name field in 4.0.x version. It was working fine till 3.6.x version. Is this working as intended?

uglyog
2019-10-22 22:18
Can you provide the error you are getting?

uglyog
2019-10-22 22:20
That runner should use the spring context for the properties.

uglyog
2019-10-22 22:21
But maybe not that one (it works for the broker properties). But if the JVM system property is working, just use that

roi.otero.morales
2019-10-23 10:35
exactly, it works for the broker properties, i was debugging the code that checks for the property `pact.verifier.publishResults` and uses `System.getProperty(),` instead of `System.getEnv()`

bartlomiej.twarog
2019-10-23 12:51
has joined #pact-jvm

sandhyarani.gabbi
2019-10-23 13:06
@uglyog ERROR a.c.d.p.c.BaseJdkMockServer:204 [Thread-2] Failed to generate response au.com.dius.pact.core.model.InvalidPathExpression: ":" is not allowed in an identifier in path expression "$.container_records[0].state[0].aDataItem[0].OrgNamBVLKey_CDF[0].OrgNamBVLNameKey_Col_CDF[0].OrgNamBVLNameKey_CDF[0].OrgNamBVLLocalNamedatadefinition:CDF" at index 149

uglyog
2019-10-23 21:21
Can you raise an issue for that on the GitHub project

vince.grossi
2019-10-26 19:42
has joined #pact-jvm

vince.grossi
2019-10-26 19:49
Hi, I?m trying to integrate pact contract creation with cucumber, but I?d like to create contract with loose response matching. Any pointer would be appreciated.

uglyog
2019-10-26 22:43
what do you mean by loose response matching?

vince.grossi
2019-10-26 23:39
I mean instead of doing strict body matching like

vince.grossi
2019-10-26 23:43
I'd rather generate something like:

uglyog
2019-10-26 23:50
Ok, you want to expose the DSL matching methods to cucumber steps?

vince.grossi
2019-10-27 00:02
I'm not exactly sure of what I'm looking for ... Just trying to know if anything has already been done on cucumber and pact so I can dig in a little bit more. I've seen https://github.com/remondis-it/pact-consumer-builder which offers POJO to PactDSLJSonBody mapping. it'd be interesting to have a JSON to PactDSLJsonBody mapper which I could use in my cucumber testing. I have some steps where I can mock my response, I'd like to use these steps to generate a contract, so I can make sure my provider is compliant with the mocking

wongso_a
2019-10-29 12:51
The situation we are in is that not all consumers of the API are tagged yet. What we were hoping as an interim solution is to run the provider tests with the latest pacts if the consumer's pact hasn't been tagged and run with the latest tag if it exists. We have worked around this by implementing two executions in the POM file. However, if there is a way to do it all in one execution, I would be keen to know.

rafael.anachoreta
2019-10-31 10:44
has joined #pact-jvm

rafael.anachoreta
2019-10-31 11:57
good afternoon! I?m trying to use `pact-jvm-consumer-junit`?s version 4.0.2 and having trouble understanding how to use the overriden `runTest(MockServer, PactTestExecutionContext)` to run multiple tests against the same provider

rafael.anachoreta
2019-10-31 11:59
I think the README is a bit outdated (https://github.com/DiUS/pact-jvm/tree/master/consumer/pact-jvm-consumer-junit) , but by extending `ConsumerPactTest` I get to @Override `runTest()` my question - what purpose does runTest() serve when I have multiple tests? Should it be calling the other test methods? Should I just ignore it and add the @test annotation to my custom tests?

andreas
2019-10-31 12:45
Hi All, I am trying to implement Pact in our Android Project, but it seems as if the httpClient differs/conflicits between Java and AndroidJava. This seems to be a problem in Pact JVM 4.0.2, and the Android Workshop is on Pact 3.3.6 Are anyone able to use the lastest Pact-jvm in an Android (Java8/Kotlin project)

kist
2019-10-31 12:46
has joined #pact-jvm

kist
2019-10-31 12:49
Our best guess at the reason for the error is the accepted answer of this stackoverflow


andreas
2019-10-31 12:56
Thorbjørn and I are from the same project. And The above is just a further detailing.

andreas
2019-10-31 12:57
We would rather avoid suggesting a special android version of Pact, but perhaps it is possible with some Java magic to use both (I am mostly on JavaScript)

anddreiu
2019-10-31 17:30
Hi all. I would appreciate if anybody has any idea for the above question related to how to avoid calling an url by the XmlBodyMatcher? I think it tries to open the url when it parses the XML. Many thanks.

abubics
2019-10-31 23:39
If you're building an Android consumer, there shouldn't be any http client coming from Pact, just your own app's outbound request client.

abubics
2019-10-31 23:40
But I haven't done Pact+Android for about a year, so my knowledge isn't super-current

abubics
2019-10-31 23:41
Oh, it's the content-type parsing . . . not the request client :thinking_face:

abubics
2019-10-31 23:43
You may be able to use that SO answer, and exclude httpclient from the Pact dependency, and include another? But it does sound like a compat bug, maybe @uglyog has some input/ideas :slightly_smiling_face:

vetisanvasile
2019-11-04 14:30
~Hi guys, I have a question related to <https://github.com/DiUS/pact-jvm/issues/550> Should I post a comment in that issue?~ LATER EDIT: I kinda figured out :slightly_smiling_face:

antonello
2019-11-05 15:10
@uglyog The one above is from one of the devs of the client I?m working with. Another contribution for this side of the world :slightly_smiling_face:

antonello
2019-11-06 09:28
@greg.pappas is the author!

greg.pappas
2019-11-06 09:28
has joined #pact-jvm

andreas
2019-11-06 10:00
ok - @abubics - thank you for the information. We will make an issue on the pact-jvm repo for this. To get more awareness of the issue. Thanks

greg.pappas489
2019-11-06 17:03
has joined #pact-jvm

uglyog
2019-11-09 02:30
PR has been merged! Thanks!

antonello
2019-11-10 10:17
@greg.pappas

thomas.scheuchzer2
2019-11-11 13:32
Are pending pacts already implemented in pact-jvm? http://blog.pact.io/p/d7c9601f-e2ca-4208-b1c0-f02eaf96c3c2/ Can't find any hint about this in the code and I guess there should be some additional code for this. Though it's also possible that I'm just blind :slightly_smiling_face:

uglyog
2019-11-11 21:12
@thomas.scheuchzer2 I haven?t done any work on that yet. There is an issue to track it.

ryan.dens
2019-11-11 21:20
@uglyog is there any other issue besides https://github.com/DiUS/pact-jvm/issues/942?

ryan.dens
2019-11-11 21:27
Looking forward to this feature! Is there any plan to decompose this work? I?d be happy to take on at least a chunk of it

uglyog
2019-11-11 21:35
No, that's the issue for it. It points to another issue that contains the details of the change.

uglyog
2019-11-11 21:38
@ryan.dens if you want to have a look at the other issue, we need to work out what needs to be done. As far as I understand, there is a new endpoint on the broker. So we need to look for that link, and if it is there, use it otherwise fall back to the existing functionality

jks
2019-11-12 14:18
has joined #pact-jvm

rafael.anachoreta
2019-11-13 14:15
hello! maybe a silly question, but was is the recommendation for running the `can-i-deploy` command on the jvm environment? Should I just use the ruby CLI or is there a JVM implementation of it (similar to what pact-node has)?

ingo.griebsch
2019-11-13 17:04
has joined #pact-jvm

abubics
2019-11-13 23:38
We tend to just run the CLI version, and its runtime should be transparent. Since it's running on CI, just run the script in an explodey way, such as `#!/bin/bash -eu` to make sure it breaks the build if it can't deploy rn

abubics
2019-11-13 23:39
but, as usual, the correct answer is "it depends", and I don't know how complex your infra and pipelines are :slightly_smiling_face:

akazantseva2
2019-11-14 11:15
has joined #pact-jvm

rafael.anachoreta
2019-11-14 16:54
thank you, I got some extra answers on the #pact-broker thread and I think I?ve managed to proceed :muscle:

rafael.anachoreta
2019-11-14 16:56
:wave: I?m looking into publishing my pacts to my broker I went into the docs, but the consumer?s README points to the provider library (which is confusing - https://github.com/DiUS/pact-jvm/tree/master/consumer/pact-jvm-consumer-groovy#publishing-your-pact-files-to-a-pact-broker) To further add to my confusion, the variable I?m supposed to set with my pact version is called `providerVersion` and was introduced in favor of `version`. Why was that? :thinking_face: My understanding is that you should only ever be publishing the pacts from the consumer?s side (hence my confusion on this gradle task being on pact/provider/gradle), so the version would just be the version of the consumer?s pact that was published. The verification is when I?d add a version for the provider, but not on the publishing of the actual pact. Am I wrong? https://github.com/DiUS/pact-jvm/blob/master/provider/pact-jvm-provider-gradle/src/main/groovy/au/com/dius/pact/provider/gradle/PactPublish.groovy#L17

uglyog
2019-11-14 20:48
The provider version is used to store the verification results. So a consumer with a particular version publishes a pact, then a provider with it's version publishes that it's been successfully verified. That way you know which versions of a consumer are compatible with the versions of the provider.

rafael.anachoreta
2019-11-15 08:08
yes, exactly! but currently the task to publish the Pact (not the verification) also lives within the provider?s library

uglyog
2019-11-15 08:20
:man-shrugging: doesn't matter which library it's in, there is no consumer gradle plugin

rafael.anachoreta
2019-11-15 08:21
I suppose :stuck_out_tongue: but anyway, the passed in variable is also called ?providerVersion? despite being the consumer version but ye it doesn?t really matter, I just wanted to confirm my thinking was right and for that I thank you :bow:

sabil.beladri
2019-11-18 16:47
Hi, I'm looking for some examples of groovy tests using RestPactRunner, MockMvcTarget, @State and stubs, are there any around here? Here's the full story why I'm asking this: I'm a bit struggling to have a spring provider validation running fine in Groovy. I have it already working fine in Kotlin, using MockMvcTarget, coupled with @State and stubs When..thenReturn But upon trying to port this to Groovy, I'm facing weird issues [1]. Do we have examples of how to run such a validation in Groovy? I checked pact-jvm doc [2] but could not find an example using @State and stubs When..thenReturn 1: kotlin.TypeCastException: null cannot be cast to non-null type au.com.dius.pact.provider.junit.target.Target 2: https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-spring/src/test/groovy/au/com/dius/pact/provider/spring

kashikar.harsh
2019-11-18 17:47
Hey All

kashikar.harsh
2019-11-18 17:47
I am working on writing contract tests using pact-jvm for amqp protocol

kashikar.harsh
2019-11-18 17:48
and was looking for an example where multiple contracts tests written for same provider and consumer

kashikar.harsh
2019-11-18 17:49
Basically need to understand how this line of code will work if there are multiple tests in the same java file

kashikar.harsh
2019-11-18 17:50
Since there is no context to it, it always returns the same payload and hence in case of multiple tests, only one test pass

uglyog
2019-11-18 20:49
Groovy should be pretty similar to ones in Java and Kotlin. Have a look in the pact-jvm test folders, there are lots of Groovy tests.

uglyog
2019-11-18 20:51
Not sure what you mean by stubs When..thenReturn?

291636938
2019-11-19 06:30
has joined #pact-jvm

291636938
2019-11-19 06:30
Hi @channel, I using version 3 of pact and is able to generate the pact json file and do the consumer test, but when I turn to run the provider test, it came out error with message "Exception: No tests found matching Method", I use the springboot 2.x , pact 3.6.0, and my demo project is located at https://github.com/wuhuanxing/pact_demo , Ive struggled it for few days, really hope some one can help me , Thank very much!

felipe
2019-11-19 07:44
has joined #pact-jvm

felipe
2019-11-19 07:46
Hi all! im trying to verify pacts with the gradle plugin but im getting always a 400 bad request from nginx. From postman with https://myurl.com:443/service/path works perfectly. im out of ideas this is my gradle ```plugins { id "java" id "au.com.dius.pact" version "4.0.3" } task('getToken') { doLast { } } pact { serviceProviders { wmsBackend { protocol = 'https' host = 'http://myserviceurl.com' port = 443 path = '/' //insecure = true requestFilter = { req -> req.addHeader('Authorization', 'Bearer sometoken') } hasPactsWith('WmsFrontend') { pactFileLocation = file("$rootDir/../pacts/frontend") } hasPactsWith('Plentymarkets') { pactFileLocation = file("$rootDir/../pacts/plentymarkets") } } } reports { defaultReports() // adds the standard console output markdown // report in markdown format json // report in json format } } ```

felipe
2019-11-19 07:46
My pact makes a boring get: ```"request": { "headers": { "Authorization": "Bearer token", "Content-Type": "application/json" }, "method": "GET", "path": "/api/v1/entity/entty2/1", "body": {}```

felipe
2019-11-19 07:48
Check my latest message in the channel. There is an example of working build.gradle.

sabil.beladri
2019-11-19 08:14
thanks, I'll look a bit further on pact-jvm tests by stubs I meant something like ```when(awesomeBusinessLogic.getById(any(UUID.class))) .thenReturn(myTestHelper.generateRandomReturnData(UUID.randomUUID(), ExampleEnum.ONE))```

audun.halland
2019-11-19 09:53
has joined #pact-jvm

m.kwiecien
2019-11-19 10:17
has joined #pact-jvm

291636938
2019-11-19 13:12
seem not work on my project...can u take a time look at my demo project? thanks

uglyog
2019-11-19 20:38
Oh, you mean Mockito stubs

uglyog
2019-11-19 20:40
You use the different descriptions in the pact file to be mapped to different test methods using the annotation on the test method.

uglyog
2019-11-19 20:47
You?ll need to have a look at the nginx logs to see why the request is being rejected. Also, if you enable debug logs you will see the exact request being made, including headers. You can then try that in postman.

ft1704602
2019-11-20 04:19
has joined #pact-jvm

felipe
2019-11-20 04:26
I was using the request filter to set headers and it fails if the pacts have headers. Still investigating that issue

felipe
2019-11-20 04:27
I don?t have much time. I think is better that you look at my code

291636938
2019-11-20 05:46
hi, when I start the provider test with pact, it came out `failed: Connection refused `Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)`, I used springBoot v2, and pact v3, project at https://github.com/wuhuanxing/pact_demo , do I need to start my provider program before the provider test? is it possible to load the specified controller and minimum spring context to do the contract test?

291636938
2019-11-20 06:40
# run command ./gradlew pactVerify > Task :pactVerify_myProvider FAILED Verifying a pact between myConsumer and myProvider [Using File /Users/huanxing.wu/demo_pact/target/pacts/myConsumer-myProvider.json] Given sayHello WARNING: State Change ignored as there is no stateChange URL a request to /hello Request Failed - Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused) Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true') Failures: 0) Verifying a pact between myConsumer and myProvider - a request to /hello Given sayHello Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)

291636938
2019-11-20 07:03
I found this problem can be resolved by start my real provider service(spring app), but my question is how can I use a mocked provider for provider contract test? i think is not good if we do the testing on real production service. I newbie on this , could someone help explain it to me in plain word , thank you very much!

uglyog
2019-11-20 07:12
The point of the provider test is to verify the real provider adheres to the contract. Verifying a mock provides no benefit.

291636938
2019-11-20 07:19
Well , what if the provider test will modify the data on DB? then in this way the contract test is not repeatable, and if the test running on PROD ENV, that would be terrible. on the other way ,if we can mock the endpoints( and it's dependencies ) we need to test, like the mockMvc way , that would be nice .

uglyog
2019-11-20 07:23
You can use MockMVC with Pact. That does not mock your provider, but tests the actual controllers. It's mocks out the Spring MVC environment. See https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-spring

291636938
2019-11-20 07:27
yes that's what I meaning and looking for , thank you very much

291636938
2019-11-20 07:47
hello @uglyog, I've followed the link above and got below error, still the same error : cannot connect server:

291636938
2019-11-20 07:50
thank you for your kindness and patient

291636938
2019-11-20 07:52
and my pact config on build.gradle is :


291636938
2019-11-20 09:01
hello @uglyog good news! after a painful struggling, I'm now able to run test with mockMvc successfully , really thank you for your help. now I have one more question ,how to run only one test case :

uglyog
2019-11-20 09:06
That is not the test method, it is the state change method. Just run the test from the class name

291636938
2019-11-20 09:15
:joy: ok thank you

kashikar.harsh
2019-11-21 09:37
Is there a documentation for this that I can refer to? Tried looking for annotations, couldn't find it

kashikar.harsh
2019-11-21 12:13
I could achieve this with the use of different fragments

roi.otero.morales
2019-11-21 13:54
Hello everyone! , I have 2 questions is there a way to `pactPublish` using Junit instead of Gradle plugin? is there a way to not fail `pactPublish` when there is no folder containing pacts? (I want to run pactPublish even if the Repo doesnt have consumers and only providers to have a standarized pipeline) `Execution failed for task ':pactPublish'.` > `http://java.io``.FileNotFoundException: /<somepath>/build/pacts`

vijay.chinthala
2019-11-21 19:21
has joined #pact-jvm

vijay.chinthala
2019-11-21 19:24
@felipe can you please help me with example code how did you add the Authorization to the header, I am trying to find a solution while executing the pactVerify the token should be generated dynamically and set the header Authorization

crummynz
2019-11-21 23:39
has joined #pact-jvm

crummynz
2019-11-21 23:51
The docs on https://github.com/DiUS/pact-jvm/tree/master/consumer/pact-jvm-consumer-junit say to "extend ConsumerPactTestMk2". But in the source I don't see a file with that name, though there is "ConsumerPactTest.java". What should I use?

uglyog
2019-11-21 23:57
Ah, those docs are out of date. Just drop the Mk2 off

crummynz
2019-11-22 00:24
Do the JVM pact libraries support rabbitmq mocking?

uglyog
2019-11-22 00:25
The message support is abstracted and not specific to any messaging implementation

crummynz
2019-11-22 01:02
I have a service that listens to a rabbit queue, processes messages, and sends responses on another queue. Does that mean I need a consumer and provider to test this?

kiranpatel11
2019-11-22 01:06
if you deal with content before sending it to next queue, you should consider tests for that, or just have tests for the consumer in chain which deals with the content of the message.

kiranpatel11
2019-11-22 01:07
if you are just routing based on header or something, you aren't really dealing with contract, you don't need to have a test for that

crummynz
2019-11-22 01:42
Seems like I'm best off just instantiating the class that sends the responses with mock dependencies and not booting up the whole app. Is this usually the way to do it?

kiranpatel11
2019-11-22 02:05
You should mock the layers after your request is parsed and validated. Refer : https://docs.pact.io/best_practices/provider#only-stub-layers-beneath-where-contents-of-the-request-body-are-extracted

crummynz
2019-11-22 02:32
Is this an example of how I would call my rabbitmq handler? ``` @get:Rule val provider = MessagePactProviderRule("provider1", this) @Test fun test() { MyHandler().handle(Delivery(null, null, provider.message)) }```

crummynz
2019-11-22 02:34
I have a @Pact annotated MessagePact method elsewhere, and in the blog post https://dius.com.au/2017/09/22/contract-testing-serverless-and-asynchronous-applications/ it seems that I'm supposed to attach some messageHandler to it, but I don't know where I get messageHandler from. Is that MyHandler() in my earlier code?

uglyog
2019-11-22 02:40
The idea is that you split your code into two parts: the bit that generates the message, and the bit that puts it into the message queue. The contract is then with the code that creates the message. You can then test that with a Pact test without having to have a message queue.

crummynz
2019-11-22 02:41
huh OK. So just check that my object deserializes?

uglyog
2019-11-22 02:41
Well, if you have some code that deserializes and then processes the message, you could let that be your handler

crummynz
2019-11-22 02:51
The example refers to PactMessageBuilder which I don't seem to have. Is MessagePactBuilder a replacement?

uglyog
2019-11-22 02:58
It's MessagePactBuilder

uglyog
2019-11-22 02:58
The example is wrong.

kiranpatel11
2019-11-22 03:20
@crummynz this may help you visualize how pact for messaging is desinged :

crummynz
2019-11-22 03:23
Thanks, that makes sense. I think I'm stuck on step 2.

uglyog
2019-11-22 03:23
awesome diagram! Can we put that in the Pact docs?

crummynz
2019-11-22 03:24
Is the code in this guide still accurate? https://reflectoring.io/cdc-pact-messages/ The `setMessage(byte[] message)` method seems a bit... magic?

kiranpatel11
2019-11-22 03:25
sure...It helped me a lot to educate others....!!

uglyog
2019-11-22 03:29
You don't need the `setMessage` function, you can call `messageProvider.getMessage()`

uglyog
2019-11-22 03:30
Tom didn't write that blog post that long ago, so it should still be good

crummynz
2019-11-22 04:48
I found your pact-maven-amqp-test repo @uglyog. I upgraded the library version here: https://github.com/uglyog/pact-maven-amqp-test/compare/master...crummy:master However, that gets me this error: ```java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:657) at java.util.ArrayList.get(ArrayList.java:433) at http://au.com.dius.pact.consumer.junit.MessagePactProviderRule.parsePacts(MessagePactProviderRule.java:194) at http://au.com.dius.pact.consumer.junit.MessagePactProviderRule.access$500(MessagePactProviderRule.java:28)```

crummynz
2019-11-22 04:49
I was able to resolve it by changing line 26 to include a providerState (change to `return builder.given("bar")`) and line 33 to the same (change to `@PactVerification({"foo", "bar"})`). Is a state required now?

uglyog
2019-11-22 05:06
on the provider side you would get a warning if there was no state change handler for that state, but otherwise, no

crummynz
2019-11-22 05:13
So the test should still pass with my changes? Should I file a bug?

uglyog
2019-11-22 05:15
yeah, sure.

pavel.azarau
2019-11-22 17:04
has joined #pact-jvm

thomas.scheuchzer2
2019-11-25 10:23
When I build pact-jvm on my local machine I get a test failure on master: `http://au.com``.dius.pact.provider.junit.PactRunnerSpec > PactRunner throws an exception if the pact source throws an IO exception FAILED` Is this the current status on master or is it my build setup?

uglyog
2019-11-25 22:26
master builds ok on my machine, as well as on Travis CI and Apveyor

hande.sagar
2019-11-26 03:21
I am not able to see branch name in tag for published event. I am expecting branch name here along with commit number.

hande.sagar
2019-11-26 03:22
cant see branch name here , I can only see commit number.

uglyog
2019-11-26 03:23
You'll need to show us your config

hande.sagar
2019-11-26 03:24
I am using such mvn command to publish it

hande.sagar
2019-11-26 03:24
mvn clean test -Dpactbroker.host=http://kube-pact -Dpact.verifier.publishResults=true -Dpact.provider.version=0a44cd1051a1459dd4148ca6ff1c3f0ef5fdc157 -Dpact.provider.tag=feature/FMPSU-236-PACT-Publish-issue -Dpact.tag=feature/FMPSU-236-PACT-Publish-issue

hande.sagar
2019-11-26 03:25
I am using such mvn command to publish it mvn clean test -Dpactbroker.host=http://kube-pact -Dpact.verifier.publishResults=true -Dpact.provider.version=0a44cd1051a1459dd4148ca6ff1c3f0ef5fdc157 -Dpact.provider.tag=feature/FMPSU-236-PACT-Publish-issue -Dpact.tag=feature/FMPSU-236-PACT-Publish-issue

hande.sagar
2019-11-26 03:26
this is my pom file

hande.sagar
2019-11-26 03:26
<plugin> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven_2.12</artifactId> <version>3.6.2</version> <configuration> <pactDirectory>${project.build.directory}/pacts</pactDirectory> <pactBrokerUrl>http://kube-pact</pactBrokerUrl> <!-- <pactBrokerUrl>http://pact-broker.pact-broker</pactBrokerUrl> --> <projectVersion>${pact.consumer.version}</projectVersion> <projectVersion>${pact.provider.version}</projectVersion> <trimSnapshot>true</trimSnapshot> <useManifestOnlyJar>false</useManifestOnlyJar> <tags> <tag>${pact.tag}</tag> </tags> <serviceProviders> <serviceProvider> <name>package-supplier-events</name> <verificationType>ANNOTATED_METHOD</verificationType> <!-- <stateChangeUrl>http://localhost:8080/tasks/pactStateChange</stateChangeUrl> --> <pactBrokerUrl>http://kube-pact/</pactBrokerUrl> <!-- <pactBrokerUrl>http://pact-broker.pact-broker</pactBrokerUrl>--> </serviceProvider> <serviceProvider> <name>package-supplier</name> <verificationType>ANNOTATED_METHOD</verificationType> <!-- <stateChangeUrl>http://localhost:8080/tasks/pactStateChange</stateChangeUrl> --> <pactBrokerUrl>http://kube-pact/</pactBrokerUrl> <!-- <pactBrokerUrl>http://pact-broker.pact-broker</pactBrokerUrl> --> </serviceProvider> </serviceProviders> <configuration> <pact.verifier.publishResults>false</pact.verifier.publishResults> </configuration> </configuration> </plugin>

uglyog
2019-11-26 03:29
You've circled the provider version in the screenshot. That will be the value of `-Dpact.provider.version`

uglyog
2019-11-26 03:30
The tags are displayed in blue

hande.sagar
2019-11-26 03:34
I want to see provider branch name

hande.sagar
2019-11-26 03:34
consumer branch name is showing properly

hande.sagar
2019-11-26 03:35
I am using these dependency

hande.sagar
2019-11-26 03:35
<dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> <scope>test</scope> </dependency> <dependency> <configurationParameters> junit.jupiter.conditions.deactivate = * junit.jupiter.extensions.autodetection.enabled = true junit.jupiter.testinstance.lifecycle.default = per_class </configurationParameters>

uglyog
2019-11-26 03:38
What version of Pact Broker are you using?

bethskurrie
2019-11-26 03:38
Perhaps you have an old version. The latest version definitely shows the tags.

bethskurrie
2019-11-26 03:40
Also, you need the latest pact-jvm version for the provider tagging support.

bethskurrie
2019-11-26 03:40
It was only added recently.

hande.sagar
2019-11-26 03:59
which version I should use

hande.sagar
2019-11-26 03:59
using these versions

hande.sagar
2019-11-26 03:59
<plugin> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven_2.12</artifactId> <version>3.6.2</version> <configuration> <pactDirectory>${project.build.directory}/pacts</pactDirectory> <pactBrokerUrl>http://kube-pact</pactBrokerUrl> <!-- <pactBrokerUrl>http://pact-broker.pact-broker</pactBrokerUrl> --> <projectVersion>${pact.consumer.version}</projectVersion> <projectVersion>${pact.provider.version}</projectVersion> <trimSnapshot>true</trimSnapshot> <useManifestOnlyJar>false</useManifestOnlyJar> <tags> <tag>${pact.tag}</tag> </tags> <serviceProviders> <serviceProvider> <name>package-supplier-events</name> <verificationType>ANNOTATED_METHOD</verificationType> <!-- <stateChangeUrl>http://localhost:8080/tasks/pactStateChange</stateChangeUrl> --> <pactBrokerUrl>http://kube-pact/</pactBrokerUrl> <!-- <pactBrokerUrl>http://pact-broker.pact-broker</pactBrokerUrl>--> </serviceProvider> <serviceProvider> <name>package-supplier</name> <verificationType>ANNOTATED_METHOD</verificationType> <!-- <stateChangeUrl>http://localhost:8080/tasks/pactStateChange</stateChangeUrl> --> <pactBrokerUrl>http://kube-pact/</pactBrokerUrl> <!-- <pactBrokerUrl>http://pact-broker.pact-broker</pactBrokerUrl> --> </serviceProvider> </serviceProviders> <configuration> <pact.verifier.publishResults>false</pact.verifier.publishResults> </configuration> </configuration> </plugin> </plugins>

bethskurrie
2019-11-26 04:21
The latest!

uglyog
2019-11-26 04:21
Latest is 4.0.3

uglyog
2019-11-26 04:23
```<artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.3</version>```

hande.sagar
2019-11-26 04:51
ok, let me check

vijay.chinthala
2019-11-26 23:15
I am facing this issue Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')

vijay.chinthala
2019-11-26 23:15
I am using the pact-jvm provider version 4.0.3

vijay.chinthala
2019-11-26 23:15
can you please help what configuration I need to set here in my gradle script

vijay.chinthala
2019-11-26 23:39
Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')

vijay.chinthala
2019-11-26 23:40
I am getting problem, I have tried setting System.setProperty("pact.verifier.publishResults", 'true') and also did $export pact_verifier_publishResults='true' but no luck

vijay.chinthala
2019-11-26 23:40
I am using gradle script to configure the pact verify

vijay.chinthala
2019-11-26 23:41
please throw some light here what I am doing wrong here?

uglyog
2019-11-26 23:41
You need to set the properties on the test task


vijay.chinthala
2019-11-26 23:43
I am using gradle

vijay.chinthala
2019-11-26 23:43
``` task startProducer(type: com.github.psxpaul.task.JavaExecFork) { System.setProperty("JWT_PUBLIC_KEY", public_key) System.setProperty("pact.verifier.publishResults", 'true') classpath = sourceSets.main.runtimeClasspath main = 'com.five9.learningservice.LearningServiceApplication' stopAfter = pactVerify timeout = 45 waitForPort = 8080 waitForOutput = 'Started LearningServiceApplication' environment 'JWT_PUBLIC_KEY', public_key environment 'pact.verifier.publishResults', 'true' } pact { serviceProviders { learningService { startProviderTask = 'startProducer' if ('pactVerify' in gradle.startParameter.taskNames) { // hasPactsFromPactBroker(System.getenv('PACT_BROKER_URL'), authentication: ['Bearer', System.getenv('PACT_BROKER_TOKEN')]) hasPactWith('learningService') { // pactFile = file('build/pacts/learningServiceClient-learningServiceProvider.json') //used the latest pact contract to verify pactFile = url('broker-URL/pacts/provider/learningServiceProvider/consumer/learningServiceConsumerClient/version/1.0.0') System.setProperty("pact.verifier.publishResults", 'true') requestFilter = { req -> // Add an authorization header to each request req.addHeader('Authorization', 'Bearer ' + token ) } } } } } reports { defaultReports() // adds the standard console output json // report in json format } }```

uglyog
2019-11-26 23:45
Please read the answer to that SO question I posted above. System.setProperty, environment and -D will not work

vijay.chinthala
2019-11-26 23:47
test { systemProperty "pact.verifier.publishResults", "true" }

vijay.chinthala
2019-11-26 23:47
I tried this

vijay.chinthala
2019-11-26 23:47
but is is not working

vijay.chinthala
2019-11-26 23:49
```> Task :pactVerify_learningService returns a response which has status code 200 (OK) has a matching body (OK) publish message to Pubsub Topic returns a response which has status code 200 (OK) has a matching body (OK) Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true') BUILD SUCCESSFUL in 34s 9 actionable tasks: 8 executed, 1 up-to-date```

uglyog
2019-11-26 23:52
Oh, if you're using the PactVerify gradle task, then you need to use the -D option to gradle

vijay.chinthala
2019-11-26 23:54
$./gradlew -Dpact.verifier.publishResults=true pactVerify

vijay.chinthala
2019-11-26 23:54
I did this but that did not work for me

vijay.chinthala
2019-11-26 23:59
``` dependencies { classpath 'au.com.dius:pact-jvm-provider-gradle:4.0.3' classpath "gradle.plugin.com.github.psxpaul:gradle-execfork-plugin:0.1.10" }```

vijay.chinthala
2019-11-26 23:59
these deps I am using

vijay.chinthala
2019-11-27 00:21
is there a way I could use pact broker API and update it

vijay.chinthala
2019-11-27 00:22
I tried to update tag and version using the pact broker API but did not work

johnny.nilsson83
2019-11-27 08:01
has joined #pact-jvm

rafael.anachoreta
2019-11-27 16:17
A bit of an old thread, but it would be really cool to be able to set the defaults of `pactbroker.host` and `pactbroker.port` on the system Props without having to get them as properties. Much like what we have for the `@VerificationReports()` annotation and `'pact.verification.reports'` !

me1352
2019-11-27 17:01
has joined #pact-jvm

justaburneremailforso
2019-11-27 17:04
has joined #pact-jvm

vijay.chinthala
2019-11-27 18:49
@uglyog any thoughts why verify publish result not working for me?

vijay.chinthala
2019-11-27 18:52
and also I am could add the version and tags for consumer but not to provider

uglyog
2019-11-27 22:37
I don't know what you're doing wrong. I just tested my test project, and it works. Running `./gradlew pactVerify -d` I see the following in the logs: ```09:34:50.797 [WARN] [http://au.com.dius.pact.provider.ProviderVerifier] Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')``` And then running `./gradlew pactVerify -d -Ppact.verifier.publishResults=true` ```09:38:58.592 [INFO] [http://au.com.dius.pact.provider.DefaultVerificationReporter] Published verification result of 'Failed(results=[{message=Request to provider failed with an exception, exception=org.apache.http.conn.HttpHostConnectException: Connect to localhost:5050 [localhost/127.0.0.1] failed: Connection refused (Connection refused), interactionId=1b17fc7ae206564ffa469025ed5b609e5b637c7c}], description=Request to provider method failed with an exception)' for consumer 'Consumer(name=Foo Web Client 2)'```

uglyog
2019-11-27 22:40
Also, I can create a gradle.properties file in the root project with `pact.verifier.publishResults=true` also works

vijay.chinthala
2019-11-27 22:51
@uglyog I was using -D instead of -P, now I don;t see the error that I used to see but then I also don;t see last verified status in the pact broker

vijay.chinthala
2019-11-27 22:51
``` publish message to Pubsub Topic returns a response which has status code 200 (OK) has a matching body (OK) BUILD SUCCESSFUL in 31s 8 actionable tasks: 3 executed, 5 up-to-date```

uglyog
2019-11-27 22:52
run it with `-d` abd check the debug logs

vijay.chinthala
2019-11-27 22:53
```14:43:16.676 [INFO] [http://au.com.dius.pact.provider.DefaultVerificationReporter] Skipping publishing verification results for source UrlSource(url=http://pact-broker:8080/pacts/provider/learningServiceProvider/consumer/LearningServiceConsumer/latest/dev, pact=null)```

vijay.chinthala
2019-11-27 22:54
Screen Shot 2019-11-27 at 2.53.31 PM


vijay.chinthala
2019-11-27 22:56
```14:43:16.332 [DEBUG] [http://au.com.dius.pact.provider.ProviderVerifier] Verifying via request/response 14:43:16.333 [DEBUG] [http://au.com.dius.pact.provider.ProviderClient] Making request for provider http://au.com.dius.pact.provider.gradle.GradleProviderInfo@109342d5[providerVersion=<null>,providerTag=<null>,name=learningService,protocol=http,host=localhost,port=8080,path=/,startProviderTask=startProducer,terminateProviderTask=<null>,requestFilter=pact_5ro4pgonc778ffgsjjbyhctr$_run_closure3$_closure4$_closure6$_closure7@514bb795,stateChangeRequestFilter=<null>,createClient=<null>,insecure=false,trustStore=<null>,trustStorePassword=changeit,stateChangeUrl=<null>,stateChangeUsesBody=true,stateChangeTeardown=false,isDependencyForPactVerify=true,verificationType=REQUEST_RESPONSE,packagesToScan=[],consumers=[ConsumerInfo(name='learningService', stateChange=null, stateChangeUsesBody=true, packagesToScan=[], verificationType=REQUEST_RESPONSE, pactSource=UrlSource(url=http://pact-broker/pacts/provider/learningServiceProvider/consumer/LearningServiceConsumer/latest/dev, pact=null), pactFileAuthentication=[])]]: 14:43:16.333 [DEBUG] [http://au.com.dius.pact.provider.ProviderClient] method: POST```

uglyog
2019-11-27 23:01
pactSource=UrlSource means it doesn't know it's coming from a pact broker, it could be any URL. Don't use `pactFile = url('broker-URL/pacts/provider/learningServiceProvider/consumer/learningServiceConsumerClient/version/1.0.0')`, instead look at the link I posted above on how to set it up to fetch the pacts from the broker

vijay.chinthala
2019-11-27 23:06
``` pact { serviceProviders { learningService { startProviderTask = 'startProducer' if ('pactVerify' in gradle.startParameter.taskNames) { // hasPactsFromPactBroker(System.getenv('PACT_BROKER_URL'), authentication: ['Bearer', System.getenv('PACT_BROKER_TOKEN')]) requestFilter = { req -> // Add an authorization header to each request req.addHeader('Authorization', 'Bearer ' + token ) } hasPactWith('learningService') { // pactFile = file('build/pacts/learningServiceClient-learningServiceProvider.json') //used the latest pact contract to verify pactFile = url(PACT_BROKER_URL + 'pacts/provider/learningServiceProvider/consumer/LearningServiceConsumer/versions/1.0.5') } } } } reports { defaultReports() // adds the standard console output json // report in json format } }```

vijay.chinthala
2019-11-27 23:06
this is my pact config in the gradle, it looks fine

uglyog
2019-11-27 23:09
No, it's wrong. Use `hasPactsFromPactBroker`

vijay.chinthala
2019-11-27 23:11
``` pact { serviceProviders { learningService { startProviderTask = 'startProducer' if ('pactVerify' in gradle.startParameter.taskNames) { requestFilter = { req -> // Add an authorization header to each request req.addHeader('Authorization', 'Bearer ' + token ) } // You can get the latest pacts from the broker hasPactsFromPactBroker(PACT_BROKER_URL) // And/or you can get the latest pact with a specific tag hasPactsFromPactBrokerWithTag(PACT_BROKER_URL,"feat1") } } } reports { defaultReports() // adds the standard console output json // report in json format } }```

vijay.chinthala
2019-11-27 23:11
like this?

vijay.chinthala
2019-11-27 23:11
```> Task :pactVerify_learningService WARNING: There are no consumers to verify for provider 'learningService'```

uglyog
2019-11-27 23:12
The name needs to match what is in your broker, which is leaningServiceProvider

vijay.chinthala
2019-11-27 23:15
``` pact { serviceProviders { leaningServiceProvider { startProviderTask = 'startProducer' if ('pactVerify' in gradle.startParameter.taskNames) { requestFilter = { req -> // Add an authorization header to each request req.addHeader('Authorization', 'Bearer ' + token ) } // You can get the latest pacts from the broker hasPactsFromPactBroker(PACT_BROKER_URL) // And/or you can get the latest pact with a specific tag hasPactsFromPactBrokerWithTag(PACT_BROKER_URL,"feat1") } } } reports { defaultReports() // adds the standard console output json // report in json format } }```

vijay.chinthala
2019-11-27 23:15
```> Task :pactVerify_leaningServiceProvider WARNING: There are no consumers to verify for provider 'leaningServiceProvider'```

uglyog
2019-11-27 23:17
:man-shrugging: Can you check the name in your broker?

uglyog
2019-11-27 23:18
Hmm, looks correct from the previous URL

uglyog
2019-11-27 23:20
You only need to use one of the two lines: ``` // You can get the latest pacts from the broker hasPactsFromPactBroker(PACT_BROKER_URL) // And/or you can get the latest pact with a specific tag hasPactsFromPactBrokerWithTag(PACT_BROKER_URL,"feat1")```

uglyog
2019-11-27 23:21
Not both

vijay.chinthala
2019-11-27 23:23
awsome :slightly_smiling_face:

vijay.chinthala
2019-11-27 23:23
it worked

vijay.chinthala
2019-11-27 23:24
Screen Shot 2019-11-27 at 3.24.07 PM

vijay.chinthala
2019-11-27 23:24
I have asked to verify only for feat1

vijay.chinthala
2019-11-27 23:24
hasPactsFromPactBrokerWithTag(PACT_BROKER_URL,"feat1")

vijay.chinthala
2019-11-27 23:25
but I see it has updated all the consumer versions

uglyog
2019-11-27 23:25
It will update all versions where the pact file is the same

vijay.chinthala
2019-11-27 23:35
ok got it

vijay.chinthala
2019-11-27 23:36
Thank you very much for your help on this :slightly_smiling_face:

vijay.chinthala
2019-11-27 23:38
one more thing, from the gradle.properties version is being picked up and updating in the pact broker

vijay.chinthala
2019-11-27 23:38
what is configuration I need to use for tag

vijay.chinthala
2019-11-27 23:39
for provider tag

uglyog
2019-11-27 23:41
You can use what ever property you want, it needs to be the second parameter to hasPactsFromPactBrokerWithTag

vijay.chinthala
2019-11-27 23:42
no I mean how to set the tag for provider?

vijay.chinthala
2019-11-27 23:42
or we sent the tag to provider?

vijay.chinthala
2019-11-27 23:44
every time I run the pactVerify I see the pact broker duplicating versions

vijay.chinthala
2019-11-27 23:44
Screen Shot 2019-11-27 at 3.43.26 PM


vijay.chinthala
2019-11-27 23:56
``` pact { serviceProviders { learningServiceProvider { startProviderTask = 'startProducer' if ('pactVerify' in gradle.startParameter.taskNames) { requestFilter = { req -> // Add an authorization header to each request req.addHeader('Authorization', 'Bearer ' + token ) } providerVersion = { 'featBranch '+ '-' + 'abbrid1' } providerTag = { 'featBranch' } hasPactsFromPactBroker(PACT_BROKER_URL) // And/or you can get the latest pact with a specific tag // hasPactsFromPactBrokerWithTag(PACT_BROKER_URL,"feat1") // hasPactWith('learningService') { // pactFile = file('build/pacts/learningServiceClient-learningServiceProvider.json') // //used the latest pact contract to verify // pactFile = url(PACT_BROKER_URL + 'pacts/provider/learningServiceProvider/consumer/LearningServiceConsumer/versions/1.0.5') // } } } } reports { defaultReports() // adds the standard console output json // report in json format } }```

vijay.chinthala
2019-11-27 23:57
I have tired what you have advised but still I see duplicate entries

vijay.chinthala
2019-11-27 23:58
Screen Shot 2019-11-27 at 3.57.51 PM

uglyog
2019-11-28 00:00
@bethskurrie would be the best person to tell you why there are duplicate rows. But at least you're getting results

bethskurrie
2019-11-28 00:03
Most likely because the same pact has been verified multiple times. This view shows every verification.

bethskurrie
2019-11-28 00:04
As you can see, the timestamp and the verification number from the verifications are different

bethskurrie
2019-11-28 00:05
Choose the "latest for consumer version and provider version" and you'll only see one.

bethskurrie
2019-11-28 00:28
In the latest version of the broker, I've made that the default view.

vijay.chinthala
2019-11-28 00:39
Thanks Beth

vijay.chinthala
2019-11-28 00:40
``` pact { serviceProviders { learningServiceProvider { startProviderTask = 'startProducer' if ('pactVerify' in gradle.startParameter.taskNames) { requestFilter = { req -> // Add an authorization header to each request req.addHeader('Authorization', 'Bearer ' + token ) } providerVersion = { 'featBranch '+ '-' + 'abbrid1' } providerTag = { 'featBranch' } hasPactsFromPactBroker(PACT_BROKER_URL) // And/or you can get the latest pact with a specific tag // hasPactsFromPactBrokerWithTag(PACT_BROKER_URL,"feat1") // hasPactWith('learningService') { // pactFile = file('build/pacts/learningServiceClient-learningServiceProvider.json') // //used the latest pact contract to verify // pactFile = url(PACT_BROKER_URL + 'pacts/provider/learningServiceProvider/consumer/LearningServiceConsumer/versions/1.0.5') // } } } } reports { defaultReports() // adds the standard console output json // report in json format } }```

vijay.chinthala
2019-11-28 00:40
here is my pact configuration, can you please help how to filter or select the specific consumer and provider version

vijay.chinthala
2019-11-28 00:44
```> Task :pactVerify_learningServiceProvider Verifying a pact between LearningServiceConsumer and learningServiceProvider [from Pact Broker http://pact-broker/pacts/provider/learningServiceProvider/consumer/LearningServiceConsumer/version/1.0.5]```

vijay.chinthala
2019-11-28 00:45
every time I run the pactVerify, above given is the pact contract version that is being used

vijay.chinthala
2019-11-28 00:45
```$./gradlew pactVerify -Ppact.verifier.publishResults=true```

vijay.chinthala
2019-11-28 00:45
this is the command I ran

uglyog
2019-11-28 00:47
I think she meant in the matrix view of the pact broker. Every time you run the pact verify command, it will create a new row

vijay.chinthala
2019-11-28 00:48
I think that is fine for the version I am verifying, but it is also creating an entry for other versions


vijay.chinthala
2019-11-28 00:49
it should not be updating for version/1.0.4? isn't it the right expectation?

uglyog
2019-11-28 00:50
No, because the pact file is the same for all the versions

vijay.chinthala
2019-11-28 00:51
ok I see, I will make a change to the pact contract and will test it

vijay.chinthala
2019-11-28 00:52
thank you both for helping me to solve these issues, have a great thanks giving holidays :slightly_smiling_face:

bethskurrie
2019-11-28 01:01
The verification is attached to the underlying pact content. If you have two pacts with the same content, and you verify one of them, other other is also verified.

bethskurrie
2019-11-28 01:02
Technically, both pact publications point to the same pact version, and the single verification is attached to the single pact version, but when you expand that out into a table, you get two rows, because it is a many to many relationship.


artemabezruchko
2019-11-28 17:00
has joined #pact-jvm

hande.sagar
2019-11-28 17:18
Hi I have updated the pact-jvm-provider-maven to 4.0.3 and now I can see branch name and commit no.

hande.sagar
2019-11-28 17:19
I am using such command sh "mvn clean test -Dpactbroker.host=pact-broker.pact-broker -Dpact.verifier.publishResults=true -Dpact.provider.version=${gitCommit} -Dpact.tag=${branchName}"

hande.sagar
2019-11-28 17:19
but now problem is I am able to see branch name only for specific commit

hande.sagar
2019-11-28 17:20
for other commit numbers I dont know why it is not showing branch name

uglyog
2019-11-28 20:58
Best to raise an issue for it, posts on slack will get lost

uglyog
2019-11-28 21:00
It will only show the branch name associated with the commit for the result that is being published

hande.sagar
2019-12-01 12:07
as you can see , it doesnt display tag name every time , why it is?

sabil.beladri
2019-12-02 16:16
Hi, we're wondering here if anyone managed to work out a tool on the consumer side to parse & convert a JSON message to its lambda DSL code counterpart thanks for keeping me posted if so!

c.talek
2019-12-02 19:27
has joined #pact-jvm

c.talek
2019-12-04 15:00
@c.talek has left the channel

paul.simms
2019-12-04 16:12
has joined #pact-jvm

m.kwiecien
2019-12-04 17:47
Hi. I have problem with matchers. When I use value matcher in pact written on consumer ex. *stringValue(), .booleanValue()* I don't have proper validation on provider (my test passes even if provider doesn't have required state and return different value). I have noticed that in pact file that is created there is only *matching rule* for fields I used ex .stringType() matcher not for stringValue(). Example of response body I have where "avaliable" *boolenValue is not checked on provider verification*: ```DslPart responseBody = LambdaDsl.newJsonBody((body) -> { body .minArrayLike("addresses", 1, (array) -> { array.object("address", (address) -> { address .stringType("postcode", availablePostcode); }) .object("availability", (availability) -> { availability .booleanValue("available", true); }); }); }) .build();```

uglyog
2019-12-04 20:59
Those functions don?t add matches because the value will be checked that it is equal to the provided value

uglyog
2019-12-04 21:00
This is done by default by the pact verifier

yamuna.rani
2019-12-05 09:09
has joined #pact-jvm

yamuna.rani
2019-12-05 09:10
Hi Team..Can I pass the dynamic values to @Pact annotation? @Pact(provider = "Profile_Provider", consumer = "Profile_Consumer") I want to set the provider and consumer name from my property file. Is it possible ?

uglyog
2019-12-05 10:16
No, the `@Pact` annotation expects static values

m.kwiecien
2019-12-05 16:52
I used pact-jvm-provider-gradle and I got body match although I see in response from my provider when verifying pact that boolean value is false in case I expected true.

uglyog
2019-12-05 20:46
If you run with debug level logs, using the -d parameter, you should be able to see what the verifier is doing

hande.sagar
2019-12-06 09:21
I want to see tag name on pact provider and using below mvn command

hande.sagar
2019-12-06 09:21
mvn -Dtest=ClearingCaseDefinedPactTest clean test -Dpactbroker.host=http://kube-pact -Dpact.verifier.publishResults=true -Dpact.provider.version=9d0724ea6d5df37fcd3f5e97cb746de056297e29 -Dpact.tag=feature/FMCLS-338-pact-refinement

hande.sagar
2019-12-06 09:21
still I dont see tag name

hande.sagar
2019-12-06 09:21
could you please help me

justaburneremailforso
2019-12-06 16:28
I haven't tried it with mvn yet but I can get it to work by using the create version tag script mentioned here: https://github.com/pact-foundation/pact_broker-client/blob/master/README.md

ivangsa
2019-12-09 14:55
has joined #pact-jvm

justaburneremailforso
2019-12-10 09:25
Hello, I am trying to get mvn clean test to work with our broker. For some reason when I point to a broker with authentication switched on, I am getting a "Request to path '/' failed with response http/1.1 400 bad request" even when I use credentials. What dependencies do I need in my pom? The pact-junit example I was looking at seems to be based on gradle and not maven.

hande.sagar
2019-12-10 10:13
need some help

hande.sagar
2019-12-10 10:13
we can create tag using pact cli command - pact-broker create-version-tag -a clearing-events -b http://kube-pact -e a921988c106f6cfa8f19941656ff499d8a399b21 -t develop

hande.sagar
2019-12-10 10:13
do we have option to create such tag using mvn command

justaburneremailforso
2019-12-10 11:54
Got this resolved. We needed to set the scheme as Https and the full hostname in the @PactBroker annotation section of the junit class. Previously we were using a shortened hostname and not setting the scheme as anything. We are still using the @PactBrokerAuth authentication piece.

hande.sagar
2019-12-10 14:45
we can create tag using pact cli command - pact-broker create-version-tag -a clearing-events -b http://kube-pact -e a921988c106f6cfa8f19941656ff499d8a399b21 -t develop do we have option to create such tag using mvn command ?

nathan.deamer
2019-12-12 13:04
Does anyone have an example for a consumer PACT expecting a ZonedDateTime in the response?

hande.sagar
2019-12-12 14:44
we can create tag using pact cli command - pact-broker create-version-tag -a clearing-events -b http://kube-pact -e a921988c106f6cfa8f19941656ff499d8a399b21 -t develop do we have option to create such tag using mvn command ?

bart.schotten
2019-12-12 14:48
Sagar, have you read my email? I think we can conclude that it simply won't work like this. Please just use the workaround.

sam774
2019-12-13 20:28
has joined #pact-jvm

hande.sagar
2019-12-14 05:10
Hi Bart, yes I will set up an short call to understand it in better way... Thank you

anddreiu
2019-12-17 08:51
Hi @uglyog. Do you know when there will be a new release for pact-jvm? There are some nice fixes which were not released yet. Many thanks!

uglyog
2019-12-17 09:11
I?ll see if I can organise a release this week, other wise I?m away until mid January

anddreiu
2019-12-17 09:40
Ok, that would be very useful. Thanks a lot. And enjoy your holiday!

sam774
2019-12-17 11:43
I'm using pact-jvm with a spring boot test, and I'm currently seeing the following error: ```java.lang.NoClassDefFoundError: kotlin/TypeCastException at http://java.net.URLClassLoader.findClass``` Versions I'm using: pact-jvm 4.0.3 spring-boot 2.1.11-RELEASE kotlin (overridden) 1.3.61 I can't copy over the test exactly but it looks like, in short: ```@ExtendWith(PactConsumerTestExt.class) @SpringBootTest(classes=MyClassToTest.class) @AutoConfigureWebClient @PactTestFor(providerName = "provider", port = "8081") class ConsumerTest { @Autowired MyClassToTest client; @Pact(consumer = "consumer") public RequestResponsePact thePact(PactDslWithProvider builder) { return builder.given("a state") .uponReceiving("a thing") .path("/") .method("GET") .withRespondWith() .status(200) .body(... clipped ...) .toPact(); } @Test @PactTestFor(pactMethod = "thePact") public void myTest() { client.getTheThing(); } }``` So nothing out the ordinary. Anyone got any ideas what could be up?

sam774
2019-12-17 11:44
FWIW - Prior to manually adding in a kotlin version override in my pom, bumping from 1.2.something -> 1.3, the spring boot app was starting up, making the request and there was a NoSuchMethodError from the pact-jvm kotlin code thrown. So I don't think the problem is with the Spring Boot app I've written

uglyog
2019-12-17 22:26
I can't see anything wrong with your test class. Maybe raise an issue and provide the full stack trace and debug logs

loveshjain88
2019-12-18 01:54
has joined #pact-jvm

loveshjain88
2019-12-18 01:56
Hi All, I am using Pact JVM and trying to add header for every request when provider verifies it I added @TargetRequestFilter according to https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-junit#modifying-the-requests-before-they-are-sent-version-323245 but it is not getting called?

sam774
2019-12-18 08:09
Updating to 4.0.4 fixed this :party_parrot:

uglyog
2019-12-19 01:14
@loveshjain88 are you sure it is not being called? The examples from the Pact-JVM project work

uglyog
2019-12-19 01:17
Can you provide your test class?

loveshjain88
2019-12-19 02:08
@PactBroker @Provider("testConsumer") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @TestPropertySource(locations = "classpath:application-pact.yml") class TestClass { @LocalServerPort private int serverPort; @MockBean private ApplicationsController ApplicationsController; @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(PactVerificationContext context, HttpRequest httpRequest) { httpRequest.addHeader("Authorisation", "test"); context.verifyInteraction(); }

loveshjain88
2019-12-19 02:10
we are using Junit5 and Spring boot

loveshjain88
2019-12-19 02:10
and Mockmvc

uglyog
2019-12-19 02:12
@TargetRequestFilter doesn't work with MockMVC

uglyog
2019-12-19 02:12
With MockMVC, there is no actual request

loveshjain88
2019-12-19 02:15
I thought putting in the method annotated with @TestTemplate should work with Mockmvc and Junt5

loveshjain88
2019-12-19 02:15
as per the example

loveshjain88
2019-12-19 02:16
~@BeforeEach void setup(PactVerificationContext context) throws Exception { context.setTarget(new HttpTestTarget("localhost", serverPort)); } @State("a valid state") void validApplicationRequest() { when(applicationsController.createApplication( any(ApplicationRequest.class))). thenReturn(new ResponseEntity<>( new ApplicationResponse( UUID.randomUUID() )~

uglyog
2019-12-19 02:28
Oh, wait, you're not using MockMVC, you're using the HTTP to the actual provider

loveshjain88
2019-12-19 02:42
I am actually mocking the controller. I want to add the Authorisation header to every request? How can I achieve that?

uglyog
2019-12-19 02:43
With JUnit5, the correct way is to inject the request as you're example shows

loveshjain88
2019-12-19 02:45
but unfortunately its not working or else I am missing something?

uglyog
2019-12-19 02:45
What makes you think the header is not being set? I've just tested it, and it definitely works


uglyog
2019-12-19 02:47
If I change line 45 to ```request.addHeader("X-ContractTest", "false");``` the test fails with ```----------------------------------------------------------------------------------------------------------------------- | Closest stub | Request | ----------------------------------------------------------------------------------------------------------------------- | GET | GET /data | /data?ticketId=0000 | X-ContractTest: true | X-ContractTest: false <<<<< Header does not match | Query: ticketId [matches] 0000|1234|99987 | ticketId: 0000 | | -----------------------------------------------------------------------------------------------------------------------```

loveshjain88
2019-12-19 02:51
The request filter still shows null

uglyog
2019-12-19 02:52
requestFilter is not used by the JUnit5 library

loveshjain88
2019-12-19 02:55
If I check the header group, I can see the Authorisation header added

loveshjain88
2019-12-19 02:55
is that correct?

uglyog
2019-12-19 02:56
It looks correct to me

loveshjain88
2019-12-19 04:10
Thanks. It worked

loveshjain88
2019-12-19 04:10
There was something wrong in the controller implementation

sam774
2019-12-19 15:18
Hey - using pact-jvm is there a way to assert a json response contains a specific date format? Specifically YYYY-MM-dd. I was hoping that `date()` would do the trick, and without any further params generates the following matcher: ```{ "match": "date", "date": "YYYY-MM-dd" }``` But when I then run pact provider verification, I get an error because the generated value 2000-01-31 doesn't match exactly what's returned from the provider. I suspect that match: type is what I need, and was wondering if there's a better way than using a string matcher with a regex for YYYY-MM-dd formatted dates

uglyog
2019-12-19 21:41
The date matcher will try parse the string using the format pattern. What is the provider sending? Does it include timezones?

sam774
2019-12-19 22:20
The provider is sending "2019-12-19" without any timezone data.

uglyog
2019-12-19 22:30
Hmm, that should parse correctly then

uglyog
2019-12-19 22:31
what version of Pact-JVM are you using?

uglyog
2019-12-19 22:34
Also, can you check debug level logs? Those will show what the verifier is doing

sam774
2019-12-19 23:05
Will do in the morning! Using 4.0.4. thanks a lot :grin:

gaurav.singh55
2019-12-20 03:30
has joined #pact-jvm

sumeshs572
2019-12-21 01:17
has joined #pact-jvm

taisedias
2019-12-22 21:53
has joined #pact-jvm

abhilash.giridharan
2019-12-24 06:58
has joined #pact-jvm

mui_ume
2019-12-27 14:32
Hi I?m getting this error when I run my pact provider test - java.lang.NumberFormatException: null at java.base/java.lang.Integer.parseInt(Integer.java:620) at java.base/java.lang.Integer.parseInt(Integer.java:776) at au.com.dius.pact.provider.spring.SpringInteractionRunner.setupTargetForInteraction(SpringInteractionRunner.kt:103) at au.com.dius.pact.provider.junit.InteractionRunner$interactionBlock$statement$1.evaluate(InteractionRunner.kt:203)

mui_ume
2019-12-27 14:33
My pact test code snippet - import au.com.dius.pact.provider.junit.Provider; import au.com.dius.pact.provider.junit.State; import au.com.dius.pact.provider.junit.loader.PactFolder; import au.com.dius.pact.provider.junit.target.Target; import au.com.dius.pact.provider.junit.target.TestTarget; import au.com.dius.pact.provider.spring.SpringRestPactRunner; import au.com.dius.pact.provider.spring.target.SpringBootHttpTarget; import com.taiger.admin.AdminApp; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; @RunWith(SpringRestPactRunner.class) @Provider("Provider") @PactFolder("src/test/resources/pacts") @SpringBootTest(classes = AdminApp.class) public class AuthenticatePactTest { @TestTarget public final Target target = new SpringBootHttpTarget(); @State("Authenticate with valid clientId") public void authenticateTest() { System.out.println("Verifying AuthenticateTest"); } }

mui_ume
2019-12-27 14:34
My pact file in Json "body": { "accessToken": "xxxxerfhggtgggf", "timeLeftRefreshThresholdMs": 1800000, "authenticationErrorMsg": null },

sridevi_akshayapatra2
2019-12-30 17:26
has joined #pact-jvm

wesleythomaswilliams
2020-01-02 10:55
has joined #pact-jvm

swaroopshere
2020-01-03 00:28
has joined #pact-jvm

swaroopshere
2020-01-03 00:29
hello! im wondering if there is support for 'valueFromProviderState' usage in pact-jvm-consumer-java8 library? I am trying to define a json body in a POST request where I would like to inject certain string values while running the test on provider side.

gerrymcgovern
2020-01-03 15:43
has joined #pact-jvm

iaroslav.liashenko
2020-01-03 16:05
has joined #pact-jvm

brent_jackson
2020-01-03 17:01
has joined #pact-jvm

wesleythomaswilliams
2020-01-07 14:39
Hi all, quick question, using pact with junit5 and just want to double check the latest version of things. I have `pact-junit.version = 3.6.14` and the version of `pact-jvm-provider-maven = 4.0.0`

uglyog
2020-01-08 06:48
You should use the same major version. You can find the latest version at the pact-jvm GitHub page. I think it is 4.0.3

sam774
2020-01-08 10:41
I'm having some issues with pact jvm 4.0.4, where provider verification is failing. The following error is present in the logs: ```line 1:0 token recognition error at: 'nu' line 1:2 token recognition error at 'll' line 1:4 mismatched input '<EOF>' expecting {'next', 'last', 'now', 'today', 'yesterday', 'tomorrow', '+', '-'}``` That repeats another two times, which I suspect is because there's three `date` entries in the Pact. It's generated according to Pact spec v3.0.0, and the date matchers all look like this: ```"$.paidDate": { "matchers": [ { "match": "date", "date": "yyyy-MM-dd" } ], "combine": "AND" }``` and ```"generators": { "body": { ... clipped ... "$.paidDate": { "type": "Date", "format": "yyyy-MM-dd", "expression": "null" } ... clipped ... } }``` From the debug logs while I perform provider verification: ```method: POST path: <clipped> query: {} headers: {Content-Type=[application/json;charset=UTF-8]} matchers: MatchingRules(rules={header=<clipped>, body=Category(name=body, matchingRules={$.paidDate=MatchingRuleGrouyp(rules=[DateMatcher(format=yyyy-MM-dd)], ruleLogic=AND), <others>)}) generators: Generators(categories={BODY]{$.paidDate=DateGenerator(format=yyyy-MM-dd, expression=null), <others>}) body: PRESENT({"paidDate":"2020-01-08",<others>}) Received response: HTTP/1.1 400``` Anyone have any ideas what may be causing this?

sam774
2020-01-08 10:43
fwiw the dates here are in the body of the POST request

abubics
2020-01-08 23:29
nfi, but `"expression":"null"` seems hinky :thinking_face:

sam774
2020-01-09 06:52
It's auto-generated but I manually removed that and it made no difference

muppasaikarthik964
2020-01-09 09:28
has joined #pact-jvm

wesleythomaswilliams
2020-01-09 15:47
Thanks

wesleythomaswilliams
2020-01-09 17:06
Hi all, I'm trying to get pact-jvm and pact flow working together in a maven, junit5 spring environment. I've managed to publish my pact from my consumer to pact flow with `mvn pact:publish` . However, on the provider side I can't get verification working using maven. I can run my provider test directly using junit and it successfully verified a local pact or a pact stored on pact flow, but I can't get `mvn pact:verify` to work for either. ```@ExtendWith({ SpringExtension.class, MockitoExtension.class }) @Provider("wes_service") @EnableAutoConfiguration @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = { wesSearchControllerV1.class }) @TestPropertySource(properties = "server.port=1337") @PactBroker( host = "http://wesley.pact.dius.com.au", scheme = "https", port = "443", authentication = @PactBrokerAuth(token = "<token>")) public class PactProviderTest { @LocalServerPort private int port; @MockBean private wesWrapperService wesWrapperService; @MockBean private ValidationService validationService; @BeforeEach void setupTestTarget(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", port, "/")); } @Testweslate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestweslate(PactVerificationContext context) { context.verifyInteraction(); } @State({"provider returns a wes"}) public void findByIdentifier_get() { // State final Identifier eanIdentifier = Identifier.builder() .alias("<key>") .value("<value>") .build(); final wesWrapper wesWrapper = wesWrapper.builder() .wes("<value>") .identifiers(Stream.of( eanIdentifier ).collect(Collectors.toSet())) .aliases(Stream.of( "<value>" ).collect(Collectors.toSet())) .build(); when(wesWrapperService.findByIdentifierAlias(eanIdentifier.getAlias(), eanIdentifier.getFirstValue())).thenReturn(wesWrapper); } }``` Pom ```<!-- Pact --> <plugin> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.4</version> <configuration> <pactBrokerUrl>https://wesley.pact.dius.com.au</pactBrokerUrl> <pactBrokerToken>mytoken</pactBrokerToken> <pactBrokerAuthenticationScheme>Bearer</pactBrokerAuthenticationScheme> <serviceProviders> <serviceProvider> <name>sain_service</name> <protocol>http</protocol> <host>localhost</host> <port>1337</port> <path>/</path> </serviceProvider> </serviceProviders> </configuration> </plugin>``` Result ```Verifying a pact between consumer_service and provider_service [from Pact Broker https://wesley.pact.dius.com.au/pacts/provider/provider_service/consumer/consumer_service/version/0.0.4] Given provider returns a thing WARNING: State Change ignored as there is no stateChange URL a request to get a thing Request Failed - Connect to localhost:1337 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused) [WARNING] Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true') Failures: 0) Verifying a pact between consumer_service and provider_service - a request to get a thing Given provider returns a thing Connect to localhost:1337 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)```

rikeshgohil
2020-01-10 10:33
has joined #pact-jvm

wesleythomaswilliams
2020-01-13 12:08
@uglyog If you have any bright ideas on what I might be missing here, they'd be much appreciated. I've been continuing to work on a solution, but not getting far. I'm wondering if it's related to the my dependencies and runner. My pom now has these dependencies: ``` <dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-junit5</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-spring</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency>``` And I've tried playing around with the annotations in my provider test. Latest is: ```@RunWith(SpringRestPactRunner.class) @Provider("sain_service") @EnableAutoConfiguration @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = { SainSearchControllerV1.class }, properties = { "server.port=1337" }) @PactBroker( host = "http://wesley.pact.dius.com.au", scheme = "https", port = "443", authentication = @PactBrokerAuth(token = "fTXDVdhGOlKunW_wIPDn3w"))``` But still can't get a connection to the provider when run via Maven (running via junit still works fine). My knowledge of Spring and Maven are limited as it's all quite new to me.

anders
2020-01-13 17:58
has joined #pact-jvm

anders
2020-01-13 17:59
Hello. I am trying to specify (in Java) an expectation in a pact interaction that a response should contain an object with an ISO8601-formatted date-time. `io.pactfoundation.consumer.dsl.LambdaDslObject` is the relevant class, and it contains several alternatives, but I can't figure out which is correct. Firstly, there is the `dateTimeExpression` method, which takes a `String expression` as its second argument. I've been trying to figure out how this method works and find some documentation/examples of the possible values of `expression`, with no great success. I traced the source code until I reached `parseDateExpression` in https://github.com/DiUS/pact-jvm/blob/master/core/model/src/main/kotlin/au/com/dius/pact/core/model/generators/DateExpression.kt before I gave up, because I'm not about to start deciphering an actual parser. Can anyone here shed some light on what the `expression` parameter is and how it's meant to be used? (And an update to the documentation would also be useful for the next person.) Secondly, what is the difference between the `datetimeExpression` and `timestamp` methods on `LambdaDslObject`? When do you use which of the two?

kevinkontcheu
2020-01-13 22:37
has joined #pact-jvm

uglyog
2020-01-13 23:22
`dateTimeExpression` is for provider state injected values. See https://blog.pactflow.io/injecting-values-from-provider-states/ for more information. You should use `timestamp` for date-time values.

uglyog
2020-01-13 23:34
The JUnit Spring test framework is starting your provider before running your test. If you want to use the Maven plugin to run the verification, you need to have your provider started before it runs. One way of doing that is to use the integration test phase, which has a pre- and post- phase that can be used to start and stop your provider. You'll ned to work out how to bind the pact plugin to the integration test phase and find a plugin that can start your provider in the pre-integration-test phase. I would recommend using JUnit tests, though. You don't have to worry about starting and stopping the provider then.

wesleythomaswilliams
2020-01-14 09:27
@uglyog Apologies if I misunderstand this, but are you saying that the use of SpringBootTest is the main issue here because of the order of execution?

kevinkontcheu
2020-01-14 14:01
Hi there please i need help

kevinkontcheu
2020-01-14 14:02
```return builder .given("first state") .uponReceiving("GET Request from consumer") .path(GEOFENCE_PATH) .method("GET") .willRespondWith() .status(200) .headers(headers) .body(".... ") .given("new state") .uponReceiving("POST Request from consumer") .path(GEOFENCE_PATH) .method("POST") .willRespondWith() .status(200) .headers(headers) .body(".....").toPact();```

kevinkontcheu
2020-01-14 14:04
I'm trying to write some Tests with Pact but i have the following problem: When i just have one Interaction it's working well but when i try to add one more Transaction the tests are falling apart and i have this: http://au.com.dius.pact.consumer.PactMismatchesException: http://au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: method: GET path: /api/XX/locations/1234/geofences query: [:] headers: [:] matchers: MatchingRules(rules=[path:Category(name=path, matchingRules={})]) generators: Generators(categories={}) body: OptionalBody(state=MISSING, value=null)

kevinkontcheu
2020-01-14 14:05
Here are the test ```@Test @PactVerification() public void getGeofenceByLocationId_shouldReturn200WithProperHeaderAndBody() { // when ResponseEntity<GeofenceGetDTO> response = new RestTemplate().getForEntity( mockProvider.getUrl()+GEOFENCE_PATH, GeofenceGetDTO.class ); // then assertEquals(HttpStatus.OK,response.getStatusCode()); }``` Please can someone tell me what si wrong with this? Thanks

kevinkontcheu
2020-01-14 14:06
```@Rule public PactProviderRuleMk2 mockProvider = new PactProviderRuleMk2("provider", "localhost",8888, this);``` I',m using the Rule annotation to start the mockserver

wesleythomaswilliams
2020-01-14 15:34
Chatting with our dev team here, it seems my desire to execute with `mvn pact:verify` was unnecessary. The test executes perfectly as part of our unit tests executed with `mvn clean install` . Thanks for the assistance, I'm sure I'll have more questions as we move forward. Once we've got rest working, we'll be trying pact with kafka.

s1apped
2020-01-14 21:43
Hi. After publishing contract to pact-broker I'm seeing below message `Could not parse the following content to a Pact due to TypeError no implicit conversion of String into Integer, showing raw content instead` When I try to run provider verification it fails with below but when I run locally using @PactFolder everything works. ```http://au.com.dius.pact.provider.junit.MissingStateChangeMethod``` Looks like there is some issue with regex / matchPath ```return builder .given("This is valid regex") .uponReceiving("Some test request") .matchPath("/test/1/regex/(this|that)") .method("GET") .willRespondWith() .status(200) .toPact();``` Above will fail with error but when I replace matchPath with path it will work ```.path("/test/1/regex/this")``` Anyone have any ideas what may be causing this? Thanks

uglyog
2020-01-14 22:27
You've added a second interaction for a POST request, but you test is only making the GET request. So the mock server is failing the test because it did not get all the expected requests.

uglyog
2020-01-14 22:30
How are you running the verification? Using JUnit or Gradle/Maven?

s1apped
2020-01-15 06:39
using junit


wesleythomaswilliams
2020-01-15 09:35
I get the following message: ```Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')```

s1apped
2020-01-15 11:36
more precise junit5

antonello
2020-01-15 17:27
```<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <redirectTestOutputToFile>true</redirectTestOutputToFile> <testSourceDirectory>src/test/java</testSourceDirectory> <systemPropertyVariables> <pact.provider.version>${pact.pacticipantVersion}</pact.provider.version> <pact.verifier.publishResults>false</pact.verifier.publishResults> <pact.provider.version.trimSnapshot>true</pact.provider.version.trimSnapshot> </systemPropertyVariables> </configuration> </plugin>```

antonello
2020-01-15 17:29
This works for us

swaroopshere
2020-01-15 22:58
hello, is there a configuration to enable debug logging in tests written with pact-jvm-consumer-junit5. Im currently running into errors while executing the contract on consumer side and would like to debug it

swaroopshere
2020-01-15 23:04
oh turns out setting ```http://logging.level.au.com.dius.pact=DEBUG``` in application.properties worked

uglyog
2020-01-15 23:26
The `MissingStateChangeMethod` exception is normally thrown because you don't have a matching state change handler for your provider state `"This is valid regex"`. See https://github.com/DiUS/pact-jvm/blob/master/provider/pact-jvm-provider-junit/README.md#provider-state-callback-methods

uglyog
2020-01-15 23:29
You should also use the version of match path that takes an actual example path, i.e. `.matchPath("/test/1/regex/(this|that)", "/test/1/regex/this")`

shero86
2020-01-16 11:23
has joined #pact-jvm

s1apped
2020-01-16 14:41
I have @State set for every provider. Interesting thing is when I run test manually with @PactFolder everything works but gradle clean build test fails with http://au.com.dius.pact.provider.junit.MissingStateChangeMethod and in @TestTemplate during ```context.verifyInteraction();``` I'm really confused

alan.nichols
2020-01-16 15:40
has joined #pact-jvm

alan.nichols
2020-01-16 15:47
Hi all. Hoping to get some guidance on creating a PACT for an android application. When creating one for an iOS app, I can set it to type match everything in the body, meaning that I can just read in the body as a JSON blob. I see the same in some PACT docs here - https://docs.pact.io/getting_started/matching#type-matching. Is there a similar mechanism in the jvm version? Sorry if I've missed it when reading the docs!

wesleythomaswilliams
2020-01-16 17:49
Thanks @antonello, unfortunately that doesn't seem to work for me. What does work is including this in my provider tests: ``` @BeforeAll static void beforeAll() { System.setProperty("pact.verifier.publishResults", "true"); System.setProperty("pact.provider.version", "0.0.1"); }``` This isn't good though as really these need to be global settings and I don't want the provider version set manually. What am I missing @uglyog?

uglyog
2020-01-16 22:28
Do you want to just match the whole body, meaning the structure must match but the values don't need to?

fox_rul
2020-01-17 03:11
has joined #pact-jvm

s1apped
2020-01-17 08:59
looks like my issues is having state change methods in multiple classes...

alan.nichols
2020-01-17 09:50
Exactly yes. Sorry, that would have been a much better way of explaining it.

brook
2020-01-17 17:08
has joined #pact-jvm

uglyog
2020-01-18 23:20
Pact-JVM supports type matching, but there is no easy way using the DSLs to provide a JSON document and specify it should be matched by type. Maybe raise an issue at the GIthub project for this enhancement.

ssong
2020-01-20 02:17
has joined #pact-jvm

ssong
2020-01-20 02:19
Hi All, I have a question regarding to the provider Pact test. I'm using JUnit5, based on the samples provided from the github, I need to have `@PactFolder` annotation for the test class. Is there anyway I can have this value configured in the build.gradle file?

uglyog
2020-01-20 02:26
`@PactFolder` values can only be set at compile time

uglyog
2020-01-20 02:27
You should be able to create your own loader to do what you need

ssong
2020-01-20 02:36
Do I need to pass the loader to my test? how does that work?


ssong
2020-01-20 02:40
Got it. Thanks!

w.everse
2020-01-20 18:36
has joined #pact-jvm

antonello
2020-01-21 08:17
This is ?us? by the way!

uglyog
2020-01-21 23:19
Might be class path being different when run with Gradle. How where you running it when you test manually with @PactFolder?

nerea.tamayo
2020-01-22 08:41
has joined #pact-jvm

nerea.tamayo
2020-01-22 08:42
Hi! I'm trying to implement CDC with Pact, and I have a question....For verifying Pact (JVM) from the provider side, is it necessary that the provider is running?

jgfarias42
2020-01-22 09:51
has joined #pact-jvm

antonello
2020-01-22 14:20
@alessio.paciello and @emanuele.ivaldi have found that the property `pact.filter.consumers` does not seem to be applied when the entry point is junit.

emanuele.ivaldi
2020-01-22 14:20
has joined #pact-jvm

antonello
2020-01-22 14:58
However, there seems to be `pactbroker.consumers` , which works

antonello
2020-01-22 15:01
but it?s not documented :slightly_smiling_face:

sabil.beladri
2020-01-22 18:31
Hi, any hint on how to get rid of this failure I get from CI? `HeaderMismatch(headerKey=User-Agent, expected=Apache-HttpClient/4.5.5 (Java/1.8.0_202-release), actual=Apache-HttpClient/4.5.5 (Java/1.8.0_222)` I hardcoded the expected one in the contract definition (so it matches on my cpu: `.headers("User-Agent", "Apache-HttpClient/4.5.5 (Java/1.8.0_202-release)")` ) but I'd better extract this dynamically (so it matches on any cpu). Thanks in advance!

antonello
2020-01-22 22:14
@uglyog When you get a chance it would be good to get your input on this!

uglyog
2020-01-22 22:16
Yeah, I saw that one come through. Should be a simple fix

uglyog
2020-01-23 00:19
I don't think that the user agent header would be an important thing to add to your contract. It will change based on the HTTP client accessing your provider.

uglyog
2020-01-23 00:19
This will need to be fixed then

sabil.beladri
2020-01-23 07:39
Thanks for your feedback! It's clearer now the MockMVC provider side will have to handle this (otherwise I'm getting error upon trying to get a response with Spring), I wasn't too sure either to add it on consumer side or do some trickery on the provider side.

ankit992
2020-01-23 17:04
has joined #pact-jvm

antonello
2020-01-24 07:41
@uglyog would it possible to do a release of pact-jvm at some point soon?

uglyog
2020-01-24 09:03
Definitely, I?ll do one this weekend

sabil.beladri
2020-01-24 12:23
Hi, I'm back with a related doubt: how can we add headers (such as `user-agent`) following the MockMvc test examples provided in github repo [1] ? This test [2] seems to provide a way to inject headers, but it's building the request from scratch instead of retrieving it from pact broker (as in github readme examples). For now, we removed the user-agent header from the consumer declaration as we agree it's not needed there. But then we also had to make it *optional* from the controller to be able to validate the contract, since it's not clear how to inject this on provider test side :sweat: It's quite ok for user-agent but some other headers (e.g. locale) may be *mandatory* for the controller under test and different for each client running the test. So they would be excluded from the contract declaration and still would be needed for validation. Thanks for sharing your point of view on this topic! 1: https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-spring 2: https://github.com/DiUS/pact-jvm/blob/master/provider/pact-jvm-provider-spring/src/test/groovy/au/com/dius/pact/provider/spring/MvcProviderVerifierSpec.groovy

balthasarbiedermann
2020-01-24 13:01
I'm using pat-jvm with Spring Boot. I've just upgraded to Spring Boot 2.2.x and it seems like the Content-Type of the HTTP client changed from `application/json;charset=UTF-8` to `application/json`, which broke my contract test. I use a `PactDslJsonBody` and did not specify the `COntent-Type` in my pact at all. It looks like pact is implicitly expecting the `application/json;charset=UTF-8` content type. Can I change the pact definition to accept both?

g.van.vliet
2020-01-24 13:13
has joined #pact-jvm

antonello
2020-01-24 14:52
thanks!

swaroopshere
2020-01-24 23:52
Is it possible to define a Bodymatcher for Content-type "text/json"? In my Pact test, I run into this issue thats described in the foll logline - ```15:37:01.706 [Thread-15 ] DEBUG [-,,] [,] DEBUG a.c.d.p.c.m.Matching : No matcher for text/json, using equality : 15:37:01.707 [Thread-15 ] DEBUG [-,,] [,] DEBUG a.c.d.p.c.m.RequestMatching : Request mismatch: [BodyMismatch(expected=[B@64dbf925, actual=[B@5f40ca8, mismatch=Actual body '[B@5f40ca8' is not equal to the expected body '[B@64dbf925', path=/, diff=null)] : ``` I tried to look into the code in RequestMatching, Matching and MatchingConfig classes (as much as Intellij decompiler would let me look into), and it seems that in 'Matching' class, the code resorts to byte comparison when no matcher is found, which will obviously fail.

swaroopshere
2020-01-24 23:55
if I switch to 'application/json' Content-type, then I run into a different problem - ```[BodyMismatch(expected= ... (clipped text) mismatch=Type mismatch: Expected Map but received Primitive "{\"requestType\":``` Ive stripped out the payload, but it looks like the expected object is a json object, whereas the actual object is also a json object but in a String with escaped \" characters

uglyog
2020-01-25 04:45
Just set the content type to `application/json` and it will accept both

uglyog
2020-01-25 04:47
Looks like an issue with your implementation. The body should not be encoded as a String for JSON payloads

ankit992
2020-01-25 04:55
Has anyone figured out a way to use mockwebserver in android to generate the pact files? I need this to be able to run the UI tests of android on the base of the pact files generated

swaroopshere
2020-01-25 04:56
yeah turns out it was an implementation issue.

ankit992
2020-01-25 04:56
Currently we?re using unit tests to generate pacts, after that we start a pact server to run the urls on localhost and our ui tests from emulator hit the system on localhost to fill the loop

swaroopshere
2020-01-25 05:01
Does pact-jvm DSL support timestamp in 'milliseconds since epoch' format?


uglyog
2020-01-25 05:03
But 'milliseconds since epoch' is just an integer number

swaroopshere
2020-01-25 05:05
thank you @uglyog. I did use numberType in my definition for body. It seems the numberType does not really do type matching on consumer side? That timestamp field is not something I have control over, the system generates it, but I would like to ensure that it exists in the body, regardless of the value

uglyog
2020-01-25 05:07
It should do type matching on the consumer side. If you specify it as integerType, and you pass a string that will fail.

uglyog
2020-01-25 05:09
@abubics might be able to answer this one

swaroopshere
2020-01-25 05:14
hmm, here is a part of my definition ```.object() .numberType("joinedTimestamp") ....``` but when the test executes, it throws this error, along with a few other errors ```diff={ - "joinedTimestamp": 100, + "joinedTimestamp": 1579929027471, ... ...``` does this indicate that the type matching isnt happening?

uglyog
2020-01-25 05:19
Not necessarily, what is the actual message? That diff is because it is using a random value as you have not provided an example value, e.g. `.numberType("joinedTimestamp", 100)`

swaroopshere
2020-01-25 05:23
this is the message - ```21:10:28.137 [Thread-15 ] DEBUG [-,,] [,] DEBUG a.c.d.p.c.m.RequestMatching : Request mismatch: [BodyMismatch(expected="string", actual=null, mismatch=Expected null (JsonNull) to be the same type as "string" (JsonPrimitive), path=$.requestId, diff=null), BodyMismatch(expected={"joinedTimestamp":100,"app":"phone","notificationDelay":10000,"role":"Role","participantDevice":null,"subject":"005xx000001Svyg","highWatermark":null,"persistedId":null,"context":"Context","doNotReceiveOwnMessagesBack":false}, actual={"joinedTimestamp":1579929027471,"app":"phone","leftTimestamp":null,"notificationDelay":10000,"role":"Role","participantDevice":null,"subject":"005xx000001Svyg","highWatermark":null,"context":"Context","persistedId":null,"doNotReceiveOwnMessagesBack":false,"lastActiveTimestamp":null}, mismatch=Expected a Map with 10 elements but received 12 elements, path=$.participants.0, diff={ - "joinedTimestamp": 100, + "joinedTimestamp": 1579929027471, "app": "phone", + "leftTimestamp": null, "notificationDelay": 10000, "highWatermark": null, - "persistedId": null, "context": "Context", - "doNotReceiveOwnMessagesBack": false + "persistedId": null, + "doNotReceiveOwnMessagesBack": false, + "lastActiveTimestamp": null })] :```

uglyog
2020-01-25 05:26
The actual problem is `$.requestId` is null: Expected null (JsonNull) to be the same type as "string" (JsonPrimitive)

swaroopshere
2020-01-25 05:26
ah!

swaroopshere
2020-01-25 05:33
ok now i dont see the error for requestId anymore, but i see the BodyMismatch error from above logline. My DSL ensures there are 12 elements and the test request also has 12 elements

swaroopshere
2020-01-25 05:33
```21:27:26.988 [Thread-15 ] DEBUG [-,,] [,] DEBUG a.c.d.p.c.m.RequestMatching : Request mismatch: [BodyMismatch(expected={"joinedTimestamp":100,"app":"phone","notificationDelay":10000,"role":"Role","participantDevice":null,"subject":"005xx000001Svyg","highWatermark":null,"persistedId":null,"context":"Context","doNotReceiveOwnMessagesBack":false}, actual={"joinedTimestamp":1579930046352,"app":"phone","leftTimestamp":null,"notificationDelay":10000,"role":"Role","participantDevice":null,"subject":"005xx000001Svyg","highWatermark":null,"context":"Context","persistedId":null,"doNotReceiveOwnMessagesBack":false,"lastActiveTimestamp":null}, mismatch=Expected a Map with 10 elements but received 12 elements, path=$.participants.0, diff={ - "joinedTimestamp": 100, + "joinedTimestamp": 1579930046352, "app": "phone", + "leftTimestamp": null, "notificationDelay": 10000, "highWatermark": null, - "persistedId": null, "context": "Context", - "doNotReceiveOwnMessagesBack": false + "persistedId": null, + "doNotReceiveOwnMessagesBack": false, + "lastActiveTimestamp": null })] :```

swaroopshere
2020-01-25 05:33
does ordering of the elements in the request and the DSL matter?

uglyog
2020-01-25 05:38
No, but `Expected a Map with 10 elements but received 12 elements` means that this must be a consumer test? There are two extra attributes that were not expected.

swaroopshere
2020-01-25 05:42
yeah this is a consumer test

uglyog
2020-01-25 05:43
Then the matching will be strict, and not allow extra attributes

swaroopshere
2020-01-25 05:44
i see. Let me look again at my definition and the actual request that gets generated. Thank you for all your help @uglyog!

kevinkontcheu
2020-01-26 20:29
Please i need help. Can someone help me to write this JSON with PactDslJsonBody? I've tried some things but it's not working

kevinkontcheu
2020-01-26 20:29
{ "comment": { "commentaction": "UPDATE", "content": "content", "locationid": 1234, "locationname": "locationname", "username": "username" }, "geofencePoints": [ { "latitude": 1.0, "longitude": 1.0 }, { "latitude": 2.0, "longitude": 2.0 }, { "latitude": 3.0, "longitude": 3.0 } ] }

abubics
2020-01-27 22:17
it's been about 18 months since I did Android stuff . . . which mockwebserver is that? I'm pretty sure I just used regular Pact libs and Kotlintest with my API client class

abubics
2020-01-27 22:19
oh I see. No, I've never used Pact to spin up a mock server for Android. I just replaced my API client class in `androidTest` with a mock implementation

swaroopshere
2020-01-28 03:08
Ok so i have confirmed that I have defined 12 attributes for the object within an array. The request also has 12 attributes, so the number of attributes should have matched, but for some reason this exception keeps getting thrown. I wonder if this is an issue with RequestMatching? I am posting part of the DSL definition and also the exception log

swaroopshere
2020-01-28 03:08
DSL - ```.array("participants") .object() .numberType("joinedTimestamp",100) .stringType("app","phone") .numberValue("leftTimestamp", null) .numberType("notificationDelay", 10000) .stringValue("highWatermark", null) .stringValue("persistedId", null) .stringType("role", "Role") .stringType("context", "Context") .booleanType("doNotReceiveOwnMessagesBack", false) .stringValue("participantDevice", null) .numberValue("lastActiveTimestamp", null) .valueFromProviderState("subject", USER_ID_EXP,"005xx000001Svyg") .closeObject() .closeArray()```

swaroopshere
2020-01-28 03:09
Debug LogLIne - ```19:03:23.695 [Thread-15 ] DEBUG [-,,] [,] DEBUG a.c.d.p.c.m.RequestMatching : Request mismatch: [BodyMismatch(expected={"joinedTimestamp":100,"app":"phone","notificationDelay":10000,"role":"Role","participantDevice":null,"subject":"005xx000001Svyg","highWatermark":null,"persistedId":null,"context":"Context","doNotReceiveOwnMessagesBack":false}, actual={"joinedTimestamp":1580180603169,"app":"phone","leftTimestamp":null,"notificationDelay":10000,"role":"Role","participantDevice":null,"subject":"005xx000001Svyg","highWatermark":null,"context":"Context","persistedId":null,"doNotReceiveOwnMessagesBack":false,"lastActiveTimestamp":null}, mismatch=Expected a Map with 10 elements but received 12 elements, path=$.participants.0, diff={ - "joinedTimestamp": 100, + "joinedTimestamp": 1580180603169, "app": "phone", + "leftTimestamp": null, "notificationDelay": 10000, "highWatermark": null, - "persistedId": null, "context": "Context", - "doNotReceiveOwnMessagesBack": false + "persistedId": null, + "doNotReceiveOwnMessagesBack": false, + "lastActiveTimestamp": null })] : ```

swaroopshere
2020-01-28 03:16
it seems the the `.numberValue("leftTimestamp", null)` and `.numberValue("lastActiveTimestamp", null)` arent being recognized from DSL

uglyog
2020-01-28 03:23
oh, why you using nulls, should they not have actual numbers in those fields?

uglyog
2020-01-28 03:26
If you're expecting fields with nulls, you should use `nullValue` instead

swaroopshere
2020-01-28 04:15
ah! i see. let me try that out

swaroopshere
2020-01-28 04:32
yes `nullValue` worked. Thank you again!

kbsachin01
2020-01-28 17:05
has joined #pact-jvm

swaroopshere
2020-01-29 01:22
Hello, in my pact contract json file that gets generated after a consumer test passes, I see some issues with character encoding on certain characters. for Eg, a `.` is encoded as ```?``` in some places and as ```?``` in other places. also, `=` shows up as ```\u003d``` . I wonder if I need to specify a certain character set while generating pact file? I am using `pact-jvm-consumer-junit5` , `kotlin-stdlib` in my dependencies, build my app, run my tests via `maven clean package`

uglyog
2020-01-29 01:35
By default Pact-JVM uses UTF-8 for the pact files. Are you using a different character set for your data?

swaroopshere
2020-01-29 01:35
I dont think I am

swaroopshere
2020-01-29 01:36
is there a way to enforce/configure the UTF-8 charset for pactfile generation?

uglyog
2020-01-29 05:25
The default id UTF-8, there is no way to force that. You could try adding the UTF-8 chartype to your content type headers

juanma97perez
2020-02-03 11:30
has joined #pact-jvm

juanma97perez
2020-02-03 11:31
Hello, I have a little dude I want include headers in my request ``` Map<String, String> headers = new HashMap<>(); headers.put("Accept-Language", "es-ES"); return builder.given("get request") .uponReceiving("send get request") .path("/api/v1/locale/supported") .method("GET") .headers(headers) .willRespondWith() .status(200) .body(LambdaDsl.newJsonBody(o -> o .stringType("language", "es") .stringType("country", "ES") ).build()) .toPact(); }``` Without headers work correctly, but with headers, I have the next error: java.lang.AssertionError: Pact Test function failed with an exception, possibly due to Mismatches(mismatches=[PartialMismatch(mismatches=[HeaderMismatch(headerKey=Accept-Language, expected=es-ES, actual=, mismatch=Expected a header 'Accept-Language' but was missing)

juanma97perez
2020-02-03 11:31
I don't understand, because I'm only send headers, not comparing

simone.cusimano92
2020-02-03 11:35
has joined #pact-jvm

jemma.wells
2020-02-03 11:36
has joined #pact-jvm

jemma.wells
2020-02-03 12:49
Hi there. Having a bit of trouble with the matching using the DSL during verification, in particular with an array. The response we want to verify against looks something like this: ```{ "location": { "type": "Category", "categoryId": "12345", "filters": { "colour": [ "blue" ], "size": [ "small" ] } } }``` Within `filters` there could be one or many, and the name of the filter will always vary (though will always contain strings, which is what we want to check). At the moment, i can't seem to find a method that *won't* match on the name of the filter e.g. colour, size etc. I've tried a few things but at the moment i've gotten as far as the below: ```val filteredCategoryLocationJsonBody = PactDslJsonBody() .`object`( "location", PactDslJsonBody() .stringValue("type", "Category") .stringType("categoryId") .`object`( "filters", PactDslJsonBody() .eachLike("filterName", PactDslJsonRootValue.stringType())``` I know that in the above state, it will look for a name of 'filterName' but not sure what else to try/ what's best suited to this. All we really want to know is that anything coming back in the array has type String, or alternatively that if the `filters` object is present, that it isn't empty. Any suggestions? Thanks!

jemma.wells
2020-02-03 13:07
Just to add to this - i also tried using minArrayLike() to see if i could just check that it would at least be present, but it also seems to require a name, and then tries to check against it

matt.fellows
2020-02-03 22:33
Pact will check that the headers you said you wanted in the request were actually present. In your case, you said the ?Accept-Language? header would be sent in the request to `GET /api/v1/locale/supported` but it wasn?t present, so pact failed your test. Update your client code to send the header (if indeed it?s what you want) or remove it from the assertion

uglyog
2020-02-03 22:53
How is it not working? What error are you getting?

uglyog
2020-02-03 22:57
The idea would be to have different tests to check the various combinations that are important. That way each of your tests will define exactly what is expected.

ihor.dobrovolskyi
2020-02-04 11:30
has joined #pact-jvm

sumeshs572
2020-02-04 20:42
What is the actual use case of pact stub service? Can I use it as a request response mapping for api from pact file . I have a pact file in that all the request header and body is recorded how ever in integration tests I am passing different values in the body how can avoid the matching of dynamic values eg a date time stamp from matching for return the response?

asteffey
2020-02-04 20:45
has joined #pact-jvm

konrad.winkler
2020-02-04 21:31
has joined #pact-jvm

uglyog
2020-02-04 21:37
That?s exactly what the stub service was written for. It will match on the path, query parameters and headers, then return the first matching response

asteffey
2020-02-04 21:47
Hi! My team has been using Pact for the past several months and we just recently received approval to make open source contributions back to the project. To get started, I?m currently wrapping up 4 small PRs for pact-jvm. We plan to make some other contributions, especially related to XML, in the future. My team and I are looking forward to participating in the community.


sumeshs572
2020-02-04 22:27
How ever I am having an issue in matching a date time stamp value recorded on pact file , actual request body in integration test have a new value and complaining actual value x and expected y so not returning the response , can use the java refer for the matching rule

uglyog
2020-02-04 23:48
Can you provide the actual logs?

samuel.hodgkinson
2020-02-05 10:16
has joined #pact-jvm

samuel.hodgkinson
2020-02-05 10:18
Seen issues around providers in .Net for example, not supporting v3 matchers, so I was thinking it would be better if PactJVM didn't default to v3 spec (until all implementations support v3 fully) as it can cause issues when providers then come to verify those pacts.

sumeshs572
2020-02-05 15:11
This is the error while matching request

sumeshs572
2020-02-05 17:39
Do you have any reference examples for regex

uglyog
2020-02-05 20:50
That?s a different stub service. What one are you running?

sumeshs572
2020-02-05 20:51
Pact-1.77.0 cli version

uglyog
2020-02-05 20:57
That would be a normal mock server, and will validate the bodies. The one that does not is https://hub.docker.com/r/pactfoundation/pact-stub-server

sumeshs572
2020-02-05 21:00
Pact-stub-service I am using here

uglyog
2020-02-05 21:01
I?m not across what that one does. @bethskurrie will have more info

sumeshs572
2020-02-05 21:02
Thanks

sumeshs572
2020-02-05 21:10
@bethskurrie I am trying to figure out the requests mapping for a date time stamp value and another unique identifier

sumeshs572
2020-02-05 22:36
Do I need to use docker version or cli version 1.77.0 also works with matching rules

bethskurrie
2020-02-05 22:36
the format for v3 is supported, however, the new matching rules introduced in v3 aren't yet.

sumeshs572
2020-02-05 22:40
Regex and date format is supported right?

bethskurrie
2020-02-05 22:40
regex is, date format isn't

sumeshs572
2020-02-05 22:41
Ok

sumeshs572
2020-02-05 22:43
Even though I gave regex .* why it is complaining not matching could you please the above screenshot for matching rules

sumeshs572
2020-02-05 22:44
Review the above matching rules screenshot

bethskurrie
2020-02-05 22:54
I can't see a screenshot @sumeshs572

sumeshs572
2020-02-05 22:56
Are you able to see this

bethskurrie
2020-02-05 23:04
um, that's a really weird error message

bethskurrie
2020-02-05 23:04
it looks like it's doing a diff on the actual pact itself

bethskurrie
2020-02-05 23:04
not your requests.

bethskurrie
2020-02-05 23:05
If you can create a github project to recreate the issue, I'll have a look at it.

alan.nichols
2020-02-06 17:43
Hi all. I'm trying to set up some PACT consumer tests on our android app and ran into issues when trying to use the documented approach of making a retrofit client in a unit test and using that. We attach some headers using a network interceptor and I couldn't attach them in a way that would mirror any future changes to the production app without having to mock out the Context and many other things. I then tried to run the test as an Instrumented Unit Test, where I could get the okHttp client from the app and use that, but I've run into an error: ``` Caused by: java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/message/BasicHeaderValueParser; in class Lorg/apache/http/message/BasicHeaderValueParser; or its superclasses (declaration of 'org.apache.http.message.BasicHeaderValueParser' appears in /system/framework/org.apache.http.legacy.jar)``` The same config was running correctly when the test was a unit test so I'm thinking that there is something about how PACT is running that is conflicting with some http setup on the device? Has anyone else managed to run PACT tests as Instrumented Unit Tests? Any ideas of what to look into next would be greatly appreciated.

uglyog
2020-02-06 22:28
Pact-JVM uses the Apache HTTP client libraries, so the Instrumented Unit Tests must be changing the version of those libraries and causing that issue. I think that Android has it's own version of the Apache HTTP client which is not compatible.

uglyog
2020-02-06 22:30
I disagree with that. Pact-JVM has been V3 compliant for 3 years now. If there is no pain, the other language implementations will have no incentive to move and everyone will be stuck with V2

abubics
2020-02-06 22:37
Can you link the documented example with Retrofit? I'd like to see if it's similar to what I've done before :slightly_smiling_face:

audun.halland
2020-02-06 22:40
@audun.halland has left the channel


alan.nichols
2020-02-07 10:25
Ah that doesn't sound promising then :disappointed: I would have been perfect to use the same networking as the real app.

juanma97perez
2020-02-07 10:48
Hello

juanma97perez
2020-02-07 10:48
I have the next code:

juanma97perez
2020-02-07 10:48
```@RunWith(SpringRunner.class) public class HelloContractTest { @Rule public PactProviderRuleMk2 mockProvider = new PactProviderRuleMk2("poc-two", null, 8089, this); private RestTemplate restTemplate = new RestTemplateBuilder().rootUri("http://localhost:8089").build(); private final String BEARER_TOKEN = "Bearer eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJiNzky"; @Pact(consumer = "poc-one") public RequestResponsePact createContractPocOneTest(PactDslWithProvider builder) { Map<String, String> headers = new HashMap<>(); headers.put(HttpHeaders.AUTHORIZATION, BEARER_TOKEN); return builder.given("get request") .uponReceiving("send get request") .path("/api/v1/logger/hello") .method("POST") .headers(headers) .willRespondWith() .status(200) .matchHeader(HttpHeaders.CONTENT_TYPE, "application/json") .body(LambdaDsl.newJsonBody(o -> o .stringType("message", "hello") .stringType("defaultMessage", "hello") ).build()) .toPact(); } @PactVerification(fragment = "createContractPocOneTest") @Test public void givenGetRequestLocalesShouldReturnDefaultLocalesInMockProvider() { final HttpHeaders headers = new HttpHeaders(); headers.set(HttpHeaders.AUTHORIZATION, BEARER_TOKEN); final HttpEntity<String> entity = new HttpEntity<>(headers); ResponseEntity<Map> response = restTemplate.exchange("/api/v1/logger/hello", http://HttpMethod.POST, entity, Map.class); assertEquals(200, response.getStatusCode().value()); } }```

juanma97perez
2020-02-07 10:49
And when I execute this code, I have the next error:

juanma97perez
2020-02-07 10:49
org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://localhost:8089/api/v1/logger/hello": Connect to localhost:8089 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused); nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8089 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)

juanma97perez
2020-02-07 10:49
I don't know what is, I was 2 or 3 days with this error, help please :disappointed:

juanma97perez
2020-02-07 11:48
UPDATE: I am debugging and mockServer is null in PactProviderRuleMk2

wesleythomaswilliams
2020-02-07 13:46
@juanma97perez Whenever I've seen that kind of error, it's because my service wasn't available on the port specified. If you put a debug point on the line starting with `ResponseEntity<Map>` can you then try and hit your api via postman. If it fails, there's something wrong with your configuration that brings up your service. I'm far from an expert in all this and not sure if we're doing things the best way, but you may find it interesting to see how we do things with junit5 and spring for our contract tests in my team. ```@ActiveProfiles("pact") @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "consumer_service", port = "1337") @SpringBootTest(classes = { ConsumerRestClient.class, FeignClientConfiguration.class, JacksonConfiguration.class, FeignAutoConfiguration.class }) public class ConsumerServiceConsumerPactTest { private static String inboundConsumerServiceResponse; @Inject private ConsumerRestClient consumerRestClient; @Inject private ObjectMapper objectMapper;``` We then use our bootstrap.yml to define the pact profile (referenced in the @ActiveProfiles annotation): ```spring: profiles: pact consumer: url: localhost:1337``` As we use a FeignClient, that looks like this: ```@FeignClient(name = "consumer", url = "${consumer.url}", configuration = FeignClientConfiguration.class) public interface ConsumerRestClient { @RequestMapping(method = RequestMethod.PUT, value = "/v1/search/find-by-identifier?alias=sku&value={sku}&caller=service_name") ConsumerWrapperDtoV1 getConsumerWrapper(@PathVariable("sku") String sku); }``` At some point I'll put all this on a medium post. Hope some of that was useful.

sam774
2020-02-07 17:47
Has anyone had any thoughts about what a pact workflow, with the broker, looks like for a multi-module maven repository - where both the provider and consumer are modules within that same repo? Curious how this would play out, given a lot of maven commands tend to apply to all modules in a multi-module setup, unless you specify otherwise. And if you do have individual jobs for each module, there's an inherent dependency between jobs. (One answer is don't use multi module maven of course, but let's assume that isn't an option)

uglyog
2020-02-08 00:34
One argument could be that as they are both in the same project, there is less risk of drift between the consumer and provider. So Pact may not be needed in this case.

uglyog
2020-02-08 01:28
The other option is to run the consumer and provider builds separately. I'm pretty sure Maven can do that.

abubics
2020-02-08 05:23
Cool, thanks :slightly_smiling_face:

abubics
2020-02-08 05:26
I use different architecture and tooling, so my retrofit usage is a bit dissimilar (e.g. Kotlin, no repository pattern, no DI library, no Context param for Retrofit, etc)

abubics
2020-02-08 05:27
So I manually instantiate the retrofit client, and haven't had issues with Apache HTTP . . . I can check dependencies on historical projects maybe, and see if there's anything interesting, if you're still stuck

abubics
2020-02-08 05:28
but I use OkHttp, because that's what Retrofit came with, I think? Haven't had issues with interceptors not working, and I add Auth headers (for example) usually

ahmadw
2020-02-10 08:25
has joined #pact-jvm

alan.nichols
2020-02-10 09:58
Thanks for the info. Yeah I can attach interceptors but was looking for a way to not have to maintain these in the test to stop production getting out of sync with the tests.

ihor.dobrovolskyi
2020-02-10 10:47
Hello! Can you help me please! I need to create an array like: ```{ "field1":"test", "field2":"test", "field3":[ "string", "string" ] }``` How can I make this request using pact DSL? Thanks!!!


ihor.dobrovolskyi
2020-02-10 11:36
@wesleythomaswilliams Thanks

wesleythomaswilliams
2020-02-10 14:21
@uglyog If I want to drive my provider test execution with Maven and configure the Maven plugin with my PactBroker info as follows: ```<configuration> <pactBrokerUrl>https://wesley.pact.dius.com.au</pactBrokerUrl> <pactBrokerToken>jhgkdfbsdkjfbsdklbfdns</pactBrokerToken> <pactBrokerAuthenticationScheme>Bearer</pactBrokerAuthenticationScheme> ...``` How do I avoid getting this exception at runtime? `java.lang.UnsupportedOperationException: At least one pact source must be present on the test class` My assumption is that this is being generated because my test class doesn't have a `@PactBroker` or `@PactFolder` tag defined (which was intentional, as the info is defined in the pom)

wesleythomaswilliams
2020-02-10 16:03
Kept chipping away at this and my solution now looks like: ```@PactBroker( host = "${pact.broker.host}", scheme = "https", port = "443", authentication = @PactBrokerAuth(token = "${pact.broker.token}")) public class ProviderPactTest {``` ```<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <pact.broker.host>http://wesley.pact.dius.com.au</pact.broker.host> <pact.broker.token>jdsfjkhsdfkjhsdjdj</pact.broker.token> <pact.verifier.publishResults>true</pact.verifier.publishResults> <pact.provider.version>${version.number}</pact.provider.version> <pact.provider.version.trimSnapshot>false</pact.provider.version.trimSnapshot> </systemPropertyVariables> </configuration> </plugin>``` I seem to be able to remove the pact plugin entry from my Pom and everything seems to run fine with system properties defined in the surefire plugin.

uglyog
2020-02-10 22:25
You don't need the Pact Maven plugin if you're just using JUnit tests.

abubics
2020-02-10 23:27
Yeah, sounds like you can't use Apache http in that case :upside_down_face: so either allow the drift, or change http library in all places? I'm not sure

alan.nichols
2020-02-11 14:00
Thanks. I'm experimenting with using the android version in the tests by excluding some modules. Will see how that goes...

ahmadw
2020-02-12 07:06
Hi, ```"body": { "data": "succeeded", "responseStatus": { "description": "succeeded", "status": 1 } }``` How can i put a check on response attributes? for example i want to verify that ?data? is null or string!

iaroslav.liashenko
2020-02-12 10:25
Hi! I have pact tests for spring using: ```@RunWith(SpringRestPactRunner.class) @SpringBootTest``` but while executing mvn clean test, tests are executed(I could see failing requests in log) but results are not affect the test run: ```[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 15.905 s - in TestSuite``` Any Ideas how to solve it?

wesleythomaswilliams
2020-02-12 10:36
Our tests use junit/spring and maven and we use these annotations: @ActiveProfiles("pact") @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "<service_name>", port = "<port>") @SpringBootTest(classes = { ... })


alan.nichols
2020-02-12 10:52
Instrumented Unit test turned out to be a no go as I ran into an error with a JSON regex somewhere in http code not being parsable. I've moved back to a unit test using roboelectric and I'll see how that goes.

iaroslav.liashenko
2020-02-12 10:54
Ok, finally I tried everything. Issue is somewhere between junit5 and maven-surefire. https://dzone.com/articles/why-your-junit-5-tests-are-not-running-under-maven

iaroslav.liashenko
2020-02-12 10:54
this config works for me: ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.19.1</version> <dependencies> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-surefire-provider</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.1.0</version> </dependency> </dependencies> </plugin>```

wesleythomaswilliams
2020-02-12 10:57
I'm wondering if this would need to be addressed with some kind of fudge on the consumer side, so that you create multiple contracts for the consumer, one for each endpoint and name the provider for each contract to include the endpoint name. So they mention /example and /other endpoints. So on the consumer side, have separate tests to create separate contracts that look like: ``` { "provider": { "name": "<provider_name>_other" }, "consumer": { "name": "<consumer_name>" },``` ```{ "provider": { "name": "<provider_name>_example" }, "consumer": { "name": "<consumer_name>" },``` This then allows them to spit the provider tests. Not ideal, but could that work?

ahmadw
2020-02-12 11:31
```@PactBroker(host = "http://mashreq.pact.dius.com.au/", port = "8089", protocol = "https", authentication = @PactBrokerAuth(username = "Read/Write Toke", password = "abcd"))``` I am getting 401 error for this Pactbroker configuration, can anyone help


ahmadw
2020-02-12 11:36
i followed the same syntax

ahmadw
2020-02-12 11:36
scheme is now changed to protocol

matt.fellows
2020-02-12 11:37
mm, it would be nice if you could split the annotations across files at least. But within a consumer is probably hard. Might just be a code organisation thing (i.e. extract data fixtures out of the unit test into another place so it?s not so cluttered)

matt.fellows
2020-02-12 11:38
is it not working?

matt.fellows
2020-02-12 11:39
there should be a `scheme` attribute on the `authentication` property, and the password should be `""`

ahmadw
2020-02-12 11:39
i am using Junit and in @PactBroker annotation instead of scheme (Unable to resolved? it is now protocol.

wesleythomaswilliams
2020-02-12 11:40
This works for us: ```@PactBroker( host = "${pact.broker.host}", scheme = "https", port = "443", authentication = @PactBrokerAuth(token = "${pact.broker.token}"))```

matt.fellows
2020-02-12 11:42
I?ll get those docs checked if they?re out of date. Thanks Wes

ahmadw
2020-02-12 11:43
I am doing the same but scheme is not in scope i think

wesleythomaswilliams
2020-02-12 11:48
What version of pact are you using Ahmad? We're using 4.0.4. Wondering if that might be the issue?

ahmadw
2020-02-12 11:48
3.5.0

ahmadw
2020-02-12 11:56
I just updated to 4.0.5

ahmadw
2020-02-12 11:56
and it worked

ahmadw
2020-02-12 11:56
thanks Wes and Matt

neelofer.tamboli
2020-02-12 16:30
I am using au.com.dius:pact-jvm-provider-spring_2.12 version 3.6.14. I am having trouble getting the right provider version on pactbroker for a verified pact: 1. When `pact.provider.version` property is set, then the pact results are not published. 2. When `pact.provider.tag` property is set, then pact results are published to pactbroker but provider version is always 0.0.0 Am I missing something?

wesleythomaswilliams
2020-02-12 17:03
Are you running with maven? Can you share your pom?

neelofer.tamboli
2020-02-12 17:27
Using gradle: ```plugins { id 'java' id "http://au.com.dius.pact" version "3.6.14" } apply plugin: 'org.springframework.boot' bootRepackage { // spring boot is only used to use the application defined on the service module. onlyIf { false } } bootRun { enabled false } dependencies { testCompile( project('..'), "ma.glasnost.orika:orika-core:${orikaVersion}", "org.springframework.boot:spring-boot-starter-test:${springBootVersion}", "org.jolokia:jolokia-core:1.5.0", "au.com.dius:pact-jvm-consumer-junit_2.12:${pactVersion}", "au.com.dius:pact-jvm-provider-spring_2.12:${pactVersion}", 'oauth.signpost:signpost-commonshttp4:1.2.1.2', 'de.flapdoodle.embed:de.flapdoodle.embed.mongo:2.2.0' ) } test { systemProperty 'pact.rootDir', "$buildDir/pacts" systemProperty 'spring.profiles.active', "local" systemProperty 'spring.config.location', "${rootProject.rootDir}/config/" systemProperty 'pactbroker.host', project.properties['pactbroker.host'] systemProperty 'pactbroker.port', project.properties['pactbroker.port'] systemProperty 'pactbroker.tags', project.properties['pactbroker.tags'] systemProperty 'pactbroker.protocol', project.properties['pactbroker.protocol'] systemProperty 'pact.provider.tag', project.version == "latest" ? scmVersion.version : project.version // Do not add the following as pact is not published, maybe try upgrading pact jvm library // systemProperty 'pact.provider.version', project.version == "latest" ? scmVersion.version : project.version systemProperty 'pact.verifier.publishResults', 'true' doFirst { println("Running contract tests.") } onlyIf { gradle.startParameter.taskNames.contains("contractTest") } } task contractTest() { dependsOn test } def pactVersion = project.version == "latest" ? scmVersion.version : project.version def isPullRequest = { return project.hasProperty('prNumber') && project.properties['prNumber'] != null } def pactTags = isPullRequest() ? [ project.properties['prNumber'], project.properties['pactTag']] : [ project.properties['pactTag'] ] pact { publish { version = pactVersion tags = pactTags pactDirectory = "$rootDir/contract-tests/build/pacts" pactBrokerUrl = project.properties['pactbroker.host'] pactBrokerUsername = project.properties['pactbroker.username'] pactBrokerPassword = project.properties['pactbroker.password'] } } pactPublish.dependsOn contractTest```

neelofer.tamboli
2020-02-12 17:31
My contract test files are: ```@RunWith(SpringRestPactRunner.class) @ContextConfiguration(classes = { ... }) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @PactBroker(tags = "${pactbroker.tags}") @Provider("...") @IgnoreNoPactsToVerify public abstract class ContractTest { ... }``` and ```@Consumer("...") @Category({ ContractTest.class }) public class SampleContractTest extends ContractTest{ ... }```

ileshdarji
2020-02-12 18:11
has joined #pact-jvm

wesleythomaswilliams
2020-02-12 22:16
I'll see if I can work out what's wrong in the AM here (UK). We use Maven, but I remember having the same problem, so I may be able to work it out. In the meantime, maybe @uglyog will have an idea.

jks
2020-02-12 22:23
Hello, I'm in the process of trying to create an enhancement for pact-jvm to allow 'ignore-order' matchers on arrays (XML and JSON). For example: ```"content": { #the expected message "array": [ #don't care about order { "id": "a", #must be a "status": "up" #must be up }, { "id": "b", #must be b "status": "down" #can be up or down } ] } ... "matchingRules": { "$.array": { "matchers": [ { "match": "ignore-order" # means array[0] and array[1] will refer to # elements of expected array, but could match # to any element of expected array } ] }, "$.array[*].id": { #this would look for an id element with a and another with b, in any order in actual "matchers": [ { "match": "equality" } ] }, "$.array[0].status": { #array[0] refers to first index with a in expected "matchers": [ { "match": "equality" } ] }, "$.array[1].status": { #array[1] refers to second index with b in expected "matchers": [ { "match": "regex", "regex": "up|down" } ] } }``` This is an enhancement that I could use in my current work and I've seen this type of request on other Pact forums. I've been successful in adding the 'ignore-order' matcher on the Consumer side (i.e. it gets generated in the pact file). Now I'm looking at the matching aspect in JsonBodyMatcher and XmlBodyMatcher. Is this slack channel the best venue to discuss the effort if I run into implementation questions (I already have one or two)? Or should I open up an issue on the pact-jvm GitHub site? Thanks!

uglyog
2020-02-12 22:26
This is changing the behaviour which needs to be able to be replicated in the other implementations. So a more general channel would probably be better. Maybe in #feature-requests? @bethskurrie, what do you think?

james.elsey
2020-02-12 23:10
has joined #pact-jvm

uglyog
2020-02-13 00:57
`pact.provider.tag` was implemented in version 4.0.1, so you might have to upgrade to a 4.x version

uglyog
2020-02-13 00:57
That looks like a defect with 3.6.14, which I think was fixed in the 4.x branch

neelofer.tamboli
2020-02-13 04:13
Thank you both of you. We will have to upgrade then. I quickly tried upgrading, but noticed there are some failures due to upgrade that we need to fix.

me1015
2020-02-13 17:03
has joined #pact-jvm

pact501
2020-02-14 00:03
has joined #pact-jvm

uglyog
2020-02-14 02:36
You can also raise an issue at https://github.com/pact-foundation/pact-specification to discuss it

ryan.dens
2020-02-14 16:27
:wave: Curious what people?s experiences are with the `PactDslJsonBody()` as a way to match response bodies from the provider in the contract of the consumer. My team and I have used this successfully in several simple cases in a way which results in clear, readable, and maintainable expectations. In general though, my team prefers to use our JSON serializer and the POJO objects we work with to build the expectations of our contract e.g. ```RequestResponsePact sendAppCreateWithSessionId(final PactDslWithProvider builder) { final Gson gson = new Gson(); return builder .uponReceiving("Description") .path("/api/v1.0/create") .body(gson.toJson(new Foo("name", "value")) .method("POST") .body(gson.toJson(new Message("Hello, name!"))) .status(200) .toPact();``` this helps us maintain our contract tests more easily. Recently, I ran into the situation where I have an expected body that is a rather complex JSON object, to the point that I would rather use the typesafety I get with using the objects constructors/builders rather than the artisanal representation with the `PactDslJsonBody`. However, one of the fields in an object several layers of composition deep is a field I would like to match using the `PactDslJsonBody`, because it is a `Set<String>` whose contents are subject to change by the provider and not important for the contract between the consumer and the provdider (an ideal case for `PactDslJsonBody.array().stringType("example").closeArray()`. Is there a way to provide matching expectations without using `PactDslJsonBody`? I would rather not have to build the expectations for this complex java object by hand

wesleythomaswilliams
2020-02-14 16:55
The first tests we wrote we just compared json and didn't use the PactDslJsonBody, but now I'm trying to get to grips with it so we can make use of matching and avoid comparing values. I've found it tricky to get the right syntax though.

ryan.dens
2020-02-14 16:59
Agreed. Really what I would like to be able to do is specify body matchers outside the context of the `PactDslJsonBody` object and not in the context of the `PactDslResponse.body(String)` API

ryan.dens
2020-02-14 17:44
If you look at the generated contract when you use `PactDslJsonBody`, the actual response object looks the same, but there?s a different section which describes the matchers for the body, so I don?t think there?s a reason why these two things couldn?t be defined separately

ryan.dens
2020-02-14 17:45
@uglyog Is the kind of contract specified above something that?s possible today? If not, is it a change you would welcome from the community?

ryan.dens
2020-02-14 18:35
I?m also curious how pact-jvm follow Postel?s laws in this realm, in particular the portion referenced in: https://docs.pact.io/getting_started/matching/gotchas#an-empty-hash-in-the-response-means-allow-any-hash

uglyog
2020-02-16 02:31
Yes, what PactDslJsonBody does is build up a normal JSON body and also keep a map of the matchers in a separate collection. There is no reason why you couldn't do that with a POJO.

ryan.dens
2020-02-16 04:03
Cool, I?ll see what I can do to make marchers and pojos play nice together, thanks!

abubics
2020-02-16 22:27
Back on the original question, I started using the Java 8 DSL (https://github.com/DiUS/pact-jvm/tree/master/consumer/pact-jvm-consumer-java8) a couple of years ago, in Kotlin, and I find it quite nice. Still not as good as a Kotlin-first DSL, but (with some sugar) very readable and moderately terse. Regarding matchers, I was using the Groovy DSL for some years before that, so I'm familiar with all the idioms (and baggage?) that came with that. I think siloing the matchers away from the structure might not help much. But I'd love to see what you come up with :slightly_smiling_face:

antonello
2020-02-16 23:22
We?ve recently discovered an issue where `PactRunner` causes a Spring `ApplicationContext` to be created even if the provider tests are filtered by `@Category`

antonello
2020-02-16 23:23
We think we have a fix for it.

antonello
2020-02-16 23:26
@uglyog We haven?t submitted it yet as the resident experts were discussing it reviewing it internally on Friday


baquinteros
2020-02-17 01:22
has joined #pact-jvm

yau.yik.shiung
2020-02-17 16:05
has joined #pact-jvm

yau.yik.shiung
2020-02-17 16:19
hi there would like to get some insight (right/wrong) on the following initiative that i am going to introduce: ? BDD/Cucumber test is often used in microservice isolation testing with by mocking the dependent services ? I am going to replace the current mock server (wiremock) with pact-jvm-server so that the "assumption" made on the mock request/response can be verified on the provider test ? Any potential downside by doing that ? Is this design violating contract testing ?

antonello
2020-02-17 22:18
@uglyog We didn?t merge this as we wanted to give you a chance to have a look first.

antonello
2020-02-17 22:19
We wouldn?t mind a release soon though. It would speed up our builds a lot :smiley:

sumeshs572
2020-02-18 14:19
I am getting this assertion error while running junit provider test , error related to content length header property already present . Have any one faced this error before , any idea ? I am unable to figure out this issue

uglyog
2020-02-18 22:40
You should never set the content-length header. Make sure it is not set in your pact file.

mail961
2020-02-19 07:46
has joined #pact-jvm

robin.vanwijngaarden_
2020-02-19 12:06
has joined #pact-jvm

carolyn.biggar
2020-02-19 17:54
. *pact.provider.version* value restrictions? We're trying to set the pact provider version using gradle when running provider verification tests, something like ```test { useJUnitPlatform() systemProperty 'pactbroker.auth.username', System.getenv('PACT_BROKER_USERNAME') systemProperty 'pactbroker.auth.password', System.getenv('PACT_BROKER_PASSWORD') systemProperty 'pactbroker.auth.scheme', 'basic' systemProperty 'pact.verifier.publishResults', 'true' systemProperty 'pact.provider.version', 'tomte7st' }``` (we'll be varying the version .. when we get it working) We've found the following values work and the pact is published to our broker: '123' 'tomte7st' 'BC26E131' 'bc26e1' However the following values do *not* work, the pact is *not* published to the broker: 'tomtest' 'TOMTEST' 'MEGATEST' What is going on? Is there some validation that requires the version to contain a number? This is problematic for us as we're planning to use the git short sha and there's no guarantee that i'll contain a number (although it often does). Please help? Here's our dependencies/versions: ```dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" testImplementation "org.junit.jupiter:junit-jupiter-api:5.4.2" testImplementation "org.junit.jupiter:junit-jupiter-params:5.4.2" testImplementation "org.junit.jupiter:junit-jupiter-engine:5.4.2" testImplementation "org.assertj:assertj-core:3.11.1" testImplementation "au.com.dius:pact-jvm-provider-junit5_2.12:3.6.11" }``` Thanks!

carolyn.biggar
2020-02-19 17:54
@thomas.shipley FYI

thomas.shipley
2020-02-19 17:54
has joined #pact-jvm

uglyog
2020-02-19 22:54
When you say the pact is not published, is there any logs or error messages? The version is not used by Pact-JVM, it is just passed on to the broker.

carolyn.biggar
2020-02-19 23:28
Hi @uglyog thanks for looking. We couldn't see any errors :thinking_face: `./gradlew build` completes successfully in both cases; I can't see any logging of the attempt to publish in either case (successful or unsuccessful), even when passing `--info`. Maybe there is somewhere else we should be looking for error logging? Thanks for any help! I know it's tricky to help without seeing the whole thing; at the moment it's part of a work project which I can't share as-is.

uglyog
2020-02-19 23:30
OK, I'm not aware of anything that requires numbers in the version, but I'll ask @bethskurrie.

carolyn.biggar
2020-02-19 23:31
Thank you!

uglyog
2020-02-20 00:10
So it may be because you are using an old version of the Pact Broker. Can you confirm the version you have?

bethskurrie
2020-02-20 00:12
The 400 error response is not being shown when publishing fails in pact JVM.

bethskurrie
2020-02-20 00:13
There's an issue raised for it.

bethskurrie
2020-02-20 00:13
The body will tell you what the validation error is.

bethskurrie
2020-02-20 00:13
I don't know if you're able to turn on verbose logging for the pact broker client at all?

bethskurrie
2020-02-20 00:14
But most likely, it is as Ron says, you have an old version of the broker.

bethskurrie
2020-02-20 00:15
It expected semantic versions, and it's possible that the successful versions were just able to be parsed by the version parsing library that was used

bethskurrie
2020-02-20 00:15
These days, we recommend using the git sha.

bethskurrie
2020-02-20 00:15
If you're on the docker pact broker, the just grab the latest one. It's all backwards compatible.

carolyn.biggar
2020-02-20 00:58
Thanks for the info! We should be able to check out the pact broker version tomorrow (UK time!), will report back when we?ve investigated there!

thomas.shipley
2020-02-20 09:44
Hi @bethskurrie and @uglyog I have just had a look at our broker version which we are running from https://registry.hub.docker.com/r/pactfoundation/pact-broker/tags?page=1 It is set to use latest and is currently running digest: *0eb289f8623b*. Which looks like the latest version of the broker.

thomas.shipley
2020-02-20 09:45
I will do some more investigation to see if I can find the error message in the response body as you suggest.

thomas.shipley
2020-02-20 11:28
I have just attached Charles proxy to the Gradle JVM so I can see the responses coming back from the broker when running the gradle task. This is the response body of a call to ```/verification-results``` ```{ "errors": { "provider_version": ["Version number 'TOMTEST' cannot be parsed to a version number. The expected format (unless this configuration has been overridden) is a semantic version. eg. 1.3.0 or 2.0.4.rc1"] } }``` I am a bit confused now? - reading through this thread it sounds like the broker code was updated in the latest version to not use the semantic approach. Which would suggest an old version of the broker. But as you can see from my last message we are using: `````` As our image.. Any ideas?

matthew.salt
2020-02-20 15:12
has joined #pact-jvm

matthew.salt
2020-02-20 15:13
Hello, I have a question about using pact with junit5. I would like a single consumer test to generate a single .json file with multiple interactions. I want to define the RequestResponsePacts in several ?pact methods? rather than a single chained DSL to male it easier to maintain. Each time I?ve tried though I only get a single interaction in my consumer json file. And tips on how I might be able to achieve this?

wesleythomaswilliams
2020-02-20 15:18
My consumer test: ```@ActiveProfiles("pact") @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "provider_service", port = "1337") @SpringBootTest(classes = { providerRestClient.class, FeignClientConfiguration.class, JacksonConfiguration.class, FeignAutoConfiguration.class }) public class providerServiceConsumerPactTest { private static final String EAN = "3611441502380"; private static final String INVALID_EAN = "JUNK"; private static String inboundproviderServiceResponse; @Inject private providerRestClient providerRestClient; @Inject private ObjectMapper objectMapper; @BeforeAll static void beforeAll() throws Exception { inboundproviderServiceResponse = StreamUtils.copyToString(new ClassPathResource("/json/pact/provider-service-find-by-identifier-response.json").getInputStream(), Charset.defaultCharset()); } @Pact(provider = "provider_service", consumer = "consumer_service") public RequestResponsePact validEanProvided(PactDslWithProvider builder) throws Exception { return builder .given("a valid ean is provided") .uponReceiving("a request to get a provider") .path("/v1/search/find-by-identifier") .query("alias=ean&value=" + EAN + "&caller=consumer") .method("GET") .willRespondWith() .status(200) .body(inboundproviderServiceResponse) .toPact(); } @Pact(provider = "provider_service", consumer = "consumer_service") public RequestResponsePact eanValueInvalid(PactDslWithProvider builder) { return builder .given("invalid ean in query params") .uponReceiving("a request to get a provider") .path("/v1/search/find-by-identifier") .query("alias=ean&value=" + INVALID_EAN + "&caller=consumer") .method("GET") .willRespondWith() .status(404) .toPact(); } @Test @PactTestFor(pactMethod = "validEanProvided") void testValidEanProvided() throws Exception { // State final InboundproviderWrapperDto expectedInboundproviderWrapperDto = objectMapper.readValue(inboundproviderServiceResponse, InboundproviderWrapperDto.class); // Test InboundproviderWrapperDto inboundproviderWrapperDto = providerRestClient.getproviderWrapper(EAN); // Assert assertEquals(expectedInboundproviderWrapperDto, inboundproviderWrapperDto); } @Test @PactTestFor(pactMethod = "eanValueInvalid") void testInvalidEanProvided() { // Test FeignException feignException = assertThrows(FeignException.class, () -> providerRestClient.getproviderWrapper(INVALID_EAN)); // Assert assertEquals(404, feignException.status()); } }```

wesleythomaswilliams
2020-02-20 15:18
My pact: ```{ "provider": { "name": "provider_service" }, "consumer": { "name": "consumer_service" }, "interactions": [ { "description": "a request to get a provider", "request": { "method": "GET", "path": "/v1/search/find-by-identifier", "query": { "alias": [ "ean" ], "value": [ "3611441502380" ], "caller": [ "consumer" ] } }, "response": { "status": 200, "body": { "provider": "6xkh4x0q", "identifiers": [ { "alias": "ean", "value": [ "3611441502380" ] } ], "aliases": [ "kb0w8tsa" ] } }, "providerStates": [ { "name": "a valid ean is provided" } ] }, { "description": "a request to get a provider", "request": { "method": "GET", "path": "/v1/search/find-by-identifier", "query": { "alias": [ "ean" ], "value": [ "JUNK" ], "caller": [ "consumer" ] } }, "response": { "status": 404 }, "providerStates": [ { "name": "invalid ean in query params" } ] } ], "metadata": { "pactSpecification": { "version": "3.0.0" }, "pact-jvm": { "version": "4.0.4" } } }```

sramakrishnan
2020-02-20 16:16
has joined #pact-jvm

sramakrishnan
2020-02-20 16:16
has joined #pact-jvm

sramakrishnan
2020-02-20 16:16
has joined #pact-jvm

matthew.salt
2020-02-20 17:45
Thanks. All looks good now!

paul.davies
2020-02-21 03:22
Thank you @bethskurrie and @uglyog for your help just now. You were correct. It was due to an older version of the gson open tracing. I?ve bumped that up to the current version and we?ve now got tests getting verified. Your super fast response and turn around are to be envied. Brilliant and thanks again!

alan.nichols
2020-02-21 10:03
Hi everyone. I?ve successfully created a proof of concept test and have a ci job to run them and publish to the broker. The pactPublish gradle task works locally but not on CI. Has anyone run into something similar? Looking for any extra info while I look into networking set up on CI boxes and AWS security groups.

uglyog
2020-02-21 10:18
Are there proxies on the CI server?

carolyn.biggar
2020-02-21 10:20
@bethskurrie is it possible the semantic version validation is still in the current version of the pact broker? If there is some config we can set to override it would you be able to point us in the direction of that? Many thanks!

sumeshs572
2020-02-21 11:34
Is there any way we can over ride some of the provider test matching equality comparison in provider tests

wesleythomaswilliams
2020-02-21 13:19
Hi @sumeshs572 can you give an example?

sumeshs572
2020-02-21 15:07
Are you able to see the screenshot attached

sumeshs572
2020-02-21 15:08
It?s saying no matches defined and using equality

sumeshs572
2020-02-21 15:09
One more question I have is publish the verification results it?s saying pact.verifier.publishresults disabled

sumeshs572
2020-02-21 15:09
How to enable that in the junit provider test or gradle build

wesleythomaswilliams
2020-02-21 15:38
I meant can you give an example, using your code of what you have today and what you're trying to achieve through overriding the matching. In regards to the pact.verifier.publishresults, we use Maven rather than gradle and we had to set a system property variable <pact.verifier.publishResults>true</pact.verifier.publishResults>. That was done inside our surefire plugin definition. I'm not sure if you can do something similar in Gradle?

sumeshs572
2020-02-21 16:03
I could pass as a system property

sumeshs572
2020-02-21 16:04
Next I am seeing this msg skipping publishing verification

wesleythomaswilliams
2020-02-21 16:23
Is a reason for skipping provided? Also, is there anyway you can run slack on your system, so you don't have to photograph the screen?

sumeshs572
2020-02-21 16:52
I don?t see any error as such,pact slack forum as of now blocked in office laptop :thinking_face:

bethskurrie
2020-02-23 23:15
Peeps, the amazing @uglyog has been on a productivity rampage. I'd like to highlight one of my favourite new features, which is that you can now pass in an arbitrary pact URL to be verified. This will support the "pact content changed" webhook workflow, allowing you to use webhook template parameters to pass the pact URL through from the webhook to the verification job, allowing you to get quicker and more accurate feedback on your changed pacts. Thanks Ron! https://github.com/DiUS/pact-jvm/issues/998


uglyog
2020-02-23 23:35
@carolyn.biggar could you get the version of the broker? It would be displayed in the headers that are returned

tjones
2020-02-24 01:13
Party! Thanks @uglyog!!

alan.nichols
2020-02-24 09:16
good idea. I?ll ask the team that configured them and see if there?s anything like that on there.

carolyn.biggar
2020-02-24 12:10
We believe it's the latest (see above) but my colleague @thomas.shipley will capture the response headers to be sure and update , thanks

thomas.shipley
2020-02-24 15:23
Sorry would like to give an update but having some issues getting the broker to start after we switched region on GCP. It seems to be sqllite related but not sure what is going on? as soon as I figure that out I shall update here.

nerea.tamayo
2020-02-24 15:50
Hi guys, when I try to verfy the pact from the provider site, I get this error Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)

nerea.tamayo
2020-02-24 15:52
I?m using ```<groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.1</version>``` and my broker is provided by PactFlow

nerea.tamayo
2020-02-24 15:52
Do you have any idea about it?

nerea.tamayo
2020-02-24 15:52
Thanks

wesleythomaswilliams
2020-02-24 16:04
@nerea.tamayo Where have you defined your broker information? Url etc?

nerea.tamayo
2020-02-24 16:06
I have in the pom.xml

nerea.tamayo
2020-02-24 16:06
<plugin>                 <groupId>http://au.com.dius</groupId>                 <artifactId>pact-jvm-provider-maven</artifactId>                 <version>4.0.1</version>                                              <configuration>                     <serviceProviders>                         <serviceProvider>                             <name>sb-product</name>                             <pactBroker>                                 <url>https://myurl.pact.dius.com.au</url>                                 <authentication>                                     <scheme>bearer</scheme>                                     <token>tokenXX</token>                                 </authentication>                             </pactBroker>                         </serviceProvider>                     </serviceProviders>                     <pactBrokerUrl/>                 </configuration>             </plugin>

wesleythomaswilliams
2020-02-24 16:07
@nerea.tamayo Ok, I think I know the problem you're facing. Can you show me how your verification test on the provider is accessing the broker details? e.g. In my test, I have: ```@PactBroker( host = "${pact.broker.host}", scheme = "https", port = "443", authentication = @PactBrokerAuth(token = "${pact.broker.token}"))```

nerea.tamayo
2020-02-24 16:13
Sure

nerea.tamayo
2020-02-24 16:13
this is what I have

nerea.tamayo
2020-02-24 16:13
```@RunWith(PactRunner.class) @Provider("sb-product" ) @VerificationReports({"console", "markdown"}) @PactBroker(host = "https://myurl.pact.dius.com.au", scheme = "https", port = "443", authentication = "TokenXX")```

wesleythomaswilliams
2020-02-24 16:21
@nerea.tamayo Ok, so we're doing things a little differently (we are using Maven, Junit5 and Spring) and as you're defining the broker information in both the plugin in the pom and the test, I'm not 100% sure the problem you're having is the same as the one we faced, but we've done this. 1. Completely removed the pact plugin from our pom (but kept the dependency declaration, see below). 2. Configured the broker etc via system property variables in the surefire plugin (see below). 3. Referenced those properties in our test (see previous). Pact dependencies in pom: ```<dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-junit5</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency>``` Surefire plugin config in pom: ```<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <pact.broker.host>http://xxx.pact.dius.com.au</pact.broker.host> <pact.broker.token>fTxxx</pact.broker.token> <pact.verifier.publishResults>true</pact.verifier.publishResults> <pact.provider.version>${pact.provider.version}</pact.provider.version> <pact.provider.version.trimSnapshot>false</pact.provider.version.trimSnapshot> </systemPropertyVariables> </configuration> </plugin>``` We've configured things this way as we found a problem with our tests picking up the correct broker details from the pact plugin definition in our pom. @bethskurrie alluded to a problem in this area, but we never managed to find out exactly what the cause is. However, if we move that config to the surefire plugin, everything worked fine for us. We also don't use PactRunner or the SpringPactRunner, relying on Junit5 and I think the runners were needed for Junit4? @uglyog is that right as I'm really unsure on that?

nerea.tamayo
2020-02-24 16:34
Thnaks a lot, you gave some steps to follow, so in spite of having some differences, I?ll try to adapt your solution to my project

nerea.tamayo
2020-02-24 16:34
thanks a lot!!

wesleythomaswilliams
2020-02-24 16:50
Hope it proves useful.

uglyog
2020-02-24 21:06
One thing to check is that your provider is actually running on port 8080. Is it a spring boot app?

uglyog
2020-02-24 21:07
Correct, the runners are for JUnit 4

bethskurrie
2020-02-25 05:54
@thomas.shipley are you using sqlite for a production pact broker instance?

bethskurrie
2020-02-25 06:15
Ok, @carolyn.biggar I think I've worked it out. I had thought that the `order_versions_by_date=true` configuration skipped the version number validation altogether, but it doesn't. It still checks that the version number fits one of the following formats `"%M.%m.%p%s%d", "%M.%m", "%M"`

bethskurrie
2020-02-25 06:16
This will basically pass if there's a digit anywhere in the version number.

bethskurrie
2020-02-25 06:16
People have been using git shas for years without any issues, and I think nobody has ever had a problem because the chances of a git sha *not* containing a digit are vanishingly small.

bethskurrie
2020-02-25 06:18
I think if you're using real data with real git shas (even short ones), you won't have a problem.

bethskurrie
2020-02-25 06:20
> It is set to use latest

bethskurrie
2020-02-25 06:22
@thomas.shipley we haven't yet introduced any breaking changes to the Pact Broker API, and it should auto upgrade the database without issue, but it's a bit dicey using `latest` nonetheless. I'd suggest to follow best practice, which is to choose a fixed tag for your docker configuration.

bethskurrie
2020-02-25 06:26
I've raised this issue @carolyn.biggar https://github.com/pact-foundation/pact_broker/issues/329 but I don't actually think it's a blocker for you, as I said.

thomas.shipley
2020-02-25 09:31
@bethskurrie - Ah ok - thanks for raising an issue. Agreed it is probably not a blocker and just something I noticed while testing and only using chars in my input strings. Also we are not going to be using sqlite for production - this was part of a investigation piece internally to decide if we should use pact for consumer-driven contract testing. We have decided to continue with it :party_parrot: - so we need to setup a production DB for it and I will be sure to not use the latest tag either - thanks for the tip :slightly_smiling_face:

thomas.shipley
2020-02-25 09:34
Oh and the issue I was seeing yesterday when trying to setup a new broker is nothing to do with Pact. It is something to do with our K8s environment - the sqlite DB didn?t setup correctly when using a mounted volume on the pod but did when using the pods local disk? it used to work in both scenarios :man-shrugging: - but we will be looking at setting up a production DB like postgres so this won?t be an issue.

nerea.tamayo
2020-02-25 09:55
yes, it?s an springboot application

thomas.shipley
2020-02-25 10:11
A colleague of mine did the maths on how likely it is to get a short sha without a digit.. from his message: _short sha?s are by default 7 chars in length, and made up of hex chars, so there?s a 6/16 chance of not getting a number for any 1 digit. thus the probability of not getting a digit in 7 characters is (6/16)^7 = 0.00104, or *0.1%*, or 1 in 1000 times you?ll see no digits in a default short sha_

carolyn.biggar
2020-02-25 17:21
Thank you Beth!

sumeshs572
2020-02-25 20:16
I have a quick question, like pact-stub service is there any alternative for the stub mock ?server because we have some permission issues in running stub cli service etc

sumeshs572
2020-02-25 20:25
Mainly I was looking for a Junit way for mock service

uglyog
2020-02-25 21:00
No, I don?t think there is. What are you trying to do? Would something like wiremock not work for you?

sumeshs572
2020-02-25 22:43
I am getting this error skipping publishing verification results even though I am passing the VM argument any idea why this publishing verification results not happening

uglyog
2020-02-25 22:46
For Gradle, it needs to be `-P` not `-D`

sumeshs572
2020-02-25 22:46
Ok

sumeshs572
2020-02-25 22:50
Tried it no luck

uglyog
2020-02-25 22:52
You have put it in the environement variables. What you should have done is edited the `-D` and changed it to a `-P`

sumeshs572
2020-02-25 22:57
IJ VM Argos and env variable did not worked argument worked now publishing the verification results to broker thanks :blush:

bethskurrie
2020-02-26 00:26
I'll try and get the fix out before you publish 1000 pacts then @thomas.shipley!

paulg4321
2020-02-27 07:22
has joined #pact-jvm

paulg4321
2020-03-02 05:44
Hey Guys, I was trying to implement pact in android following the https://github.com/DiUS/pact-workshop-android. Will anyone be able to tel me what does the the following log indicate . "http://java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:9292"

ankit992
2020-03-02 05:47
are you trying to run pacts as instrumentation tests.

paulg4321
2020-03-02 05:47
Nope. unit tests

paulg4321
2020-03-02 05:48
I am using version as per the sample app ```testImplementation "au.com.dius:pact-jvm-consumer-junit_2.11:3.3.6"```

paulg4321
2020-03-02 05:49
Wondering if this error has any relation with the PactProviderRule i am declaring in the test class..

paulg4321
2020-03-02 05:49
```@JvmField @Rule val mockProvider = PactProviderRule(PROVIDER, "localhost", 9292, this)``` This is how i am declaring the PactProviderRule in the test class

ankit992
2020-03-02 05:50
Can you check if something else is running on port 9292 on your system? Also if your code have a different url then this ? ``` service = new Service(networkModule.getRetrofit(mock(Context.class), "http://localhost:9292").create(Service.Api.class));``` and ``` public PactProviderRule mockProvider = new PactProviderRule("our_provider", "localhost", 9292, this);```

ankit992
2020-03-02 05:50
this should be fine

ankit992
2020-03-02 05:51
can you share on which url your service is sending requests in the http logs, you can also debug and check where the request is going ?

paulg4321
2020-03-02 05:53
INFO: --> GET http://localhost:9292/digital/utils/v1/appconfiguration?appName=sample&platformName=Android&appVersion=1.0.0&platformVersion=6.0&appBuildType=debug&timezone=Australia%2FMelbourne Mar 02, 2020 4:35:57 PM okhttp3.internal.platform.Platform log INFO: X-App-Platform: Android Mar 02, 2020 4:35:57 PM okhttp3.internal.platform.Platform log INFO: X-OS-Version: 7.0 Mar 02, 2020 4:35:57 PM okhttp3.internal.platform.Platform log INFO: X-App-Version: 1.0.0 Mar 02, 2020 4:35:57 PM okhttp3.internal.platform.Platform log INFO: --> END GET Mar 02, 2020 4:35:57 PM okhttp3.internal.platform.Platform log INFO: <-- HTTP FAILED: http://java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:9292 This is the info log i am getting when i run the test.

ankit992
2020-03-02 05:57
I?ll try to run the github sample here to see if i can replicate the issue

paulg4321
2020-03-02 05:58
Thanks Ankit .. I have the github sample as well. It just does run fine for me.

ankit992
2020-03-02 06:02
If that?s the case I can only suggest matching the code, and checking if you have something already on the port 9292 running [in case you was trying out the stub server for pacts too].

antonello
2020-03-02 18:31
@uglyog do you have any ideas on how to address https://github.com/DiUS/pact-jvm/pull/1036#issuecomment-593391506 in a different way?

avinash.eediga533
2020-03-02 23:38
has joined #pact-jvm

avinash.eediga533
2020-03-02 23:40
Hey guys Could any one please help me in setting up pact dir for kotlin based project

avinash.eediga533
2020-03-02 23:40
I?m new yo pact thingy

matt.fellows
2020-03-03 00:18
What have you looked at / tried so far?

avinash.eediga533
2020-03-03 00:20
Figured out thanks @matt.fellows

uglyog
2020-03-03 06:17
I'll have some time to look into this weekend

antonello
2020-03-03 06:58
:+1::skin-tone-2:

wesleythomaswilliams
2020-03-03 12:16
@uglyog for `mvn pact:publish` I see there are options for `-Dpact.consumer.version` and `-Dpact.tag` , which I've made use of when integrating with our pipeline. Additionally, I've also integrated the `can-i-deploy` command with our pipeline and that can take the pact broker url and token etc as options. As a result this means I have my pact broker details in two places, my pom and my stage definition in my pipeline groovy file. Ideally I'd like to avoid that duplication. So are there options for passing those values into pact:publish as I do with version and tag?

oleg.shuliak
2020-03-03 14:52
has joined #pact-jvm

oleg.shuliak
2020-03-03 15:06
Hey all. Sorry in advance for stupid question, but i'm very new to gradle and kotlin and, to be honest, it's complicated for me to understand how to publish pact contract to broker service. I've added to `build.gradle`file this code block ```pact { publish { pactBrokerUrl = 'https://localhost:9292' pactBrokerUsername = 'PACT' pactBrokerPassword = 'PACT' } }``` but I don't understand how to trigger this one from a test in Kotlin. Could you, please, show me at least the direction to search for right answer?

uglyog
2020-03-03 22:48
Could you raise a Github issue for that?

uglyog
2020-03-03 22:49
You don't trigger it from a test. You use the Gradle pactPublish task after all the tests have run. It will then publish any pacts files generated from the tests.

oleg.shuliak
2020-03-04 08:53
thanks a lot

jussi.saurio
2020-03-04 17:16
has joined #pact-jvm

oleg.shuliak
2020-03-05 08:59
good morning. Got stuck with PACT publishing verification step with Kotlin. Problem is that, when i run tests with `gradlew test`, test is passing using `Broker` service, but it doesn't publish verification results to PactBroker. This how i use BrokerService ```@PactBroker(host = "localhost", port = "9292", consumers = ["payrollDatevServiceForBroker"]) @PactBrokerAuth(username = "PACT", password = "PACT")``` And when i'm running `gradlew pactVerify` , test is publishing result, but everything is failing, because it doesn't get 200 status of response. This how my `build.gradle` looks like: ```pact { serviceProviders { payrollAttributeServiceForBroker { hasPactsFromPactBroker('http://localhost:9292', authentication: ['Basic', 'PACT', 'PACT']) } } }``` What am i missing? And is it possible to publish results from test, but not from gradle? Thanks in advance

smilewithvammy
2020-03-05 09:09
has joined #pact-jvm

oleg.shuliak
2020-03-05 10:13
solved. added this block and it works: ```val props = System.getProperties() props["pact.verifier.publishResults"] = "true" System.setProperties(props)```

tainguyen
2020-03-05 11:30
has joined #pact-jvm

tainguyen
2020-03-05 11:30
hello everyone

tainguyen
2020-03-05 11:31
would like to send a POST request, where the request body get value from provider state However I am facing the issue: The request body content is escaped after it is rebuilt by using value injected from provider state https://github.com/DiUS/pact-jvm/issues/1031 Does anyone help me to solve this problem?

tainguyen
2020-03-05 11:31
Thanks so much

oleg.shuliak
2020-03-05 12:48
Hi again. Got a question with BrokerService. When I'm running in locally - test can reach it to get the pact and everything works fine. But when i started to host in k8t cluster - i lost my access to the broker from test with this error -> `main.cdc.http.units.ContractVerificationTest > main.cdc.http.units.ContractVerificationTest > initializationError FAILED` `http://au.com.dius.pact.pactbroker.RequestFailedException: Request to path 'path to pact' failed with response 'HTTP/1.1 308 Permanent Redirect'` And i can access this `<path to pact>` from browser and even from postman without any issues. Any idea how to fix that?

tyler.rasor
2020-03-05 12:57
has joined #pact-jvm

reemadhiman92
2020-03-05 19:37
has joined #pact-jvm

uglyog
2020-03-05 22:31
I'll have some time this weekend to look into it

uglyog
2020-03-05 22:32
It's not following the redirect. Where is it redirecting to? You should just use that URL

tainguyen
2020-03-06 03:00
Thank you :slightly_smiling_face:

sjdl
2020-03-06 12:16
has joined #pact-jvm

sumeshs572
2020-03-06 15:13
Query regarding provider test the equality matching fails because pact response and actual provider response differ in multiple dynamic values in api response how we can override the provider equality matching rules ?

wesleythomaswilliams
2020-03-06 15:26
Hi Sumesh, can you give an example of the dynamic values you're referring to

sumeshs572
2020-03-06 16:08
Eg . Date time stamp dynamic value at the response time

wesleythomaswilliams
2020-03-06 16:22
I've made use of the PactJsonDSL matchers, so I have lines like: ```.datetimeExpression("dateCreated", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")```

sumeshs572
2020-03-06 16:23
Let me try this out and get back

phil.brock
2020-03-06 19:19
has joined #pact-jvm

phil.brock
2020-03-09 12:38
@phil.brock has left the channel

vasilisnx
2020-03-09 14:28
has joined #pact-jvm

antonello
2020-03-09 17:41
:point_up: Good to see it works again, but does it mean that the initialisation is not deferred though?

ahsan_bhai
2020-03-09 19:49
has joined #pact-jvm

ahsan_bhai
2020-03-09 19:49
I am looking for some clarification in regards to the recent fix for this issue: https://github.com/DiUS/pact-jvm/issues/768 I've tried to test with `4.0.7` with `@IgnoreNoPactsToVerify` annotation. I get NullPointerException on `PactVerificationContext`. It looks like `context` variable is still set to null when there are no pacts found in pact broker. ```@IgnoreNoPactsToVerify @ExtendWith(SpringExtension.class) @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT ) @Provider("invalid-provider") @PactBroker( host = "${pact.broker.host}", port = "${pact.broker.port}", tags = "${pact.consumer.tag}", authentication = @PactBrokerAuth(username = "${pact.broker.username}", password = "${pact.broker.password}") ) public class ProviderTests { @LocalServerPort private int serverPort; @BeforeEach void setupTestTarget(PactVerificationContext context) { System.out.println(context); // this returns null context.setTarget(new HttpTestTarget("localhost", serverPort, "/")); } }``` Does anyone have any idea how to NOT fail pact provider tests in JUnit5 when pacts cannot be found. I assume `IgnoreNoPactsToVerify` is for that purpose. But it just doesn't seem to work as desired with JUnit5.

jagmeet_randhawa
2020-03-09 19:57
has joined #pact-jvm

jagmeet_randhawa
2020-03-09 20:04
@ahsan_bhai I think there is something wrong in your code, did you try restarting the PACT server?

ahsan_bhai
2020-03-09 20:05
I don't think it has anything to do with PactBroker instance. I am getting NPE on this line: `context.setTarget(new HttpTestTarget("localhost", serverPort, "/"));`

uglyog
2020-03-09 20:59
@ahsan_bhai the context will be null if there is no pacts to verify, because there are no pacts hence no context. Just make sure you tests check for null values.

ahsan_bhai
2020-03-09 21:06
@uglyog that's what I figured. and just added null check. It worked like a charm. I appreciate your help. Thank you.

tainguyen
2020-03-10 04:26
Thank you for you update. However, I have been creating pacts using framework JUnit 3.6.11

tainguyen
2020-03-10 04:26
```au.com.dius:pact-jvm-consumer-junit_2.12:3.6.11```

tainguyen
2020-03-10 04:27
If I change to 4.0.7, I will update a lot.

tainguyen
2020-03-10 04:29
And after investigation, I think it also come from Consumer when generate expression


simone.cusimano92
2020-03-10 08:15
Hi everyone, I have implemented 2 Consumer Contract Test in a Java Application like this: ```@Pact(provider = "providerName", consumer = "consumerName") public RequestResponsePact generateContract(PactDslWithProvider builder) { RequestResponsePact responsePact = builder .given("Get a apple that exists") .uponReceiving("Retrieve the apple 123, which exists ") .matchPath(format("/apples/%s", "123")) .method(HttpMethod.GET.name()) .headers(this.getRequestHeaders()) .body("") .willRespondWith() .headers(this.getResponseHeaders()) .status(200) .body(this.getDummyResponseBody()) .given("Delete a apple that exists") .uponReceiving("Delete the apple 1234, which exists ") .matchPath(format("/compositions/%s", "1234")) .method(HttpMethod.DELETE.name()) .headers(this.deleteRequestHeaders()) .willRespondWith() .headers(this.getResponseHeaders()) .status(204) .toPact(); return responsePact; } @Test @PactVerification("providerName") public void test_1() { String responseFromCds = this.service.getAppleById("123"); assertThat(responseFromCds).isNotNull(); } @Test @PactVerification("providerName") public void test_2() { ResponseEntity<String> response = this.service.deleteEntities("1234"); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); }``` Both tests are failing with the following message: `http://au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received:` If I merge the two methods into one, it works: ```@Test @PactVerification("providerName") public void test_1() { String responseFromCds = this.service.getAppleById("123"); assertThat(responseFromCds).isNotNull(); ResponseEntity<String> response = this.service.deleteEntities("1234"); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); }``` As @wesleythomaswilliams and @matt.fellows adviced me, I want each test to fail independently of each other. More like this: ``` @Pact(provider = "provider", consumer = "consumer") public RequestResponsePact validThingProvided(PactDslWithProvider builder) { return builder .given("") .uponReceiving("") .path("") .query("") .method("GET") .willRespondWith() .status(200) .body(response) .toPact(); } @Pact(provider = "provider", consumer = "consumer") public RequestResponsePact thingValueInvalid(PactDslWithProvider builder) { return builder .given("") .uponReceiving("") .path("") .query("") .method("GET") .willRespondWith() .status(404) .toPact(); }``` Then tag your tests with `@PactTestFor(pactMethod = "validThingProvided")` `@PactTestFor(pactMethod = "thingValueInvalid")` Unfortunately, I'm using the following dependencies: ``` testCompile group: 'junit', name: 'junit', version: '4.12' testCompile 'au.com.dius:pact-jvm-provider-junit:4.0.6' testImplementation("au.com.dius:pact-jvm-provider-spring:4.0.6") testImplementation('au.com.dius:pact-jvm-consumer-junit:4.0.6')```

simone.cusimano92
2020-03-10 08:15
and @PactForTest is not present . I think this is a solution valid for JUnit 5. Could you please suggest the right configuration/solution for JUnit 4? :slightly_smiling_face: Thanks in advance!

s1apped
2020-03-10 10:33
Hi. I'm having issue running junit5 tests and latest pact consumer versions (4.0.6+). When running gradle test I'm getting below. It works just fine on 4.0.4 `FAILED org.junit.jupiter.api.extension.ParameterResolutionException at ExecutableInvoker.java:200` Any ideas? Thanks

phil.brock
2020-03-10 14:43
has joined #pact-jvm

jarmy
2020-03-10 16:04
has joined #pact-jvm

uglyog
2020-03-10 20:47
Could you create a issue on the GitHub project with the full stack trace?

uglyog
2020-03-10 22:31
JUnit4 @PactVerification annotation has a fragment attribute that works in the same way as the JUnit5 @PactForTest annotation

tainguyen
2020-03-11 03:54
Hi all

tainguyen
2020-03-11 03:56
Are there the way to define a pact with response body is Array may or may not empty

tainguyen
2020-03-11 03:56
something like: ```[{ "id": "001", "name": "John", "projects": [ { "id": 01, "name": "Project1" }, { "id": 02, "name": "Project2" } ] }, { "id": "002", "name": "Peter", "projects": [] } }]```

tainguyen
2020-03-11 03:59
The project may be empty. If it's not empty, I need to verify the "id", "name" exist

uglyog
2020-03-11 04:03
eachLike will check the items in the list, but not fail if it is empty

tainguyen
2020-03-11 04:06
thanks

tainguyen
2020-03-11 04:06
I will try

tainguyen
2020-03-11 04:42
it works. Thanks @uglyog

adamadiopzongo
2020-03-11 16:20
has joined #pact-jvm

timo
2020-03-12 08:41
has joined #pact-jvm

s1apped
2020-03-12 09:38
Hello. I have noticed below warnings when running consumer tests but everything seems to be working just fine. Am I missing something?

wesleythomaswilliams
2020-03-12 09:42
What does the matching rule look like that is creating the error (if you've identified it)?

s1apped
2020-03-12 10:14
look like all of them. Problem is that they are really straight forward `return builder` `.given("Test Case 1")` `.uponReceiving("GET request to retrieve Car details")` `.matchPath(format(SOME_PATH, "\\d+"))` `.method("GET")` `.willRespondWith()` `.status(200)` `.headers(RESPONSE_HEADERS)` `.body(LambdaDsl.newJsonBody((body) -> {` `body.numberType("id", 85);` `body.stringMatcher("country", [A-Z]{3}, "POL");` `}).build())` `.toPact()`

uglyog
2020-03-12 20:53
What version of pact-jvm are you using?

bsigney
2020-03-13 05:11
has joined #pact-jvm

bentstuart
2020-03-13 05:28
has joined #pact-jvm

bentstuart
2020-03-13 05:31
well. I see my github ticket is already here :sweat_smile:

ankit992
2020-03-13 05:33
Not really sure if it will work or not, but can you try chaining closeObject method call after stringType

bentstuart
2020-03-13 05:36
Didn't seem to help. But thanks for trying!

bentstuart
2020-03-13 05:40
https://blog.codecentric.de/en/2019/11/message-pact-contract-testing-in-event-driven-applications/ I'm trying to follow along with this fellas example. He is using Kotlin but should be more or less the same I imagine. I can't really tell if I am doing it right either. As Message is a class of the dius.pact package I presume some auto linking is happening there resulting in a callback (at-least trying to).

uglyog
2020-03-13 05:46
Looks like a defect, good thing you already created an issue for it

bentstuart
2020-03-13 05:57
I just added a little note to it btw. but all good. @uglyog thanks for your response. Could I pick your brain a little? Are my thoughts correct in that the linking works like this. You make a @pact function which defines what you expect to retrieve as the consumer. The @PactVerifyProvider function returns the 'actual data' passed into the the @test and would be the content of the message passed to the @Test callback function?

uglyog
2020-03-13 05:58
Yes, that sounds about right

bentstuart
2020-03-13 05:59
Ok cool and in the @Test you are comparing essentially the data the provider has passed in matches the pact files expectations

s1apped
2020-03-13 08:08
jUnit5 and pact 4.0.4

bradyzp
2020-03-13 21:38
has joined #pact-jvm

guidopio.mariotti10_d
2020-03-14 09:14
Hi, I'm the author of the PR up there :point_up_2:. I find incredibly useful to use the Kotlin DSL for pact, however, I start to think that the naming is not that intuitive. Would you be interested in a different proposal for the DSL? I'll also make sure that the existing one gets deprecated appropriately with support to migrate to the new one

uglyog
2020-03-15 00:50
The current one is for Java 8. For a pure Kotlin one, I would create a new module so that Java users are not affected

guidopio.mariotti10_d
2020-03-15 09:29
You would separate the Kotlin one from the Java one? :thinking_face: I'm not planning of rewrite it entirely, just adjusting the naming of some kotlin methods so that it looks nicer

simone.cusimano92
2020-03-16 18:59
Thanks @uglyog :muscle:

bentstuart
2020-03-17 00:29
Hey. Is there any example of doing type matching against the mock-server response? The example here has value matching https://github.com/DiUS/pact-jvm/blob/master/consumer/pact-jvm-consumer-junit5/src/test/java/au/com/dius/pact/consumer/junit5/ArticlesTest.java

bentstuart
2020-03-17 00:30
I am trying to think how I'd do the type matching against httpResponse.getEntity().getContent()

bentstuart
2020-03-17 00:31
maybe I'd need to convert it to Json and do a type match against each json property. I just don't want to re-invent the wheel if there is something already.

tausif2909
2020-03-17 11:06
has joined #pact-jvm

tausif2909
2020-03-17 11:23
Hello, I am looking for example to update request while running provider verification for below calls `/api/asset/1234` & `/api/assets?assetId=1234` .


tausif2909
2020-03-17 11:24
Somewhere I found the link https://github.com/DiUS/pact-jvm/blob/master/pact-jvm-provider-junit/README.md#modifying-the-requests-before-they-are-sent-version-323245 but content is no more available its throwing 404 NOT FOUND Can someone share the example to handle such cases?

tausif2909
2020-03-17 11:24
I tried to use request filters like below but it worked for updating path, not working for query parameters like `/api/assets?assetId=1234`.

tausif2909
2020-03-17 11:24
```@TargetRequestFilter public void updateRequest(HttpRequest request) throws Exception { HttpGet httpGet = (HttpGet) request; URIBuilder builder = new URIBuilder(httpGet.getURI()); builder.setPath(builder.getPath().replaceAll("/api/assets/20000", "/api/assets/" + mediaAssetId) .replaceAll("/api/assets/21000","/api/assets/" + rootGroupAssetId)); System.out.println("Built request is "+request); }```

tainguyen
2020-03-17 11:28
I am using .pathFromProviderState

tainguyen
2020-03-17 11:29
and queryParameterFromProviderState

tausif2909
2020-03-17 11:32
@tainguyen Could you please share example of that? consumer side & provider side both?

tainguyen
2020-03-17 11:32
public RequestResponsePact createPact(PactDslWithProvider builder) { return builder .given("user exists") .uponReceiving("A request to get user details") .path(/users) .queryParameterFromProviderState(id, "${userId}", "001") .method(HttpMethod.GET.name()) .willRespondWith() .status(HttpStatus.OK.value()) ) .toPact(); }

tainguyen
2020-03-17 11:34
On providerSite you will have: @State("user exists") public Map<String,Object> createUser() throws Exception { // write code to create user HashMap<String, Object> map = new HashMap<>(); map.put("userId", "005"); return map; }

tainguyen
2020-03-17 11:34
```dependencies { compile 'au.com.dius:pact-jvm-consumer-junit_2.12:3.6.11' }```

tausif2909
2020-03-17 11:36
ok, I believe this should be done at consumer side, How do I pass parmeterized request from provider verification ?

tainguyen
2020-03-17 11:37
On providerSite you will have: @State("user exists") public Map<String,Object> createUser() throws Exception { // write code to create user HashMap<String, Object> map = new HashMap<>(); map.put("userId", "005"); return map; }

tausif2909
2020-03-17 11:37
aaah ok, ,let me try that, thanks @tainguyen

tainguyen
2020-03-17 11:37
This will return values to consumer

tainguyen
2020-03-17 11:40
This is example on Git


tainguyen
2020-03-17 12:08
I am finding the way to update request body while running provider verification


tainguyen
2020-03-17 12:12
@uglyog I you have bandwidth, could you take a look at my comment and fix? Thanks

tainguyen
2020-03-17 12:13
Or if you have other solution to update request body while running provider verification, please share with me.

tainguyen
2020-03-17 12:13
My dependencies:

tainguyen
2020-03-17 12:14
```compile 'au.com.dius:pact-jvm-consumer-junit_2.12:3.6.14'```

tainguyen
2020-03-17 12:14
And on provider side: ```compile 'au.com.dius:pact-jvm-provider-junit:4.0.7'```

tausif2909
2020-03-17 13:15
I have updated my my dependencies ```<!-- https://mvnrepository.com/artifact/au.com.dius/pact-jvm-consumer-junit --> <dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-consumer-junit_2.12</artifactId> <version>3.6.11</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/au.com.dius/pact-jvm-provider-maven --> <dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven_2.12</artifactId> <version>3.6.11</version> </dependency>``` from `3.5.21` & `3.6.7` respectively, But Now it stopped generating pact files

uglyog
2020-03-17 23:55
That's not how it works. The mock server is the one doing the matching, and if everything matches it generates the response.

uglyog
2020-03-18 00:26
I'll have some time to look into Pact-JVM issues this weekend

tainguyen
2020-03-18 02:24
Thanks in advance

tainguyen
2020-03-18 02:30
I have no ideas, but i am working with gradle project

tainguyen
2020-03-18 02:34
And it's working well

tainguyen
2020-03-18 02:35
```<dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven_2.12</artifactId> <version>3.6.11</version> </dependency>``` You don't need to add this to consumer side

tausif2909
2020-03-18 04:53
ok, I just found that pacts gets generated under target folder.. before it was generated under user specified folder..

tausif2909
2020-03-18 05:29
Hello All, After upgrading pact dependency to `3.6.11` , All pacts are now generating by default under `target/pacts` folder instead of specified folders

tausif2909
2020-03-18 05:29
my code to specify pact location is like below

tausif2909
2020-03-18 05:29
```@Before public void setPactDirectory() { System.setProperty(PACT_ROOT_DIRECTORY_KEY, PACT_FASTOBJECTS_PATH); }```

tausif2909
2020-03-18 05:30
and all locations are defined under constant like below

tausif2909
2020-03-18 05:30
```/*** Pact settings ***/ String PACT_ROOT_DIRECTORY_KEY = "pact.rootDir"; String PACT_ENTERPRISE_PATH = "../AcceptanceTests/pacts/flex-enterprise"; String PACT_AUTHORISATION_PATH = "../AcceptanceTests/pacts/flex-authorisation-service"; String PACT_TAG_PATH = "../AcceptanceTests/pacts/flex-tag-service";```

tausif2909
2020-03-18 05:31
when I was on ``3.5.21`` it was working fine..

uglyog
2020-03-18 06:08
How are you running the tests?

tausif2909
2020-03-18 06:42
I am running by mvn command like: `mvn -B -Drevision=3.5.10 verify -P pact-tests -http://Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn`

tausif2909
2020-03-18 06:44
I have added path under my pom.xml file ```<systemPropertyVariables> <pact.rootDir>../AcceptanceTests/pacts/</pact.rootDir> <buildDirectory>${project.build.directory}</buildDirectory> [...] </systemPropertyVariables>``` But now its adding all service pacts in same folder.. my existing implementation was generating pact file on different folder for each service

tausif2909
2020-03-18 07:40
Any idea ?

tausif2909
2020-03-18 08:50
2

alan.nichols
2020-03-18 12:27
HI all, my pact test seems passes every time but only generates the contract file sometimes. Has anyone else experienced this?

s1apped
2020-03-18 14:49
Hi. Is it possible to use MockMVC with junit5 provider?

arho.huttunen
2020-03-18 18:57
has joined #pact-jvm

uglyog
2020-03-18 21:44
That's how it is designed to work, all pacts go to the same directory so they can all be published afterwards

adamadiopzongo
2020-03-18 22:20
Hi @here, is there a way to only publish contract verification results from pact-cli or PactFlow REST API?

uglyog
2020-03-18 22:33
Are asking how to skip the verification results if the pact is not loaded from Pactflow?

adamadiopzongo
2020-03-18 22:36
Hi here is my scenario: 1. Verify contracts from PactFlow from the UT (which generates the verifications results) 2. Use the pact-cli or curl (through rest) to push the verification results to PactFlow. I will need to have this call in my CI pipeline later. So I am looking for ways to do #2 above. Thanks!

uglyog
2020-03-18 22:46
You can, when the pact is fetched from pactflow, there are a list of associated links (it's in HAL format). One of the links is`*pb:publish-verification-results`*. You need to post the verifications results to HREF for that link. It is done for each pact file that is verified.

adamadiopzongo
2020-03-18 22:52
I have been trying that, but kept getting 400 Bad Request: ```> * Connection state changed (MAX_CONCURRENT_STREAMS updated)! * We are completely uploaded and fine < HTTP/2 400 < date: Wed, 18 Mar 2020 22:50:30 GMT < content-type: application/hal+json;charset=utf-8 < content-length: 144 < status: 400 Bad Request < vary: Accept < x-pact-broker-git-sha: d15fc575843d8587ba3f6e69cf153e723c30ac0a < x-request-id: cda19179b4ba5b871855ba0f3d4eea05 < x-saas-broker-git-sha: e1d7aaf2 < x-pact-broker-version: 2.51.0 < x-frame-options: SAMEORIGIN < x-xss-protection: 1; mode=block < x-content-type-options: nosniff < referrer-policy: strict-origin < strict-transport-security: max-age=31536000 ; includeSubDomains < * Connection #0 to host http://azongo.pact.dius.com.au left intact {"error":"Error parsing JSON - 783: unexpected token at 'content-delivery-service/target/pacts/reports/provider-content-delivery-service.json'"}```

adamadiopzongo
2020-03-18 22:53
Maybe there is something wrong with my Content-type?

uglyog
2020-03-18 22:53
> `'content-delivery-service/target/pacts/reports/provider-content-delivery-service.json'`

uglyog
2020-03-18 22:54
That looks like you are sending the file name, not the contents of the file

adamadiopzongo
2020-03-18 22:54
hum, yes indeed. Let me fix that and see?

adamadiopzongo
2020-03-18 23:06
Still 400, but now with the following error: ```{"errors":{"success":["can't be blank"],"provider_version":["can't be blank","Version number '' cannot be parsed to a version number. The expected format (unless this configuration has been overridden) is a semantic version. eg. 1.3.0 or 2.0.4.rc1"]}}%```

tausif2909
2020-03-19 13:26
Hi All, I am trying to use .queryParameterFromProviderState()` But I get below error while running the code.

tausif2909
2020-03-19 13:27
```Default ConstructorUnable to get Response...java.lang.IllegalArgumentException: Illegal character in query at index 42: http://localhost:8112/api/assets?assetId=${assetId}&includeDetails =true&page=0&limit=50 Caused by: http://java.net.URISyntaxException: Illegal character in query at index 42: http://localhost:8112/api/assets?assetId=${assetId}&includeDetails=true&page=0&limit=50 [ERROR] Failures: [ERROR] FastObjectsChildAssetsConsumerTest.doCreateGroupFirstLevelMemberResponse The following requests were not received: method: GET path: /api/assets query: [includeDetails:[true], page:[0], limit:[50]] headers: [:] matchers: MatchingRules(rules={}) generators: Generators(categories={QUERY={assetId=ProviderStateGenerator(expression=${assetId})}}) body: MISSING```

tausif2909
2020-03-19 13:28
& my code is like below:

tausif2909
2020-03-19 13:28
``` @Test @PactVerification(fragment = "createGroupFirstLevelMemberResponse") public void doCreateGroupFirstLevelMemberResponse() { log.debug("port is: {}", provider.getPort()); String params = "?" + "assetId=" + "${assetId}" + "&" + "includeDetails=true" + "&page=0" + "&limit=50"; new CustomClient().getResponse(FAST_OBJECTS_API_PATH + GET_ASSETS+params); } @Pact(provider = FLEX_FASTOBJECTS_SERVICE, consumer = FLEX_PUBLISHINDEXER_SERVICE) public RequestResponsePact createGroupFirstLevelMemberResponse(PactDslWithProvider builder) throws JsonProcessingException { Asset memberAsset = assetCreator.createGroupAsset(FIRST_LEVEL_GROUP_ASSET_CHILD, ACCOUNT_ID, AUTHORISED_USER_ID, "firstLevelGroupAsset"); AssetList assetList = new AssetList(Lists.newArrayList(memberAsset)); return createMediaAssetResponse(builder, assetList, "rootGroupFirstLevelMember"); } private RequestResponsePact createMediaAssetResponse(PactDslWithProvider builder, AssetList assetList, String responseName) throws JsonProcessingException { Map<String, String> headers = Maps.newHashMap(); headers.put("Content-Type", "application/json"); return builder .given("There is a request to get the assets " + responseName) .uponReceiving("Returns the assets " + responseName) .path(GET_ASSETS) .method("GET") .queryParameterFromProviderState("assetId","${assetId}","10000") .query("&includeDetails=true&page=0&limit=50") .willRespondWith() .status(200) .headers(headers) .body(objectMapper.writeValueAsString(assetList)) .toPact(); }```

tausif2909
2020-03-19 13:29
Can you suggest, What is wrong with above code

tausif2909
2020-03-20 04:53
Can any one help on this please ?? :point_up_2:

uglyog
2020-03-20 04:56
You're not passing a value for assetId in your query string


uglyog
2020-03-20 04:58
See, assetId = `${assetId}` which is creating an invalid URL, so your CustomClient is not actually making the request

tausif2909
2020-03-20 06:24
@uglyog Could you please suggest me how do I do that?? Where exactly I need to pass the value for assetId?

uglyog
2020-03-20 06:25
What is the assetId? It is a value to you need to pass to your provider.

tausif2909
2020-03-20 06:53
assetId is `21001` @uglyog

uglyog
2020-03-20 07:02
Then you should use that value

tausif2909
2020-03-20 12:14
```While trying to publish pact I get below error [ERROR] Failed to execute goal au.com.dius:pact-jvm-provider-maven_2.12:3.6.14:publish (default-cli) on project flex-publishindexer: The parameters 'pactBrokerUrl' for goal au.com.dius:p act-jvm-provider-maven_2.12:3.6.14:publish are missing or invalid -> [Help 1]```

tausif2909
2020-03-20 12:14
Error started all of sudden

tausif2909
2020-03-20 12:14
Any idea?

tausif2909
2020-03-20 12:37
Please ignore, I have found the problem :point_up_2:

s1apped
2020-03-20 16:25
Hi. Have you made some change to MockServer? In latest version I can't inject MockServer @BeforeEach annotated method ```@BeforeEach public void setUp(MockServer mockServer) {``` with error ```org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [http://au.com.dius.pact.consumer.MockServer arg0] ```

uglyog
2020-03-20 22:40
That shouldn?t have changed, but I?ll have a look. What version are you using?

uglyog
2020-03-21 02:36
Do you still have `@ExtendWith(PactConsumerTestExt.class)` on the test class?

uglyog
2020-03-21 02:42
Don't worry, I've reproduced the issue

s1apped
2020-03-21 21:19
Great sorry I didn't respond earlier,

ewa
2020-03-22 11:44
has joined #pact-jvm

tausif2909
2020-03-23 07:14
Thanks alot @uglyog

grzegorzkrol90
2020-03-23 08:31
has joined #pact-jvm

arho.huttunen
2020-03-23 09:21
Has anyone tried to make the consumer side agnostic of the providers behind an API gateway? I was thinking that you could just have one `api-gateway` provider that would then figure out which provider behind the gateway handles which request, and publish pacts that have the correctly mapped providers written into it. I just can?t help thinking that maybe this is overcomplicated, and there could possibly be a simpler way to do it.

tjones
2020-03-23 14:58
> publish pacts that have the correctly mapped providers written into it. I?m not sure what you mean by the bit I?ve quoted, but I?ll have a go at answering. I think the answer depends a bit on whether your conceptual units also map to atomically deployable things (and also on what your API gateway is doing). If you have several related micro-services behind one API gateway, then yes, it _might_ make sense for consumers to think of the whole gateway as the provider of the the API. However, from a practical perspective, it?s best if the pacts are between discrete deployment units. You want to be able to say ?does this version X of my consumer successfully communicate with version Y of the provider??, and to be able to say that, you need the consumer and the provider to be easy to reason about from a deployment and versioning perspective. If your whole API gateway is actually version W, V and U of some microservice A, B and C, then it depends. Can you easily say ?this is version Y of the gateway, which is A, B and C exposed at these different prefixes? (or whatever). Another angle on this - if your API gateway is complex (some do quite a bit of rewriting), then perhaps you have pacts between: your consumer -> API Gateway API Gateway -> microservice A API Gateway -> microservice B ?. etc

tjones
2020-03-23 14:59
(also, this is a good question that might benefit from being in #general)

aliihlail
2020-03-23 15:41
has joined #pact-jvm

aliihlail
2020-03-24 05:59
Hi every one. im trying to run contract test using pactFLow. I wrote a simple contract and i tested it using local dockerbroker it is worked correctly. but when i upload the contract the pactFlow i got always the same error as attached in the file

abubics
2020-03-24 06:01
> There were 1 pact failures To me, this says you need to check the pact logs to see what the failure was :slightly_smiling_face:

aliihlail
2020-03-24 06:03
I used the same Pact file and it worked on the local pactbroker

uglyog
2020-03-24 06:03
The log entries before that will display what failed

aliihlail
2020-03-24 06:03
even if the contract file is empty i got the same error

aliihlail
2020-03-24 09:06
Now when im using the verication test i got this error message java.lang.UnsupportedOperationException: At least one pact source must be present on the test class

aliihlail
2020-03-24 09:13
@uglyog can you assist

waquino
2020-03-24 12:47
has joined #pact-jvm

arho.huttunen
2020-03-24 18:07
That?s a good point, maybe I?ll rephrase and ask in #general

josue.boix
2020-03-24 19:12
has joined #pact-jvm

josue.boix
2020-03-24 19:12
Hello everyone!

josue.boix
2020-03-24 19:20
I have an issue when running a MockMvc test with `RestPactRunner` . Can anybody help?

uglyog
2020-03-24 22:07
It would be more helpful to let us know what the issue is before we can answer that question :smile:

uglyog
2020-03-24 22:08
Still, the error would have been displayed in the console

uglyog
2020-03-24 22:09
You haven't provided a source for pact files (i.e. using the @PactFolder or @PactBroker annotations)

tainguyen
2020-03-25 02:57
@uglyog I have a comments on ticket https://github.com/DiUS/pact-jvm/issues/1031 about using generator to replace the fields that correspond to value that need to change when running pact verification. If you have time, pls help me address. Thanks so much

borsuk.artem034
2020-03-25 06:36
Hello, did not get how I can specify lambdaPactDsl for array of the typical objects? ```[{ "type": "type", "title": "title" }, { "type": "type", "title": "title" }, //many the same objects ]```

borsuk.artem034
2020-03-25 08:35
stuck here ```LambdaDslJsonArray body = newJsonArray((rootArray) -> rootArray.object((filter -> { filter.stringMatcher("type", "[\\w\\W]*", "type") .stringMatcher("title", "[\\w\\W]*", "title"); }) ) );```

josue.boix
2020-03-25 09:00
I?ll post the issue below

josue.boix
2020-03-25 09:03
Hello! I have an issue when creating a MockMVC test from the provider side. So I have the following contract test written from the consumer: ```Upon receiving get whatever from service, with { "method": "GET", "path": "/v1/endpoint", "headers": { "Accept": "application/json", "Content-Type": "application/json" } } Service will respond with: { "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "array": [ ] }``` If I verify the contract using `mvn pact:verify` using one of the services deployed in my environment, it works fine, as follows: ```Verifying a pact between consumer and provider [from Pact Broker https://pact-broker] Get returns a response which has status code 200 (OK) includes headers "Content-Type" with value "application/json" (OK) has a matching body (OK)``` But then I write a MockMVC test to verify it from the provider, which looks very similar to this one here: https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-spring The verfication fails, as you can see below: ```Verifying a pact between myConsumer and myProvider Get Whatever MockHttpServletRequest: HTTP Method = GET Request URI = /v1/endpoint Parameters = {} Headers = {Accept=[application/json], Content-Type=[application/json]} Body = <no character encoding set> Session Attrs = {} Handler: Type = com...controller...TypeController Method = public ...myDTO myController.get(java.lang.String) Async: Async started = false Async result = null Resolved Exception: Type = null ModelAndView: View name = null View = null Model = null FlashMap: Attributes = null MockHttpServletResponse: Status = 200 Error message = null Headers = {Content-Type=[application/json;charset=UTF-8]} Content type = application/json;charset=UTF-8 Body = {"myArray":[]} Forwarded URL = null Redirected URL = null Cookies = [] returns a response which has status code 200 (OK) includes headers "Content-Type" with value "application/json" (FAILED) has a matching body (OK) Failures: 0) Get Whatever returns a response which includes headers "Content-Type" with value "[application/json]" Expected 'application/json;charset=UTF-8' to match 'application/json' java.lang.AssertionError: 0 - Expected 'application/json;charset=UTF-8' to match 'application/json'```

tainguyen
2020-03-25 09:05
try ```new PactDslJsonArray() .arrayMinLike(2) .stringType("type","type") .stringType("title","title") .closeObject()```

josue.boix
2020-03-25 09:08
Any clues? I?m running out of ideas here

tainguyen
2020-03-25 09:51
Hello, Does anyone know how to define pact using ```valueFromProviderState``` to verify value in numberType?

tainguyen
2020-03-25 09:53
I define ```.valueFromProviderState("id","${id}",100)``` So, it is understanding id must be string

tainguyen
2020-03-25 09:54
While I expect id is an integer

tainguyen
2020-03-25 09:55
The method ```valueFromProviderState```

tainguyen
2020-03-25 10:00
Do you all have any ideas? Thanks

borsuk.artem034
2020-03-25 11:42
Thanks! Good for me

carolyn.biggar
2020-03-25 19:45
*Incorrect "validated" state on broker for provider test with runtime error* Following on from https://pact-foundation.slack.com/archives/C9VPNUJR2/p1584863869106000?thread_ts=1584800617.098000&cid=C9VPNUJR2 ... When the provider verification test fails due to a *runtime error* - most commonly we have `MissingStateChangeMethod` due to getting the state match up wrong - the results still get published to the broker and *incorrectly show as verified*. This is pretty misleading, because actually the verification test didn't run so we don't know if it would have passed or not - we've had cases where it wouldn't. Could you help me problem solve this? Is it a bug or is there a setting I can tweak so that this shows as "not run" or something else on the broker? Our main requirement is that it doesn't show as "passed" Here's an example using the public broker as suggested - nb the consumer and provider tests are both in the same project for convenience here! https://github.com/csbiggar/pact-example/blob/master/README.md I've added steps to recreate to the readme, let me know if anything is unclear. Many thanks for any help

ravi.dasari
2020-03-25 21:26
has joined #pact-jvm

ravi.dasari
2020-03-25 21:29
@here how do I use pending pacts ? any guides or documentation related to this? I just couldn't find anything except this blog - http://blog.pact.io/2020/02/24/how-we-have-fixed-the-biggest-problem-with-the-pact-workflow/

uglyog
2020-03-25 22:16
Can you raise an issue for that at the Github project?

uglyog
2020-03-25 22:16
A fix would be to change the content type to `application/json;charset=UTF-8`

abubics
2020-03-25 22:17
Did that matcher not get relaxed?

uglyog
2020-03-25 22:18
The values injected from the provider states are parsed as an expression, which will always be a string. Please raise an issue for this at the Github project.

uglyog
2020-03-25 22:19
Please raise a Github issue for this

uglyog
2020-03-25 22:20
Pending pact support is still being worked on. The latest version of Pact-JVM uses the new endpoint, but still verifies all the pacts regarding of status.

uglyog
2020-03-25 22:22
It should have been, but maybe the MockMVC version is doing something different

carolyn.biggar
2020-03-25 23:27
Thanks have done so now, here https://github.com/DiUS/pact-jvm/issues/1058

carolyn.biggar
2020-03-25 23:27
cheers!


ravi.dasari
2020-03-26 02:34
ah. I see . Thanks for the reply

josue.boix
2020-03-26 09:10
I fixed it by changing the content type as you suggested. Thanks @uglyog!

ahsan_bhai
2020-03-26 20:07
Getting 400 error after moving to a different pact broker that has `https` enabled. The tests work fine with current pact broker with `http`

ahsan_bhai
2020-03-26 20:07
``` 14:57:25.693 [Test worker] DEBUG http://au.com.dius.pact.provider.junit.loader.PactBrokerLoader - Loading pacts from pact broker for provider my_provider and tag prod 14:57:25.699 [Test worker] DEBUG http://au.com.dius.pact.provider.junit.loader.PactBrokerLoader - Authentication: Basic 14:57:25.717 [Test worker] DEBUG http://au.com.dius.pact.core.pactbroker.HalClient - Fetching: / 14:57:26.227 [Test worker] DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default 14:57:26.265 [Test worker] DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context 14:57:26.267 [Test worker] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {}->http://my_pact_broker:443][total kept alive: 0; route allocated: 0 of 5; total allocated: 0 of 10] 14:57:26.313 [Test worker] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->http://my_pact_broker:443][total kept alive: 0; route allocated: 1 of 5; total allocated: 1 of 10] 14:57:26.316 [Test worker] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {}->http://my_pact_broker:443 14:57:26.350 [Test worker] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to my_pact_broker/10.129.3.59:443 14:57:26.528 [Test worker] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 10.207.25.100:51194<->10.129.3.59:443 14:57:26.529 [Test worker] DEBUG org.apache.http.impl.execchain.MainClientExec - Executing request GET / HTTP/1.1 14:57:26.529 [Test worker] DEBUG org.apache.http.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED 14:57:26.530 [Test worker] DEBUG org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED 14:57:26.536 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> GET / HTTP/1.1 14:57:26.536 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Type: application/json 14:57:26.536 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept: application/hal+json, application/json 14:57:26.536 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: my_pact_broker:443 14:57:26.536 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive 14:57:26.537 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.10 (Java/11.0.2) 14:57:26.537 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate 14:57:26.537 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "GET / HTTP/1.1[\r][\n]" 14:57:26.537 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Type: application/json[\r][\n]" 14:57:26.538 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept: application/hal+json, application/json[\r][\n]" 14:57:26.538 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: my_pact_broker:443[\r][\n]" 14:57:26.538 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]" 14:57:26.538 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.10 (Java/11.0.2)[\r][\n]" 14:57:26.538 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]" 14:57:26.538 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]" 14:57:27.254 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 400 Bad Request[\r][\n]" 14:57:27.254 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "Server: awselb/2.0[\r][\n]" 14:57:27.254 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Thu, 26 Mar 2020 19:57:26 GMT[\r][\n]" 14:57:27.254 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Type: text/html[\r][\n]" 14:57:27.254 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Length: 236[\r][\n]" 14:57:27.255 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "Connection: close[\r][\n]" 14:57:27.255 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]" 14:57:27.255 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "<html>[\r][\n]" 14:57:27.255 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>[\r][\n]" 14:57:27.255 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "<body bgcolor="white">[\r][\n]" 14:57:27.255 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "<center><h1>400 Bad Request</h1></center>[\r][\n]" 14:57:27.256 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "<center>The plain HTTP request was sent to HTTPS port</center>[\r][\n]" 14:57:27.256 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "</body>[\r][\n]" 14:57:27.256 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "</html>[\r][\n]" 14:57:27.260 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 400 Bad Request 14:57:27.260 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << Server: awselb/2.0 14:57:27.260 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Thu, 26 Mar 2020 19:57:26 GMT 14:57:27.261 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: text/html 14:57:27.261 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Length: 236 14:57:27.261 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << Connection: close Gradle Test Executor 12 finished executing tests. > Task :test FAILED com.trendmicro.np.ms.aggregator.contracttests.UiApiAggregatorProviderTests > com.trendmicro.np.ms.aggregator.contracttests.UiApiAggregatorProviderTests > initializationError FAILED http://au.com.dius.pact.core.pactbroker.RequestFailedException: Request to path '/' failed with response 'HTTP/1.1 400 Bad Request'```

ahsan_bhai
2020-03-26 20:08
This is the message body with `400` ```The plain HTTP request was sent to HTTPS port``` any ideas if I need to do anything different with a pact broker that has `https` enabled?

ahsan_bhai
2020-03-26 21:34
Fixed it! need to have `scheme` set!

tainguyen
2020-03-27 12:22
@uglyog Sorry to bother you. But could you please help me to take a look at my comment on https://github.com/DiUS/pact-jvm/issues/1031

tainguyen
2020-03-27 12:23
I don't know how to use generator to replace the fields in the Request Body that correspond to value that need to change Thanks so much

ina.lopez
2020-03-30 21:29
has joined #pact-jvm

aliihlail
2020-03-31 20:31
``` import http://au.com.dius.pact.consumer.MockServer; import http://au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import http://au.com.dius.pact.consumer.junit5.PactTestFor; import http://au.com.dius.pact.consumer.junit5.ProviderType; import http://au.com.dius.pact.core.model.annotations.Pact; import http://au.com.dius.pact.core.model.messaging.MessagePact; import org.apache.http.HttpHeaders; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.hateoas.MediaTypes; import java.util.HashMap; import java.util.Map; import static io.pactfoundation.consumer.dsl.LambdaDsl.newJsonBody; @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "contract-service", providerType = ProviderType.ASYNCH) public class PactContractTesting { private static final String CONTENT_HEADER = HttpHeaders.CONTENT_TYPE; @Pact(consumer = "document-service") public MessagePact contractDelegateTest(MessagePact builder) { Map<String, String> metadata = new HashMap<>(); metadata.put(CONTENT_HEADER, MediaTypes.HAL_JSON_UTF8_VALUE); return builder.given("SomeProviderState2") .expectsToReceive("a test message") .withMetadata(metadata) .body(newJsonBody((contract) -> { contract.id("id"); contract.object("currentEmail", (email) -> { email.stringValue("email", ""); }); contract.object("person", (firstName) -> { firstName.stringValue("firstName", "Max"); }); }).getPactDslObject()) .toPact(); } @Test @PactTestFor(pactMethod = "user") public void testContract(MockServer mockServer) { } }```

aliihlail
2020-03-31 20:32
Im writing this code to test an assyncroyns message but i got an eror that i cant use builder.given

uglyog
2020-04-01 04:26
What error did you get?

lbraymusso
2020-04-02 05:40
has joined #pact-jvm

aliihlail
2020-04-02 11:22
`@ExtendWith(SpringExtension.class)` `@ActiveProfiles("test")` `@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)` `@Provider("contact-service")` `@PactBroker()@IgnoreNoPactsToVerify` `public class DocumentVerificationTest {` `@TestTemplate` `@ExtendWith({PactVerificationInvocationContextProvider.class})` `public void pactVerificationTestTemplate(PactVerificationContext context) {` `context.verifyInteraction();` `}` `@State("test case")` `public void test() {` `}` `}`

aliihlail
2020-04-02 11:23
im trying on the provider side to to test the contract. the contract is an amqp. im getting the following error java.lang.UnsupportedOperationException: Only request/response interactions can be used with an HTTP test target

borsuk.artem034
2020-04-02 12:11
```@BeforeEach void setupTestTarget(PactVerificationContext context) { context.setTarget(new AmpqTestTarget(Collections.singletonList("com.yourcompany.main"))); }```

aliihlail
2020-04-02 21:28
@borsuk.artem034 thanks for your answer it is really help but now i have a second issue that i have provider service has to two contracts one rest and amqp when i run the service it run error on the other contract. my question how to configure the class to run only this contract with ignoring the second one.

uglyog
2020-04-02 22:27
With JUnit 5 you can't filter the pacts at the moment. Please raise an issue for that at the github project. THe only way you could really do it is have a different consumer name for the HTTP and async interactions. For example, `contact-service` and `contact-service-async`

aliihlail
2020-04-02 22:31
Thanks for your help for that. i will check it keep you updated

aliihlail
2020-04-02 22:48
@uglyog you meen differn provider name because the consumers are different. and do in need to to only mentioned that in provide annotaion ```@Provider("contact-service-async") @Provider("contact-service")``` or also i need to chang in the pom file

uglyog
2020-04-02 22:49
If the consumers are different, you can have different tests for each consumer. Use the `@Consumer` annotation

aliihlail
2020-04-02 22:52
yes the provider has 2 contracts one HTTP with X consumer and async with Y consumer

aliihlail
2020-04-02 22:56
thanks @uglyog worked

antonello
2020-04-03 06:29
when running provider verification tests, I get this message: [DefaultTestResultAccumulator] Not all of the 28 were verified. Is there any convenient way to figure out which exact state was not verified? I am very reluctant to check 28 states one-by-one by hand. :blush:

uglyog
2020-04-03 06:35
ah, yeah, that is not that helpful. I'll update it to print out the missing ones

antonello
2020-04-03 06:48
Sounds good to me @uglyog - thank you! :)

aliihlail
2020-04-03 09:03
when we upload the pact contract to Pact Flow using mvn pact:publish. I recognize the old contract is still exist. How to replace the new you contract with the old one with doing it manually by deleting the contract integration integration.

borsuk.artem034
2020-04-03 13:14
do "mvn clean" before new run? or always use "mvn clean test"

reemadhiman92
2020-04-03 15:15
hello, How can i verify pact at provider end with mvn command ? is it possible to run via command as , it will not run by mvn clean test .

lbraymusso
2020-04-03 15:55
you can use a `mvn pact:verify` task


ryanlevell
2020-04-03 16:27
has joined #pact-jvm

aliihlail
2020-04-04 21:20
when we upload the pact contract to Pact Flow using mvn pact:publish. I recognize the old contract is still exist. How to replace the new you contract with the old one with doing it manually by deleting the contract integration integration.

uglyog
2020-04-05 04:11
I'm not sure what the question is. Are you asking how to update a contract without deleting the old one?

aliihlail
2020-04-05 13:56
No with deleting the old one

uglyog
2020-04-05 23:17
Versioning in the Pact Broker is documented here: https://docs.pact.io/getting_started/versioning_in_the_pact_broker

martin.nilsson
2020-04-06 13:10
has joined #pact-jvm

paras.vora1801
2020-04-07 02:59
has joined #pact-jvm

paras.vora1801
2020-04-07 14:43
I have a SprintBootApplication & the provider test written is something like: ```package com.inq.auth.contract.test; import http://au.com.dius.pact.provider.junit.Provider; import http://au.com.dius.pact.provider.junit.State; import http://au.com.dius.pact.provider.junit.loader.PactFolder; import au.com.dius.pact.provider.junit.target.Target; import au.com.dius.pact.provider.junit.target.TestTarget; import http://au.com.dius.pact.provider.spring.SpringRestPactRunner; import au.com.dius.pact.provider.spring.target.SpringBootHttpTarget; import org.junit.Before; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; @RunWith(SpringRestPactRunner.class) @Provider("auth_server") @PactFolder("/Users/paras.vora/n_workspace/rt/customer-eapi/target/pacts") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ProviderTests { @Before public void setup() { } @State("A request to fetch the authorization token") public void getAuthToken() { } @TestTarget public final Target target = new SpringBootHttpTarget(); }``` For initiating the application, there are some arguments that needs to be passed, like this: title AUTH ``` java -Xdebug -agentlib:jdwp=transport=dt_socket,address=8888,server=y,suspend=n -DuseSSL=false -Dmonitoring.enabled=false -Dmanagement.security.enabled=false -Dlogs.dir=logs -Djmx.host=http://auth.something.com -Djmx.port=9090 -Dserver.address=http://auth.something.com -Dserver.port=10080 -DDB_USER=v2arch -DDB_PASS=munbah1 -jar .\target\some-server-4.0-SNAPSHOT.jar```

paras.vora1801
2020-04-07 14:44
The *@TestTarget* fails to provide these arguments hence, my application fails to initiate.

paras.vora1801
2020-04-07 14:45
Can anyone help how can I provide these arguments while initiating the application with @TestTarget?

uglyog
2020-04-07 23:07
@TestTarget doesn't start your application, spring boot does that. The spring test support will start your test application context before the pact test. You need to have any parameters required by your application provided from the spring context or maybe a before method.

vasilisnx
2020-04-08 10:25
Hi everyone, I started using pact-jvm-consumer-junit a couple of days ago and by looking at the documentation i cannot find if its possible and if yes how would someone create 2 separate fragments for different outcomes of the same interaction with the same provider. So for example see this consumer code ```@Pact(provider = "providerA", consumer = "consumer") public RequestResponsePact fragment1(final PactDslWithProviderBuilder builder) { return builder .given("book doesn't exist") .when("request to create book") .path("/books") .method("POST") .headers(headers) .body(body) .willRespondWith() .headers(responseHeaders) .body(responseBody) .status(200) .toPact(); } @Pact(provider = "providerA", consumer = "consumer") public RequestResponsePact fragment2(final PactDslWithProviderBuilder builder) { return builder .given("book does exist") .when("request to create book") .path("/books") .method("POST") .headers(headers) .body(body) .willRespondWith() .headers(responseHeaders) .body(errorBody) .status(409) .toPact(); } @Test @PactVerification(value = "providerA", fragment = "fragment1") public RequestResponsePact successfulCreation(final PactDslWithProvider builder) { // a test for the first fragment1 success } @Test @PactVerification(value = "providerA", fragment = "fragment2") public RequestResponsePact failCreation(final PactDslWithProvider builder) { // a test for the first fragment2 failure }``` The above example fails. Is that possible? Or whats the right approach if not?

uglyog
2020-04-08 23:16
Looks fine to me. What is the error you are getting?

vasilisnx
2020-04-09 07:57
The error i am getting is ```Test function failed with an exception, possibly due to ExpectedButNotReceived(expectedRequests=[ method: POST path: /books``` So it looks like there is some sort of conflict when running both test cases at the same time, cause when i run individually they both pass. When i run them in one go only one succeeds. The other one fails with the above message. *Edit*: i managed to bypass this issue by adding a delay between tests ``` @Before public void addDelay() throws InterruptedException { Thread.sleep(2500); }``` but i don't think thats a good solution. Any suggestions?

uglyog
2020-04-09 22:57
Your http client library is caching the connections. The sleep works because after that amount of time the http connection would be considered stale.


kjtester
2020-04-10 09:30
has joined #pact-jvm

l.dziedziul
2020-04-10 14:09
has joined #pact-jvm

l.dziedziul
2020-04-10 14:19
Hi all! I've got a question regarding provider tests with junit5 and spring. Is it possible to use `MockMvcTarget` or `WebMvcTest` to avoid spinning up the whole application context? I can't find any example.

tyler.rasor
2020-04-10 14:40
we?re successfully using `MockMvcTarget`, not sure what example we followed

l.dziedziul
2020-04-10 14:41
with junit5? I?ve found only examples for junit4

tyler.rasor
2020-04-10 14:46
ahh, sorry, just checked and we are using 4

l.dziedziul
2020-04-10 14:46
no problem

uglyog
2020-04-11 02:00
MockMvcTarget has not been ported to JUnit 5 yet. Please raise an issue on the Github project for that.


l.dziedziul
2020-04-13 14:24
Hi, I?ve added a PR to fix this issue: https://github.com/DiUS/pact-jvm/pull/1068. I closed the first PR (1067) because I?ve used the wrong GH account :wink:

komeershettyvinod
2020-04-14 17:13
has joined #pact-jvm

aliihlail
2020-04-15 08:50
``` [ERROR] Failed to execute goal au.com.dius:pact-jvm-provider-maven:4.0.8:verify (default-cli) on project contact-service: A type incompatibility occurred while executing au.com.dius:pact-jvm-provider-maven:4.0.8:verify: class http://au.com.dius.pact.core.model.messaging.Message cannot be cast to class http://au.com.dius.pact.core.model.RequestResponseInteraction (http://au.com.dius.pact.core.model.messaging.Message and http://au.com.dius.pact.core.model.RequestResponseInteraction are in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @7fad214a)``` My code at the consumer side is working perfectly but when im trying to use mvn pact:verify i got the above error

wesleythomaswilliams
2020-04-15 16:07
@uglyog Something I noticed recently that I wanted to query you about. I have a provider that is consumed from by six other services and results in a total of 17 provider tests. When I run those tests, I get output that looks similar to this for each of the 17 tests: Verifying a pact between myconsumer1 and myprovider [Using PactBrokerSource(host=${pact.broker.host}, port=443, scheme=https, pacts={...}] Given state a request returns a response which has status code 400 (OK) has a matching body (OK) In the pacts section of that second line, I get repeating content for all six consumer services in the test output for each of the 17 tests, even though each of those tests is being run for one consumer. This is making the output much bigger than I was expecting. Is that intentional as I only expected to see output for the consumer specified at the start of the output (in this case myconsumer1)? I've added the full output from one test as a snippet.

uglyog
2020-04-15 23:13
Can you raise an issue for that?

uglyog
2020-04-15 23:14
Can you raise an issue for that?

uglyog
2020-04-15 23:15
We should definitely clean it up

chandanakurumeti27
2020-04-16 07:33
has joined #pact-jvm

wesleythomaswilliams
2020-04-16 10:27
@uglyog Just going through updating documentation of our pact solution for our team and one thing I'm curious about is a difference I have in my REST and Messaging provider tests. Both include this code: ``` @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); }``` However, my REST tests are annotated with `@State`, while my Messaging tests are annotated with `@PactVerifyProvider`. Is that the correct way to do things and if so, why?

uglyog
2020-04-16 22:50
`@State` is for annotating provider state callbacks. You can use them for both types of tests. `@PactVerifyProvider` is for annotating methods that return the response body. These are mainly used for message interactions.

aliihlail
2020-04-16 23:18
```package de.mediciliving.cloud.owner.pactTesting; import http://au.com.dius.pact.provider.junit.Consumer; import http://au.com.dius.pact.provider.junit.IgnoreNoPactsToVerify; import http://au.com.dius.pact.provider.junit.Provider; import http://au.com.dius.pact.provider.junit.State; import http://au.com.dius.pact.provider.junit.loader.PactBroker; import http://au.com.dius.pact.provider.junit.loader.PactBrokerAuth; import http://au.com.dius.pact.provider.junit5.PactVerificationContext; import http://au.com.dius.pact.provider.spring.junit5.PactVerificationSpringProvider; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @ActiveProfiles("test") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @Provider("operator-service") @Consumer("document-service") @PactBroker(authentication = @PactBrokerAuth(token = "${pactbroker.auth.token}"), scheme = "${pactbroker.scheme}", port = "${pactbroker.port}", host = "${pactbroker.host}") @IgnoreNoPactsToVerify public class OwnerVerificationTest { @TestTemplate @ExtendWith(PactVerificationSpringProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { if (context != null) { context.verifyInteraction(); } } @State("operator with id 1 exist") public void documentServiceTest() { } }```

aliihlail
2020-04-16 23:19
im writing this small testing code but ia got this error

aliihlail
2020-04-16 23:19
java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125) at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108) at http://au.com.dius.pact.provider.spring.junit5.PactVerificationSpringProvider.getValueResolver(PactVerificationSpringProvider.kt:16) at http://au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.resolvePactSources(PactJUnit5VerificationProvider.kt:395) at http://au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:366) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:97) at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:271) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:101) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:38) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:112) at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:120) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:120) at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$2(HierarchicalTestExecutor.java:120) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:120) at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:55) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58) Caused by: java.lang.IllegalStateException: Logback configuration error detected: ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [LOG_APPENDER_IS_UNDEFINED]. Did you define it below instead of above in the configuration file? ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details. at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:169) at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:82) at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60) at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:117) at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:264) at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:237) at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:200) at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:173) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74) at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:338) at org.springframework.boot.SpringApplication.run(SpringApplication.java:297) at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:137) at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:208) at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:104) at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:70) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74) at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:338) at org.springframework.boot.SpringApplication.run(SpringApplication.java:297) at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:127) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117) ... 58 more

aliihlail
2020-04-16 23:19
Can any one assist me how to handle this issue

uglyog
2020-04-16 23:29
> Logback configuration error detected: This is nothing to do with Pact, but your Spring/Logback configuration that is wrong

chandanakurumeti27
2020-04-17 09:41
Hello @RunWith(PactRunner.class) @Provider("playerservice") @PactFolder("pacts") public class IfProviderTest { @TestTarget public final Target target = new HttpTarget("http", "127.0.0.1:10001", 443, "/frontend/api"); @TargetRequestFilter public void exampleRequestFilter(HttpRequest request) { request.addHeader("Content-Length", "84"); } }

chandanakurumeti27
2020-04-17 09:43
so this is the simple pact jvm providr junit test of mine looks like

chandanakurumeti27
2020-04-17 09:43
when am running this:I got the below error, not sure what am actually missing here:

chandanakurumeti27
2020-04-17 09:44
error: java.lang.NullPointerException: Cannot invoke method split() on null object at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:35) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at http://au.com.dius.pact.provider.reporters.AnsiConsoleReporter.displayError(AnsiConsoleReporter.groovy:226) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) at http://au.com.dius.pact.provider.reporters.AnsiConsoleReporter$_displayFailures_closure1.doCall(AnsiConsoleReporter.groovy:187) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021) at groovy.lang.Closure.call(Closure.java:426) at org.codehaus.groovy.runtime.DefaultGroovyMethods.callClosureForMapEntryAndCounter(DefaultGroovyMethods.java:5245) at org.codehaus.groovy.runtime.DefaultGroovyMethods.eachWithIndex(DefaultGroovyMethods.java:2155) at org.codehaus.groovy.runtime.dgm$175.invoke(Unknown Source) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at http://au.com.dius.pact.provider.reporters.AnsiConsoleReporter.displayFailures(AnsiConsoleReporter.groovy:184) at http://au.com.dius.pact.provider.reporters.VerifierReporter$displayFailures$3.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at http://au.com.dius.pact.provider.ProviderVerifier$_displayFailures_closure33.doCall(ProviderVerifier.groovy:394) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021) at groovy.lang.Closure.call(Closure.java:426) at groovy.lang.Closure.call(Closure.java:442) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056) at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at http://au.com.dius.pact.provider.ProviderVerifier.displayFailures(ProviderVerifier.groovy:394) at au.com.dius.pact.provider.junit.target.HttpTarget.testInteraction(HttpTarget.java:114) at http://au.com.dius.pact.provider.junit.InteractionRunner$2.evaluate(InteractionRunner.java:183) at au.com.dius.pact.provider.junit.InteractionRunner.run(InteractionRunner.java:143) at http://au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.java:100) at http://au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.java:48) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

chandanakurumeti27
2020-04-17 09:44
I made sure,i have pact file in test/resources/pact and can see that test can pick up the pact file

chandanakurumeti27
2020-04-17 09:45
Please help me to resolve this issue

chandanakurumeti27
2020-04-17 10:27
Please ignore the above message as its resolved after I adjusted the dependency versions. Sorry for you time if you already spent some. Thank you!

komeershettyvinod
2020-04-17 11:01
hi

komeershettyvinod
2020-04-17 11:01
I am using gradle as provider for my pacts

komeershettyvinod
2020-04-17 11:01
and I am seeing below error No such property: isDependencyForPactVerify for class: http://au.com.dius.pact.provider.gradle.GradleProviderInfo Possible solutions: dependencyForPactVerify

komeershettyvinod
2020-04-17 11:01
I could not understand rarely whats wrong with my gradle file

komeershettyvinod
2020-04-17 11:21
//import com.github.jengelman.gradle.plugins.processes.tasks.JavaFork buildscript { repositories { maven { url "https://repo.grails.org/grails/core" } } dependencies { classpath "org.grails:grails-gradle-plugin:$grailsVersion" classpath "org.grails.plugins:hibernate5:7.0.0" classpath "gradle.plugin.com.github.erdi.webdriver-binaries:webdriver-binaries-gradle-plugin:2.0" classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.0.10" classpath "org.grails.plugins:views-gradle:2.0.0.BUILD-SNAPSHOT" classpath("com.github.jengelman.gradle.plugins:gradle-processes:0.3.0") //Producer side dependencies classpath("au.com.dius:pact-jvm-provider-gradle_2.11:3.5.0") classpath("com.github.jengelman.gradle.plugins:gradle-processes:0.3.0") } } plugins { id "http://au.com.dius.pact" version "4.0.0" } version "0.1" group "studentservice" apply plugin:"eclipse" apply plugin:"idea" apply plugin:"war" apply plugin:"org.grails.grails-web" apply plugin:"com.github.erdi.webdriver-binaries" apply plugin:"org.grails.grails-gsp" apply plugin:"com.bertramlabs.asset-pipeline" apply plugin:"org.grails.plugins.views-json" //Producer side plugins //apply plugin: 'http://au.com.dius.pact' apply plugin: 'com.github.johnrengelman.processes' repositories { maven { url "https://repo.grails.org/grails/core" } } configurations { developmentOnly runtimeClasspath { extendsFrom developmentOnly } } dependencies { developmentOnly("org.springframework.boot:spring-boot-devtools") compile "org.springframework.boot:spring-boot-starter-logging" compile "org.springframework.boot:spring-boot-autoconfigure" compile "org.grails:grails-core" compile "org.springframework.boot:spring-boot-starter-actuator" compile "org.springframework.boot:spring-boot-starter-tomcat" compile "org.grails:grails-web-boot" compile "org.grails:grails-logging" compile "org.grails:grails-plugin-rest" compile "org.grails:grails-plugin-databinding" compile "org.grails:grails-plugin-i18n" compile "org.grails:grails-plugin-services" compile "org.grails:grails-plugin-url-mappings" compile "org.grails:grails-plugin-interceptors" compile "org.grails.plugins:cache" compile "org.grails.plugins:async" compile "org.grails.plugins:scaffolding" compile "org.grails.plugins:events" compile "org.grails.plugins:hibernate5" compile "org.hibernate:hibernate-core:5.4.0.Final" compile "org.grails.plugins:gsp" compileOnly "io.micronaut:micronaut-inject-groovy" console "org.grails:grails-console" profile "org.grails.profiles:web" runtime "org.glassfish.web:el-impl:2.1.2-b03" runtime "com.h2database:h2" runtime "org.apache.tomcat:tomcat-jdbc" runtime "javax.xml.bind:jaxb-api:2.3.0" runtime "com.bertramlabs.plugins:asset-pipeline-grails:3.0.10" testCompile "org.grails:grails-gorm-testing-support" testCompile "org.mockito:mockito-core" testCompile "org.grails:grails-web-testing-support" testCompile "org.grails.plugins:geb" testCompile "org.seleniumhq.selenium:selenium-remote-driver:3.14.0" testCompile "org.seleniumhq.selenium:selenium-api:3.14.0" testCompile "org.seleniumhq.selenium:selenium-support:3.14.0" testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:3.14.0" testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:3.14.0" compile "org.grails.plugins:views-json" compile "org.grails.plugins:views-json-templates" compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7' testCompile 'au.com.dius:pact-jvm-consumer-groovy_2.11:3.5.0' testCompile 'au.com.dius:pact-jvm-consumer-junit_2.11:3.5.0' } bootRun { jvmArgs( '-Dspring.output.ansi.enabled=always', '-noverify', '-XX:TieredStopAtLevel=1', '-Xmx1024m') sourceResources sourceSets.main String springProfilesActive = 'spring.profiles.active' systemProperty springProfilesActive, System.getProperty(springProfilesActive) } webdriverBinaries { chromedriver '2.45.0' geckodriver '0.24.0' } tasks.withType(Test) { systemProperty "geb.env", System.getProperty('geb.env') systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest") systemProperty "webdriver.chrome.driver", System.getProperty('webdriver.chrome.driver') systemProperty "webdriver.gecko.driver", System.getProperty('webdriver.gecko.driver') } assets { minifyJs = true minifyCss = true } test { systemProperties['pact.rootDir'] = "$buildDir/pacts" } // This will be called before the provider task task('startTheApp') { doFirst { // start up your provider here classpath = sourceSets.main.runtimeClasspath //// main = 'com.github.felipecao.pactsample.producer.Application' main = 'studentservice.Application' } doLast { Thread.sleep(15000) // time Spring Boot takes to start } } // This will be called after the provider task //task killTheApp{ // doLast { // // kill your provider here // // startTheApp.processHandle.abort() // // } //} pact { serviceProviders { StudentProducer { // dependencyForPactVerify = false protocol = 'http' host = 'localhost' port = 8080 path = '/' startProviderTask = startTheApp // terminateProviderTask = killTheApp hasPactWith('StudentConsumer1') { pactFile = file('target/pacts/StudentConsumer1-StudentProducer.json') } } } } //task startProducer(type: JavaFork) { //// classpath = sourceSets.main.runtimeClasspath ////// main = 'com.github.felipecao.pactsample.producer.Application' //// main = 'studentservice.Application' //// doLast { //// Thread.sleep(15000) // time Spring Boot takes to start //// } ////} ////task stopProducer << { //// startProducer.processHandle.abort() ////}

komeershettyvinod
2020-04-17 11:21
My gradle files looks like

darshan
2020-04-17 16:27
has joined #pact-jvm

uglyog
2020-04-18 04:35
You shouldn't modify the content length header, it will be set based on the size of the body.

uglyog
2020-04-18 04:40
You're mixing different versions of Pact-JVM. You have ```classpath("au.com.dius:pact-jvm-provider-gradle_2.11:3.5.0")``` as well as ```plugins { id "http://au.com.dius.pact" version "4.0.0" }```

uglyog
2020-04-18 04:41
You should try the latest version for both (4.0.9)

uglyog
2020-04-18 04:41
```plugins { id "http://au.com.dius.pact" version "4.0.9" }```

uglyog
2020-04-18 04:42
```classpath("au.com.dius:pact-jvm-provider-gradle:4.0.9")```

aliihlail
2020-04-19 10:56
I wrote a test code for both Assync and http Get request. the code is runnib and testing perfictly. but when i run mvn pact:verify i got this error. any help please `[ERROR] Failed to execute goal au.com.dius:pact-jvm-provider-maven:4.0.8:verify (default-cli) on project contact-service: A type incompatibility occurred while executing au.com.dius:pact-jvm-provider-maven:4.0.8:verify: class http://au.com.dius.pact.core.model.messaging.Message cannot be cast to class http://au.com.dius.pact.core.model.RequestResponseInteraction (http://au.com.dius.pact.core.model.messaging.Message and http://au.com.dius.pact.core.model.RequestResponseInteraction are in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @7fad214a)`

jayeshdalal7
2020-04-19 12:29
has joined #pact-jvm

uglyog
2020-04-19 22:27
Are you able to share your test and pact file?

chandanakurumeti27
2020-04-20 09:46
Yeah, I just randomly picked the "Content-Lendth" header to see how request filters are working. and ended up with error which says ,content length is already exists. So came to know that i shouldnt change contentlength header using request filter. :slightly_smiling_face:

chandanakurumeti27
2020-04-20 09:46
Anyways, Thank you so much for responding! Have a nice monday!

paras.vora1801
2020-04-20 13:35
Hello, below is the DEBUG log for my pact verification result: `Verifying a pact between ceapi and auth_server` `[from Pact Broker http://localhost/pacts/provider/auth_server/consumer/ceapi/version/1.0.100]` `Given A valid authorization token is returned` `WARNING: State Change ignored as there is no stateChange URL` `[DEBUG] State Change: "ProviderState(name=A valid authorization token is returned, params={})" -> Ok(value={})` `A request to fetch the authorization token` `[DEBUG] Verifying via request/response` `[DEBUG] Making request for provider http://au.com.dius.pact.provider.maven.Provider@f3b3f2c[name=auth_server,protocol=http,host=localhost,port=8080,path=/,startProviderTask=<null>,terminateProviderTask=<null>,requestFilter=<null>,stateChangeRequestFilter=<null>,createClient=<null>,insecure=false,trustStore=<null>,trustStorePassword=changeit,stateChangeUrl=<null>,stateChangeUsesBody=true,stateChangeTeardown=false,isDependencyForPactVerify=true,verificationType=REQUEST_RESPONSE,packagesToScan=[],consumers=[ConsumerInfo(name='ceapi', stateChange=null, stateChangeUsesBody=true, packagesToScan=[], verificationType=null, pactSource=BrokerUrlSource(url=http://localhost/pacts/provider/auth_server/consumer/ceapi/version/1.0.100, pactBrokerUrl=http://localhost:80, attributes={}, options={}, tag=null), pactFileAuthentication=[basic, pact_workshop, pact_workshop])],pactFileDirectory=<null>,pactBrokerUrl=<null>,pactBroker=PactBroker(url=http://localhost:80, tags=[], authentication=PactBrokerAuth(scheme=basic, token=null, username=pact_workshop, password=pact_workshop), serverId=null),pactFileDirectories=[],name=provider,protocol=http,host=localhost,port=8080,path=/,startProviderTask=<null>,terminateProviderTask=<null>,requestFilter=<null>,stateChangeRequestFilter=<null>,createClient=<null>,insecure=false,trustStore=<null>,trustStorePassword=changeit,stateChangeUrl=<null>,stateChangeUsesBody=true,stateChangeTeardown=false,isDependencyForPactVerify=true,verificationType=REQUEST_RESPONSE,packagesToScan=[],consumers=[ConsumerInfo(name='ceapi', stateChange=null, stateChangeUsesBody=true, packagesToScan=[], verificationType=null, pactSource=BrokerUrlSource(url=http://localhost/pacts/provider/auth_server/consumer/ceapi/version/1.0.100, pactBrokerUrl=http://localhost:80, attributes={}, options={}, tag=null), pactFileAuthentication=[basic, pact_workshop, pact_workshop])]]:` `[DEBUG] method: POST` `path: /oauth-server/oauth/token` `query: {}` `headers: {Authorization=[Basic Y2VhcGlDbGllbnRJZDpjZWFwaUNsaWVudFNlY3JldA==], Content-Type=[application/x-www-form-urlencoded; charset=utf-8]}` `matchers: MatchingRules(rules={})` `generators: Generators(categories={})` `body: PRESENT(client_id=ceapiClientId&grant_type=client_credentials)` `Request Failed - Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)` `[WARNING] Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')` `Failures:` `0) Verifying a pact between ceapi and auth_server - A request to fetch the authorization token Given A valid authorization token is returned` `Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)`

paras.vora1801
2020-04-20 13:37
It seems that the request is going is being made assuming the server is spawned to localhost:8080

paras.vora1801
2020-04-20 13:37
Whereas, in my test I have given the configuration as: ```@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)```

paras.vora1801
2020-04-20 13:38
I am verifying the pact via `mvn pact:verify`

paras.vora1801
2020-04-20 13:41
```<plugin> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.9</version> <configuration> <serviceProviders> <serviceProvider> <name>auth_server</name> <pactBroker> <url>http://localhost:80</url> <authentication> <scheme>basic</scheme> <username>pact_workshop</username> <password>pact_workshop</password> </authentication> </pactBroker> </serviceProvider> </serviceProviders> </configuration> </plugin>```

paras.vora1801
2020-04-20 13:41
This is how the pom.xml plugin looks like.

paras.vora1801
2020-04-20 13:42
Any idea why it is always pointing to localhost:8080?

wesleythomaswilliams
2020-04-20 13:52
@paras.vora1801 In your provider test, what have you set your target as: ```@BeforeEach void setupTestTarget(PactVerificationContext context) { context.setTarget(???); }```


paras.vora1801
2020-04-20 13:59
```@RunWith(SpringRestPactRunner.class) @Provider("auth_server") //@PactFolder("/Users/paras.vora/n_workspace/rt/customer-eapi/target/pacts") @PactBroker( host = "localhost", port = "80", authentication = @PactBrokerAuth(username = "pact_workshop", password = "pact_workshop")) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) //@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) //@Ignore public class ProviderTests { @Before public void setUp() { System.out.println("Runs before the Service boot"); } @State("A valid authorization token is returned") public void getAuthToken() { System.out.println("I am in test"); } @TestTarget public final Target target = new SpringBootHttpTarget(); }```

paras.vora1801
2020-04-20 14:00
I have set the TestTarget using the annotation.

paras.vora1801
2020-04-20 14:16
Catch here is, when I run the test from the class, then it points to the desired server url which is not the case when I do is via command line `mvn pact:verify`

wesleythomaswilliams
2020-04-20 14:52
@paras.vora1801 I remember having a similar issue (https://pact-foundation.slack.com/archives/C9UN99H24/p1578589599016300), but ultimately didn't need to execute `mvn pact:verify`. We ended up removing use of `pact-jvm-provider-maven` from our pom and removed @RunWith(SpringRestPactRunner.class), so we run with junit and just provide any required properties via the surefire plugin as follows: ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <pact.provider.version>${pact.provider.version}</pact.provider.version> <pact.broker.host>http://pde.pact.dius.com.au</pact.broker.host> <pact.broker.token>********</pact.broker.token> </systemPropertyVariables> </configuration> </plugin>``` I'll send you my test class in a DM

wesleythomaswilliams
2020-04-20 14:53
@paras.vora1801 This from @uglyog (the expert here) set me on my path: ```The JUnit Spring test framework is starting your provider before running your test. If you want to use the Maven plugin to run the verification, you need to have your provider started before it runs. One way of doing that is to use the integration test phase, which has a pre- and post- phase that can be used to start and stop your provider. You'll ned to work out how to bind the pact plugin to the integration test phase and find a plugin that can start your provider in the pre-integration-test phase. I would recommend using JUnit tests, though. You don't have to worry about starting and stopping the provider then.```

komeershettyvinod
2020-04-20 17:08
Hi I am writing a pact-jvm groovy consumer test

komeershettyvinod
2020-04-20 17:08
I have service where i give input firstName & lastName as part of json input

komeershettyvinod
2020-04-20 17:09
the o/p is json body: firstName, lastName and lastUpdated which returns in format of "2020-04-20T15:04:24Z"

komeershettyvinod
2020-04-20 17:09
But I could not apply timestampmatchers

komeershettyvinod
2020-04-20 17:10
correctly

komeershettyvinod
2020-04-20 17:10
It always fails at assertion error

komeershettyvinod
2020-04-20 17:10
can you please how to apply patterns

komeershettyvinod
2020-04-20 17:12
package studentservice //import http://au.com.dius.pact.consumer.Pact import http://au.com.dius.pact.consumer.PactVerificationResult import http://au.com.dius.pact.consumer.groovy.PactBuilder import http://au.com.dius.pact.model.Pact import http://au.com.dius.pact.model.matchingrules.MatchingRuleGroup import http://au.com.dius.pact.model.matchingrules.RegexMatcher import http://au.com.dius.pact.model.matchingrules.TimeMatcher import http://au.com.dius.pact.model.matchingrules.TimestampMatcher //import http://au.com.dius.pact.core.model.matchingrules.TimestampMatcher import http://groovyx.net.http.RESTClient import org.junit.Test class StudentServiceConsumerPactTest { @Test void "Post User service test"() { PactBuilder student_service = new PactBuilder() // Create a new PactBuilder student_service { serviceConsumer "StudentConsumer1" // Define the service consumer by name hasPactWith "StudentProducer" // Define the service provider that it has a pact with port 9000 // The port number for the service. It is optional, leave it out to // to use a random one } student_service { given('test post call for with student details') // defines a provider state. It is optional. uponReceiving('student details') // upon_receiving starts a new interaction // withAttributes(method: 'post', path: '/api/v1/student', body: '{"id":22, "firstName":"vinod", "lastName":"komeershetty"}') withAttributes(method: 'post', path: '/api/v1/student') withBody { firstName 'vinod' lastName 'komeershetty' } willRespondWith( // define the response we want returned status: 200, headers: ['Content-Type': 'application/json'], // body: "{\"id\":2,\"firstName\":\"vinod\",\"lastUpdated\":\"2020-04-15T12:24:31Z\",\"lastName\":\"komeershetty\"}" // body: "{\"id\":2,\"firstName\":\"vinod\",\"lastUpdated\":\"2020-04-15T12:24:31Z\",\"lastName\":\"komeershetty\"}" body: { // id(integer) firstName("vinod") lastName("komeershetty") // lastUpdated = timestamp('yyyy/MM/dd - HH:mm:ss.S','2020-04-20T15:04:24Z') lastUpdated("2020-04-20T15:04:24Z") } ) } // Execute the run method to have the mock server run. // It takes a closure to execute your requests and returns a PactVerificationResult. PactVerificationResult result = student_service.runTest { def client = new RESTClient('http://localhost:9000/') def alice_response = http://client.post(path: '/api/v1/student', body: '{"firstName":"vinod", "lastName":"komeershetty"}', requestContentType: 'application/json',) assert alice_response.status == 200 def data = alice_response.data assert data.firstName == "vinod" assert data.lastName == "komeershetty" assert data.lastUpdated == [new TimestampMatcher('yyyy-MM-dd\'T\'HH:mm:ss')] } assert result == PactVerificationResult.Ok.INSTANCE // This means it is all good } }

komeershettyvinod
2020-04-20 17:12
Above is the sample program

paras.vora1801
2020-04-20 19:14
Hello, I am facing issues while running the provider test via command line - `mvn pact:verify` below is my provider test class. ```@RunWith(SpringRestPactRunner.class) @Provider("auth_server") @PactBroker( host = "localhost", port = "80", authentication = @PactBrokerAuth(username = "pact_workshop", password = "pact_workshop")) @SpringBootTest( classes = AuthorizationServerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = "spring.profiles.active=test") /*@SpringBootTest( classes = AuthorizationServerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, properties = "spring.profiles.active=test")*/ //@Ignore public class ProviderTests { @LocalServerPort private int port; @Before public void setUp() { System.out.println("Runs before the Service boot"); } @State("A valid authorization token is returned") public void getAuthToken() { System.out.println("I am in test"); } @TestTarget public final Target target = new SpringBootHttpTarget(); }```

paras.vora1801
2020-04-20 19:16
This code runs as an individual test class however, fails to upload the verification result to the broker from where it fetches the pacts: ```Verifying a pact between ceapi and auth_server Given A valid authorization token is returned A request to fetch the authorization token 2020-04-21 00:30:57,403 INFO [com.touchcommerce.commons.auth.db.dao.impl.ApiClientAppDaoImpl] - <Dao [com.touchcommerce.commons.auth.db.dao.impl.ApiClientAppDaoImpl] in-memory dataset was updated in [5] ms. [6] records loaded, [6] total size.> 2020-04-21 00:30:57,403 DEBUG [com.inq.auth.service.authentication.ApiClientDetailsService] - <Found client app for clientId ceapiClientId : BaseClientDetails [clientId=ceapiClientId, clientSecret=ceapiClientSecret, scope=[read, write], resourceIds=[ceapi], authorizedGrantTypes=[client_credentials], registeredRedirectUris=null, authorities=[], accessTokenValiditySeconds=60, refreshTokenValiditySeconds=null, additionalInformation={}]> returns a response which has status code 200 (OK) has a matching body (OK) 2020-04-21 00:30:57,666 WARN [http://au.com.dius.pact.provider.DefaultTestResultAccumulator] - <Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')> HttpAdaptor version 3.0.1 stopped on port 9090```

paras.vora1801
2020-04-20 19:18
@matt.fellows /@uglyog How can I make this run via command line?, I plan to include this command line into the jenkins pipeline stage.

paras.vora1801
2020-04-20 19:21
I tried using the `pact-jvm-provider-maven` plugin, below is the pom content; ```<plugin> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.9</version> <configuration> <serviceProviders> <serviceProvider> <name>auth_server</name> <pactBroker> <url>http://localhost:80</url> <authentication> <scheme>basic</scheme> <username>pact_workshop</username> <password>pact_workshop</password> </authentication> </pactBroker> </serviceProvider> </serviceProviders> </configuration> </plugin>``` dependencies used are: ```<dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-spring</artifactId> <version>4.0.9</version> </dependency> <dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.10</version> </dependency>``` While doing a `mvn pact:verify` this is the output: ```Verifying a pact between ceapi and auth_server [from Pact Broker http://localhost/pacts/provider/auth_server/consumer/ceapi/version/1.0.100] Given A valid authorization token is returned WARNING: State Change ignored as there is no stateChange URL A request to fetch the authorization token Request Failed - Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused) [WARNING] Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')``` The request goes to the provider server *`localhost:8080`* which seems not available.

a.carpe
2020-04-20 20:46
has joined #pact-jvm

a.carpe
2020-04-20 21:00
Hello everybody, I?m having an issue publishing my pacts with `pact-jvm-provider-gradle` the error I receive is: ```Caused by: java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseString(Ljava/lang/String;)Lcom/google/gson/JsonElement; at http://au.com.dius.pact.core.pactbroker.PactBrokerClient.uploadPactFile(PactBrokerClient.kt:184)``` The offending code is this one: ```open fun uploadPactFile(pactFile: File, unescapedVersion: String, tags: List<String> = emptyList()): Any? { val pactText = pactFile.readText() val pact = JsonParser.parseString(pactText)``` I tried to debug the task, the content of the file is there and it is a valid json. I see the `JsonParser` class and the `parseString` static method too, I can navigate with idea to the method as the dependency on `com.google.code.gson:gson:2.8.6` is there. I double checked the `build.gradle` but I wasn?t able to see anything wrong. Has anyone an idea on what?s going on?

aliihlail
2020-04-20 23:08
~can i use at the provider side for Amqp test.~ ```@TestTemplate @ExtendWith(PactVerificationSpringProvider.class) void testTemplate(Pact pact, Interaction interaction, PactVerificationContext context) { http://LOGGER.info("testTemplate called: " + pact.getProvider().getName() + ", " + interaction); context.verifyInteraction(); }```

uglyog
2020-04-20 23:12
The Maven plugin does not work with springboot. It won't know what port your app is running on. It also won't be able to start and stop your app. You are using a JUnit test, so there is no need for the plugin.

uglyog
2020-04-20 23:14
You must have a dependency issue where an older version of GSon is being loaded. Can you check your project dependencies to see what is being loaded?

a.carpe
2020-04-21 08:19
I though the same, doing a `./gradlew -q dependencies my-project:dependencies` I can find the pact dependencies only in `testCompileClasspath` and `testRuntimeClasspath` . There I found: ```+--- org.springframework.boot:spring-boot-starter-jdbc -> 2.3.0.M3 | +--- org.springframework.boot:spring-boot-dependencies:2.3.0.M3 | | +--- com.google.code.gson:gson:2.8.6 (c) +--- au.com.dius:pact-jvm-provider-spring:4.0.10 | \--- au.com.dius:pact-jvm-provider-junit:4.0.10 | +--- au.com.dius:pact-jvm-core-support:4.0.10 | | +--- com.google.code.gson:gson:2.8.6 | \--- au.com.dius:pact-jvm-provider:4.0.10 | +--- au.com.dius:pact-jvm-core-model:4.0.10 | | +--- au.com.dius:pact-jvm-core-pact-broker:4.0.10 | | | +--- com.github.salomonbrys.kotson:kotson:2.5.0 | | | | +--- com.google.code.gson:gson:2.8.0 -> 2.8.6 | | | +--- com.google.code.gson:gson:2.8.6 | | \--- com.google.code.gson:gson:2.8.6```

uglyog
2020-04-21 22:59
I wonder what the `(c)` means?

uglyog
2020-04-21 22:59
> com.google.code.gson:gson:2.8.6 (c)

a.carpe
2020-04-22 09:15
```(c) - dependency constraint (*) - dependencies omitted (listed previously) (n) - Not resolved (configuration is not meant to be resolved)```

uglyog
2020-04-22 22:21
Ah, that?s the class path for the tests. It?s not the classpath used by the plugin tasks. Just to confirm, are you using the same version of the gradle plugin (4.0.10)?

uglyog
2020-04-22 22:22
Can you provide what other plugins you are using?

corey
2020-04-22 22:41
has joined #pact-jvm

corey
2020-04-22 22:51
I'm attempting to upgrade a small consumer junit test that was using `pact-jvm-consumer-junit_2.11:3.5.0` to `pact-jvm-consumer-junit:4.0.10` and, after resolving some changed imports, am running into a `SocketException: Connection reset` when the consumer attempts to make a request to the mock provider. I ran the test with the debugger and hopped out into `curl` and see that I'm getting `curl: (52) Empty reply from server` . Not sure where to proceed from here

uglyog
2020-04-22 23:00
One of the issues that cause this is the version of Gson library. It needs to be 2.8.6. See https://github.com/DiUS/pact-jvm/issues/1054 and https://github.com/DiUS/pact-jvm/issues/1057

corey
2020-04-22 23:12
Upgrading gson did not resolve the issue. I may try and post an example tomorrow

aliihlail
2020-04-23 06:21
Hi, im trying to test amqp messages and one Drawback is that auto-filling the pactbroker-auth data from application.properties won't work anymore. this is appeared when i use @ExtendWith(PactVerificationInvocationContextProvider.class). any idea how to overccome this issue

uglyog
2020-04-23 06:28
Was the auto-filling done by Spring?

aliihlail
2020-04-23 06:32
yes.

uglyog
2020-04-23 06:34
And why can't you use Spring for this test?

aliihlail
2020-04-23 06:34
but with PactVerificationInvocationContextProvider no. and i dont need to use Spring Application Context

aliihlail
2020-04-23 06:34
it slow. and i have to write more ccode

aliihlail
2020-04-23 06:35
code. and i would stick with PactVerificationInvocationContextProvider.

uglyog
2020-04-23 06:35
Well, you will have to configure the broker in a different manner, because to get Spring to inject those values you need to start a Spring context

aliihlail
2020-04-23 06:36
how

uglyog
2020-04-23 06:36
You can use JVM system properties

a.carpe
2020-04-23 15:26
Yes I?m using the same version of the gradle plugin. here is the plugins? list: ```apply plugin: 'kotlin' apply plugin: 'kotlin-spring' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'org.flywaydb.flyway' apply plugin: 'http://au.com.dius.pact'``` and this is the dependecies inside the `buildscript` ```dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}") classpath "org.flywaydb:flyway-gradle-plugin:${flywayVersion}" classpath "au.com.dius:pact-jvm-provider-gradle:${pactVersion}" }``` where `pactVersion` is `4.0.10`

a.carpe
2020-04-23 15:38
I?m not able to find a command to list the classPath used by plugins to check the dependencies used by the plugin?

a.carpe
2020-04-23 16:04
I managed to make it works!

corey
2020-04-23 16:08
Dug in more this morning and the issue was around Kotlin version as pointed out in issue 949. Thanks Spring /sarcasm

a.carpe
2020-04-23 16:08
my app is structured in this way: ```+---my-app | +---my-app-domain | | \---build.gradle | +---my-app-web | | \---build.gradle | \---build.gradle``` because all my contract tests are under `my-app-web` I placed all the dependencies and the plugin configuration under the `my-app-web`?s `build.gradle` . Than I thought? ?I?m running gradle from the root folder? let me try to move only the plugin configuration on the root?s `build.gradle` ? and boom! It worked!

asher.feil
2020-04-23 19:31
has joined #pact-jvm

asher.feil
2020-04-23 19:37
Hi there, I'm trying to test out publishing a pact to a broker. But when I run the pactPublish task I just get this exception `Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)` I'm using au.com.dius:pact-jvm-provider-gradle:4.0.9 and the pact config isn't much ```pact { publish { pactBrokerUrl = myBrokerUrl version = '1.1.0' } }```

asher.feil
2020-04-23 19:39
that sent a little before I was done. I'm wondering if there is more required in the pact config for it to work or if the issue might lie outside of the plugin config. The pact are stored in the default directory so I left that option off.

uglyog
2020-04-23 22:36
what versions of Gradle and Java are you using?

asher.feil
2020-04-23 23:00
java 11 gradle 5.6.2

uglyog
2020-04-23 23:03
You might need to find any Gradle logs. There may be a stack trace logged somewhere to indicate why the Gradle deamon died

asher.feil
2020-04-24 00:15
thanks! it seems to be a similar issue to this one https://github.com/DiUS/pact-jvm/issues/414 with the root cause being jansi. the link you posted at the bottom doesn't seem to work now, though. FWIW unlike the description in that issue, I'm not doing this in docker


uglyog
2020-04-24 00:25
Apart from using docker, does the info in that issue help?

asher.feil
2020-04-24 00:59
i tried changing the reports to not include console, but i think the issue is on AnsiConsole init so thats not going to do it. looking at the linked issues, seems like there were work around but they stopped functioning?

asher.feil
2020-04-24 03:19
any other thoughts on workarounds?

mbieganski.infomatt
2020-04-24 12:40
has joined #pact-jvm

aliihlail
2020-04-26 21:50
@ActiveProfiles("test") @Provider("key-service") @Consumer("document-service") @PactBroker( authentication = @PactBrokerAuth(token = "${pactbroker.auth.token}"), scheme = "https", port = "443", host = "${pactbroker.auth.host}") @IgnoreNoPactsToVerify public class DocumentVerificationTest { private static final Logger LOGGER = LoggerFactory.getLogger(DocumentVerificationTest.class); @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(Pact pact, Interaction interaction, PactVerificationContext context) throws IOException { http://LOGGER.info("testTemplate called: " + pact.getProvider().getName() + ", " + interaction); context.verifyInteraction(); } @BeforeEach void setupTestTarget(PactVerificationContext context) throws IOException { context.setTarget(new AmpqTestTarget()); } @PactVerifyProvider("key handover") public Object documentServiceTest() { KeyProtocol keyProtocol = TestKeyFactory.createKeyProtocol(); keyProtocol.setId(1L); keyProtocol.setHandoverNote("test HandoverNote"); keyProtocol.setStatus(KeyProtocolStatus.PENDING_ISSUED); MessageModel model = new MessageModel("key-service", "key-service", keyProtocol); JsonNode messageModel = JacksonUtil.toJsonTree(model); return messageModel; } @PactVerifyProvider("key return") public Object documentServiceTest2() { KeyProtocol keyProtocol = TestKeyFactory.createKeyProtocol(); keyProtocol.setId(1L); keyProtocol.setReturnNote("test return Note"); keyProtocol.setStatus(KeyProtocolStatus.PENDING_CLOSING); MessageModel model = new MessageModel("key-service", "key-service", keyProtocol); JsonNode messageModel = JacksonUtil.toJsonTree(model); return messageModel; } @State("KEY_SERVICE_KEY_PROTOCOL_STATUS_PENDING_ISSUED") public void someProviderState() { http://LOGGER.info("document service provider state callback"); } @State("KEY_SERVICE_KEY_PROTOCOL_STATUS_PENDING_CLOSING") public void someProviderState2() { http://LOGGER.info("document service provider state callback"); } } Hi im still new with Pact testing, Im trying to write this code for testing Amqp. when i use the PactVerificationInvocationContextProvider i got an error java.lang.RuntimeException: Could not resolve property "pactbroker.auth.host" in the system properties or environment variables and no default value is supplied the idea how to inject the hosta nd token without using spring. is their any available example. i tried to to write a propertyReader class but also i cant do it because it should be constant. I would appreciate it if any one help with how to overcome it and solve it.

uglyog
2020-04-26 22:56
How are you running the test? Using Gradle or Maven?

aliihlail
2020-04-26 23:05
MAven

aliihlail
2020-04-26 23:05
Maven

aliihlail
2020-04-26 23:07
and as you know @uglyog using Spring for testing Amqp is much slower.

uglyog
2020-04-26 23:10
Using Maven you can either pass the values on the command line (`-Dpactbroker.auth.host=http://...`) or you can configure them using the surefire plugin (it's what runs the tests in Maven)

aliihlail
2020-04-26 23:18
can i add them to the application properties and then use a propertyReader, I tried but i got an error that it should be constant.

uglyog
2020-04-26 23:29
You can't use propertyReader, because you are not loading a Spring context. The only options you have is to use the command line parameters or set the properties on the surefire plugin.

aliihlail
2020-04-26 23:32
So can i understand that those the only 2 way and only those. can you also link me to an example of how to use them. i mean ether surefire pluging or the command line

aliihlail
2020-04-26 23:43
when i use the surefire plugin i got the following error java.lang.UnsupportedOperationException: At least one pact source must be present on the test class

uglyog
2020-04-26 23:52
There is something wrong with your setup, because it's not seeing the `@PactBroker` as a pact source. Can you confirm the full class for that annotation?

aliihlail
2020-04-26 23:54
when i added the @PactBrocker i got the follwoing error java.lang.IllegalArgumentException: Invalid pact broker host specified ('${pactbroker.host:}'). Please provide a valid host or specify the system property 'pactbroker.host'.

aliihlail
2020-04-26 23:55
im using thuis Suriefire configuration ```<plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> </plugin> <plugin> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.0</version> <configuration> <serviceProviders> <serviceProvider> <name>key-service</name> <protocol>http</protocol> <host>localhost</host> <port>8080</port> <path>/</path> <pactBroker> <url>https://XXXXX.pact.dius.com.au:443/</url> <authentication> <scheme>Bearer</scheme> <token>1-X-XXXXXXXXX</token> </authentication> </pactBroker> </serviceProvider> </serviceProviders> <pactBrokerUrl/> </configuration> </plugin>```

uglyog
2020-04-27 00:09
You can try using the latest version of the Maven plugin (4.0.10)

aliihlail
2020-04-27 00:14
java.lang.IllegalArgumentException: Invalid pact broker host specified ('${pactbroker.host:}'). Please provide a valid host or specify the system property 'pactbroker.host'.

aliihlail
2020-04-27 00:15
@uglyog and here is what i changed ``` @ActiveProfiles("test") @Provider("key-service") @Consumer("document-service") @PactBroker() public class DocumentVerificationTest {```

aliihlail
2020-04-27 00:17
i already tried also version 4.0.10

uglyog
2020-04-27 00:25
And did you run it with `-Dpactbroker.host=...`)

aliihlail
2020-04-27 10:26
No i did not tried. but i assume that this confugration should work.

aliihlail
2020-04-27 10:31
``` @ActiveProfiles("test") @Provider("key-service") @Consumer("document-service") @PactBroker @IgnoreNoPactsToVerify public class DocumentVerificationTest { private static final Logger LOGGER = LoggerFactory.getLogger(DocumentVerificationTest.class); @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(Pact pact, Interaction interaction, PactVerificationContext context) throws IOException { http://LOGGER.info("testTemplate called: " + pact.getProvider().getName() + ", " + interaction); context.verifyInteraction(); } @BeforeEach void setupTestTarget(PactVerificationContext context) throws IOException { context.setTarget(new AmpqTestTarget()); } @PactVerifyProvider("key handover") public Object documentServiceTest() { KeyProtocol keyProtocol = TestKeyFactory.createKeyProtocol(); keyProtocol.setId(1L); keyProtocol.setHandoverNote("test HandoverNote"); keyProtocol.setStatus(KeyProtocolStatus.PENDING_ISSUED); MessageModel model = new MessageModel("key-service", "key-service", keyProtocol); JsonNode messageModel = JacksonUtil.toJsonTree(model); return messageModel; } @PactVerifyProvider("key return") public Object documentServiceTest2() { KeyProtocol keyProtocol = TestKeyFactory.createKeyProtocol(); keyProtocol.setId(1L); keyProtocol.setReturnNote("test return Note"); keyProtocol.setStatus(KeyProtocolStatus.PENDING_CLOSING); MessageModel model = new MessageModel("key-service", "key-service", keyProtocol); JsonNode messageModel = JacksonUtil.toJsonTree(model); return messageModel; } @State("KEY_SERVICE_KEY_PROTOCOL_STATUS_PENDING_ISSUED") public void someProviderState() { http://LOGGER.info("document service provider state callback"); } @State("KEY_SERVICE_KEY_PROTOCOL_STATUS_PENDING_CLOSING") public void someProviderState2() { http://LOGGER.info("document service provider state callback"); } }```

aliihlail
2020-04-27 10:31
here is the code which also wrote on the provider side

aliihlail
2020-04-27 10:31
``` <plugin> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.10</version> <configuration> <serviceProviders> <serviceProvider> <name>key-service</name> <pactBroker> <url>https://XXXXXXXX.pact.dius.com.au:443</url> <authentication> <scheme>bearer</scheme> <token>1-A-XXXXXX</token> </authentication> </pactBroker> </serviceProvider> </serviceProviders> </configuration> </plugin>```

aliihlail
2020-04-27 10:32
and this is the suriefire plugin. i got always the same error. java.lang.IllegalArgumentException: Invalid pact broker host specified ('${pactbroker.host:}'). Please provide a valid host or specify the system property 'pactbroker.host'.

aliihlail
2020-04-27 22:27
``` @ActiveProfiles("test") @Provider("key-service") @Consumer("document-service") @PactBroker @IgnoreNoPactsToVerify public class DocumentVerificationTest { private static final Logger LOGGER = LoggerFactory.getLogger(DocumentVerificationTest.class); @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(Pact pact, Interaction interaction, PactVerificationContext context) throws IOException { http://LOGGER.info("testTemplate called: " + pact.getProvider().getName() + ", " + interaction); context.verifyInteraction(); } @BeforeEach void setupTestTarget(PactVerificationContext context) throws IOException { context.setTarget(new AmpqTestTarget()); } ---------------------- <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> </plugin> <plugin> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.10</version> <configuration> <serviceProviders> <serviceProvider> <name>key-service</name> <pactBroker> <url>https://XXXXXXX.pact.dius.com.au:443/</url> <authentication> <scheme>bearer</scheme> <token>1-A-XXXXXXXXXXX</token> </authentication> </pactBroker> </serviceProvider> </serviceProviders> </configuration> </plugin> Im trying to run the code which i have cut part of it above. when i use the Spring it works. But when i use @ExtendWith(PactVerificationInvocationContextProvider.class)``` i got the following error : java.lang.IllegalArgumentException: Invalid pact broker host specified ('${pactbroker.host:}'). Please provide a valid host or specify the system property 'pactbroker.host'.

uglyog
2020-04-27 22:54
I've already explained this to you. ```Please provide a valid host or specify the system property 'pactbroker.host'``` means exactly that. You need to provide this value as a JVM system property. There are two ways you can do this You can either set the value using the -D parameter when running Maven like `mvn verify -Dpactbroker.host=http://pactbroker ` (obliviously putting your host in there) OR You can configure the properties on the Maven surefire plugin. Here is a URL from Googling how to do that: http://www.javabyexamples.com/set-system-property-for-tests/

uglyog
2020-04-27 23:09
The other option is not to use system properties at all, and just set the value directly on the annotation

uglyog
2020-04-27 23:11
I.e. `@PactBroker(host = 'https://pactbroker')`

aliihlail
2020-04-27 23:45
Thanks alot this relly helped. and ever thing worked.

matt.fellows
2020-04-28 12:04
For those using Pact JVM, new guide on migrating from JUnit 4->5 https://twitter.com/kreuzwerker/status/1255057639702134784

mbieganski.infomatt
2020-04-29 04:29
Hi. Is it possible to use pending pacts and wip in junit implementation?

uglyog
2020-04-29 04:31
This hasn't been implemented yet

mbieganski.infomatt
2020-04-29 04:37
Thanks.

mbieganski.infomatt
2020-04-29 07:26
@uglyog what would be the approach for verifying pacts from feature branch with CI? Example: Consumer pushed new pact on branch feat/new and the provider webhook failed. Provider creates branch and pushes changes. What is the best appraoch for prvider CI now? 1. Have branch name match consumer branch ```pactbroker.tags="${BRANCH},master,dev"``` 2. Add latest to tags? ```pactbroker.tags='latest,master,dev'```

uglyog
2020-04-29 07:28
Was the new pact tagged with the consumer branch?

mbieganski.infomatt
2020-04-29 07:28
yes

uglyog
2020-04-29 07:29
I would go for option 1

mbieganski.infomatt
2020-04-29 07:30
will the CI fails if there is no contract to corresponding provider branch?

uglyog
2020-04-29 07:34
I'm not sure, I haven't tried that

mbieganski.infomatt
2020-04-29 07:37
will play around with it. thanks :slightly_smiling_face:

sen.rudrappa
2020-04-29 08:51
has joined #pact-jvm

mbieganski.infomatt
2020-04-29 11:06
looks like it will break build :confused: I'm wondering if there is some downside of using latest like pactbroker.tags='latest,master,dev' Unfortunately I do see yet any possibility to find consumer by tag. @bethskurrie maybe you would have have some idea :slightly_smiling_face:

mbieganski.infomatt
2020-04-29 11:41
as a workaround since I haven't found anything in Pact Broker I guess I could query database if given tag exists if not use default

bethskurrie
2020-04-29 21:04
@mbieganski.infomatt this step in our newly written CI/CD workshop explains how to verify feature pacts https://github.com/pactflow/ci-cd-workshop/blob/master/workshop/05_verifying_feature_pacts.md

bethskurrie
2020-04-29 21:05
Don't ever use "latest".

bethskurrie
2020-04-29 21:05
Also, "latest" is not actually a tag.

bethskurrie
2020-04-29 21:08
So, your option 1 (which is option 2 in that workshop) is your best approach (assuming pact JVM doesn't blow up if the tag doesn't exist) for now, because pact JVM doesn't use the APIs that allow "work in progress" pacts to be enabled yet. Once it does, you'll have the "selectors" shown in that example, but for now, your dynamic list of tags will work.

bethskurrie
2020-04-29 21:08
But I believe Ron is working on it!

bethskurrie
2020-04-29 21:13
If you're super keen, you could call the API directly to get the list of pacts, and then verify each pact individually by calling the pact verify task for each pact URL.

bethskurrie
2020-04-29 21:14
I believe pact JVM recently added support for verifying a pact at a given url (correct me if I'm wrong @uglyog)

uglyog
2020-04-29 23:29
Latest Pact-JVM does use the new endpoint

bethskurrie
2020-04-29 23:50
Ooh, exciting.

preethighalke
2020-04-30 05:51
has joined #pact-jvm

preethighalke
2020-04-30 05:53
Hi All, I have a query regarding Pact ProviderTest is this the right channel to place my query? Regards

uglyog
2020-04-30 06:09
If it's written for JVM, then yes

preethighalke
2020-04-30 06:37
Thank you @uglyog. I'm using 4.0.6 version of pact-jvm-provider-junit and seeing a RuntimeError (java.lang.NoSuchMethodError: org.junit.runners.model.TestClass.getAnnotation) as its unable to find the @PactSource , I have the following defined for my test: @RunWith(PactRunner.class) @PactFolder("src/test/resources/pacts") @Provider("xyz")

uglyog
2020-04-30 06:40
What version of JUnit are you using?

preethighalke
2020-04-30 06:40
JUnit4

uglyog
2020-04-30 06:43
I mean, what version of JUnit4?

preethighalke
2020-04-30 06:44
4.11 to be precise

uglyog
2020-04-30 06:45
You'll need to use 4.12

preethighalke
2020-04-30 06:48
ok. we are right now exploring the possibility to write contract test using pact for our product, do you have any suggestions for Pact version to beigin with?

preethighalke
2020-04-30 06:49
I just started off using 4.0.6 for Provider/Consumer. is it OK or better to shift to a greater version?

uglyog
2020-04-30 06:50
Use the latest version (4.0.10)

preethighalke
2020-04-30 06:51
sure and will that work with JUnit 4.12 ? as we cannot move to JUnit5 for now


preethighalke
2020-04-30 06:53
Many Thanks for the inputs. Regards.

mbieganski.infomatt
2020-04-30 07:17
Thank you very much . This is exactly what I thought. Since I'm using Jeknins I found a way to query broker db in pipeline and set the tags dynamically just in case pact jvm would have issue with missing tag and I will use URL functionality in webhooks.

bethskurrie
2020-04-30 07:32
Given that you have can I deploy, to emulate the "pending" feature, you could ignore all pact test failures and rely on can I deploy to report failures that affect your ability to deploy.

bethskurrie
2020-04-30 07:33
I'm pretty sure pact JVM is fine with a missing pact for a tag, as long as there is at least one pact to verify.

preethighalke
2020-04-30 10:22
With Junit version at 4.12 pact JVM version for consumer/Provider at 4.0.10 Running the provider test now throws org.junit.runners.model.InitializationError at http://au.com.dius.pact.provider.junit.PactRunner.getPactSource(PactRunner.kt:155) at http://au.com.dius.pact.provider.junit.PactRunner.initialize(PactRunner.kt:83) at http://au.com.dius.pact.provider.junit.PactRunner.getChildren(PactRunner.kt:140) at org.junit.runners.ParentRunner.getFilteredChildren(ParentRunner.java:426) I have the following annotations defined @RunWith(PactRunner.class) @PactFolder("src/test/resources/pacts") @Provider("xyz") and the pact json is very much present in the "/pacts" folder. Not sure what is amiss this time, need help as we are unable to get the ProviderTest running as a Junit. We were able to verify the generated pact using the maven plugin "pact:verify" but unable to get the simple JUnit to work. Any inputs would unblock us. Many Thanks.

jsanchez
2020-04-30 11:46
has joined #pact-jvm

komeershettyvinod
2020-04-30 12:16
I am getting 401 Unautorized error when tried to publish pact via gradle

komeershettyvinod
2020-04-30 12:20
Please correct me if I am missing there

komeershettyvinod
2020-04-30 12:20
I just put the login credentials of pact broker url

komeershettyvinod
2020-04-30 12:20
is that right?

komeershettyvinod
2020-04-30 12:33
@asher.feil I was also facing same issue, as part of a POC i am trying to publish a simple pact file via gradle , But i am seeing un uthorization issue. Did you got any soln

komeershettyvinod
2020-04-30 14:22
@matt.fellows Can you please help me here

matt.fellows
2020-04-30 22:08
You need to use tokens and not your username/password

matt.fellows
2020-04-30 22:08
Did you enable the debug logs? You would see a message explaining that

matt.fellows
2020-04-30 22:09
Also the email you received from signup mentions you need a token


uglyog
2020-04-30 23:04
@komeershettyvinod you need to use an API token, not your username and password. You can get an API token from the settings screen in Pactflow.

srinivasan.sekar1990
2020-05-03 10:44
has joined #pact-jvm

srinivasan.sekar1990
2020-05-03 10:48
Hi Team, can someone help me fix below issue when validating messages at producer end of a spring boot kafka application? ```Verifying a pact between dateConsumerKafka and dateProviderKafka [from Pact Broker http://localhost:82/pacts/provider/dateProviderKafka/consumer/dateConsumerKafka/version/0.0.1-SNAPSHOT] valid date from kafka provider Verification Failed - No annotated methods were found for interaction 'valid date from kafka provider'. You need to provide a method annotated with @PactVerifyProvider("valid date from kafka provider") on the classpath that returns the message contents. java.lang.RuntimeException: No annotated methods were found for interaction 'valid date from kafka provider'. You need to provide a method annotated with @PactVerifyProvider("valid date from kafka provider") on the classpath that returns the message contents. at http://au.com.dius.pact.provider.ProviderVerifier.verifyResponseByInvokingProviderMethods(ProviderVerifier.kt:282)``` My provider test looks like below: ```@RunWith(SpringMessagePactRunner.class) @Provider("dateProviderKafka") @Consumer("dateConsumerKafka") @PactBroker(host = "localhost", port = "82") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class DateProducerTest { @TestTarget public final Target target = new SpringAwareAmqpTarget(); @PactVerifyProvider("valid date from kafka provider") String verifyDateInformationMessage() { System.out.println("i m invoked"); return "{\"isLeapYear\":true,\"localDate\":\"2000-01-31\"}"; } }``` Maven config looks like below: ``` <plugin> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.0</version> <configuration> <serviceProviders> <serviceProvider> <name>dateProviderKafka</name> <verificationType>ANNOTATED_METHOD</verificationType> <packagesToScan> <packageToScan>http://src.test.java.com.example.producer.pact</packageToScan> </packagesToScan> <pactBroker> <url>http://localhost:82/</url> </pactBroker> </serviceProvider> </serviceProviders> <configuration> <pact.showStacktrace>true</pact.showStacktrace> <pact.verifier.publishResults>true</pact.verifier.publishResults> </configuration> <pactBrokerUrl/> </configuration> </plugin>``` Appreciate any help. Thanks in advance.


chandanakurumeti27
2020-05-04 08:45
Hi , I wanted to use `pact-jvm-consumer` dependency to support (testNG @Test annotation )and not `pact-jvm-consumer-junit.2.11` as my consumer code base is using testNG framework. Is there any possibility to use `pact -jvm-comsumer` dependency which can support TestNG. Cannot really use `pact-jvm-consumer-junit.2.11` for my consumer code base, please help me to find the solution here in this case. looking forward to some suggestions. Thanks, Chandana

chandanakurumeti27
2020-05-04 09:08
Can you please change this line to `@PactFolder("src/test/resources/pacts")` to `@PactFolder("pacts")` as @pactfolder will try to look for the *pacts* inside the *src/test/Resources* by default. From your `@PactFolder("src/test/resources/pacts")` , I guess it is trying to look for `src/test/resources/pacts inside src/test/resources`

chandanakurumeti27
2020-05-04 13:40
Can someone please help me to understand the difference between `pact-jvm-consumer` and `pact-jvm-consumer-junit` dependencies ?

theuiser
2020-05-04 16:52
has joined #pact-jvm

theuiser
2020-05-04 16:54
Hi. I'm want to run my Pact Provider test via mvn. I followed the instructions here: https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-junit and included ```<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> <configuration> <useSystemClassLoader>false</useSystemClassLoader> </configuration> </plugin>``` However, when I run `mvn clean install` it doesn't seem to be running my Pact test (I forced it to fail) because everything still passes.

srinivasan.sekar1990
2020-05-04 17:06
@uglyog Thanks for your time. Unfortunately no luck with above luck. I'm still getting same issue. ```Verifying a pact between dateConsumerKafka and dateProviderKafka [from Pact Broker http://localhost:82/pacts/provider/dateProviderKafka/consumer/dateConsumerKafka/version/0.0.1-SNAPSHOT] valid date from kafka provider Verification Failed - No annotated methods were found for interaction 'valid date from kafka provider'. You need to provide a method annotated with @PactVerifyProvider("valid date from kafka provider") on the classpath that returns the message contents. java.lang.RuntimeException: No annotated methods were found for interaction 'valid date from kafka provider'. You need to provide a method annotated with @PactVerifyProvider("valid date from kafka provider") on the classpath that returns the message contents. ```

wesleythomaswilliams
2020-05-04 20:24
Hi Tanya, have you included these dependencies: ``` <dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-junit5</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency>```

wesleythomaswilliams
2020-05-04 20:25
Also, are you junit4 or junit5?

theuiser
2020-05-04 20:52
@wesleythomaswilliams I'm using junit5. I have the following ```<dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-junit5_2.12</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency>```

theuiser
2020-05-04 20:53
I was able to get it working after following instructions from this article: https://blog.ramjee.uk/microservices-and-consumer-tests/

theuiser
2020-05-04 20:55
My setup: ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.2</version> <dependencies> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-surefire-provider</artifactId> <version>1.2.0</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.2.0</version> </dependency> </dependencies> </plugin>```

wesleythomaswilliams
2020-05-04 20:56
Glad you've got it working :slightly_smiling_face:

theuiser
2020-05-04 20:56
Wondering if that should be included in the Pact docs: https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-junit @uglyog

theuiser
2020-05-04 20:57
The next step is to publish the verification results. @wesleythomaswilliams Have you done that by any chance?

wesleythomaswilliams
2020-05-04 21:53
I have

wesleythomaswilliams
2020-05-04 21:55
I restrict publishing of verification results to our pipeline only. I decided I don't want that to happen in local builds unless it's deemed absolutely necessary, so I set these defaults in our pom ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <pact.broker.host>http://mybroker.pact.dius.com.au</pact.broker.host> <pact.broker.token>mytoken</pact.broker.token> <pact.verifier.publishResults>false</pact.verifier.publishResults> <pact.provider.version>${pact.provider.version}</pact.provider.version> <pact.provider.version.trimSnapshot>false</pact.provider.version.trimSnapshot> </systemPropertyVariables> </configuration> </plugin>```

wesleythomaswilliams
2020-05-04 21:57
In my pipeline when I execute provider tests, I have something like this: ``` ' mvn -B -f pom.xml verify' + ' -Dpact.provider.version=' + env.GIT_COMMIT + ' -Dpact.verifier.publishResults=true' + ' -Dpact.provider.tag=' + env.GIT_BRANCH```

theuiser
2020-05-04 22:02
I believe it?s this plugin that lets me run pact:verify, right? ``` <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency>```

uglyog
2020-05-04 23:08
I'm just trying to work out what you're actually asking. I think you want to use TestNG instead of JUnit? If that is the case, there is no direct support for TestNG. You can use the `pact-jvm-consumer` to write your own TestNG support.

abubics
2020-05-04 23:51
The distinction is hinted at in https://github.com/DiUS/pact-jvm#service-consumers: > *Service Consumers* > Pact-JVM has a number of ways you can write your service consumer tests. > > *I Use Scala* > You want to look at: https://github.com/ITV/scala-pact or https://github.com/DiUS/pact-jvm/blob/master/consumer/pact-jvm-consumer-specs2 > > *I Use Java* > You want to look at: https://github.com/DiUS/pact-jvm/blob/master/consumer/pact-jvm-consumer-junit for JUnit 4 tests and https://github.com/DiUS/pact-jvm/blob/master/consumer/pact-jvm-consumer-junit5 for JUnit 5 tests. Also, if you are using Java 8, there is https://github.com/DiUS/pact-jvm/blob/master/consumer/pact-jvm-consumer-java8. > > ... > > *I Use some other jvm language or test framework* > You want to look at: https://github.com/DiUS/pact-jvm/blob/master/consumer/pact-jvm-consumer

abubics
2020-05-04 23:52
but, basically, `pact-jvm-consumer` is the base library, and `pact-jvm-consumer-junit` is junit bindings for the base

wesleythomaswilliams
2020-05-05 08:28
Yes, I believe so

wesleythomaswilliams
2020-05-05 08:28
I have both of these defined in my provider pom ``` <dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-junit5</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency>```

chandanakurumeti27
2020-05-05 09:43
Is there any example to consider for reference where i can use `pact-jvm-consumer` to write my own TestNG support ? if so please provide the link.Thank you

rjaladurgam
2020-05-05 16:42
has joined #pact-jvm


nick.smith3128
2020-05-06 14:21
has joined #pact-jvm

nick.smith3128
2020-05-06 14:22
hi. is there any reason why my Pact file generation fails unless I put a sleep in @PactVerificationmethopd? ```@Test @PactVerification(fragment = "createCreateAssetSyndicationResponse") public void doCreateCreateAssetSyndicationResponse() throws InterruptedException { Thread.sleep(WAIT_TIME); new CustomClient().getPostResponse(ENTERPRISE_API_PATH + GET_ASSETS + "/" + ROOT_MEDIA_ASSET + ASSET_SYNDICATION_API); }``` If I dont have it then i get the error: ```[ERROR] EnterpriseCreateAssetSyndicationConsumerTest.doCreateCreateAssetSyndicationResponse Pact Test function failed with an exception, possibly due to ExpectedButNotReceived(expectedRequests=[ method: POST path: /api/assets/70/syndication query: {} headers: {} matchers: MatchingRules(rules={path=Category(name=path, matchingRules={=MatchingRuleGroup(rules=[RegexMatcher(regex=/api/assets/[0-9]+/syndication, example=null)], ruleLogic=AND)})}) generators: Generators(categories={}) body: MISSING]) [INFO] ``` I'm using v4.0.10

nick.smith3128
2020-05-06 14:54
ok looks like this was the issue https://github.com/DiUS/pact-jvm/issues/342

plessmann
2020-05-07 13:09
has joined #pact-jvm

plessmann
2020-05-07 13:10
Hi all, Im following https://github.com/DiUS/pact-jvm/blob/v4.x/consumer/pact-jvm-consumer-specs2/src/test/scala/au/com/dius/pact/consumer/specs2/ExamplePactSpec.scala to migrate from ScalaPact to PactJVM. Im having an issue when having 2 interactions like in the example, i get the following exception: ```[error] java.lang.UnsupportedOperationException: null (MutableCollectionsJVM.kt:42) [error] kotlin.collections.CollectionsKt__MutableCollectionsJVMKt.sortWith(MutableCollectionsJVM.kt:42) [error] http://au.com.dius.pact.core.model.RequestResponsePact.sortInteractions(RequestResponsePact.kt:65) [error] http://au.com.dius.pact.core.model.DefaultPactWriter.writePact(PactWriter.kt:56) [error] http://au.com.dius.pact.core.model.DefaultPactWriter.writePact(PactWriter.kt:100) [error] http://au.com.dius.pact.consumer.BaseMockServer.verifyResultAndWritePact(MockHttpServer.kt:133) [error] http://au.com.dius.pact.consumer.BaseMockServer.runAndWritePact(MockHttpServer.kt:119) [error] http://au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest(ConsumerPactRunner.kt:13) [error] http://au.com.dius.pact.consumer.specs2.PactSpec$ReadyForTest.$anonfun$withConsumerTest$2(PactSpec.scala:54) [error] http://au.com.dius.pact.consumer.specs2.PactSpec$$anon$1.asResult(PactSpec.scala:33)``` I copied the example from the repo previously referenced and got the same error. So far i can infer an issue while sorting interactions but i have no clue what i am missing, can anyone point me in the correct path? Im using Java 11 but it also fails in Java 8.

antonello
2020-05-07 18:47
Our team has come across and raised this issue today https://github.com/DiUS/pact-jvm/issues/1086 Is there something we?re missing?

uglyog
2020-05-07 22:55
Can you raise an issue on Github? TBH, the Scala support hasn't been looked at for a long time because Scala-Pact existed. Is there a reason you are trying to migrate to Pact-JVM?

abubics
2020-05-07 23:44
Probably because ScalaPact is kinda nonstandard and unsupported :stuck_out_tongue:

plessmann
2020-05-08 07:04
my organization is mostly Java prefering PactJVM because of Pact V3, so in oder to standarize we started this migration

plessmann
2020-05-08 07:05
ok, i will create an issue

plessmann
2020-05-08 08:23
i created it https://github.com/DiUS/pact-jvm/issues/1088 thanks for your help :slightly_smiling_face:

hoagiex
2020-05-09 21:53
has joined #pact-jvm

hoagiex
2020-05-09 21:53
nvm, found it: I needed a generator in the json

preethighalke
2020-05-11 04:26
Thank you @chandanakurumeti27 !!

hans.brouwer
2020-05-13 08:27
has joined #pact-jvm

hans.brouwer
2020-05-13 08:59
Hi, we are using Scala 2.13 and want to do CDC-testing with kafka. Which version of the pact-jvm should we use?

uglyog
2020-05-13 23:14
Depends on the version of Java you want to use. I don't think the Spec2 and Scalatest support is working with the latest version (I haven't checked it), but if you stick to JUnit tests it should work.

ashwin.bakker
2020-05-14 12:22
has joined #pact-jvm

ashwin.bakker
2020-05-14 13:36
Hi Pact community! Question: I'm trying to add an authorization token to the request headers in my provider verification tests using `@TargetRequestFilter`, but I'm getting the exception `java.lang.Exception: Method addJwtToHeaderFilter should take only a single HttpRequest parameter`. I've tried changing `HttpRequest` to `MockHttpServletRequestBuilder` as per https://github.com/DiUS/pact-jvm/issues/983 but to no avail. Has something changed in the way headers should be added to requests? This is the test: ```@RunWith(SpringRestPactRunner.class) @ActiveProfiles("default") @Provider("RekeningInzicht") @PactBroker(scheme = "https", host = "MY_PACTFLOW", port = "443", authentication = @PactBrokerAuth(token = "MY_TOKEN")) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class MijnRekeningRekeningInzichtSpringPactRunner extends BaseOperationIntegrationTest { @TestTarget public final Target target = new SpringBootHttpTarget(); @MockBean private RekeningenService rekeningenService; @BeforeClass public static void setupOnce() { System.setProperty("developmentMode", "true"); } @Before public void setup() { IntegrationTestHelper.createTokenForContract( authenticator, IdentityType.CUSTOMER, AuthLevel.LEVEL30, ConfLevel.PUBLIC, IntegrationTestHelper.DEFAULT_CONTRACT); } @TargetRequestFilter public void addJwtToHeaderFilter(HttpRequest request) { request.getHeaders().add(IntegrationTestHelper.customerHeader.getName(), IntegrationTestHelper.customerHeader.getValue()); } @State("logged in user") public void getRekening() { reset(rekeningenService); } }``` Brief explanation: the class extends a base class `BaseOperationIntegrationTest` used by all integration tests my organization writes. I'm not sure if it's relevant, but I'll share it anyways: ```@RunWith(SpringRunner.class) @SpringBootTest @ActiveProfiles({"integration"}) public abstract class BaseOperationIntegrationTest { protected MockMvc mockMvc; @Autowired protected WebApplicationContext webApplicationContext; @Autowired protected MockIdentityAuthenticator authenticator; @Autowired protected List<FilterRegistrationBean> filterRegistrationBeans; @Autowired private FilterChainProxy filterChainProxy; public BaseOperationIntegrationTest() { } @Before public final void beforeBaseOperationIntegrationTest() { this.initializeMockMvc(); } protected void initializeMockMvc() { Filter[] filters = (Filter[])this.filterRegistrationBeans.stream().map(FilterRegistrationBean::getFilter).filter((f) -> { return f.getClass().getSimpleName().matches(".*(Logging|HeaderContext)Filter"); }).toArray((x$0) -> { return new Filter[x$0]; }); this.mockMvc = ((DefaultMockMvcBuilder)((DefaultMockMvcBuilder)MockMvcBuilders.webAppContextSetup(this.webApplicationContext).addFilters(filters)).addFilter(this.filterChainProxy, new String[0])).build(); } }``` Full exxception: java.lang.Exception: Method addJwtToHeaderFilter should take only a single HttpRequest parameter at au.com.dius.pact.provider.junit.target.BaseTarget.validateTargetRequestFilters(BaseTarget.kt:111) at au.com.dius.pact.provider.junit.target.HttpTarget.getProviderInfo(HttpTarget.kt:121) at au.com.dius.pact.provider.junit.target.HttpTarget.testInteraction(HttpTarget.kt:67) at http://au.com.dius.pact.provider.junit.InteractionRunner$interactionBlock$statement$1.evaluate(InteractionRunner.kt:204) at http://au.com.dius.pact.provider.junit.RunStateChanges.evaluate(RunStateChanges.kt:20) at http://au.com.dius.pact.provider.spring.SpringBeforeRunner.evaluate(SpringInteractionRunner.kt:32) at http://au.com.dius.pact.provider.spring.SpringAfterRunner.evaluate(SpringInteractionRunner.kt:48) at au.com.dius.pact.provider.junit.InteractionRunner.run(InteractionRunner.kt:145) at http://au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:147) at http://au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:52) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:64) The way tokens are generated is copied from their existing integration tests. Usage of tokens is mandatory and cannot be disabled. Me and my team are trying to introduce CDCT using Pact to the development teams at one of the larger banks here in The Netherlands, so we want to make adoption as easy as possible for them. That's why I'm closely following the way they currently run integration tests. I'm having some trouble determining what goes wrong when the `@TargetRequestFilter` is called, since evidently more than one parameter is passed to the function. Can anyone provide us with some insights? Thanks! EDIT: we use `pact-jvm-provider-spring` version `4.0.10`

mbieganski.infomatt
2020-05-14 14:11
Hi is there a plan to add this functionality https://github.com/DiUS/pact-jvm/issues/600 in any nearest release?

uglyog
2020-05-15 00:15
Can you confirm the import for the HttpRequest you are using? Is it `org.apache.http.HttpRequest`?

uglyog
2020-05-15 00:17
I've recently implemented this in the Pact-Rust, Pact-JS V3 and Pact-C++. I can now port that back to the JVM version.

ashwin.bakker
2020-05-15 07:23
@uglyog My goodness, I can't believe I used a wrong import :rolling_on_the_floor_laughing::rolling_on_the_floor_laughing: I was using `org.springframework.http.HttpRequest` . I was in such a Spring mindset that I just automatically imported that one as soon as I saw 'spring'. The header is now added, thank you!! :smile:

antonello
2020-05-18 09:29
For anyone who is/was interested in this issue: https://github.com/DiUS/pact-jvm/issues/1035, we?re putting it to bed by migrating provider tests to Junit5. The filtering using `@Tag` prevents the spring context to be initialised even when no tests are running. (use case is that we don?t run provider verification with all other tests, but in a separate stage).

robert.strauch_slack
2020-05-18 21:25
has joined #pact-jvm

robert.strauch_slack
2020-05-18 21:30
Taking my first steps with pact-jvm. I do have a pact file and would now like to verify the provider. I took the JUnit5 approach. ```@Provider("my-backend") @PactFolder("src/test/resources/pacts") public class PactProviderTest { private static final String PROVIDER_URL = "http://localhost:8090"; @BeforeEach void before(PactVerificationContext context) throws MalformedURLException { context.setTarget(HttpTestTarget.fromUrl(new URL(PROVIDER_URL))); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) private void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } }``` When running this test class I get the message that no tests were found. Using the same directory with the Maven plugin executes just fine. Is there something I'm missing?

wesleythomaswilliams
2020-05-18 21:36
You'll want @state methods to validate the pact against.

wesleythomaswilliams
2020-05-18 21:38
JUnit 5?s @TestTemplate feature is used in combination with PactVerificationInvocationContextProvider to dynamically create a test for every interaction found in the pact. For REST contracts, verifyInteraction is executed against methods with the @State annotation. For Messaging contracts, the @PactVerifyProvider annotation is used.

wesleythomaswilliams
2020-05-18 21:41
The value of the @state annotation should match the .given value set in the consumer test.

robert.strauch_slack
2020-05-18 21:44
Ah, I see... thanks. My understanding was that `@State` was only necessary when not using the test template. Guess I was wrong :-)

robert.strauch_slack
2020-05-18 22:01
Hmmm, guess I'm still missing something. I added the following to the class: ```@State("portal API is deployed") public void check() { System.out.println("foo"); }``` The interaction reads: `"providerState": "portal API is deployed"` but it stil says that no tests are found.

robert.strauch_slack
2020-05-18 22:17
Found the mistake... I marked the before and template methods as private. Having removed this is working

baquinteros
2020-05-19 12:53
Hey there, I'm a noob to java and pact jvm. I'm using the junit5 consumer like https://github.com/DiUS/pact-jvm/blob/master/consumer/pact-jvm-consumer-junit5/src/test/java/au/com/dius/pact/consumer/junit5/ArticlesTest.java And I'm trying to set the ProviderInfo to https and insecure which looks like it's a param for https://github.com/DiUS/pact-jvm/blob/fc25baf610dd78c2c9b4ff95a29a4a92d42a5212/consumer/pact-jvm-consumer-junit5/src/main/kotlin/au/com/dius/pact/consumer/junit5/PactConsumerTestExt.kt#L189 so the test hits a https mockServer. How can I achieve this?

wesleythomaswilliams
2020-05-19 13:51
I don't suppose anyone is aware of a convertor that reads a piece of json and turns it into PactDslJsonBody. That would make my life so much easier. :smile: Also, does everyone else write their PactDslJsonBody with indentation to match the indentation in their json? I find it's the only way I can make it readable, but my IDE just wants it all in a flat structure. e.g.: I write: ```final DslPart body = new PactDslJsonBody() .object("idWrapper") .stringType("sain", "9rz8rz2y") .eachLike("identifiers", 1) .stringType("alias", "thing") .minArrayLike("value", 1, PactDslJsonRootValue.stringType("0634158430268"), 1) .closeObject() .closeArray().asBody() .minArrayLike("aliases", 1, PactDslJsonRootValue.stringType("Test"), 1) .closeObject()``` My IDE would prefer it if I wrote: ```final DslPart body = new PactDslJsonBody() .object("idWrapper") .stringType("sain", "9rz8rz2y") .eachLike("identifiers", 1) .stringType("alias", "thing") .minArrayLike("value", 1, PactDslJsonRootValue.stringType("0634158430268"), 1) .closeObject() .closeArray().asBody() .minArrayLike("aliases", 1, PactDslJsonRootValue.stringType("Test"), 1) .closeObject()``` So any time I cut and paste what I've written into a another class, it automatically flattens it :disappointed:

uglyog
2020-05-19 22:47
Pact JUnit 5 has no may to specificity to use a HTTPS mock server. Please raise an issue for this at the github project.

matt.fellows
2020-05-19 22:58
Oh, a client I worked on did this

matt.fellows
2020-05-19 22:58
I?ll see if they are willing to share it

matt.fellows
2020-05-19 22:58
they created an Intellij plugin actually


antonello
2020-05-20 06:18
Support for pending pacts in 4.1.0! ?

wesleythomaswilliams
2020-05-20 08:12
And I'm using IntelliJ, so that would be great.

matt.fellows
2020-05-20 10:06
I?ll ping them now

thinh.tranquoc
2020-05-20 10:57
has joined #pact-jvm

ashish_garg5
2020-05-20 11:08
has joined #pact-jvm

thinh.tranquoc
2020-05-20 11:08
hi all, I have a question https://stackoverflow.com/questions/61206271/pact-jvm-matching-rules-are-being-ignored-when-running-test . Could you please help me a response :slightly_smiling_face:

ashish_garg5
2020-05-20 11:08
Hi All, I want to combine my GET and POST request. return builder .given("create inventory").uponReceiving("a request to save inventory").path("/api/inventory") .body(requestBody).method(RequestMethod.POST.name()).willRespondWith().headers(headers).status(200) .body(responseBody) .toPact(); return builder .given("get inventory").uponReceiving("a request to get inventory").path("/api/inventory").method("GET") .willRespondWith().headers(headers).status(200).body(responseBody) .toPact(); right now i have these 2 in different files if i am combining i am getting error. Please help.

matt.fellows
2020-05-20 11:09
Ashish, it looks like you?re trying to first ?create? the inventory and then ?get? it. That smells like a typical end-to-end test, which is not how you should approach things in Pact

matt.fellows
2020-05-20 11:10
You should instead use a state for the GET call. e.g. ?inventory with id X exists?

ashish_garg5
2020-05-20 11:14
sorry i didn't get actually... i am new to pact so i just wanted to combine 2 api's in same builder instead of creating a different class for it

matt.fellows
2020-05-20 11:15
Why do you need to create it in the same builder though?

matt.fellows
2020-05-20 11:15
As a general rule, you want each interaction to have its own test


wesleythomaswilliams
2020-05-20 11:21
@ashish_garg5 This previous thread may be of help: https://pact-foundation.slack.com/archives/C5F4KFKR8/p1588616560319700

wesleythomaswilliams
2020-05-20 11:22
I think from your example, you have one API, but you want to make different types of call to that API (e.g. GET, POST etc.).

matt.fellows
2020-05-20 11:55
Wes, are you a bot?!

wesleythomaswilliams
2020-05-20 12:01
lol, just a guy who gets far too easily distracted and uses slack waaay too much

jake.chandrasakera
2020-05-20 12:28
has joined #pact-jvm

sairsule
2020-05-20 13:22
has joined #pact-jvm

sairsule
2020-05-20 13:39
what version of JDK is recommended to work with Pact?

sairsule
2020-05-20 13:58
i am getting following error while trying out workshop project org.gradle.api.GradleScriptException: A problem occurred evaluating project ':providers:dropwizard-provider'.

aliihlail
2020-05-21 13:46
Hi i wrote a test for provider service. when i run the code locally every thing works fine. once i upload it bitbucket i got the followin error Failed to invoke provider method 'testDocumentService2' (java.lang.RuntimeException)

lankala321
2020-05-21 13:48
has joined #pact-jvm

aliihlail
2020-05-21 14:18
`Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.util.PropertiesUtil at org.apache.logging.log4j.status.StatusLogger.<clinit>(StatusLogger.java:71) at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:60) at org.apache.commons.logging.LogFactory$Log4jLog.<clinit>(LogFactory.java:199) at org.apache.commons.logging.LogFactory$Log4jDelegate.createLog(LogFactory.java:166) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:109) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:99) at org.springframework.beans.BeanUtils.<clinit>(BeanUtils.java:68) at de.mediciliving.cloud.contact.member.QuartersMemberMapper.toMessageModel(QuartersMemberMapper.java:43) at de.mediciliving.cloud.contact.member.QuartersMemberMapper.createMessageModel(QuartersMemberMapper.java:71) at de.mediciliving.cloud.contact.pactTesting.CommunityAmqpVerificationTest.testCommunityServiceMemberProfileIsCreated(CommunityAmqpVerificationTest.java:61)`

aliihlail
2020-05-21 14:18
here is the error also which i got in bitbucket

praneethkumar
2020-05-21 15:57
has joined #pact-jvm

antonello
2020-05-22 07:13
Can @PactUrl point to a specific url in the broker or can it only be to a file system? https://github.com/DiUS/pact-jvm/blob/master/provider/junit/README.md#pact-url

uglyog
2020-05-22 07:14
Any URL

antonello
2020-05-22 07:27
Great - so I think this should help with the issue I mentioned earlier.

uglyog
2020-05-22 07:40
The only problem is that @PactUrl won't include the bearer token (if the broker is authenticated)

antonello
2020-05-22 07:43
Luckily it isn?t :)

aliihlail
2020-05-22 09:24
I have an issue: trying to i worte an Amqp test but when we have more than one amq contract at the proider side i got the following error at pact Broker Failed to invoke provider method 'testCommunityServiceMemberProfileIsCreated' (java.lang.RuntimeException) also i got an error `aused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.util.PropertiesUtil`

wesleythomaswilliams
2020-05-22 10:02
Can you share the whole provider test class

praneethkumar
2020-05-22 10:21
I am getting the below error when running the. Provider test against a real API . ?Expected a response type of 'application/json' but the actual type was 'text/plain'?. The API is returning Json Did anyone face this issue ?

aliihlail
2020-05-22 10:22
``` @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "contact-service", providerType = ProviderType.ASYNCH) public class ContactAmqpTest { @Pact(consumer = "document-service") public MessagePact createCustomerDocumentsPact(MessagePactBuilder builder) { return builder .given("member document is created") .expectsToReceive("CONTACT_SERVICE_MEMBER_CREATED") .withContent(newJsonBody((result) -> { result.object("entities", (entities) -> { entities.object("member", (member) -> { member.id("id"); member.stringType("firstName"); member.stringType("lastName"); member.datetimeExpression("createdAt", "2020-01-01T12:20:40"); member.stringMatcher("countryCode", "DE|NL|US", "DE"); }); }); }).getPactDslObject()) .toPact(); } @Pact(consumer = "document-service") public MessagePact reCreateCustomerDocumentsPact(MessagePactBuilder builder) { return builder .given("member document is recreated") .expectsToReceive("CONTACT_SERVICE_MEMBER_RECREATE_DOCUMENTS") .withContent(newJsonBody((result) -> { result.object("entities", (entities) -> { entities.object("member", (member) -> { member.id("id"); member.stringType("firstName"); member.stringType("lastName"); member.datetimeExpression("createdAt", "2020-01-01T12:20:40"); member.stringMatcher("countryCode", "DE|NL|US", "DE"); }); }); }).getPactDslObject()) .toPact(); } @Test @PactTestFor(pactMethod = "createCustomerDocumentsPact") void testCreateContactDocumentPact(List<Message> messages) { } @Test @PactTestFor(pactMethod = "reCreateCustomerDocumentsPact") void testReCreateContactDocumentPact(List<Message> messages) { } }```

aliihlail
2020-05-22 10:24
```package de.mediciliving.cloud.community.pact.pactConsumer; import http://au.com.dius.pact.consumer.MessagePactBuilder; import http://au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import http://au.com.dius.pact.consumer.junit5.PactTestFor; import http://au.com.dius.pact.consumer.junit5.ProviderType; import http://au.com.dius.pact.core.model.annotations.Pact; import http://au.com.dius.pact.core.model.messaging.Message; import http://au.com.dius.pact.core.model.messaging.MessagePact; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import java.util.List; import static io.pactfoundation.consumer.dsl.LambdaDsl.newJsonBody; @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "contact-service", providerType = ProviderType.ASYNCH) public class ContactAmqpTest { @Pact(consumer = "community-service") public MessagePact createChatProfilePact(MessagePactBuilder builder) { return builder .given("member profile is created") .expectsToReceive("CONTACT_SERVICE_MEMBER_CREATED") .withContent(newJsonBody((result) -> { result.object("entities", (entities) -> { entities.object("member", (member) -> { member.numberType("userId"); member.stringType("firstName"); member.stringType("lastName"); }); }); }).getPactDslObject()) .toPact(); } @Pact(consumer = "community-service") public MessagePact deleteProfilePact(MessagePactBuilder builder) { return builder .given("member profile is disabled") .expectsToReceive("CONTACT_SERVICE_MEMBER_STATUS_DISABLED") .withContent(newJsonBody((result) -> { result.object("entities", (entities) -> { entities.object("member", (member) -> { member.numberType("userId"); }); }); }).getPactDslObject()) .toPact(); } @Test @PactTestFor(pactMethod = "createChatProfilePact") void testCreateChatProfilePact(List<Message> messages) { } @Test @PactTestFor(pactMethod = "deleteProfilePact") void testDeleteProfilePact(List<Message> messages) { } }```

matt.fellows
2020-05-22 10:25
Check Content type header

praneethkumar
2020-05-22 10:33
Hi Matt , the expected content type was application/ json and the api is returning the same . But for some reason the test fails

matt.fellows
2020-05-22 10:53
Can you please show some logs to prove that? I'm 99.99% sure that your provider is not returning the correct header

matt.fellows
2020-05-22 10:54
Alternatively it's hitting the wrong endpoint which doesn't send that header

sairsule
2020-05-22 12:19
JVM workshop project does not compile. Is anybody else facing the issue?

sairsule
2020-05-22 12:19
Could not resolve all files for configuration ':providers:dropwizard-provider:compile'. > Could not resolve org.slf4j:slf4j-api:1.7.22. Required by: project :providers:dropwizard-provider > Could not resolve org.slf4j:slf4j-api:1.7.22. > Could not get resource 'https://repo.maven.apache.org/maven2/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22.pom'. > Could not HEAD 'https://repo.maven.apache.org/maven2/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22.pom'. > Received fatal alert: protocol_version

sairsule
2020-05-22 14:47
Nevermind, got to know this is my JDK error

zeldigas
2020-05-22 17:49
has joined #pact-jvm

uglyog
2020-05-24 00:20
This looks like an issue with your project. You might be missing a library your code is using.

uglyog
2020-05-24 00:21
`org.apache.logging.log4j.util.PropertiesUtil` is not used by anything the Pact-JVM libraries.

mbieganski.infomatt
2020-05-25 09:03
Hi. I'm working now the amqp contract tests. Could you tell me what is the difference between @PactVerifyProvider and @State annotations? From what I have read it seems to be the same where @State is being used in Rest. Unless I'm missing something. Thanks!

wesleythomaswilliams
2020-05-25 14:40


mbieganski.infomatt
2020-05-25 20:25
Thanks @wesleythomaswilliams! `given` and `expectsToReceive` messed with me.. Messages are giving me a bit of a headache :wink: @uglyog can I in `@PactVerifyProvier` return whole message and the metadata will be verified as well?

uglyog
2020-05-25 22:59
Yes, if you return both, they will both be verified

ashish_garg5
2020-05-26 05:44
Hi All, How can i pass a json body in my PactDslJsonBody response ? I have created a json file which my consumer is expecting as a response now i want to pass that in my PactDslJsonBody response. // Want to do something like this PactDslJsonBody responseBody = new PactDslJsonBody().object("test.json");

uglyog
2020-05-26 05:50
If you load the file into a String, you can then use `PactDslResponse.body(String body, String contentType)`

ashish_garg5
2020-05-26 05:52
so how can i load the file in String, do i have to hard code the json file content so there is a way to directly load it ?

uglyog
2020-05-26 05:54
Are you using Java, or some other language?

ashish_garg5
2020-05-26 05:54
Java

uglyog
2020-05-26 05:55
Do you any libraries like Apache commons-io?


ashish_garg5
2020-05-26 05:58
ok so there is no way so that i can directly read in PactDslJsonBody, 1st i have to write a code to read it from file and then i can use that.

uglyog
2020-05-26 05:59
Oh, you're asking to construct a PactDslJsonBody object from the contents of a JSON file. I think someone may have created a library to do that, but I don't know about it

ashish_garg5
2020-05-26 06:00
yeah correct i am asking to contruct a PactDslJsonBody, ok thanks.

ashish_garg5
2020-05-26 08:13
Hi, How can i pass Map<String, Object> in my PactDslJsonBody while constructing ?

ashish_garg5
2020-05-26 10:51
Hi All, How i can pass parameter in my api call ? return builder.path("api/test")... now here i want to pass a parameter api/test?param="paramValue"

matt.fellows
2020-05-26 12:02
What have you tried? What docs have you looked at?

francislainy.campos
2020-05-26 16:05
has joined #pact-jvm

francislainy.campos
2020-05-26 16:05
Hi, How do I check for longs as in `"timestamp": 1589451234126` in PACT with Java, since integer or number type is not available for large numbers please?

wesleythomaswilliams
2020-05-26 16:08
I assume you can't match with ```.numberType("timestamp", 1589451234126)```

francislainy.campos
2020-05-26 16:09
Hi, no, that gives me an error due to the length of the input.

francislainy.campos
2020-05-26 16:18
Removed the sample for the input altogether such as in `.integerType("timestamp")` rather than `.integerType("timestamp", 1589451234126)` and it worked now. Thanks.

francislainy.campos
2020-05-26 16:24
Hi, different issue. Could I get some help with this error I'm getting here please? https://stackoverflow.com/questions/62001663/exception-in-thread-thread-2-java-lang-nosuchmethoderror-kotlin-io-bytestream. Thank you very much.

ashish_garg5
2020-05-27 04:57
Hi All, How can i publish provider tag in pact broker ? <systemPropertyVariables> <pact.provider.version>${version}</pact.provider.version> <pact.provider.tag>dev</pact.provider.tag> <pact.verifier.publishResults>true</pact.verifier.publishResults> </systemPropertyVariables> I am able to publish version and results by configure it in system props but tag is not getting published.

uglyog
2020-05-27 05:01
`pact.provider.tag` is the correct system property. How are you determining that it is not being published with the results?

ashish_garg5
2020-05-27 05:03
m not able to see tag name in pact broker

ashish_garg5
2020-05-27 05:03
and if m using can i deploy its not able to find tag for provider

uglyog
2020-05-27 05:06
What version of the Pact Broker do you have?

ashish_garg5
2020-05-27 05:06
can-i-deploy?pacticipant=PactConsumerJavaRest&version=1.0.0&to=dev this is not working in my pact broker as provider tag is not published can-i-deploy?pacticipant=PactConsumerJavaRest&version=1.0.0 but if i remove the tag and check only

ashish_garg5
2020-05-27 05:06
3.6.7

uglyog
2020-05-27 05:07
Is that Pact-JVM version?

ashish_garg5
2020-05-27 05:09
yes

uglyog
2020-05-27 05:10
Publishing provider tags is implemented in 3.6.15 or 4.0.2+

ashish_garg5
2020-05-27 05:10
ohh k

ashish_garg5
2020-05-27 05:10
so i have to upgrade my version

francislainy.campos
2020-05-27 09:33
Hi, good morning. I'm trying to initiate my base url based on a param given so tried to add a before method to my class but that doesn't seem to work. Any ideas on how to do this please?

zeldigas
2020-05-27 09:53
Hi guys, I'm a bit confused with docs about publishing provider verification results. Context: I'm using junit5 to create provider tests ```@PactBroker(host="http://example.org") @VerificationReports("console", "json") @Provider("my_provider") class TpsCommandsProviderTest { @BeforeEach fun before(context: PactVerificationContext) { context.target = AmpqTestTarget() } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun pactVerificationTestTemplate(context: PactVerificationContext) { context.verifyInteraction() } @PactVerifyProvider("Build message command") fun buildTreamentMessage():String = """{"hello": "world"}""" }```

zeldigas
2020-05-27 09:55
So the question is how to properly publish verification results? Pact maven plugin docs tells me that I need to set `pact.verifier.publishResults` inside pact maven configuration, not in surefire

zeldigas
2020-05-27 09:56
But during regular tests execution I see a warning that results are not published as property is not set

wesleythomaswilliams
2020-05-27 09:56
@zeldigas I had to set it in surefire to get it to work

zeldigas
2020-05-27 09:57
Ok, thanks @wesleythomaswilliams. Looks like docs are confusing or applicable to different use case..



zeldigas
2020-05-27 10:00
Great, thank you for detailed example. I also was about doing the same thing, just wanted to doublecheck if I'm missing something

aliihlail
2020-05-27 10:03
i found an issue when im trying to test service that send the same message to different other service. i used the message event as PactVerifyProvider at the provider side and expectsToReceive at the consumer side. what i found the pact tries to pic all the the same expectsToReceive even if they are in different pact consumers. any idea how to overcome this


aliihlail
2020-05-27 10:03
```@State("Contract is created") @PactVerifyProvider("CONTRACT_SERVICE_CONTRACT_STATUS_CREATED") public JsonNode testContractServiceStatusCreated() { Contract contract = TestContractFactory.createContract(); contract.setRebookedContract(TestContractFactory.createContract()); contract.setStatus(Contract.Status.CREATED); MessageModel model = contractMapper.toMessageModel(contract); JsonNode messageModel = JacksonUtil.toJsonTree(model); return messageModel; }``` here is an example at the provider side

aliihlail
2020-05-27 10:04
unfortunately it fails until i change the PactVerifyProvider

wesleythomaswilliams
2020-05-27 10:08
@aliihlail If it's any use for your case, my messaging tests don't make use of state, just @PactVerifyProvider. My consumer is tagged as: ```@Pact(provider = "provider-service", consumer = "consumer-service")``` and has: ```.expectsToReceive("a provider-service update")``` My provider just has: ```@PactVerifyProvider("a provider-service update")``` I only have one consumer from that provider though.

aliihlail
2020-05-27 10:28
@wesleythomaswilliams i have the same but as i mentioned when there is more than one consumer then it may has a problem

wesleythomaswilliams
2020-05-27 10:32
@aliihlail With my REST tests where I have one provider and multiple consumers, it's the `.given` field in the builder that ties to the `@state` tag. Would adding that solve this?

aliihlail
2020-05-27 10:35
with rest it is not a problem. I think the issue that with Amqp that it tests all contracts who have the same PactVerifyProvider. What i need is to pick the only the PactVerifyProvider for the specific consumer

sairsule
2020-05-27 15:52
~Hi All, are there any examples of message-driven pacts tests in GO?~

antonello
2020-05-27 19:09
We have a provider (a BFF) that is organised in multiple modules, each module is responsible for different areas of the domain and each module has its own controllers. Any recommendations on how to go about organising the provider tests? I can think of two options and I like neither: 1. Each module would have its own test class, but states would need to be filtered. However, using `@PactFilter` to split state change methods is a recipe for disaster as we?ve realised when doing it for other applications, as it leads to verifications passing when they should not. 2. Treat each module as a separate provider with a different name. I don?t like this either as it would quickly lead to a proliferation of providers.

aliihlail
2020-05-27 22:19
Thanks for your recommendation. but i thought since they are in 2 different contracts then this the provider should search only for its related contract from the brocker. i do not see my self is going with both suggestions also the first one does not work.

antonello
2020-05-27 22:22
Ali - not making any recommendations here, asking for advice instead.

uglyog
2020-05-27 23:01
Unfortunately, the target is a field so it will be set when the test class is instantiated. But you can try instantiate the test target in the before method, that might work.

uglyog
2020-05-27 23:03
No, that won't work either. Sorry. The only way is to create a subclass of HttpTarget that can override the host name. Or you can try using JUnit 5.

uglyog
2020-05-27 23:04
If you're using JUnit tests, you are not using the Pact Maven plugin. So just set the property in the Surefire config or on the Maven command line

uglyog
2020-05-27 23:07
You should use different descriptions then. It will try verify all interactions that match the provider state and description.

uglyog
2020-05-27 23:12
People who access APIs though API gateways have this same problem. I normally recommend to try think about who the contract is between. > each module is responsible for different areas of the domain This does feel like there are separate concerns and maybe the BFF is jus the intermediary and multiple providers make sense.

uglyog
2020-05-27 23:13
Unless the BFF is modifying the downstream responses etc.

swaroopshere
2020-05-27 23:46
Hello, I have a question about verifying interactions in provider in pact-jvm. Is it possible to dynamically filter interactions that can be executed? One of the idiosyncrasies in our browser based Test runner UI frontend that is backed by JUnit 4, is, it can show test methods within a test class. Via the UI, I can select a test method to execute. With some tweaking, I hooked the UI frontend up with PactRunner, so it shows individual interactions in the UI test console, with the ability to select a particular interaction and execute. However, when I do that, I see that all interactions are run, regardless of which one is picked. Is there a way to override anything within PactRunner to say, "just run this interaction"?

uglyog
2020-05-28 00:27
The only way currently is to use provider states, and then filter by the provider state. But this seems like a useful feature, so please raise a issue for it on the Github project

ashish_garg5
2020-05-28 04:31
Hi All, Curious to know how would can-i-deploy check version compatibility ? I mean how it actually works ? Thanks.

tjones
2020-05-28 04:32
can-i-deploy checks with the broker to determine verification status between the versions you?re asking about in deployment

tjones
2020-05-28 04:33
if you?re deploying version 2 of a provider to a prod environment where version A of a consumer is, then it checks to see if ?consumer A <---> provider 2? has been verified

ashish_garg5
2020-05-28 04:33
yeah but how it actually verifies that the version will be compatible ?

tjones
2020-05-28 04:35
it asks the broker

tjones
2020-05-28 04:35
if the broker doesn?t know (ie, if the relevant verification status hasn?t been published to the broker), then can-i-deploy will say no

ashish_garg5
2020-05-28 04:36
ok

ashish_garg5
2020-05-28 04:38
in pact broker itself we can run the can-i-deploy command right ? //Something like this /can-i-deploy?pacticipant=PactConsumerJavaRest&version=1.0.0

ashish_garg5
2020-05-28 04:38
so it will check with the available provider whether it is compatible or not

ashish_garg5
2020-05-28 04:41
m checking like this in my pact broker

swaroopshere
2020-05-28 04:49
will do, thank you


francislainy.campos
2020-05-28 08:05
Okay, thank you. Will try it when working again on this piece and see if can make it work as per your suggestion.

aliihlail
2020-05-28 09:54
Hi All Is it possible to define more than one consumer to the same provider test? i mean sometimes i wrote the same rest test for different class.

wesleythomaswilliams
2020-05-28 09:55
I have a rest test which has multiple consumers for one provider.

wesleythomaswilliams
2020-05-28 09:58
So for example, I have a service that generates IDs. Different consumers make a request to that service with different input values to the service. So the service has states based on those inputs to serve each of the consumers.

aliihlail
2020-05-28 11:25
doest means that i need to remove the @Consumer annotaion

wesleythomaswilliams
2020-05-28 11:27
I know I don't use it, so quite possibly

mbieganski.infomatt
2020-05-28 11:33
It varies for me. I either share 1 State with multiple services, use Provider state parameters or have separate State for different response. I think it will not work with @Consumer annotation because you can pass only one

aliihlail
2020-05-28 11:34
i found an intresting thing that inside the @PactBroker you can define multiple consumer to the same provider

mbieganski.infomatt
2020-05-28 11:37
@uglyog @wesleythomaswilliams maybe you could have some idea. What should be the message format returned by the `@PactVerifyProvier` ? I'm playing around and returning ActiveMQTextMessage which doesn't work `com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 22 path $`

wesleythomaswilliams
2020-05-28 11:48
@mbieganski.infomatt In my provider test, I build a message object using the microservice code and then return it as a string. ```@PactVerifyProvider("a provider service update") public String providerServiceUpdateMessage() throws Exception { final ProviderServiceDtoV1 providerServiceDtoV1 = ProviderServiceDtoV1.builder() .thing() .anotherthing() .build(); return objectMapper.writeValueAsString(providerServiceDtoV1); }```

wesleythomaswilliams
2020-05-28 11:48
That's a massively cut down example

mbieganski.infomatt
2020-05-28 11:52
You are only returning body right? I'm wondering how to verify message with metadata e.g destination since we can include it in pact. I thought that I should return whole message but maybe I'm missing something..

wesleythomaswilliams
2020-05-28 11:52
Yeah, just the body

mbieganski.infomatt
2020-05-28 11:55
I couldn't find any other example though :pensive:

wesleythomaswilliams
2020-05-28 11:57
Ah wait, so the ProviderServiceDtoV1 object in our service include a metadata object.

wesleythomaswilliams
2020-05-28 11:58
Messaging you privately as working in this thread is a pain

matt.fellows
2020-05-28 12:52
How much of the docs have you read?


ashish_garg5
2020-05-28 14:33
Hi All, How can i pass JSONObject in PactDslJsonBody ? PactDslJsonBody responseBody = new PactDslJsonBody().stringType(jsonData.toString()); I am passing like this stringType(jsonData.toString()), but i want to pass json object itself which i am expecting in a response. Thanks.

ashish_garg5
2020-05-28 14:35
ok thanks i will check those docs.

wesleythomaswilliams
2020-05-28 14:40
Hi Ashish, I think the general advice is to avoid doing it if you can and make use of the matchers for PactDslJsonBody, but when I was starting out, I just used the Json like you're doing and still have some tests using it. ```@BeforeAll static void beforeAll() throws Exception { providerServiceResponse = StreamUtils.copyToString(new ClassPathResource("/json/pact/response.json").getInputStream(), Charset.defaultCharset()); }``` Then this in my builder: ```.body(providerServiceResponse)```

jarmy
2020-05-28 20:59
Hello. I?m writing a consumer jvm test for a Graphql provider and I?m curious how I?d include the equivalent of `{"query":"query Search{search(query: \"Drake\" types: [AR]) {items {id}}}"}` in the request of my `PactDslWithProvider` object. Does the jvm implementation have an equivalent of the pact-js `GraphQLInteraction` as described here? http://blog.pact.io/2018/07/24/contract-testing-a-graphql-api/ Here?s my existing code _without_ the query in the request ``` @Pact(consumer="PegasusConsumer") public RequestResponsePact searchItems(PactDslWithProvider builder) { return builder .given("Search items exist") .uponReceiving("a request to search for item data") .path("/graphql") .method("POST") .willRespondWith() .headers(headers) .status(200) .body( new PactDslJsonBody() .object("data") .object("search") .minArrayLike("items", 3) .stringType("id", "AR:306247") .stringType("id", "AR:623522") .stringType("id", "AR:396517") .closeArray() .closeObject() .closeObject() ) .toPact(); }```

uglyog
2020-05-28 23:12
Can you raise this as an issue on the Github project?


matt.fellows
2020-05-28 23:51
@jarmy thanks for raising this

matt.fellows
2020-05-28 23:53
Just so you know, the JS interface is a fairly lightweight shim over the existing interface. Because under the good, GraphQL actually sends a JSON payload with the gql query as a string, we construct a _very_ crude regex

matt.fellows
2020-05-28 23:53
so matchers and so on aren?t available - it really is just a string matcher

matt.fellows
2020-05-28 23:53
My point is that you could basically do that yourself now in the JVM interface, I think (happy to give you pointers)

jarmy
2020-05-28 23:54
I?ll happily take any pointers you can give

matt.fellows
2020-05-28 23:54
Long term, we need to detect that it is a GraphQL interaction (there is no standard media type, sadly, because it?s actually JSON) and then convert into a GraphQL AST and do the matchers that way - so it?s a bit more involved


matt.fellows
2020-05-28 23:57
All it does is this: 1. Takes the query, validates that it is indeed valid GraphQL syntax 2. Generates the JSON HTTP payload (this is just a convenience wrapper really) 3. Escapes the query string

matt.fellows
2020-05-29 00:03
It will produce a contract that looks a bit like this: ```{ "consumer": { "name": "GraphQLConsumer" }, "provider": { "name": "GraphQLProvider" }, "interactions": [ { "description": "a hello request", "request": { "method": "POST", "path": "/graphql", "headers": { "content-type": "application/json" }, "body": { "operationName": "HelloQuery", "query": "\n query HelloQuery {\n hello\n }\n ", "variables": { "foo": "bar" } }, "matchingRules": { "$.body.query": { "match": "regex", "regex": "\\s*query\\s*HelloQuery\\s*\\{\\s*hello\\s*\\}\\s*" } } }, "response": { "status": 200, "headers": { "Content-Type": "application/json; charset=utf-8" }, "body": { "data": { "hello": "Hello world!" } }, "matchingRules": { "$.body.data.hello": { "match": "type" } } } } ], "metadata": { "pactSpecification": { "version": "2.0.0" } } }```

uglyog
2020-05-29 00:03
I'm going to copy this thread onto the Github issue so we don't lose it

matt.fellows
2020-05-29 00:04
Ron - this should work similar to the XML stuff we recently did

matt.fellows
2020-05-29 00:04
One key difference is that it?s _both_ JSON and GraphQL

matt.fellows
2020-05-29 00:04
It?s all JSON/HTTP, except for the `query` parameter

ashish_garg5
2020-05-29 04:38
ok thanks

oscarg798
2020-05-29 07:16
has joined #pact-jvm

sabil.beladri
2020-05-29 08:09
Hi, are we already able to run a JVM spring-provider check against multiple versions for a same tag? As described at https://pact.canny.io/feature-requests/p/ability-to-ensure-compatibility-with-multiple-versions-of-a-consumer-in-producti Thanks for keeping me posted on that one & regards!

aliihlail
2020-05-29 08:14
```public class FeatureRestTest { private static final String AMENITIES_PATH = "/amenities"; private static final String FEATURES_IMPORT_PATH = "/features/import"; private static final String CONTENT_HEADER = HttpHeaders.CONTENT_TYPE; @Pact(consumer = "import-service", provider = "feature-service") public RequestResponsePact featureServiceGetPact(PactDslWithProvider builder) { return builder .given("amenity with name Elevator exist") .uponReceiving("GET request to retrieve city") .path(AMENITIES_PATH ) .query("name=Elevator") .method(HttpMethod.GET) .willRespondWith() .status(HttpStatus.OK.value()) .headers(responseHeaders()) .body(newJsonBody((amenity) -> { amenity.id("id"); }).getPactDslObject()) .toPact(); } @Pact(consumer = "import-service", provider = "feature-service") public RequestResponsePact featureServicePostPact(PactDslWithProvider builder) { return builder .given("post feature from import file") .uponReceiving("POST request to import feature") .path(FEATURES_IMPORT_PATH ) .method(http://HttpMethod.POST) .body(newJsonBody((amenity) -> { amenity.numberType("amenityId"); amenity.numberType("aggregateId"); amenity.stringMatcher("aggregateType", "UNIT|ROOM|BUILDING"); }).getPactDslObject()) .willRespondWith() .status(HttpStatus.CREATED.value()) .toPact(); } @Test @PactTestFor(pactMethod = "featureServiceGetPact") public void testGetFeatureService(MockServer mockServer) throws IOException { HttpResponse httpResponse = Request.Get(mockServer.getUrl() + AMENITIES_PATH + "?name=Elevator").execute().returnResponse(); assertEquals(httpResponse.getStatusLine().getStatusCode(), HttpStatus.OK.value()); } @Test @PactTestFor(pactMethod = "featureServicePostPact") public void testPostFeatureService(MockServer mockServer) throws IOException { HttpResponse httpResponse = http://Request.Post(mockServer.getUrl() + FEATURES_IMPORT_PATH).execute().returnResponse(); assertEquals(httpResponse.getStatusLine().getStatusCode(), HttpStatus.CREATED.value()); } private Map<String, String> responseHeaders() { Map<String, String> headers = new HashMap<>(); headers.put(CONTENT_HEADER, MediaTypes.HAL_JSON_UTF8_VALUE); return headers; } }``` Hi im trying to run this test for Get and Post. But with post it fails when i run the class. If i tried to run only the post test then it works fine. Any help how to to test post. or if there is any example that would be really amazing

francislainy.campos
2020-05-29 08:52
Hi all, good morning. So I'm trying to update our provider tests to use JUnit5 but they keep hanging on the screen and eventually time out and it's been a while trying to figure it out but not able to know why this is happening. I can run the consumer fine under the same repo. This is my whole provider piece if I could please get any pair of eyes on it. Many thanks.

matt.fellows
2020-05-29 08:54
That looks pretty clear to me - unable to reach your internal domain

matt.fellows
2020-05-29 08:54
Can you cURL / telnet or something to that host/port?

chandanakurumeti27
2020-05-29 09:07
Hi, I want to use regular expressions in expected request body in pact jvm, Can someone please provide any example on how to use it?

matt.fellows
2020-05-29 09:09
What docs have you looked at so far?

francislainy.campos
2020-05-29 09:11
Hi, thank you! Yeah, you're right. I was all this time thinking the error was on the PACT file but it was actually the url itself.


chandanakurumeti27
2020-05-29 09:24
but wanted to see any working example


chandanakurumeti27
2020-05-29 09:28
but didnt get clear picture of using regular expressions while defining the expected request in pact mock provider using pact jvm

francislainy.campos
2020-05-29 09:57
Sorry @matt.fellows, I think I may be a bit confused as still new to PACT, but we fixed the api however getting the same error still. Tried with both the full url and only the base one but keep getting the connection timeout.

francislainy.campos
2020-05-29 10:29
I don't understand why the error shows only the base path rather than the full url and I think that may be related to the issue, not sure.

chandanakurumeti27
2020-05-29 11:58
this is my expected body which i defined in pact mock provider

chandanakurumeti27
2020-05-29 11:58
playeruid above keeps on changing for every run of consumer tests

matt.fellows
2020-05-29 11:59
Can you try and connect to that host in your terminal? e.g. `telnet http://api.int.eng.hmhco.com 8080`

chandanakurumeti27
2020-05-29 11:59
so i want to use some reg exp or matchers while defining the expected request body so that it will accept the playeruid even after it chnages every time

matt.fellows
2020-05-29 11:59
The error is very clear to me - your IDE/Machine is unable to connect to that host

matt.fellows
2020-05-29 12:00
One thing I can?t see is why it?s trying to hit `8080` - should it be hitting that port or something else? It looks like it should be hitting a secure port (e.g. `443` or `8443` by convention)

chandanakurumeti27
2020-05-29 12:01
part of my consumer test where am defining the request body

chandanakurumeti27
2020-05-29 12:01
Please help me on this!, looking forward to any kind reply and help



wesleythomaswilliams
2020-05-29 12:08
@chandanakurumeti27 I don't think you need regex here. Taking the playerUid example, the contract is with the schema, so the value isn't important, so when building your PactDslJsonBody, you can use a line like .stringType("playedUid", "130"). The 130 part isn't strictly necessary it's just used as an example, but you're effectively just saying you expect playerUid to be a stringType. Will that suffice for you?

chandanakurumeti27
2020-05-29 12:13
yeah, as value of playeruid keeps on changing everytime, i just want to have that expected playeruid to be a string type

chandanakurumeti27
2020-05-29 12:14
but i want other values above like password and ispasswordencrypted to have exact same values

chandanakurumeti27
2020-05-29 12:14
so can i please have the syntax of my expected request body here ??

wesleythomaswilliams
2020-05-29 12:15
lol, I'll be super nice and write it for you. one sec

wesleythomaswilliams
2020-05-29 12:18
What I would do: ```final DslPart body = new PactDslJsonBody() .object("credential") .stringType("playerUid", "130") .stringType("password", "pjsvdkc12@44?§|[1") .closeObject().asBody() .booleanType("isPasswordEncrypted", false)``` That's how I'd do it personally, as I don't think you should be matching on exact values, regardless of if any of those values are changing or not.

chandanakurumeti27
2020-05-29 12:38
Thats so nice of you , thank you so much. I followed the above pact jvm repo and almost had the exact one like you sent above

chandanakurumeti27
2020-05-29 12:38
but was having this error `"http://au.com.dius.pact.consumer.dsl.DslPart cannot be converted to http://au.com.dius.pact.consumer.dsl.PactDslJsonBody"`

chandanakurumeti27
2020-05-29 12:39
as in README.md file above i have something like this ```PactDslJsonBody body = new PactDslJsonBody() .object("credential") .stringType("playerUid", "130") .stringType("password", "pjsvdkc12@44?§|[1") .closeObject().asBody() .booleanType("isPasswordEncrypted", false);```

chandanakurumeti27
2020-05-29 12:39
so corrected it to `DslPart body = new PactDslJsonBody()` and now its working

chandanakurumeti27
2020-05-29 12:39
thank you so much once again:+1::grinning:


wesleythomaswilliams
2020-05-29 12:58
@chandanakurumeti27 no problem at all :smile:

francislainy.campos
2020-05-29 13:58
Yeah, no. The api I can hit is this one https://api.int.eng.hmhco.com/update-catalog/v1/lastUpdateSummary but I don't know why the error shows just the base path for this url.

francislainy.campos
2020-05-29 14:00
8080 is just the port I have on my consumer from copying from some tutorials on the internet. I get a connection denied error with other ports. I'm on a vpn and a mac if that's make any difference?

francislainy.campos
2020-05-29 14:27
That's what I have on my consumer.

jarmy
2020-05-29 16:34
Can I get an ETA on when this can be implemented? I?m happy to help test the design.

mbieganski.infomatt
2020-05-29 20:03
Hey is there some way to handle `DateTimeFormatter ISO_ZONED_DATE_TIME` using `LambdaDslObject date`? There is ZonedDateTime but I'm unable to parse it to expected format `2020-01-01T10:00+01:00[Europe/Warsaw]`

matt.fellows
2020-05-29 23:59
I'm not sure. But I wouldn't wait as it's easy enough to do the basic version yourself.yoi basically just implement a regex on the query key, and do regular json matching on the rest. It shouldn't take you very long to create a convenience/helper/subclass that does the defaults for you

uglyog
2020-05-30 02:38
At the moment it only allows you to specify multiple tags, not versions.

uglyog
2020-05-30 02:40
What error do you get?

uglyog
2020-05-30 02:53
With ISO_ZONED_DATE_TIME looks like it's just an ISO date/time with the zone ID in the brackets. You can try match it with something like `yyyy-MM-dd'T'HH:mm:ssZZZ'['V']'`

uglyog
2020-05-30 02:53
`V` is the symbol for the zone ID

uglyog
2020-05-30 02:54
Actually, looks like you don't need to quote the brackets. See https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html

sairsule
2020-05-30 06:14
I keep on getting links to unavailable github repo links in Pact documentation like the one below. Any idea where this is moved to? https://github.com/DiUS/pact-jvm/blob/master/provider/pact-jvm-provider-maven/README.md#verifying-a-message-provider


uglyog
2020-05-30 06:43
Where are you getting the links from? They need to be updated

sairsule
2020-05-30 09:18
Thanks.


sairsule
2020-05-30 09:20
Are there any more examples of message Pacts? I am trying to implement this in kafka driven project. JVM or JS examples will do.

wesleythomaswilliams
2020-05-30 13:01
@sairsule I'm testing with pact-jvm and kafka, what's the schema for the message you want to verify?


chandanakurumeti27
2020-05-30 15:36
but the consumer service in my case is java based one, so someone please clarify whether this is possible in java as well?

chandanakurumeti27
2020-05-30 16:23
I found the same kind of issue https://github.com/DiUS/pact-jvm/issues/117, but couldnt really understand the solution provided here.

chandanakurumeti27
2020-05-30 16:37
I think i found the solution, I have added two provider names in this annoattion @PactVerification({?auth_For_Player?,?account_For_Player?}), started two mock providers at diff ports using @Rule and its working now

mbieganski.infomatt
2020-05-30 20:23
I have tried multiple configurations and no luck `http://au.com.dius.pact.consumer.MockServer)]: Illegal pattern component: V` eg. ```body.date("date", "yyyy-MM-dd'T'HH:mmZZZV", ZonedDateTime.parse("2020-01-01T10:00+01:00[Europe/Warsaw]"));``` Looks like the problem is that Pact is using FastDateFormat which seems to be based of SimpleDateFormat. Is there a plan to move to DateTimeFormatter?

uglyog
2020-05-30 23:07
Can you raise an issue for that?

sairsule
2020-05-31 07:28
I am not sure what you meant by schema, I want to check that a message is sent to a topic say "topic1" and payload has a key 'username'

wesleythomaswilliams
2020-05-31 12:47
By schema I mean the structure of the message, what keys are expected and what are the their respective data types. Contract testing services that write messages to kafka topics is pretty straightforward, because the kafka element is really not important. Here's a simple example from my own tests: Consumer Test: ``` @BeforeAll static void beforeAll() throws Exception { providerKafkaMessageFromJson = StreamUtils.copyToString(new ClassPathResource("/json/pact/providerKafkaMessage.json").getInputStream(), Charset.defaultCharset()); } @Pact(provider = "provider-service", consumer = "consumer-service") public MessagePact providerKafkaMessage(MessagePactBuilder builder) { final DslPart body = new PactDslJsonBody() .object("metaData") .stringType("origin", "provider-service") .datetimeExpression("dateCreated", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") .closeObject() .stringType("itemId", "9325858") .stringType("itemType", "Item"); return builder .expectsToReceive("a provider service message") .withContent(body) .toPact(); } @Test @PactTestFor(pactMethod = "providerKafkaMessage") public void testProviderKafkaMessage(MessagePact pact) throws Exception { // State final String messageFromPact = pact.getMessages().get(0).contentsAsString(); // Assert JSONAssert.assertEquals(messageFromPact, providerKafkaMessageFromJson, false); }```

wesleythomaswilliams
2020-05-31 12:53
Provider Test ``` @BeforeEach void setupTestTarget(PactVerificationContext context) { context.setTarget(new AmpqTestTarget()); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @PactVerifyProvider("an provider Kafka message") public String providerKafkaMessage() throws Exception { final MetaDataDtoV1 metaDataDtoV1 = MetaDataDtoV1.builder() .origin("provider-service") .dateCreated("2000-01-31T13:00:00.000Z") .build(); final ProviderServiceMessageDtoV1 providerServiceMessageDtoV1 = ProviderServiceMessageDtoV1.builder() .metaData(metaDataDtoV1) .itemId("9325858") .itemType("Item") .build(); return objectMapper.writeValueAsString(providerServiceMessageDtoV1); }```

sairsule
2020-05-31 14:20
I am confused for provider tests.


sairsule
2020-05-31 14:21
I could write pact test at consumer side. here's the code https://github.com/sairandhree/Spring-kafka-Receiver

wesleythomaswilliams
2020-05-31 14:29
Your consumer test looks ok, although consider using the matchers so that you're not doing comparisons on the actual data. How can I help with the provider side?

sairsule
2020-05-31 14:30
Thanks Wes,

sairsule
2020-05-31 14:31
I do not know what is PactVerificationContext and amqpTarget

sairsule
2020-05-31 14:31
am I missing any dependancies

wesleythomaswilliams
2020-05-31 14:33
I have: ```import au.com.dius.pact.provider.PactVerifyProvider; import au.com.dius.pact.provider.junit.Provider; import au.com.dius.pact.provider.junit.loader.PactBroker; import au.com.dius.pact.provider.junit.loader.PactBrokerAuth; import au.com.dius.pact.provider.junit5.AmpqTestTarget; import au.com.dius.pact.provider.junit5.PactVerificationContext; import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider;```

wesleythomaswilliams
2020-05-31 14:34
If you're junit4 these are likely different

sairsule
2020-05-31 14:34
I am on junit5

sairsule
2020-05-31 14:36
got it, I was having comsumer-junit jar in my pom.xml

sairsule
2020-05-31 14:37
do I need to mark any class as AMPQTestTarget?

wesleythomaswilliams
2020-05-31 14:43
JUnit 5?s @TestTemplate feature is used in combination with PactVerificationInvocationContextProvider to dynamically create a test for every interaction found in the pact, so you just need to set the target for the context to AmpqTestTarget and annotate tests with @PactVerifyProvider.

sairsule
2020-05-31 14:46
Do you have a sample for provider please?


sairsule
2020-05-31 14:49
I would like to see it in project.

wesleythomaswilliams
2020-05-31 14:51
Ah, sorry, I can't share in the project as its taken from my work's project repository. What you see above is just a cutdown anonymised version.

wesleythomaswilliams
2020-05-31 14:51
Happy to answer questions though.

sairsule
2020-05-31 14:52
whats the type of ProviderServiceMessageDtoV1 and what is it returning

sairsule
2020-05-31 15:01
Also my pact has to be validated against MessageGenerator.generateMessage(). How do I tell that to Pact?

wesleythomaswilliams
2020-05-31 15:31
Our provider microservice builds a DTO object which it then writes out to Kafka as the message body. I reuse the DTO builders to build a message to compare my pact against in my provider test. I use the DTO builders as it is extra validation of the microservice's code. I could instead have just used a piece of json. This line then returns the object as a string for pact to compare against: ```return objectMapper.writeValueAsString(providerServiceMessageDtoV1);```

wesleythomaswilliams
2020-05-31 15:40
So I see your `MessageGenerator` class is doing the send to kafka. I wouldn't use that as part of the contract test myself, but if that class was modified a little, I could see how you could. Instead of: ``` public void generateMessage() throws JsonProcessingException { /// some procession... User user = new User (1L,"Bar"); sender.send("third_topic", "update", objectMapper.writeValueAsString(user) ); }``` Have: ``` public void sendMessage() { sender.send("third_topic", "update", generateMessage()); } public void generateMessage() throws JsonProcessingException { /// some procession... User user = new User (1L,"Bar"); return objectMapper.writeValueAsString(user); }``` Then in your provider test, you could do something like this (if my java brain is working today): ```    @PactVerifyProvider("an provider Kafka message")    public String providerKafkaMessage() throws Exception {        return MessageGenerator.generateMessage();    }```

sairsule
2020-05-31 15:40
@wesleythomaswilliams I updated my provider https://github.com/sairandhree/Spring-kafka-sender

sairsule
2020-05-31 15:40
It gives me error "provider State change callback failed"

sairsule
2020-05-31 15:42
could you please check what is it that I am doing wrong.

sairsule
2020-06-01 04:06
So Finally I could do it.

sairsule
2020-06-01 04:07
So Thanks you.


wesleythomaswilliams
2020-06-01 08:06
No problem, sorry I couldn't help more yesterday, had to spend some time with family :slightly_smiling_face:

sjuli.chen
2020-06-01 17:14
has joined #pact-jvm

dgaglani
2020-06-02 00:10
has joined #pact-jvm

dgaglani
2020-06-02 00:11
Hi.. I am using PACT test framework (on Java) .. I am stuck in creating array of interactions in pact programatically..  I know one way is: ```return builder .uponReceiving("a request for something") .path("/hello") .method("GET") .willRespondWith() .status(200) .body("{\"hello\": \"Ada\"}") .uponReceiving("another request for something") .matchPath("/hello/[0-9]+") .method("GET") .willRespondWith() .status(200) .body("{\"hello\": \"Ada\"}") .toPact();``` I am looking for creating array of interactions dynamically though loop.. how do I do that?

uglyog
2020-06-02 00:12
just put in the loop body ```builder .uponReceiving("a request for something") .path("/hello") .method("GET") .willRespondWith() .status(200) .body("{\"hello\": \"Ada\"}")```

dgaglani
2020-06-02 00:14
Also, I need to parse query parameters from a file as well and set it as matchQuery in a loop[

uglyog
2020-06-02 00:19
matchQuery takes a name, regex and example value. You will need to create those values from your file contents

dgaglani
2020-06-02 00:20
Thanks!! I have this in loop... ```for(Map.Entry<String, Request> entry: variableGenMap.entrySet()){ String responseBody = FileUtils.readFileToString(new File("test.json"),StandardCharsets.UTF_8); builder.uponReceiving(entry.getKey()) .method("GET") .matchPath(entry.getValue().getPath()) .willRespondWith() .body(responseBody) .status(HttpResponseStatus.OK.code()); }``` how do I call toPact() and return pactresponse?

uglyog
2020-06-02 00:21
`return builder.toPact()`

dgaglani
2020-06-02 00:22
builder is PactDslWithProvider. which does not have toPact() method

uglyog
2020-06-02 00:24
Ah, re-assign builder to the result in your loop

uglyog
2020-06-02 00:24
`builder = builder.uponReceiving...`

dgaglani
2020-06-02 00:29
tried this... does not work... ```PactDslResponse response = null; for(Map.Entry<String, Request> entry: variableGenMap.entrySet()){ String responseBody = FileUtils.readFileToString(new File("test.json"),StandardCharsets.UTF_8); response = builder.uponReceiving(entry.getKey()) .method("GET") .matchPath(entry.getValue().getPath()) .willRespondWith() .body(responseBody) .status(HttpResponseStatus.OK.code()); } return response.toPact();```

uglyog
2020-06-02 00:36
`response = response.uponReceiving`

dgaglani
2020-06-02 00:40
but `uponReceiving` method is from `PactDslWithProvider` class which will return `PactDslWithoutPath` and hence not compatible return type

uglyog
2020-06-02 00:42
They have a common base class

dgaglani
2020-06-02 00:49
not working.. do you have an example I can refer to?

uglyog
2020-06-02 00:49
No, sorry, there are no examples of anyone doing this in a loop

dgaglani
2020-06-02 00:49
similar issue with setting matchQuery in loop where I have to set matching parameters from a file

uglyog
2020-06-02 00:54
You're kind of on your own here. You might have to build the Pact object yourself, rather than using the DSL classes. You can look at what the DSL class methods are doing to get an idea of what you need to do

srinivasan.sekar1990
2020-06-02 06:54
@sairsule you can also refer to this if you still facing any issues - https://github.com/SrinivasanTarget/ContractTestingBoilerplate

sairsule
2020-06-02 07:11
@srinivasan.sekar1990 thank you.

aliihlail
2020-06-02 07:29
org.apache.http.NoHttpResponseException: 127.0.0.1:8080 failed to respond only the first class managed to respose correctlly only the first

uglyog
2020-06-02 07:35
You need to get the Apache HTTP client to stop caching connections.

uglyog
2020-06-02 07:36
You can try ```@After void teardown() { Executor.closeIdleConnections() }```

uglyog
2020-06-02 07:36
But it depends on the version of the Apache HTTP client you are using

aliihlail
2020-06-02 07:38
Apache-HttpClient/4.5.6 this is what im using

aliihlail
2020-06-02 07:46
it doesnt worked.

uglyog
2020-06-02 07:51
You can try a Thread.sleep(2000) in the after method

wesleythomaswilliams
2020-06-02 09:53
@srinivasan.sekar1990 That's really handy, thanks for sharing. Saves me pasting code snippets everywhere :smile:

mbieganski.infomatt
2020-06-02 11:05
Hi. Looks like Pact is adding default response "Content-Type" header even if it's not included in contract. ``` "Content-Type" with value "application/json; charset=UTF-8"``` Is there a way to disable it or way to test response that has empty headers?

uglyog
2020-06-02 13:08
It will default to either JSON or text. It needs to know the content type so that it knows how to deal with the body.

uglyog
2020-06-02 13:08
If you specify the content type header yourself, it will not default

mbieganski.infomatt
2020-06-02 13:13
problem is that pact expects headers to exists but in my case response have empty headers and if I would like to verify body test fails

sabil.beladri
2020-06-02 16:40
Many thanks for clarifying this one @uglyog ! Also please let me know in case I can check progress on that subscribing or watching a github ticket.

rjaladurgam
2020-06-02 16:42
My Spring provider test gives below error. Any help that could be provided? Caused by: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.

rjaladurgam
2020-06-02 18:29
Could SpringBootHttpTarget be used along with @WebMVCTest for Testing REST Controllers (API) written with Spring Boot?

dgaglani
2020-06-02 19:56
Hi.. I kinda created interactions with loop in pact object by looping... ```pact = builderWithPath.willRespondWith() .headers(headers) .body(responseBody) .status(HttpResponseStatus.OK.code()).toPact();``` I have this consumer unit test case which will hit mock endpoint with request parameters with each interactions: ```variableMapList.forEach((queryMap) -> { HttpUriRequest request = buildRequest(mockProvider.getPort(),queryMap); CloseableHttpClient httpClient = HttpClients.createDefault(); try { httpClient.execute(request); } catch (IOException e) { e.printStackTrace(); } });``` When I run this unit test, it throws this error: ```Unexpected Request: method: GET path: /api/v2/gql/content_view query: [notification:[true] headers: [Accept-encoding:[gzip,deflate], Connection:[Keep-Alive], Host:[localhost:62563], User-agent:[Apache-HttpClient/4.5.5 (Java/1.8.0_212)]] matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: EMPTY``` Same parameter and request works fine with single interaction

dgaglani
2020-06-02 19:57
`pact` object does have interactions which I can see from debug mode

dgaglani
2020-06-02 21:58
actually now I am getting this error: out of 3 requests, failed for 2 and works for 1st request send... ```au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: method: GET path: /api/v1/gql/content_view query: [notification:[true]] headers: [:] matchers: MatchingRules(rules={path=Category(name=path, matchingRules={=MatchingRuleGroup(rules=[RegexMatcher(regex=/api/v1/gql/content_view, example=null)], ruleLogic=AND)}), query=Category(name=query, matchingRules={notification=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), site=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), caasAppId=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), namespace=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), id=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), region=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), lang=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), device=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), uuid=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), version=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), caasFeatures=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND)})}) generators: Generators(categories={}) body: MISSING method: GET path: /api/v1/gql/content_view query: [notification:[true]] headers: [:] matchers: MatchingRules(rules={path=Category(name=path, matchingRules={=MatchingRuleGroup(rules=[RegexMatcher(regex=/api/v1/gql/content_view, example=null)], ruleLogic=AND)}), query=Category(name=query, matchingRules={notification=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), site=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), caasAppId=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), namespace=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), id=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), region=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), lang=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), device=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), uuid=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), version=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND), caasFeatures=MatchingRuleGroup(rules=[RegexMatcher(regex=.*, example=null)], ruleLogic=AND)})}) generators: Generators(categories={}) body: MISSING```

dgaglani
2020-06-02 22:27
@uglyog how do we create consumer unit test to work with array of interactions in pact?

uglyog
2020-06-02 23:02
No, SpringBootHttpTarget is for testing the actual springboot app

uglyog
2020-06-02 23:34
Sorry, I'm not sure what you're trying to accomplish here. Pact is designed to test the interactions in isolation. Looks like you are trying to do some type of automated integrated testing. There are better tools out there for doing that.

jarmy
2020-06-03 00:09
I?m ready to give this a shot. Can you point me to the `XML stuff we recently did` so I can get an idea on how I?d implement things?

matt.fellows
2020-06-03 00:29
awesome

matt.fellows
2020-06-03 00:29
the XML stuff we recently did thing is a note that will only make sense for Ron in the long term

matt.fellows
2020-06-03 00:29
unless you?re keen to get stuck into Rust code for solving it in other languages too? :stuck_out_tongue:

matt.fellows
2020-06-03 00:30
The pointers I?ve given you above in JS should be a good start

rjaladurgam
2020-06-03 06:30
Thank you for the reponse

sbartsa
2020-06-03 07:59
has joined #pact-jvm

ale.paciello
2020-06-03 08:14
has joined #pact-jvm

ale.paciello
2020-06-03 08:17
Hello! Any tip on how install a development version of pact-jvm in local maven repository using gradle? By running the `publishToMavenLocal` task the jars are placed in the correct folders but no metadata-local file is generated. Thank you!

shawn.edge
2020-06-03 13:48
has joined #pact-jvm

jacek.okrojek
2020-06-03 15:15
has joined #pact-jvm

dgaglani
2020-06-03 17:52
@uglyog I am trying to create unit test similar to : https://github.com/DiUS/pact-jvm/blob/master/consumer/junit/src/test/java/au/com/dius/pact/consumer/junit/pactproviderrule/PactProviderWithMultipleFragmentsTest.java#L107 except that I have all GET method call with different param values... But for me, it accepts first request, but fails for subsequent requests with error: `http://au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received:`

jarmy
2020-06-03 21:52
I?m following the _Buidling the library_ directions https://github.com/DiUS/pact-jvm/wiki/How-to-contribute-to-Pact-JVM and trying to build a local snapshot of `pact-jvm` with `./gradle clean install` AFAICT, snapshots aren?t getting built or published to my local maven repository. Are there more up-to-date directions elsewhere?

uglyog
2020-06-03 23:08
If you're using the Apache HTTP client, it caches connections which will cause that error. You need to either disable that or add a sleep between tests.

uglyog
2020-06-03 23:10
I use publishToMavenLocal, it works ok for me

uglyog
2020-06-03 23:12
Gradle projects don't create snapshots or publish artefacts to the Maven repo. That is a Maven thing. You can use the `publishToMavenLocal` Gradle task to put the artefacts in your local repo.

jarmy
2020-06-03 23:17
I ended up using `publishToMavenLocal`

mail961
2020-06-04 00:57
hi, I?m currently trying to write a pact test with an http target for a spring boot application. the provider test runs fine in the IDE, but when I call ?mvn pact:verify? I get a ?Connection refused? for localhost:8080, when pact tries to call the spring service (?mvn install? runs the tests without problems). Does anybody know what I?m doing wrong?

uglyog
2020-06-04 00:59
`mvn pact:verify` is not for running Pact unit tests. Just run `mvn verify`

mbieganski.infomatt
2020-06-04 04:39
Hey @uglyog Just wanted to clarify pactbroker.providerTags for pending pacts. If i have feature branch "test" and master then i set pactbroker.providerTags with one of them depending which pipeline is running?

uglyog
2020-06-04 04:41
As far as I understand it, pactbroker.providerTags must be set to the tag that the provider verification result is tagged with. It depends on your pipeline

mbieganski.infomatt
2020-06-04 04:54
So sounds about right. Example : Publish new contract from pipeline "test" this will trigger webhook to run provider verifification from master so providerTags=master. When i would run provider verification from branch "feature" then providerTags=feature? I Just want double check due to question i left on #pact-broker channel..

uglyog
2020-06-04 05:03
No, I think providerTags must always be master.

uglyog
2020-06-04 05:04
The feature branch pacts will be pending because there will be no verification results tagged with master for them

mbieganski.infomatt
2020-06-04 05:23
Isn't this correct? Consumer changed pact tagged "test" then it was verified by webhook "master" which should fail and is pending. So then provider branch "test" matching consumer is executed and pass so pact isnt pending anymore?

uglyog
2020-06-04 05:37
No, I don't think so. But @bethskurrie is the one who can confirm

mbieganski.infomatt
2020-06-04 05:55
Had the same idea :slightly_smiling_face: i have also read the blog entry and demo but maybe I'm missing something. https://github.com/pactflow/ci-cd-workshop/blob/master/workshop/02_protecting_the_provider.md

mail961
2020-06-04 05:57
hi uglyog. thanks, for the prompt response. with just `mvn verify` it works. What is `mvn pact:verify` for then? Based on https://github.com/DiUS/pact-jvm/tree/master/provider/maven#3-execute-mvn-pactverify I assumed it was responsible for running the tests and uploading the results.

bethskurrie
2020-06-04 09:17
The webhook flow does not use pending because it's just passing the specific pact url through to the verification.

bethskurrie
2020-06-04 09:17
The webhook does not know which provider tags will be used to verify the pact, and hence, it can't know if the pact will be pending or not.

bethskurrie
2020-06-04 09:18
The pending functionality only applies to the "provider changed" workflow, where the provider is fetching the configured pacts from the broker.

bethskurrie
2020-06-04 09:20
> Isn't this correct? Consumer changed pact tagged "test" then it was verified by webhook "master" which should fail and is pending. So then provider branch "test" matching consumer is executed and pass so pact isnt pending anymore? The pact would be pending on provider master still, but not pending on provider test.

bethskurrie
2020-06-04 09:22
The pending calculation is always based on the provider tags. If the content has not been successfully verified by a certain provider tag, it is pending for that tag. Once it has been successfully verified by that provider tag, it is no longer pending for that tag, but it remains pending for all other tags.

mbieganski.infomatt
2020-06-04 09:24
yes. so basically pactbroker.providerTags = branch of the current provider

bethskurrie
2020-06-04 09:24
Yes

mbieganski.infomatt
2020-06-04 09:25
great! Thanks again!

bethskurrie
2020-06-04 09:25
Tag with the branch when you build, tag with the environment when you deploy.

bethskurrie
2020-06-04 09:25
I'm actually going to add explicit branch support, because people get confused about tags and branches.

bethskurrie
2020-06-04 09:26
It will make it simpler to explain, even though it will be the same underlying logic.

mbieganski.infomatt
2020-06-04 09:26
this is clear for me :slightly_smiling_face: I only got confused about not failing builds

jarmy
2020-06-04 21:00
I?m looking for some help with the implementation details. Would I be correct to add a new class (e.g. `PactDslGraphQLRequest`) under `http://au.com.dius.pact.consumer.dsl`? Would this new class extend from `PactDslRequestBase`? Am I barking up the wrong tree?

jks
2020-06-04 21:08
Hello, I have a question about the DSL. I?ve noticed the PactDslJsonBody class doesn?t create JSON with the same order as coded. For instance, this code: ```subject .array('array1') .object().stringValue('foo', 'b').closeObject() .object().stringValue('foo', 'a').closeObject() .closeArray() .array('array2') .number(1).number(2).number(3).number(4) .closeArray() .close()``` Produces: `{"array2":[1,2,3,4],"array1":[{"foo":"b"},{"foo":"a"}]}` When I?d expect: ```'{"array1":[{"foo":"b"},{"foo":"a"}],"array2":[1,2,3,4]}'``` It seems the PactDslJsonArray class preserves order, which I would expect. From a JSON perspective it may not matter. Just wondering if there is a reason, or just a side effect. I?m writing some tests for PactDslJsonBodyMatcherSpec and want to make sure I do it in a way that works into the future.

matt.fellows
2020-06-04 23:18
I might need @uglyog to help out with that specific advice (I?m not intimately familiar with the class hierarchy etc.), but I?d start with writing a standard test as per above and getting it to work. Once you?ve got that working, extract it out into a base class as you suggest

uglyog
2020-06-04 23:57
Seems like a reasonable place to start

jarmy
2020-06-05 00:01
okay. thanks

dgaglani
2020-06-05 00:04
How do I set matcher which has field which can either have value string or can be null? I tried this: ```"$.data.displayName": { "matchers": [ { "match": "type", "value": "Hello" }, { "match": "null" } ], "combine": "OR" }``` This does not work in case actual response from server for displayName is null


uglyog
2020-06-05 00:12
Better to have two tests, one with the values and one where they are missing.

dgaglani
2020-06-05 00:22
but values are dynamic.. depending on other factors which provider / consumer does not care if null or not.. hence want to ignore

uglyog
2020-06-05 00:28
If the consumer doesn't care about the attributes, leave them out of the contract

phil.endsley
2020-06-05 05:08
has joined #pact-jvm

thomas.koerner
2020-06-05 07:50
has joined #pact-jvm

alex810
2020-06-05 08:05
has joined #pact-jvm

thomas.fisher
2020-06-05 08:28
has joined #pact-jvm

jks
2020-06-05 13:14
Disregard, found examples of how to deal with this.

dgaglani
2020-06-05 16:31
Thanks!

raghulraj
2020-06-07 20:34
has joined #pact-jvm

steven.knopf
2020-06-08 08:32
has joined #pact-jvm

r.iglesias
2020-06-08 09:43
has joined #pact-jvm

sonney.patel
2020-06-08 12:31
has joined #pact-jvm

rafael.espillaque
2020-06-08 12:51
has joined #pact-jvm

ryan.dens
2020-06-08 13:07
:wave: Curious if someone has experience with writing Pacts whose request bodies have been gzip?d? I stumbled across this old issue for ?pact-js? to add support for content encodings: https://github.com/pact-foundation/pact-js/issues/93. In that issue, it is suggested that content encodings are a transport concern handled by underlying libraries and is therefore not a good candidate for inclusion in the contract. I tend to very much agree, so ordinarily this would end here, however I have some nastiness in the API provider I work with which deviates from best practices from handling content encodings. I don?t remotely expect Pact to have an optimal UX for this uncommon use case, but I would like to be able to have gzip?d JSON bodies as one of my contracts. Right now, when I attempt to do this, I get a JSON parse exception. I can see there is an open issue here on pact-jvm: https://github.com/DiUS/pact-jvm/issues/556 which suggests that what I?m looking for is outside the scope of the decision made on the pact-js issue. I think the best path forward would be to include the `Content-Encoding` header in `lookupBodyMatcher` and to use the `PlainTextBodyMatcher` if it is gzip?d, but curious to see what others have done

sonney.patel
2020-06-08 13:09
Hello there, I just spoke to someone in #general who redirected me here. I'm writing pact tests in java, have successfully published the consumer test, however i'm receiving 401 when i attempt to reconcile it on the providers side. Our provider does have basic authentication, but I'm not sure where to configure this. I'd appreciate any help

ryan.dens
2020-06-08 13:13
There?s a helpful portion of the docs on this: https://docs.pact.io/provider/handling_auth#docsNav My team has found success using #2, however I suspect using a request filter as specified in #4 would be a good general purpose solution

sonney.patel
2020-06-08 13:16
ooh thank you ill check this out

matt.fellows
2020-06-08 13:46
Basic auth :nauseated_face:. You could just put the creds for your test environment in the contract if they aren't sensitive

matt.fellows
2020-06-08 13:46
That would be the simplest

sadeed.bari
2020-06-08 14:08
has joined #pact-jvm

christopher.kies
2020-06-08 14:13
has joined #pact-jvm

sonney.patel
2020-06-08 14:23
I looked to do #4 because it made the most sense to me when i read it and i found this annotation @TargetRequestFilters where HttpRequest is passed as a parameter, however I couldn't invoke the method when i ran the test :angry:

sonney.patel
2020-06-08 14:24
@matt.fellows I might be able to do that, but i need to talk to my team first

v.scherr
2020-06-08 15:12
has joined #pact-jvm

v.scherr
2020-06-08 15:13
Im writing a small programm for a University project. I'd like to test it with the pact framewok. Unfortunately, no Pact.json file is created for me, although there are no errors. My Consumer iss written in Javascript. Below you can see the source code of my javascript file, the console output and my package.json file: ```const {Pact} = require('@pact-foundation/pact'); const axios = require('axios'); const path = require('path'); jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000 describe('Pact Consumer', () => { const provider = new Pact({ consumer: 'consumer', provider: 'producer', port: 1234, cors:true, log: path.resolve(process.cwd(), 'logs', 'pact.log'), dir: path.resolve(process.cwd(), 'pacts'), logLevel: 'INFO', }); beforeAll(() => provider.setup()); describe('consumer', () => { beforeAll ((done) => provider.addInteraction({ uponReceiving: "a request for JSON data", withRequest: { method: "GET", path: "/test", headers: { Accept: "application/json" }, }, willRespondWith: { status: 200, headers: { "Content-Type": "application/json","Access-Control-Allow-Origin": '*' }, body: { name: 'Scherr', surname: 'Valerian', age: 28, }, }, }) .then(done, error => done.fail(error)), ); }); describe('test', () => { it('should return the correct data', () => { axios.get('localhost:8888/test').then(response => { expect(response[0].name).toBe('Scherr'); expect(response[0].surname).toBe('Valerian'); expect(response[0].age).toBe(28); }) }); }); afterEach(() => { provider.verify(); }); afterAll(done => { provider.finalize().then(done, done.fail); }); });``` Console output:`"C:\Program Files\nodejs\node.exe" C:\Users\vsche\IdeaProjects\testscenario\webservice\node_modules\jasmine\bin\jasmine.js --reporter=C:\Users\vsche\.IntelliJIdea2019.3\config\plugins\IdeaJasmine\lib\intellij_reporter.js C:/Users/vsche/IdeaProjects/testscenario/webservice/spec/WebService.spec.js --filter=test` [2020-06-08T15:05:38.629Z] INFO: pact-node@10.9.5/8152 on DESKTOP-FH2DU0O: Creating Pact Server with options: {"consumer":"consumer","cors":true,"dir":"C:\\Users\\vsche\\IdeaProjects\\testscenario\\pacts","host":"127.0.0.1","log":"C:\\Users\\vsche\\IdeaProjects\\testscenario\\logs\\pact.log","pactFileWriteMode":"overwrite","port":1234,"provider":"producer","spec":2,"ssl":false} [2020-06-08T15:05:39.679Z] INFO: pact@9.11.0/8152 on DESKTOP-FH2DU0O: Setting up Pact with Consumer "consumer" and Provider "producer" using mock service on Port: "1234" [2020-06-08T15:05:39.700Z] INFO: pact@9.11.0/8152 on DESKTOP-FH2DU0O: Pact File Written [2020-06-08T15:05:39.701Z] INFO: pact-node@10.9.5/8152 on DESKTOP-FH2DU0O: Removing Pact process with PID: 13428 [2020-06-08T15:05:41.800ZPact verification failed!] INFOPopsicleError: Unable to connect to "http://127.0.0.1:1234/interactions" : pact-node@10.9.5/8152 on DESKTOP-FH2DU0O: Caused by: Error: connect ECONNREFUSED 127.0.0.1:1234 Deleting Pact Server with options: {"consumer":"consumer","cors":true,"dir":"C:\\Users\\vsche\\IdeaProjects\\testscenario\\pacts","host":"127.0.0.1","log":"C:\\Users\\vsche\\IdeaProjects\\testscenario\\logs\\pact.log","pactFileWriteMode":"overwrite","port":1234,"provider":"producer","spec":2,"ssl":false} Thanks in advance for any help

phil.endsley
2020-06-08 15:45
The pact json is generated by the consumer, so you'll probably get more help in the #pact-node channel

v.scherr
2020-06-08 15:48
Thank u. I write to #pact-node

aliihlail
2020-06-08 16:24
I have an issue with publishing the verification results of the Amqp testing to the pact broker. when the results passes. this is only when there are multiple consumers for the same provider. When tests fails it can publish that results.

antonello
2020-06-08 20:36
Any chance of a release of pact-jvm soon? :blush:

jarmy
2020-06-08 23:24
@matt.fellows What is this code doing exactly? ```const escapeGraphQlQuery = (s: string) => escapeSpace(escapeRegexChars(s)) const escapeRegexChars = (s: string) => s.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") const escapeSpace = (s: string) => s.replace(/\s+/g, "\\s*")``` https://github.com/pact-foundation/pact-js/blob/master/src/dsl/graphql.ts#L113-L118

matt.fellows
2020-06-08 23:29
I?ve responded to your SO question Valerian

matt.fellows
2020-06-08 23:31
It?s escaping certain characters and allowing a regex match on the query (and allowing spaces)

matt.fellows
2020-06-08 23:32
I can?t exactly remember why the regex was necessary, because if you can control the query then you should be able to control spaces etc. It may have been that I experienced a breaking Pact change upgrading minor version of Apollo or something so guarded against it.

matt.fellows
2020-06-08 23:32
You could see how you go without that initially

matt.fellows
2020-06-08 23:32
The key thing is that you can get the `query` attribute to have the exact string that your GraphQL client sends

raghulraj
2020-06-09 02:12
Hi All, facing an issue in my springboot app while running mvn pact:verify, its not starting the mock server, but when it got triggered like a junit test it works. Any idea?

raghulraj
2020-06-09 02:13
``` Given Create customer for an existing Account WARNING: State Change ignored as there is no stateChange URL create customer call to custmart-service returns a response which has status code 200 (FAILED) has a matching body (FAILED)```

raghulraj
2020-06-09 02:13
```assert expectedStatus == actualStatus | | | 200 | 404 false```

uglyog
2020-06-09 02:19
`mvn pact:verify` does not start the mock server. It should be run against your actual springboot app. You will need to ensure your app is started before hand. If you are using the JUnit Spring runner, it will automatically start the springboot app using the Spring test support.

raghulraj
2020-06-09 02:30
ok. Thanks for the quick response, will check.

raghulraj
2020-06-09 03:53
i am using junit4 ```@RunWith(SpringRestPactRunner.class)```

raghulraj
2020-06-09 03:54
which is running fine, when i trigger it from IDE.

raghulraj
2020-06-09 03:55
But springboot app is not starting when i run mvn pact:verify.


uglyog
2020-06-09 04:21
don't use `mvn pact:verify`, use `mvn verify`

raghulraj
2020-06-09 05:15
cool. That worked. Thanks

v.scherr
2020-06-09 10:16
Thank u i have a new failure i updated my code on stackover

anddreiu
2020-06-09 10:40
Hi. I've just upgraded the provider library from 4.0.4 to 4.1.1, but I have some issues with `PactRunner.class` and `HttpTarget` which cannot be resolved to a type. I've looked over the Release notes (https://github.com/DiUS/pact-jvm/releases) but didn't figure if these were changed and if I have to change the implementation. Also, in the documentation (https://github.com/DiUS/pact-jvm/tree/v4.1.x/provider/junit) I can still see those classes used. I am using Junit 4.

raghulraj
2020-06-09 15:15
Hi @uglyog though tests are passed, it shows ```Tests run: 0, Failures: 0, Errors: 0, Skipped: 0```

raghulraj
2020-06-09 15:15
when use mvn verify

raghulraj
2020-06-09 15:20
also it skips publishing of verification results, though it set to true.

rafael.espillaque
2020-06-09 16:27
Hi all, what?s the best way of analysing/rendering this kind of errors? junit log doesn?t seem very helpful

rafael.espillaque
2020-06-09 16:29
I guess the I can use this part of the message: `mismatch=Expected id="string" but was missing` but I wonder if there?s a tool that is able to parse those errors

raghulraj
2020-06-10 00:15
Hi @uglyog, with `mvn pact:verify` it's updating the results to pact broker. but not with `mvn verify`. how to fix this?

uglyog
2020-06-10 00:23
@raghulraj if Maven is not running your test, then the results will be not published because the test does that. This has nothing to do with Pact, you need to work out why the test is not running. Consult the Maven Surefire documentation, because that is what runs the tests when you execute `mvn verify`.

raghulraj
2020-06-10 00:23
my bad, just tested it.. mvn verify is running it, but results shows 0

raghulraj
2020-06-10 00:23
its updating it as failure in pact broker

raghulraj
2020-06-10 00:26
```Verifying a pact between Ms1 customer regristrion ui and custmart-service Given Create customer for an existing Account create customer call to custmart-service .... returns a response which has status code 200 (OK) has a matching body (OK) [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 9.531 s - in com.custmart.pact.Custmart_Create_Customer_ProviderPactTest [INFO] [INFO] Results: [INFO] [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO] ```

raghulraj
2020-06-10 00:29
command used: ```mvn verify -Dpact.verifier.publishResults=true -Dpact.provider.version=1.0.0```

raghulraj
2020-06-10 00:32
broker shows: ```"testResults": [ { "interactionId": "d2bb56ec9e2ad448eac2713932a26d5f06f34025", "success": false, "mismatches": [ { "attribute": "status", "description": null }, { "attribute": "body", "description": "null" } ] } ],```

uglyog
2020-06-10 00:33
What versions of Pact-JVM and Maven are you using?

raghulraj
2020-06-10 00:38
```<dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-spring</artifactId> <version>4.0.10</version> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.10</version> </dependency>```

uglyog
2020-06-10 00:39
Sorry, I meant the version of Maven

raghulraj
2020-06-10 00:40
```<maven.surefire.plugin.version>2.22.1</maven.surefire.plugin.version>```

raghulraj
2020-06-10 00:42
```Apache Maven 3.6.3 ```

uglyog
2020-06-10 00:45
You need to enable debug logging to see what is going on.

raghulraj
2020-06-10 00:48
ok

godfrey
2020-06-10 07:35
has joined #pact-jvm

matt.fellows
2020-06-10 08:05
Thanks Anto!

matt.fellows
2020-06-10 08:05
(and team at Treatwell)

cristian.schez
2020-06-10 08:22
has joined #pact-jvm

anddreiu
2020-06-10 09:06
@uglyog can you please take a look on this? I just want to know if I am doing something wrong or if it's an issue on this version. Thanks.

wesleythomaswilliams
2020-06-10 10:15
Are all the tests in a single class? I'd be interested in seeing it if you can share. Also, any output from the test execution.

wesleythomaswilliams
2020-06-10 10:18
I usually copy the first line into an editor for closer analysis. I find the diff part quite hard to read and just look at the actual and expected myself.

wesleythomaswilliams
2020-06-10 10:19
Btw, your failure is casing id != ID

rafael.espillaque
2020-06-10 10:22
I see, thanks

antonello
2020-06-10 11:34
You?re welcome, @matt.fellows! My first attempt at writing Kotlin!

antonello
2020-06-10 11:35
There is an unrelated failing tests, but apart from that it should be good to go!

slack1274
2020-06-10 11:41
has joined #pact-jvm

wvdbraak
2020-06-10 12:02
has joined #pact-jvm

uglyog
2020-06-10 22:57
The module names have changed. See https://github.com/DiUS/pact-jvm/releases/tag/4_1_0 for the details

jarmy
2020-06-11 00:12
Hi @uglyog I?ve got my `PactDslGraphQLRequest` class in place which `extends PactDslRequestBase` and would like to test some of the methods I?ve written. How exactly do the methods in here https://github.com/DiUS/pact-jvm/blob/master/consumer/src/test/java/au/com/dius/pact/consumer/MatchingTest.java#L87 map to their respective classes? For example, both `PactDslRequestWithPath` and `PactDslRequestWithoutPath` contain `method(String method)` yet this line resolves to the one in _PactDslRequestWithPath._ For that matter, how does the test become context aware of classes such as `PactDslGraphQLRequest`?

uglyog
2020-06-11 00:24
Those two classes work together to create the DSL, they are really just historical and one class is fine. Probably could refactor them into one class in the future. That test just uses the DSL (see line 162) and doesn't even know about the individual classes.

antonello
2020-06-11 09:25
@uglyog I saw you removed `appveyor` but it?s still running on PRs

ashish_garg5
2020-06-11 11:12
Hi All, How i can publish the consumer app version using command line. I don't want to take it from my pom.xml. In provider side i am able to do it by passing -Dpact.provider.version=1.0.0 Thanks.

rafael.espillaque
2020-06-11 11:49
I?d try to use `projectVersion` in the maven pact plugin config and set it to a custom project property and then use -DyourProperty=xxx


ashish_garg5
2020-06-11 11:50
ok thanks

wesleythomaswilliams
2020-06-11 12:42
We do this in our pipeline: ```'mvn test -Dpact.provider.version=' + env.GIT_COMMIT '-Dpact.verifier.publishResults=true' + ' -Dpact.provider.tag=' + env.GIT_BRANCH```

satya.quote_pact
2020-06-11 13:45
has joined #pact-jvm

satya.quote_pact
2020-06-11 13:52
Apologies if this has been asked here already, Quick question any pointers for getting secrets from vaults while verifying the pact with secrets in it. Don't want to hardcode that in the published pact but wanted to get on runtime

matt.fellows
2020-06-11 22:02
Why do you have secrets in your pacts? As a general rule it should all be test data that you can control, but I'm keen to understand further. In java at least, you could use request filters to dynamically replace secrets

bradley.smith
2020-06-11 23:03
has joined #pact-jvm

ashish_garg5
2020-06-12 05:35
@wesleythomaswilliams - Hey thanks but i was asking for the consumer side... projectVersion tag worked for me :slightly_smiling_face:

satya.quote_pact
2020-06-12 12:09
Yes agree all the data we are passing is test data which is been setup as state change. However it requires some authentication secrets which could not be exposed in pacts. So wondered if there is any option for doing so. Yeah will look into filters to dynamically replacing it.

aliihlail
2020-06-12 15:33
Yes. they are in a single class.

aliihlail
2020-06-12 15:34
Thread.sleep(2000) also does not worked

matt.fellows
2020-06-13 09:15
Ron on a PR purge!

vivek.thangathurai
2020-06-13 14:14
has joined #pact-jvm

antonello
2020-06-15 22:34
Is there a way to apply a like matcher to a whole Json body as you could do in JavaScript with like?

uglyog
2020-06-15 23:34
Can you provide an example?

srikanth.chikkala
2020-06-16 04:03
has joined #pact-jvm

mbieganski.infomatt
2020-06-16 13:36
hey. is there a way to make name matching any String? Like case where Object is a Map and property name can be any String?

phil.endsley
2020-06-16 16:55
I'm trying to wrap my head around what our workflow will look like with pending pacts. I've read through some of the docs (ci/cd workshop, pact-jvm-provider) , but still have a couple questions 1. Consumer team publishes a new/updated contract 2. Provider verifies the specified tags like normal. 3. In addition, the provider will verify any Pacts that have not been verified by the latest version of the specified provider tag 4. If the pending pacts fail, no change. If they pass, results are published and they're no longer pending for that provider version Is that correct? The junit 5 jvm provider docs say: > You also need to provide the tags used to publish the providers main-line results (i.e. tags like prod or master) https://github.com/DiUS/pact-jvm/tree/master/provider/junit5#pending-pact-support-version-410-and-later Is this supposed to be hard coded to a branch, and stay that way for all feature branches (With the assumption that you only publish verification results from CI server)? If that's the case, is the intended workflow for the provider: 1. Manually update the tags you verify against to include the consumer feature 2. Implement like normal 3. Remove the consumer feature tag before merging? I guess it all boils down to, what is the providerTags parameter actually used for?

phil.endsley
2020-06-16 19:12
Still have questions, but I think part of my issue was I was treating WIP pacts and pending pacts as the same feature. According to this table https://docs.pact.io/feature_support, it doesn't look like wip pacts are supported for jvm yet. Is there an open issue for this?

antonello
2020-06-16 19:43
@phil.endsley I thought that pending pacts was just the new, better name for WIP pacts.

antonello
2020-06-16 19:44
@bethskurrie @matt.fellows @uglyog or @tjones should be able to confirm.

phil.endsley
2020-06-16 19:56
Could be. I haven't been able to find a ton out about them. My current (maybe wrong :slightly_smiling_face: ) understanding is: Pending pacts: Don't fail provider builds if it has never been verified WIP Pacts: Update outstanding unverified pacts

robert.strauch_slack
2020-06-16 21:53
Hello all, I've just setup my first provider verification with JUnit 5 and it's basically working. I do have some trouble with the proper use of the `@State` annotation. Let's take this for example: ```@State("user already exists") public void createInactiveUser() { // logic to create user }``` The application under test already provides an endpoint to create a new user, so my first idea is using this endpoint. But how would I do this? I'm aware that the pct-jvm Maven plugin provides a state change URL parameter but it seems as if this is not available in the JUnit approach?

antonello
2020-06-16 22:02
hey @robert.strauch_slack. Inside that method annotated with your `@State` you would implement the logic to create the inactive user, for example using the endpoint that you?re referring to.

antonello
2020-06-16 22:02
that said, that state needs to be defined in the pact interaction

antonello
2020-06-16 22:03
if it is, when pact-jvm retrieves the pact and tries to run the interaction, it will run that method annotated with `@State`, provided that you?ve written your provider tests correctly.

robert.strauch_slack
2020-06-16 22:06
Sorry, my question was asked wrongly :slightly_smiling_face: I'm wondering if there is something like the `stateChangeUrl` in the Maven plugin but for the JUnit apporach. Something like an annotation like `@StateUrl("http://some-state-setup")`

robert.strauch_slack
2020-06-16 22:06
Or would the apporach be to just make a REST call with any of the available libraries?

antonello
2020-06-16 22:20
I would imagine only the latter is possible

robert.strauch_slack
2020-06-16 22:21
Thanks @antonello, that's why I was thinking as well...

antonello
2020-06-16 22:24
no problem!

phil.endsley
2020-06-16 22:30
Just curious, what rest calls are you making? One to your application that creates a user?

uglyog
2020-06-16 23:03
WIP == Pending. If your work is in progress, the pacts are marked as pending

uglyog
2020-06-16 23:06
The providerTags is needed by the broker to work out if a pact should be pending or not. The logic is that you provide the tags for your main branch (master, main, prod, whatever), and then if the broker finds a pact that does not have a verifaction result tagged with one of those, it marks it as pending.

uglyog
2020-06-16 23:07
Without that info, all pacts will be pending

phil.endsley
2020-06-17 01:11
My confusion is coming from the docs treating pending pacts and WIP pacts as two separate features. At least, that's how I keep interpreting it :confused: examples: Announcements: Pending: http://blog.pact.io/2020/02/24/how-we-have-fixed-the-biggest-problem-with-the-pact-workflow/ WIP: http://blog.pact.io/2020/02/24/introducing-wip-pacts/ CI/CD WorkShop: Pending: https://docs.pactflow.io/docs/workshops/ci-cd/workshop/protecting-the-provider/#enable-pending-pacts-for-the-provider WIP: https://docs.pactflow.io/docs/workshops/ci-cd/workshop/verifying-feature-pacts/#work-in-progress-pacts A few followup questions: 1. Are Pending Pacts flagged in Pact Broker's UI in any way, or is it just something that's tracked on the backend? 2. The jvm provider libs have support for enablePendingPacts. All other provider libs have a includeWipPactsSince parameter that gets set somewhere. This is also called out in the master issue for WIP pacts (~https://github.com/pact-foundation/pact_broker/issues/307~ oops https://github.com/pact-foundation/pact_broker/issues/338). I can't find any reference to it in the jvm libs. Is it supported? Not needed?

uglyog
2020-06-17 01:26
This is one for @bethskurrie

matt.fellows
2020-06-17 01:28
> Are Pending Pacts flagged in Pact Broker?s UI in any way, or is it just something that?s tracked on the backend? Not at the moment. It gets complicated, because the ?pending? status is not a binary yes/no - it depends on what tags it has

matt.fellows
2020-06-17 01:28
e.g. a pact can still be pending for `master` (e.g. the mainline code base) but verified for another tag e.g. `feature-x` (say, the working feature branch on the provider side)

phil.endsley
2020-06-17 01:29
> Not at the moment. It gets complicated, because the ?pending? status is not a binary yes/no - it depends on what tags it has That makes sense, because it all depends on what tag it has verified with

matt.fellows
2020-06-17 01:30
I think a better way of thinking about the differences is this: Pending pacts: don?t break the provider if it hasn?t seen a pact before WIP pacts: don?t make the provider have to guess the tags of new contracts in order to verify them. Find all of the WIP pacts and verify them (but don?t break the build)

matt.fellows
2020-06-17 01:30
I hope Beth is happy with that characterisation, because that?s how I?ve internalised it and have been communicating it

bethskurrie
2020-06-17 01:31
Yep, that's pretty accurate Matt.

matt.fellows
2020-06-17 01:31
phew

bethskurrie
2020-06-17 01:32
I'd probably say, "don't make the provider team have to manually update the list of tags to verify. Find all the pacts that are pending for this version of the provider, and automatically verify them along with the configured ones."

bethskurrie
2020-06-17 01:34
The includeWipPactSince isn't implemented in pact JVM yet, because I had forgotten that it wasn't in there, and hadn't raised the issue for Ron to do it.

bethskurrie
2020-06-17 01:34
I'll raise that today.

phil.endsley
2020-06-17 01:36
So until then, we can use pending pacts, and not break our provider builds. But we need to wait for that until we can do the WIP/second part of verifying outstanding pacts?

bethskurrie
2020-06-17 01:36
Yes.


phil.endsley
2020-06-17 01:37
Awesome. Many thanks to all of you! I think I understand it now

phil.endsley
2020-06-17 01:55
Ok, a couple more, just to make sure I really do understand :slightly_smiling_face: : Once we are able to use the WIP feature, we would want to set the providerVersionTag to whatever the current branch would be tagged as, right? We tag everything with the branch name, so for us, we would set it to `feature-x` (when on the feature-x branch) and `master` (when on the master branch). And that's so we're correctly verifying the pact on every branch is has been verified on. We can start using pending pacts today. That would be a good thing, because if a team ever merged a change with a new contract into master, the provider builds wouldn't fail. Provider can still deploy. Consumer could not (rightfully so) unless they revert it.

bethskurrie
2020-06-17 01:55
Verification results for pending pacts are published whether or not they pass or fail. They just won't fail the build.

bethskurrie
2020-06-17 01:56
> Once we are able to use the WIP feature, we would want to set the providerVersionTag to whatever the current branch would be tagged as, right?

bethskurrie
2020-06-17 01:56
Yes

bethskurrie
2020-06-17 01:56
> Consumer could not (rightfully so) unless they revert it.

bethskurrie
2020-06-17 01:57
Yes. It pushes the responsibility back on to the consumer. They need to make sure they're using can-i-deploy to ensure they don't deploy a broken contract.

bethskurrie
2020-06-17 01:58
> We tag everything with the branch name The golden rule for tagging is: Tag with the branch when you publish pacts/results, tag with the environment when you deploy.

phil.endsley
2020-06-17 01:58
Great features, btw. These were the two sources of push back we got from various teams across our company. Now, they won't have any excuses :slightly_smiling_face:

bethskurrie
2020-06-17 01:58
There is no flexible matching for key names @mbieganski.infomatt

bethskurrie
2020-06-17 01:59
It may be a feature request for the next version of the specification. Have a look at https://github.com/pact-foundation/pact-specification/issues

antonello
2020-06-17 06:18
Could all this be documented somewhere? :blush:

robert.strauch_slack
2020-06-17 07:58
@phil.endsley Exactly, at first I tried to go directly via the DAOs but as our application runs in a Java EE / CDI context there was too much overhead for me to inject the services. Do you see any "issue" in using the REST apporach?

mbieganski.infomatt
2020-06-17 10:24
Thanks:)

mbieganski.infomatt
2020-06-17 10:34
Hi. I have a service that is both Rest and amqp provider. I have 2 classes to handle each setup but problem is that now both type of consumer tests are being run by both classes so I'm ending up with error like `Only request/response interactions can be used with an HTTP test target` `java.lang.UnsupportedOperationException: Only request/response interactions can be used with an HTTP test target` I using junit5 and PactBroker. Any advice how to handle it?

phil.endsley
2020-06-17 12:39
No, not really. I was going to recommend what you were saying first, inject the DAOs directly for the setup pieces, but it looks like you already tried that. I'm not a fan of calling other parts of the system for setup for state initialization/setup, because you can get some misleading results in your tests if that's where a breaking change is made. This pact will start failing on a condition it's not responsible for. But sometimes, it is what it is, and you just have to work with what you have.

phil.endsley
2020-06-17 12:39
Also just trying to broaden my horizons and see what other strategies people are using

robert.strauch_slack
2020-06-17 13:04
Yeah, I get your point and agree. Our application is "much too heavyweight" and this causes all kind of more heavyweight stuff for testing. Maybe I'll find a more lightweight approach directly using the DAOs.

matt.fellows
2020-06-17 13:25
Beth, I love that rule. Perhaps we need to find a set of principles like the proverbs Go have: https://go-proverbs.github.io/ https://the-zen-of-go.netlify.app/

robert.strauch_slack
2020-06-17 13:47
I have a somewhat geenral question about verifying the provider side. Our application under test is kind of heavyweight, so setting up state is less than trivial. It would include a lot of different entities, database tables, etc. What's your apporach for these situations? Would you say it's fine to mock the services for the contract testing? Or would you recommend to go "all the way"?

phil.endsley
2020-06-17 14:06
We're in a similar situation. Some of our providers are giant monolithic applications that were not built with testing in mind. We're just getting to the point where we're writing Pacts for them, but our approach is going to be taking baby steps. ? Get Pacts working with mocks. Not ideal, but it's better than nothing. ? Gradually refactor so we can put more real classes into the provider verification flow ? Hopefully refactor enough that our features aren't as tightly coupled, and we can "go all the way" We know that realistically, there will be some paths that we probably won't ever get around to. But our stance is still, something is better than nothing

robert.strauch_slack
2020-06-17 19:35
@phil.endsley Do you have an example how to use Mockito in combination with Pact? My idea is to mock the injected service.

phil.endsley
2020-06-17 19:38
Nothing concrete yet, sorry. We'll hopefully have a team start on it within the next week or two. Right now, it's just our plans on paper.

robert.strauch_slack
2020-06-17 19:38
Thanks anyway. I'll ask in a channel :slightly_smiling_face:

robert.strauch_slack
2020-06-17 19:42
Hello all, I'm not sure if my apporach might be working at all... is is possible to use Mockito in combiation with JUnit 5 and Pact? The idea is to mock the specific service calls in order to avoid considering all dependencies. Does someone have a working example using Pact and Mockito?

antonello
2020-06-17 20:57
yes, you definitely can!

antonello
2020-06-17 20:59
You should be able to write your tests in the same way you?d write any other spring tests - you can choose between the HttpTarget and the MockMvc one

robert.strauch_slack
2020-06-17 21:25
@antonello Forgot to mention that the application is not based on Spring but a CDI application running within a Wildfly application server. This makes it kind of hard for me finding a meaningful approach. I've found examples for Spring but none for CDI.

antonello
2020-06-17 21:32
it should still be doable using the HttpTarget

robert.strauch_slack
2020-06-17 21:39
Do you have any examples for such a setup?

tjones
2020-06-18 00:55
For provider tests, I have found it?s generally easier to write concrete mocks rather than use a mock framework

tjones
2020-06-18 00:55
Also, if it makes sense for your case, it?s good to mock below the service layer if you can

tjones
2020-06-18 00:56
this gives some functional coverage of the service layers (Pact tests aren?t functional tests, but having some functional coverage ensures you?re testing a response your real code can actually produce)

tjones
2020-06-18 00:58
eg, if your code goes `http call ->{ controller -> service -> repository } -> SQL call to DB` , then put the cut point for the mock at `repository`

phil.endsley
2020-06-18 02:03
I'm looking for help getting pending pacts working. Everything is turned on (broker and provider), the build says it's using pending pacts, but it's still failing (1 failed test, and it's a pending one) :confused: ```com.mycompany.app.PactProviderTest > pactVerificationTestTemplate(HttpRequest, PactVerificationContext)[50] STANDARD_OUT Verifying a pact between Pact between consumerApp (079547da2e) and providerApp [PENDING] Notices: 1) The pact at [url to pact] is being verified because it matches the following configured selection criterion: latest pact for a consumer version tagged 'feature/pending-pact-tests' 2) This pact is in pending state for this version of providerApp because a successful verification result for a version of providerApp with tag 'develop' has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at https://pact.io/pending [from Pact Broker [url]] Given things exist a request to get all things returns a response which has status code 200 (OK) has a matching body (FAILED) Pending Failures: 1) Verifying a pact between consumerApp and providerApp - a request to get all things 1.1) BodyMismatch: [thing that doesn't match] ... ... > Task :app:test FAILED ... ... 336 tests completed, 1 failed FAILURE: Build failed with an exception. ... ... BUILD FAILED in 4m 34s```

uglyog
2020-06-18 02:05
Hmm, are you using the latest Pact-JVM version?

uglyog
2020-06-18 02:07
Are there any other logs? Could something else have caused the test to fail?

phil.endsley
2020-06-18 02:13
> Hmm, are you using the latest Pact-JVM version?Hmm, are you using the latest Pact-JVM version? ```testCompile("au.com.dius.pact.provider:junit5:4.1.2") testCompile("au.com.dius.pact:provider:4.1.2")``` There's logs for the other tests, but this is the only thing causing a failure. The junit report also shows this as the only failure. That shows the stack trace where it fails at at http://au.com.dius.pact.provider.junit5.PactVerificationContext.verifyInteraction(PactJUnit5VerificationProvider.kt:94) But it also has this before it, so everything looks like it should work, it's just not ```java.lang.AssertionError: Pending Failures:```

abubics
2020-06-18 02:13
In some important ways, it might depend on how the provider is layered. My usual preference is to provide stub responses from the layer just past the API endpoints (to make sure it's not just serialising/deserialising, but also validating the edge of business logic). Other people prefer to stub the services on the other end of the provider, which reduces specificity, but is often easier to inject/intercept. Always good to think about which balance you're trying to strike (some examples are listed near the end of https://medium.com/@kentbeck_7670/test-desiderata-94150638a4b3).

uglyog
2020-06-18 02:16
Oh, damn, It's not checking the pending status before throwing the exception.

uglyog
2020-06-18 02:17
I'll fix that

mbieganski.infomatt
2020-06-18 04:22
Maybe you could help @uglyog?

uglyog
2020-06-18 05:40
You need to use different consumer names, because they can't go into the same pact file

mbieganski.infomatt
2020-06-18 05:52
thanks! that's a bummer.. now wondering if or how it will impact our pipelines with webhooks

uglyog
2020-06-18 05:53
It has been raised as something to fix with V4 pact spec version

nmsuryavanshi
2020-06-18 06:46
has joined #pact-jvm

robert.strauch_slack
2020-06-18 07:13
@tjones I get your point. Setting the cut point at the repository level (that would be the DAO in our case) is a reasonable approach. But I'm not sure how to do this. I'm coming more from the tester's perspective rather than a Java developer.

robert.strauch_slack
2020-06-18 07:14
How would I "hook" that mock into the logic while running the Pact tests.

tjones
2020-06-18 07:14
Usually it?s a simple stub that implements the same interface as the repository

tjones
2020-06-18 07:15
Using whatever dependency injection framework constructs your application at startup

mbieganski.infomatt
2020-06-18 07:55
@uglyog I have to set different names for both consumer and provider right?

uglyog
2020-06-18 08:00
If you have consumer named `service1`, use that for HTTP pact test and `service1-amqp` for the message one

uglyog
2020-06-18 08:00
Provider must be the same

mbieganski.infomatt
2020-06-18 08:07
just to be clear provider also needs to be `service2` for HTTP and `service2-amqp` for AMQP.

uglyog
2020-06-18 08:09
No, you can have the provider name the same. Just change the consumer name

mbieganski.infomatt
2020-06-18 08:32
I did that and still it doesn't work. If there is more consumers for this provider tests are being run for both implementations. Unless I'm missing something in my setup..

aliihlail
2020-06-18 10:42
Help needed. :pray: Can any recommend an example for consumer test for POST method in junit5 maven.

antonello
2020-06-18 10:44
hey @aliihlail Which docs have you had a look at so far? What?s not clear specifically

aliihlail
2020-06-18 10:45
``` @Pact(consumer = "import-service", provider = "rental-service-Rest") public RequestResponsePact rentalServiceGetPact(PactDslWithProvider builder) { return builder .given("rental object with referenceId DE-01-01-02 and size 1 exist") .uponReceiving("GET request to retrieve rentals") .path(RENTAL_OBJECTS_PATH) .query("referenceId=DE-01-01-02&size=1") .method(HttpMethod.GET) .willRespondWith() .status(HttpStatus.OK.value()) .headers(responseHeaders()) .body(newJsonBody((result) -> { result.object("_embedded", (embedded) -> { embedded.minMaxArrayLike("rentalObjects", 0, 2, (rentalObjects) -> { rentalObjects.id("id"); }); }); }).getPactDslObject()) .toPact(); } @Pact(consumer = "import-service", provider = "rental-service-Rest") public RequestResponsePact rentalServicePostPact(PactDslWithProvider builder) { return builder .given("post rental from import file") .uponReceiving("POST request to import rental") .path(RENTAL_OBJECTS_BATCH_PATH) .method(http://HttpMethod.POST) .body(newJsonBody((rental) -> { rental.numberType("aggregateId"); rental.stringType("referenceId"); rental.stringMatcher("aggregateType", "UNIT|ROOM"); }).getPactDslObject()) .willRespondWith() .status(HttpStatus.OK.value()) .toPact(); } @Test @PactTestFor(pactMethod = "rentalServiceGetPact") public void testGetRentalService(MockServer mockServer) throws IOException { HttpResponse httpResponse = Request.Get(mockServer.getUrl() + RENTAL_OBJECTS_PATH + "?referenceId=DE-01-01-02&size=1").execute().returnResponse(); assertEquals(httpResponse.getStatusLine().getStatusCode(), HttpStatus.OK.value()); } @Rule private RestTemplate restTemplate = new RestTemplate(); @Test @PactTestFor(pactMethod = "rentalServicePostPact") public void testPostRentalService(MockServer mockServer) throws URISyntaxException { } private Map<String, String> responseHeaders() { Map<String, String> headers = new HashMap<>(); headers.put(CONTENT_HEADER, MediaTypes.HAL_JSON_UTF8_VALUE); return headers; } }```

aliihlail
2020-06-18 10:46
I wrote this method but im not sure how to handle ```@Test @PactTestFor(pactMethod = "rentalServicePostPact") public void testPostRentalService(MockServer mockServer) throws URISyntaxException { }```

antonello
2020-06-18 10:48
In there you need to call your actual service that will make the api request and assert something to ensure that the response that the mock server returned based on your pact is right

aliihlail
2020-06-18 11:06
```HttpResponse httpResponse = http://Request.Post(mockServer.getUrl() + RENTAL_OBJECTS_BATCH_PATH).execute().returnResponse(); assertEquals(httpResponse.getStatusLine().getStatusCode(), HttpStatus.CREATED.value());``` i tried use this but i dont belive it is right

aliihlail
2020-06-18 11:06
any recomendation ?

antonello
2020-06-18 11:07
this is not really a pact question though - it?s more about how to use clients to make post requests

mbieganski.infomatt
2020-06-18 11:21
So I found a way to solve it and don't have to change consumer name. Also looks like I have to also use 1 Context Provider where in this case I was using `PactVerificationInvocationContextProvider`and `PactVerificationSpringProvider`. For REST tests I switched to `@WebMvcTest` so now I have only one Context. In `@BeforeEach` I'm setting HTTP target and I have created `@State` for AMQP which I'm using it to set `AmpqTestTarget`. Not sure if it's best solution but working

phil.endsley
2020-06-18 12:40
Upgraded to 4.1.3 and it's working great now :tada:

satya.quote_pact
2020-06-18 14:56
I am looking for pointers/help how to use provider state change response from willrespondwith() into next uponreceiving() block. Have tried like below ```https://github.com/DiUS/pact-jvm/blob/512f683c9dd3d6659ac61f45e2a97baca18a82f7/consumer/junit5/src/test/groovy/au/com/dius/pact/consumer/junit5/ProviderStateInjectedPactTest.groovy#L33``` but not sure how to use that in uponreceiving() block any pointers much appreciated


kristine.jetzke
2020-06-18 15:02
As @antonello said, you need to call the actual service.

kristine.jetzke
2020-06-18 15:03
which will call the pact mock server (for the rest call)

kristine.jetzke
2020-06-18 15:05
In my example the test method is `userExists` which calls the `userServiceClient`(the actual service) which uses a RestTemplate. The URL of the RestTemplate gets replaced by the test to point to the pact mock server (via `user-service.base-url`property)

kristine.jetzke
2020-06-18 15:06
(This is just an example so for production-use you should need to find a way to use a random port instead of 8080. I have a Junit4 example for that https://github.com/tinexw/cdc-with-pact/blob/master/messaging-app/src/test/java/de/kreuzwerker/cdc/messagingapp/UserServiceContractTest.java but I did not yet have time to implement it for the Junit5 version)

kristine.jetzke
2020-06-18 15:11
Do you mean that for example you get `userId=100` back and then would like to another interaction where the value is used e.g. ```.uponReceiving('a request for one user') .path('/users/100')```

satya.quote_pact
2020-06-18 15:17
yes exactly, when i tried to use i always get back empty. My scenario is i need to pass 100 in the header of uponreceiving() i am doing like this ```willRespondWith() .body(new PactDslJsonBody().valueFromProviderState("id","\\${id}", "100")) .uponReceiving("another request ") .headers("xyz"," ${id}")``` but when i debug it looks ${id} is not replaced with provider state response or default value of 100

kristine.jetzke
2020-06-18 15:18
@robert.strauch_slack I have a very small example https://github.com/tinexw/cdc-with-pact/blob/master/user-service/src/test/java/de/kreuzwerker/cdc/userservice/MockedUserServiceContractTest.java that mocks out the service behind the controller. It uses spring?s `@MockBean` but can be done similarly with plain mockito. It would be the first option mentioned above > [?] to provide stub responses from the layer just past the API endpoints [?] I?m actually prefer to stub further down but it really depends on the application I would say.

kristine.jetzke
2020-06-18 15:30
:thinking_face: @uglyog?

zhukeven86
2020-06-18 18:07
has joined #pact-jvm

zhukeven86
2020-06-18 18:07
Hi. I'm planning on adding the JVM implementation of Pact (version 4.x) from the Maven Central repository, but I am unsure of which files to use. The files there seem to be fragmented and there does not seem to be a fully packaged version of JVM Pact on there. Any help would be greatly appreciated!

robert.strauch_slack
2020-06-18 18:14
Thanks @kristine.jetzke... I looked at your example and do understand your approach. I'm afarid that it won't work that simple in a CDI context? As fat I could find information it seems as if I need to spin up a "full" CDI environment with cdi-unit, Weld or else. Is that correct?

kristine.jetzke
2020-06-18 18:20
I have no experience with that :disappointed:

kristine.jetzke
2020-06-18 18:22
But maybe are there regular unit tests somewhere in the code base that already use mocks? Because the pact test is like a normal unit test so the approach should be the same

phil.endsley
2020-06-18 18:30
I'll help as much as I can... I don't know if there's an "always use this" jar out there. We just picked the one we needed for our case, and it pulled in everything else we needed. Are you adding a Consumer or Provider? Or both?

zhukeven86
2020-06-18 18:48
Im planning on providing both

zhukeven86
2020-06-18 18:49
and I'm going to set up a pact broker too

phil.endsley
2020-06-18 18:53
The repo readme has a good "what to use" section. For Consumer: https://github.com/DiUS/pact-jvm#service-consumers For Provider: https://github.com/DiUS/pact-jvm#service-providers

kristine.jetzke
2020-06-18 19:57
There is a `.headerFromProviderState` method, maybe that is what you are looking for?

kristine.jetzke
2020-06-18 20:00
```.uponReceiving('another request') .headerFromProviderState('xyz', 'id', '100')```

satya.quote_pact
2020-06-18 20:04
hmmm.. i thought if you want to get anything from header in the provider state response we should use that .headerFromProviderState.

kristine.jetzke
2020-06-18 20:05
the java doc says > Adds a header that will have it?s value injected from the provider state

kristine.jetzke
2020-06-18 20:05
I don?t fully get what you mean with > if you want to get anything from header in the provider state response

satya.quote_pact
2020-06-18 20:08
i meant if willrespondwith() returns response with headers if we want to retrieve header of the response we need to use that .headerFromProviderState. I see java docs says something different than what i thought will try with that

phil.endsley
2020-06-18 21:17
@zhukeven86 Did you get what you were looking for?

zhukeven86
2020-06-18 21:36
Yes, thanks @phil.endsley!

uglyog
2020-06-18 23:15
@satya.quote_pact Pact tests are for validating the that the individual interactions are correct according to a contract. They are tested in isolation and have no way of keeping state between tests. Seems like you are trying to do more traditional integration tests.

bethskurrie
2020-06-18 23:23
I've just added a page in http://docs.pact.io comparing Pact with other well known mocking/stubbing/contract tools. I'd like to add a section on Spring Cloud Contracts, but I've never used it. Is there anyone here who has used both, and is interested in writing a comparison? It should be as fair as possible, even calling out out what sort of situations SCC would be preferable in - we don't want to be one eyed! Here's the page https://docs.pact.io/getting_started/comparisons To contribute, just hit the EDIT button at the top, and submit a PR to the page. Ping me if you're interested. Many thanks!

aliihlail
2020-06-19 00:15
We have a scenario where we need to upload a file using post. Is there an option in pact jvm to send it in body. As i see that the bodyFile only contain file and content type.

uglyog
2020-06-19 00:16
Is it a multipart FORM POST?

aliihlail
2020-06-19 00:17
yes


uglyog
2020-06-19 00:22
You would probably need Pact-JVM 4.1.2

jess.c.ho
2020-06-19 02:25
has joined #pact-jvm

satya.quote_pact
2020-06-19 10:00
@uglyog - Well i am believe my usecase above is individual interactions only. But for doing individual interactions i need to pass header from provider state response i.e, given("provider state ") <respone of this state > into the my uponreceiving(). exactly same as here https://github.com/DiUS/pact-jvm/blob/512f683c9dd3d6659ac61f45e2a97baca18a82f7/consumer/junit5/src/test/groovy/au/com/dius/pact/consumer/junit5/ProviderStateInjectedPactTest.groovy#L23

williamfslima
2020-06-19 12:38
has joined #pact-jvm

nmsuryavanshi
2020-06-19 17:34
Hi All, one doubt, Can the pacts generated by ruby server having pact.term as part of it for matching rules(consumers) be verified by java(providers) ?

matt.fellows
2020-06-19 22:31
Yes

nouri.tawfik
2020-06-20 08:32
has joined #pact-jvm

antonello
2020-06-20 09:52
Sorry for the spam!


antonello
2020-06-20 11:53
There is more to be closed for sure. It?d be tempted to close anything that has been inactive for longer than n months

matt.fellows
2020-06-20 13:18
We use stalebot in Pact JS and it certainly helps keep things in check. Also liberal use of labels to indicate where an issue is at and how people can help

antonello
2020-06-20 13:18
Do you also have a template in pact is?

antonello
2020-06-20 13:19
Js*

matt.fellows
2020-06-21 00:09
Do you mean issue template or something else?

antonello
2020-06-21 06:57
Yes, sorry.

matt.fellows
2020-06-21 10:37
Yes we do. and examples that can be used to reproduce issues

nmsuryavanshi
2020-06-21 17:16
@matt.fellows It will be very helpful if you give any example of provider for that. I m getting an error like "Expected xxx to have value "[{"json_class":"Pact::Term", "data":{"generate"........... but was ''," Thanks

matt.fellows
2020-06-21 23:59
Please share the full error. The Ruby matchers should be fully compatible with most library versions. The Java library has the most breadth of support

matt.fellows
2020-06-21 23:59
But if I can ease your mind - one of the main benefits of pact is its multi language support

phil.endsley
2020-06-22 03:51
@uglyog /anyone else. I have a feature branch that implements this. Does this need to be discussed at all before opening a pr? My proposal would deprecate a field in the junit PactBroker annotation and replace it with a new one. This is my first foray into contributing to oss, so I figured I'd ask first before opening a pr and finding out there

uglyog
2020-06-22 03:52
Discussions would happen on the PR

uglyog
2020-06-22 03:53
Just create it and we can take it from there

nmsuryavanshi
2020-06-22 03:54
@matt.fellows here is the error Expected header 'Content-Type' to have value '{"json_class":"Pact::Term"' but was 'application/json', Expected header 'Content-Type' to have value '"data":{"generate":"application/json"' but was '', Expected header 'Content-Type' to have value '"matcher":{"json_class":"Regexp"' but was '', Expected header 'Content-Type' to have value '"o":0' but was '', Expected header 'Content-Type' to have value '"s":"application\/json"}}}' but was ''

aliihlail
2020-06-22 10:51
``` @Pact(consumer = "import-service", provider = "rental-service-Rest") public RequestResponsePact rentalServiceGetPact(PactDslWithProvider builder) { return builder .given("rental object with referenceId DE-01-01-02 and size 1 exist") .uponReceiving("GET request to retrieve rentals") .path(RENTAL_OBJECTS_PATH) .query("referenceId=DE-01-01-02&size=1") .method(HttpMethod.GET) .willRespondWith() .status(HttpStatus.OK.value()) .headers(responseHeaders()) .body(newJsonBody((result) -> { result.object("_embedded", (embedded) -> { embedded.minMaxArrayLike("rentalObjects", 0, 2, (rentalObjects) -> { rentalObjects.id("id"); }); }); }).getPactDslObject()) .toPact(); } @Pact(consumer = "import-service", provider = "rental-service-Rest") public RequestResponsePact rentalServicePostPact(PactDslWithProvider builder) throws IOException { return builder .given("post rental from import file") .uponReceiving("POST request to import rental") .path(RENTAL_OBJECTS_BATCH_PATH) .method(http://HttpMethod.POST) .body(newJsonBody((rental) -> { rental.numberType("aggregateId"); rental.stringType("referenceId"); rental.stringMatcher("aggregateType", "UNIT|ROOM"); }).getPactDslObject()) .withFileUpload("file", "file", "multipart/form-data", "aggregateId,aggregateType,amenityId".getBytes()) .willRespondWith() .status(HttpStatus.CREATED.value()) .toPact(); } @Test @PactTestFor(pactMethod = "rentalServiceGetPact") public void testGetRentalService(MockServer mockServer) throws IOException { HttpResponse httpResponse = Request.Get(mockServer.getUrl() + RENTAL_OBJECTS_PATH + "?referenceId=DE-01-01-02&size=1").execute().returnResponse(); assertEquals(httpResponse.getStatusLine().getStatusCode(), HttpStatus.OK.value()); } @Test @PactTestFor(pactMethod = "rentalServicePostPact") public void testPostRentalService(MockServer mockServer) throws Exception { String body = "{\"aggregateId\": 100, \"referenceId\": \"DE-01-001-01\", \"aggregateType\": \"UNIT\"}"; HttpEntity data = MultipartEntityBuilder.create() .setMode(HttpMultipartMode.BROWSER_COMPATIBLE) .addBinaryBody("file", "aggregateId,aggregateType,amenityId".getBytes()) .build(); HttpResponse httpResponse = http://Request.Post(mockServer.getUrl() + RENTAL_OBJECTS_BATCH_PATH) .bodyString(body, ContentType.MULTIPART_FORM_DATA) .body(data).execute().returnResponse(); assertEquals(httpResponse.getStatusLine().getStatusCode(), HttpStatus.CREATED.value()); } private Map<String, String> responseHeaders() { Map<String, String> headers = new HashMap<>(); headers.put(CONTENT_HEADER, MediaTypes.HAL_JSON_UTF8_VALUE); return headers; } }``` Hi Im getting an error when im trying to test the rentalServicePostPact any hellp how to do it. I would appreciate it if any one helped me...

antonello
2020-06-22 10:52
Telling us what error you?re getting would help us :slightly_smiling_face:

aliihlail
2020-06-22 10:53
path: /rental-objects/batch query: {} headers: {Accept-encoding=[gzip,deflate], Connection=[Keep-Alive], Host=[localhost:33325], User-agent=[Apache-HttpClient/4.5.6 (Java/11.0.1)], Content-type=[multipart/form-data; boundary=0Tj2WYylWt0ZsDhKjKEFVfQjrvRrdD1RSeH], Content-length=[164]} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: PRESENT(--0Tj2WYylWt0ZsDhKjKEFVfQjrvRrdD1RSeH Content-Disposition: form-data; name="file" aggregateId,aggregateType,amenityId --0Tj2WYylWt0ZsDhKjKEFVfQjrvRrdD1RSeH-- ) 11:24:33.995 [HTTP-Dispatcher] DEBUG http://au.com.dius.pact.core.matchers.RequestMatching - comparing to expected request: method: POST path: /rental-objects/batch query: {} headers: {Content-Type=[multipart/form-data; boundary=Sd9x3en73qCRHCLgd7d6Ltzy9dGPoVJ5FmEkQ9_9]} matchers: MatchingRules(rules={body=Category(name=body, matchingRules={$.aggregateId=MatchingRuleGroup(rules=[NumberTypeMatcher(numberType=NUMBER)], ruleLogic=AND), $.referenceId=MatchingRuleGroup(rules=[http://au.com.dius.pact.core.model.matchingrules.TypeMatcher@4446726c], ruleLogic=AND), $.aggregateType=MatchingRuleGroup(rules=[RegexMatcher(regex=UNIT|ROOM, example=null)], ruleLogic=AND)}), header=Category(name=header, matchingRules={Content-Type=MatchingRuleGroup(rules=[RegexMatcher(regex=multipart/form-data;(\s*charset=[^;]*;)?\s*boundary=.*, example=multipart/form-data; boundary=Sd9x3en73qCRHCLgd7d6Ltzy9dGPoVJ5FmEkQ9_9)], ruleLogic=AND)})}) generators: Generators(categories={BODY={$.aggregateId=RandomIntGenerator(min=0, max=2147483647), $.referenceId=RandomStringGenerator(size=20), $.aggregateType=RegexGenerator(regex=UNIT|ROOM)}}) body: PRESENT(--Sd9x3en73qCRHCLgd7d6Ltzy9dGPoVJ5FmEkQ9_9 Content-Disposition: form-data; name="file"; filename="file" Content-Type: multipart/form-data aggregateId,aggregateType,amenityId --Sd9x3en73qCRHCLgd7d6Ltzy9dGPoVJ5FmEkQ9_9-- ) 11:24:34.003 [HTTP-Dispatcher] DEBUG http://au.com.dius.pact.core.matchers.HeaderMatcher - Comparing header 'Content-Type': 'multipart/form-data; boundary=0Tj2WYylWt0ZsDhKjKEFVfQjrvRrdD1RSeH' to 'multipart/form-data; boundary=Sd9x3en73qCRHCLgd7d6Ltzy9dGPoVJ5FmEkQ9_9' 11:24:34.010 [HTTP-Dispatcher] DEBUG http://au.com.dius.pact.core.matchers.MatcherExecutor - comparing 'multipart/form-data; boundary=0Tj2WYylWt0ZsDhKjKEFVfQjrvRrdD1RSeH' with regexp multipart/form-data;(\s*charset=[^;]*;)?\s*boundary=.* at [Content-Type] -> true 11:24:34.450 [HTTP-Dispatcher] DEBUG http://au.com.dius.pact.core.matchers.Matching - Found a matcher for multipart/form-data -> http://au.com.dius.pact.core.matchers.MultipartMessageBodyMatcher@13dc4dd2 11:24:34.521 [HTTP-Dispatcher] ERROR http://au.com.dius.pact.consumer.BaseJdkMockServer - Failed to generate response javax.mail.MessagingException: Missing start boundary

antonello
2020-06-22 10:57
could you format it please?

aliihlail
2020-06-22 10:59
ERROR http://au.com.dius.pact.consumer.BaseJdkMockServer - Failed to generate response javax.mail.MessagingException: Missing start boundary

aliihlail
2020-06-22 10:59
here is the error

aliihlail
2020-06-22 11:03
the idea that i trying to test the post with multipart FORM POST and it is a bit complicated. If any one helped it would be amzing

dattasai.chunduru
2020-06-22 12:48
has joined #pact-jvm

dattasai.chunduru
2020-06-22 12:50
Hi Can anyone help me in doing a POST request by using PACT this is my code snippet.

dattasai.chunduru
2020-06-22 12:52
it is showing me error

dattasai.chunduru
2020-06-22 12:52
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 8.793 sec <<< FAILURE! testPact(pact_post.pact_post.PactBaseConsumerTest) Time elapsed: 2.54 sec <<< FAILURE! java.lang.AssertionError: Pact Test function failed with an exception, possibly due to Mismatches(mismatches=[UnexpectedRequest(request= method: GET path: /comments query: {} headers: {Accept=[application/json, application/*+json], Connection=[keep-alive], Host=[kubernetes.docker.internal:54925], User-agent=[Java/14.0.1]} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: EMPTY)]) at http://au.com.dius.pact.consumer.junit.ConsumerPactTest.testPact(ConsumerPactTest.java:41) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) Caused by: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Internal Server Error: [{ "error": "Unexpected request : \tmethod: GET\n\tpath: \/comments\n\tquery: {}\n\theaders: {Accept=[application\/json, application\/*+json], Connection=[keep-alive], Host=[kubernetes.docker.internal:54925], User-agent=[Java\/14.0.1]}\n\tmatchers: MatchingRules(rules={})\n\tgenerators: Generators(categories={})\n\tbody: EMPTY" }] at org.springframework.web.client.HttpServerErrorException.create(HttpServerErrorException.java:100) at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:172) at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:112) at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63) at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:782) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:740) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:674) at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:315) at pact_post.pact_post.ProviderService.getInformation(ProviderService.java:20) at pact_post.pact_post.PactBaseConsumerTest.runTest(PactBaseConsumerTest.java:54) at http://au.com.dius.pact.consumer.junit.ConsumerPactTest.lambda$testPact$0(ConsumerPactTest.java:32) at http://au.com.dius.pact.consumer.BaseMockServer.runAndWritePact(MockHttpServer.kt:110) at http://au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest(ConsumerPactRunner.kt:13) at http://au.com.dius.pact.consumer.junit.ConsumerPactTest.testPact(ConsumerPactTest.java:31) ... 38 more 2020-06-22 18:21:40.530 INFO 11840 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' Results : Failed tests: testPact(pact_post.pact_post.PactBaseConsumerTest): Pact Test function failed with an exception, possibly due to Mismatches(mismatches=[UnexpectedRequest(request= method: GET(..) Tests run: 1, Failures: 1, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 49.969 s [INFO] Finished at: 2020-06-22T18:21:40+05:30 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project pact-post: There are test failures. [ERROR] [ERROR] Please refer to C:\Users\dattasai.sukumar\Documents\workspace\pact-post\target\surefire-reports for the individual test results. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

dattasai.chunduru
2020-06-22 13:22
I tried removing the body formating and send it as normal body but still it is failing

dattasai.chunduru
2020-06-22 13:22
@RunWith(SpringRunner.class) @SpringBootTest public class PactBaseConsumerTest extends ConsumerPactTest{ @Autowired ProviderService providerService; @Override @Pact(provider="ProviderJson", consumer="ConsumerJson") public RequestResponsePact createPact(PactDslWithProvider builder) { Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/json;charset=utf-8"); return builder .given("example verification") .uponReceiving("request verification") .method("POST") .headers(headers) .body("{ \"id\": 3,\"name\": \"postcomments\", \"postId\": 3 }") .path("/comments") .willRespondWith() .status(201) .toPact(); } @Override protected String providerName() { return "ProviderJson"; } @Override protected String consumerName() { return "ConsumerJson"; } @Override protected void runTest(MockServer mockServer, PactTestExecutionContext context) { providerService.setBackendURL(mockServer.getUrl()); Information information = providerService.getInformation(); //assertEquals(information.getTitle(),"sunt aut facere repellat provident occaecati excepturi optio reprehenderit"); } }

dattasai.chunduru
2020-06-22 13:23
I have used https://github.com/Mikuu/Pact-JVM-Example/tree/master/example-consumer-miku this GITHUB and build my code for Consumer side POST method

dattasai.chunduru
2020-06-22 13:25
Hi All

dattasai.chunduru
2020-06-22 13:25
If anyone can help me with POST METHOD CODE snippet I will be really Thankful

phil.endsley
2020-06-22 13:32
I thought I replied, but I don't see it anywhere. Guess it got lost :shrug: Based on the error, it looks like your test is making a GET call, but your pact is expecting a POST. I would double check the code in here to make sure it's making a POST call ```Information information = providerService.getInformation();```

dattasai.chunduru
2020-06-22 13:40
Hi Phil

dattasai.chunduru
2020-06-22 13:40
I am using ProviderSerivce class like this

phil.endsley
2020-06-22 13:44
```restTemplate.getForObject(getBackendURL(), Information.class);``` This is making a GET call. You would need to change this to make a POST. ex: `restTemplate.postForObject` or however you want to make the call. The test is correctly failing, since your consumer's behavior does not match what the pact is defining.

dattasai.chunduru
2020-06-22 14:19
Actually I tried with postFor Location it is not working

dattasai.chunduru
2020-06-22 14:19
I did not find postforObject I will check this Thank you Phil :slightly_smiling_face:

antonello
2020-06-22 14:51
@dattasai.chunduru I?d recommend that you create one clear message, format your code properly, and keep all your messages in one thread.

wesleythomaswilliams
2020-06-22 14:56
@antonello I wish slack would automatically convert long messages into snippets.

dattasai.chunduru
2020-06-22 18:42
Hi All , Can anyone please share Code snippets for PACT POST method. I am not able to get any GITHUB examples for POST method

dattasai.chunduru
2020-06-22 18:55
I am getting URI not absolute error can anyone please help me on this

dattasai.chunduru
2020-06-22 18:56
this is my code snipper

phil.endsley
2020-06-22 19:14
What's the uri you're trying to call? From the snippet below, are you missing the `@Rule` annotation for `mockProvider`

phil.endsley
2020-06-22 19:18
As for not being able to get any POST contracts working, have you been able to get any working (ex: GET)? It's all pretty much the same from the Pact side

phil.endsley
2020-06-22 19:20
If you're looking for a tutorial, there's a jvm workshop that's linked in the pact-jvm repo. https://github.com/DiUS/pact-workshop-jvm It walks through an example for a GET request. But like I said, once you get one of them working, it's all pretty much the same for the other verbs

dattasai.chunduru
2020-06-22 20:24
I have working code for PACT-GET method. I did both Consumer and provider side and the verification in PACT broker is also done

dattasai.chunduru
2020-06-22 20:25
I started with POST and in restTemplate.PostForObject I am not able to give proper parameters

dattasai.chunduru
2020-06-22 20:27
I tried with resttemplate.exchange also when using this I am getting URI not absolate error

dattasai.chunduru
2020-06-22 20:49
Ohh I missed @rule yes thank you @phil.endsley

aliihlail
2020-06-22 22:23
Again im trying to test a post with mutltipart file Post. I wrote this simple test. Here is the code ```@Pact(consumer = "import-service", provider = "feature-service") public RequestResponsePact featureServicePostPact(PactDslWithProvider builder) throws IOException { return builder .given("post feature from import file") .uponReceiving("POST request to import feature") .path(FEATURES_IMPORT_PATH) .method(http://HttpMethod.POST) .withFileUpload("file", "data.csv", "multipart/form-data", "aggregateId,aggregateType,amenityId".getBytes()) .willRespondWith() .body("every thing is okay") .status(HttpStatus.CREATED.value()) .toPact(); } @Test @PactTestFor(pactMethod = "featureServicePostPact") public void testPostFeatureService(MockServer mockServer) throws IOException { CloseableHttpClient httpclient = HttpClients.createDefault(); HttpEntity data = MultipartEntityBuilder.create() .setMode(HttpMultipartMode.BROWSER_COMPATIBLE) .addBinaryBody("file", "aggregateId,aggregateType,amenityId".getBytes(), ContentType.MULTIPART_FORM_DATA, "data.csv") .build(); HttpUriRequest request = RequestBuilder .post(mockServer.getUrl() + FEATURES_IMPORT_PATH) .setEntity(data) .build(); httpclient.execute(request); }``` Unfortinattly im getting the following error: http://au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: method: POST path: /features/import query: {} headers: {Content-Type=[multipart/form-data; boundary=QpUt6W_VwiazcsGsTjIZhx36U2USKZNzCcN-J2BX]} matchers: MatchingRules(rules={header=Category(name=header, matchingRules={Content-Type=MatchingRuleGroup(rules=[RegexMatcher(regex=multipart/form-data;(\s*charset=[^;]*;)?\s*boundary=.*, example=multipart/form-data; boundary=QpUt6W_VwiazcsGsTjIZhx36U2USKZNzCcN-J2BX)], ruleLogic=AND)}), path=Category(name=path, matchingRules={})}) generators: Generators(categories={}) body: PRESENT(--QpUt6W_VwiazcsGsTjIZhx36U2USKZNzCcN-J2BX Content-Disposition: form-data; name="file"; filename="data.csv" Content-Type: multipart/form-data aggregateId,aggregateType,amenityId --QpUt6W_VwiazcsGsTjIZhx36U2USKZNzCcN-J2BX-- )

uglyog
2020-06-22 23:15
Are you able to provide debug logs to see why it is not matching?

uglyog
2020-06-22 23:16
The only thing I can see that is wrong, is you specified `"multipart/form-data"` as the file content type, when I think it should be `text/csv`

artur.ashyrov
2020-06-23 06:53
has joined #pact-jvm

antonello
2020-06-23 09:46
Does anyone know how to change the log level to get some more verbose logging?

chandanakurumeti27
2020-06-23 10:47
Hi, is it possible to send post request inside the provider states in pact jvm?

chandanakurumeti27
2020-06-23 10:51
My issue is , am basically about to run provider tests for ,lets say , `getgames` request , i need to have some games in first place to get them. so am planning to have `savegame` request inside the provider state so some games exists in DB to retrieve them while running provider tests.

chandanakurumeti27
2020-06-23 10:52
Any help would be much appreciated!

matt.fellows
2020-06-23 10:56
Provider states are just functions that execute when the state needs to be setup. You can do whatever you need in them. I would try to make things faster though, so dealing with on memory database objects tends to be simpler and more performant

aliihlail
2020-06-23 11:40
i changed it and i got the same error Do i need to add the Pact JVM 4,.1.4 dependency.

satya.quote_pact
2020-06-23 12:37
Hi just wondering if this use case is possible in pact-jvm. 1. In given("statechange"). --> save the response of given () 2. And use response of 1 in the uponreceiving() 3. And perform the interaction

matt.fellows
2020-06-23 12:49
Are you asking if it?s possible to persist data from a state change for use when the interaction is called during provider verification?

matt.fellows
2020-06-23 12:49
What do you want to do?

satya.quote_pact
2020-06-23 13:12
yes, basically for each interaction we do we need to have token. We have state change for getting s2s setup as a part of given(). but we need to use that in the header of the uponreceiving() for testing the contract

matt.fellows
2020-06-23 13:46
Have a look at request filters

chandanakurumeti27
2020-06-23 14:50
Thank you :slightly_smiling_face:

rafael.espillaque
2020-06-23 15:07
hi all, I?m having a problem when trying to migrate from 4.0.10 to 4.1.4. 4.1.4 says: `java.lang.UnsupportedOperationException: At least one pact source must be present on the test class` I believe it?s related to my `@PactFolder` annotation not being read. I?m using the following annotations at class level: ```@SpringBootTest @Provider("my-project") @PactFolder("../pacts") @IgnoreNoPactsToVerify``` any ideas? thanks

aliihlail
2020-06-23 15:08
I have the same issue

phil.endsley
2020-06-23 15:25
Double check your imports and make sure you're using `http://au.com.dius.pact.provider.junitsupport.loader.PactFolder`

rafael.espillaque
2020-06-23 15:26
wow good catch! that?s it. I was using ```au.com.dius.pact.core.model.annotations.PactFolder;```

rafael.espillaque
2020-06-23 15:26
thanks a lot

francislainy.campos
2020-06-23 15:36
.

francislainy.campos
2020-06-23 15:37
.

rafael.espillaque
2020-06-23 18:54
Pending pacts and WIP pacts seem a very useful feature. How well supported are them from jvm libraries?



antonello
2020-06-23 19:47
(the whole thread)


uglyog
2020-06-23 22:59
Depends. With Gradle, Maven or JUnit?

uglyog
2020-06-23 23:24
I'm going to rename those annotations, because those are totally confusing

antonello
2020-06-23 23:59
Junit and maven

matt.fellows
2020-06-24 00:02
It looks like your pact generation is broken. Can you please share the contract that was generated?

uglyog
2020-06-24 00:04
With JUnit, you have it set on the test JVM. Easiest way is to add logback to the test classpath. It should configure DEBUG level by default.

uglyog
2020-06-24 00:05
For other levels, you need to add a logback configuration file to the test resources.

uglyog
2020-06-24 00:06
For Maven (i.e. the Maven pact plugin, not running tests with Maven), the -X command line argument will do it.

mbieganski.infomatt
2020-06-24 04:59
Hi. I have a case when there is no contract on master branch yet and when I merge provider will throw error `".NoPactsFoundException at PactJUnit5VerificationProvider".` There is an option to use `@IgnoreNoPactsToVerify` but wondering if it's good practice to use it in CI, is it expected Pact behaviour for provider to pass when there is no pacts or it should be handeled differently? @uglyog, @bethskurrie what do you think? Thanks

uglyog
2020-06-24 05:07
That is what that annotation is for. Just remember to remove it once you have pacts published.

gerrelatanacio
2020-06-24 07:02
has joined #pact-jvm

mbieganski.infomatt
2020-06-24 07:57
So there is no way to do it fully "automatically". For a second I thought to include `latest` like tags = {"latest", "dev", "prod"} but I think it's not really recommended?

rafael.espillaque
2020-06-24 08:45
thanks you both!

d.duraivelan
2020-06-24 09:00
has joined #pact-jvm

antonello
2020-06-24 09:58
Thank you!

chandanakurumeti27
2020-06-24 10:57
Hi, Can i access request body inside statechange method, as i want to use one of the request field values inside statechange

chandanakurumeti27
2020-06-24 10:57
Is it possible?

chandanakurumeti27
2020-06-24 10:59
lets say, my request body in the contract is {?consumerid? = ?462"} and i want to get the orders for this customer from the order service which inturn talks to DB. so am planning to add some random order for this consumer ?462? in DB inside statechange method

chandanakurumeti27
2020-06-24 10:59
so I want to get that consumerid into statechange method from the requestbody

chandanakurumeti27
2020-06-24 11:00
How can i do that?, kindly help me on this. Looking forward to any kind of help.thanks

francislainy.campos
2020-06-24 11:42
Hi, I'm getting this error when trying to run my provider tests please. `org.junit.runners.model.InitializationError` `at http://au.com.dius.pact.provider.junit.PactRunner.initialize(PactRunner.kt:112)` `at http://au.com.dius.pact.provider.junit.PactRunner.getChildren(PactRunner.kt:140)`

francislainy.campos
2020-06-24 11:42
This is my full pom.

francislainy.campos
2020-06-24 11:43
```<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.hmhco</groupId> <artifactId>tests</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <properties> <java.version>1.8</java.version> <maven.compiler.version>3.8.1</maven.compiler.version> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <rest-assured.version>3.0.0</rest-assured.version> <json-schema-validator.version>3.3.0</json-schema-validator.version> </properties> <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.5.2</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-junit5</artifactId> <version>4.0.10</version> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit</artifactId> <version>4.0.10</version> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit5</artifactId> <version>4.0.10</version> <scope>test</scope> </dependency> <dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <version>${rest-assured.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>io.rest-assured</groupId> <artifactId>json-schema-validator</artifactId> <version>${json-schema-validator.version}</version> <scope>test</scope> </dependency> <!-- As per https://stackoverflow.com/a/52872160/6654475 --> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.1</version> </dependency> <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> <version>2.3.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.7.30</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M4</version> <!--- This is creating conflicts between junit 4 and 5 --> <dependencies> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-surefire-provider</artifactId> <version>1.2.0</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.2.0</version> </dependency> </dependencies> </plugin> <plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.10</version> <configuration> <pactDirectory>target/pacts</pactDirectory> <pactBrokerUrl>http://pact-broker-hmh.devel.hmheng-qe.brnp.internal/</pactBrokerUrl> <projectVersion>${project.version}</projectVersion> <trimSnapshot>true</trimSnapshot> </configuration> </plugin> </plugins> </build> </project>```

chandanakurumeti27
2020-06-24 11:43
Can i get some link where i could find any example

chandanakurumeti27
2020-06-24 11:43
and i think valueFromProviderState method helps me in this case.

francislainy.campos
2020-06-24 11:43
Thank you.



chandanakurumeti27
2020-06-24 13:37
Yeah it did help me. Thanks @phil.endsley :+1:

matt.fellows
2020-06-24 13:49
Thanks for all of your recent help here @phil.endsley, loving waking up and see all of these responses!

phil.endsley
2020-06-24 14:10
My pleasure! I'm just happy I can give back to the project

phil.endsley
2020-06-24 15:13
On the 4.x branch, that stacktrace points to a line indicating no pacts were found for the specified provider. https://github.com/DiUS/pact-jvm/blob/v4.x/provider/pact-jvm-provider-junit/src/main/kotlin/au/com/dius/pact/provider/junit/PactRunner.kt#L112

hadjaliabir
2020-06-24 16:09
has joined #pact-jvm

antonello
2020-06-24 22:05
@phil.endsley - Do you think it would be worth adding something to readmes to document your consumerVersionSelectors feature? https://github.com/DiUS/pact-jvm/pull/1143/

phil.endsley
2020-06-24 22:08
Yes. I was actually thinking the same thing today

antonello
2020-06-24 22:12
We had a conversation on the functionality at Treatwell today as one of the native apps team wanted just that

antonello
2020-06-24 22:15
Do you need it released by the way?

antonello
2020-06-24 22:16
For their specific use case I also mentioned to them an alternative approach - tag every release with a unique release number and then whitelist the versions/releases that the provider needs to verify.

phil.endsley
2020-06-24 22:20
For releasing, I have a branch I'm working on for wip pacts. They can be released independently though

antonello
2020-06-24 22:24
Let me know - I?m sure we can do a patch release.

uglyog
2020-06-24 23:04
You can provide parameters to the state change when it is defined in the consumer test. These parameters will be passed to the state change method when verifying the provider.

uglyog
2020-06-24 23:06
BTW, @bethskurrie has done some loverly work and all the readmes now also appear on http://docs.pact.io

uglyog
2020-06-24 23:15
latest is normally used to fetch the latest pact for a tag. It becomes confusing if you use it as a tag as well.

bethskurrie
2020-06-24 23:16
I've been thinking of disallowing this as a tag!

bethskurrie
2020-06-24 23:16
I think the jvm api is confusing by calling the tag "latest" personally.

antonello
2020-06-25 06:14
:clap::skin-tone-2:

francislainy.campos
2020-06-25 08:13
Thank you Phil. I wasn't being able to fix this so changed the file to use JUnit5 instead and it's working now. Cheers.

bethskurrie
2020-06-25 22:52
All the Pact JVM docs are now synced to http://docs.pact.io and have been indexed by our wonderful free-for-OSS search engine Algolia. This should make things much easier to find. Remember to do a search at http://docs.pact.io before you ask a question here - you just might find the answer yourself now :wink: I know it can often be tricky to get all the maven stuff working with the annotations - if you have a working example, I'd love to add one to the docs. Please let me know!

bethskurrie
2020-06-26 01:51
@antonello @phil.endsley I'm going to add a specific section for consumer version selectors here: https://pact.io/selectors

bethskurrie
2020-06-26 01:52
I'd prefer to have the docs all in one place, so the JVM ones can explain the technical bits, and then point to the generic docs for understanding the functionality.

phil.endsley
2020-06-26 02:00
I like that idea :+1:

phil.endsley
2020-06-26 03:24
@antonello /(anyone else?), I'm good with a release now. Not really sure how that process works/what governs it.

uglyog
2020-06-26 03:24
I could do a release this weekend

srinivasan.sekar1990
2020-06-26 05:03
Thanks alot for sharing @bethskurrie Here is an example on jvm - https://github.com/SrinivasanTarget/ContractTestingBoilerplate

nmsuryavanshi
2020-06-26 05:50
Hi All, can anyone please suggest how can we write provider test for 400 bad request(missing field(@NotNull) value in dto) in java. Thanks.

uglyog
2020-06-26 05:53
It's pretty much the same as any other Pact test. You have an example in the consumer test that will make a request that will generate the response, and set the expected response as 400

nmsuryavanshi
2020-06-26 05:56
Can we also check error message in provider test or only we can verify status?

uglyog
2020-06-26 06:01
You can verify the error message if it is returned in the body, which with Spring it will be

nmsuryavanshi
2020-06-26 06:41
In provider test we set the controller as target and we mock the service implementation and use when(service.something()).then return(). So how do I test the 400 bad request in provider test?

nmsuryavanshi
2020-06-26 06:43
for successfull scenarios we do when().thenReturn() beacuse we use @Mock for service. But how can i do it for 400 badrequest as it will not be thrown from service its in dto validation through annotations like @NotNull

bethskurrie
2020-06-26 08:23
Awesome! Thanks @srinivasan.sekar1990

ashish_garg5
2020-06-26 10:57
Hi All, Is there any way to check if consumer is there in my pact broker or not ? Or any api to get the consumer names from the pact broker ? Thanks in advance.

nmsuryavanshi
2020-06-26 11:03
@uglyog can you give any example please for checking 400 badrequest thrown for @NotNull annotation

antonello
2020-06-26 11:04
you can check if there is a pacticipant `/pacticipants/{pacticipant}`

ashish_garg5
2020-06-26 11:10
ok thanks but if it is not there then i am getting 4040

ashish_garg5
2020-06-26 11:10
404

matt.fellows
2020-06-26 11:11
The pact broker is entirely API driven and very RESTful. If you query the root resource at / you can follow links to anything you need. There is also a HAL browser in the UI you can use to explore the API

antonello
2020-06-26 11:12
Yes, getting a 404 is expected if the pacticipant doesn?t exist

ashish_garg5
2020-06-26 11:14
sure thanks

phil.endsley
2020-06-26 13:16
@nmsuryavanshi If your controller is taking action based on an exception thrown from the service layer, you would need to setup your mock to throw the expected exception. `when(service.something()).thenThrow(...)`

nmsuryavanshi
2020-06-26 15:12
@phil.endsley Yes that can be done but the thing is when the request is received in endpoint @Valid annotation is written so the call doesn't go to service layer.

phil.endsley
2020-06-26 17:18
Ah...I misunderstood. I guess I don't fully understand the issue. If the validation is happening by the framework at the controller level, before it hits any of your controller code, wouldn't this "just work"? Either that, or there's a piece of the application (maybe at the framework level) not being stood that your provider would normally have when deployed?

phil.endsley
2020-06-26 17:20
I don't have experience with those specific annotations, but I don't think that implementation detail really matters in trying to understand the issue. There's some component that runs validation somewhere. That either needs to be mocked out like your service layer, or stood up with your controller.

phil.endsley
2020-06-26 17:20
If that's not the case, I think you'll have to wait for someone else to chime in

nmsuryavanshi
2020-06-26 17:47
I tried using mockmvc but it didnt worked.

phil.endsley
2020-06-26 17:59
Are you using spring boot?

phil.endsley
2020-06-26 18:09
I did a quick and dirty test for one of our Spring Boot projects (Added `@Valid` to the controller, and `@NotNull` to an entity property, and it looks like it's working like I would expect ```MockHttpServletResponse response = mockMvc.perform(post(url) .contentType(MediaType.APPLICATION_JSON) .content(toJson(body)) .headers(headers)) .andReturn() .getResponse(); assertThat(HttpStatus.resolve(response.getStatus())).isEqualTo(HttpStatus.CREATED);``` > org.opentest4j.AssertionFailedError: > Expecting: > <400 BAD_REQUEST> > to be equal to: > <201 CREATED> > but was not. > Expected :201 CREATED > Actual :400 BAD_REQUEST

phil.endsley
2020-06-26 18:10
And to clarify, this doesn't seem like an issue with Pact, rather getting the framework you're using to behave as you expect

kristine.jetzke
2020-06-26 21:01
I agree, it?s a spring boot question. > when the request is received in endpoint @Valid annotation is written so the call doesn?t go to service layer. It does not need to because the framework will return a 400 because of the `@Valid` annotation. Obviously the payload you?re passing must not be valid. But with `MockMvc` you don?t get the actual JSON response, you just get the http://org.springframework.web.bind.MethodArgumentNotValidException. In theory you could manually add the https://github.com/spring-projects/spring-boot/blob/2.3.x/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorController.java but I would recommend to use a ?real? spring boot integration test i.e. one that loads the complete web application instead. Because one important aspect of the contract test it to test the actual format of the response. There are so many places in spring boot where this can be configured which is why I would load the complete application.

phil.endsley
2020-06-26 21:19
> But with `MockMvc` you don?t get the actual JSON response, you just get the https://slack-redir.net/link?url=http%3A%2F%2Forg.springframework.web.bind.MethodArgumentNotValidException. Didn't realize this. Maybe that's why it wasn't working for @nmsuryavanshi if they were trying to assert specific properties aside from status code? > I would recommend to use a ?real? spring boot integration test i.e. one that loads the complete web application instead. This is what we do, and it works great

uglyog
2020-06-27 02:03
@phil.endsley 4.1.5 is released

ag.robinson
2020-06-27 15:41
has joined #pact-jvm

nmsuryavanshi
2020-06-29 04:34
Hi @phil.endsley can you please show me what all class level annotation you used during test that you written above . Thanks

andreas
2020-06-29 08:49
@bethskurrie This is great! Consider pinning this post, or make a post for about "not asking before you have searched" kind of post that you can pin to the channel?

naree.song
2020-06-29 09:12
has joined #pact-jvm

phil.endsley
2020-06-29 13:14
```@Provider("providerApp") @PactBroker( host = "pactbrokerhost", scheme = "https", tags = "develop" ) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ExtendWith(SpringExtension.class) @ActiveProfiles("test") class ProviderAppPactProviderTest {``` We're using Spring Boot with junit 5 Our consumer/provider are not in prod yet, so we're only verifying against our develop tag. Once we go to prod, we'll update our tags to verify against that too.

r.iglesias
2020-06-30 06:26
Hello people. I have a couple of questions regarding some last features added since version 4.1.X ? Is the pending pacts feature also supported in the `pact-broker-docker` ? I read in some doc that this only available through the hosted version with `http://pacflow.io` ? Same for the consumer version selectors. We are interested in verifying contracts where the consumer is a mobile app, and here several versions could be tagged as `prod` Thanks in advance!


matt.fellows
2020-06-30 06:43
you need to explictly enable it

r.iglesias
2020-06-30 06:57
you mean this `PACT_BROKER_FEATURES=pacts_for_verification` right? and does this allow both WIP and pending pacts?

matt.fellows
2020-06-30 07:02
yes I believe so

r.iglesias
2020-06-30 07:03
Cool thanks!

gauravsingh1095
2020-06-30 07:22
has joined #pact-jvm

gauravsingh1095
2020-06-30 07:26
Hi team, need some help, I facing an issue while verifying contract on Provider side Scenario: My consumer is a React app, Providers are Spring-boot microservices Now while verifying the Contract, Microservice A requires cookies in the header which I inject using `@TestTemplate` . Internally microservice A calls microservice B using FeignClient to verify the session. I am not able to mock microservice B while verifying Provider A. Tried mockito to mock but it didnt work. :persevere: Please help!!!

sairsule
2020-06-30 07:27
what is the issue

gauravsingh1095
2020-06-30 08:02
Or can you point me to any docs related to this?

sairsule
2020-06-30 08:02
please post your code snippet. are u using Junit 5?

gauravsingh1095
2020-06-30 08:03
yes

gauravsingh1095
2020-06-30 08:04
``` import au.com.dius.pact.core.model.Interaction; import au.com.dius.pact.core.model.Pact; import au.com.dius.pact.provider.junit.IgnoreNoPactsToVerify; import au.com.dius.pact.provider.junit.Provider; import au.com.dius.pact.provider.junit.State; import au.com.dius.pact.provider.junit.loader.PactBroker; import au.com.dius.pact.provider.junit5.HttpTestTarget; import au.com.dius.pact.provider.junit5.PactVerificationContext; import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; import com.github.tomakehurst.wiremock.WireMockServer; import org.apache.http.HttpRequest; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; import static com.github.tomakehurst.wiremock.client.WireMock.*; /** * Created by gaurav13.singh on Jun, 2020 **/ @ExtendWith(SpringExtension.class) @Provider("Provider") @PactBroker(host = "host", port = "30953") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, properties = {"server.port=5009", "redis-service.ribbon.listOfServers: localhost:5011"}) @IgnoreNoPactsToVerify public class PactTestWire { private static final int WIREMOCK_PORT = 5011; private WireMockServer wireMockServer; @BeforeEach public void setup() { wireMockServer = new WireMockServer(WIREMOCK_PORT); wireMockServer.stubFor(get( urlEqualTo("http://redis-service")) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") .withBody("[\"Tables\",\"Chairs\"]") )); wireMockServer.start(); } @BeforeEach void setTarget(PactVerificationContext context) { HttpTestTarget target = new HttpTestTarget("localhost", 5009); context.setTarget(target); } @State("with session") public void withSession() { System.out.println("with session"); } @State("without session") public void withoutSession() { System.out.println("without session"); } @AfterEach public void tearDown() { wireMockServer.stop(); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(Pact pact, Interaction interaction, HttpRequest request, PactVerificationContext context) { request.addHeader("cookie", "cookies"); context.verifyInteraction(); } }```

gauravsingh1095
2020-06-30 08:06
Tried this too ``` import au.com.dius.pact.provider.junit.IgnoreNoPactsToVerify; import au.com.dius.pact.provider.junit.Provider; import au.com.dius.pact.provider.junit.State; import au.com.dius.pact.provider.junit.loader.PactBroker; import com.jio.jpw.exception.JPWException; import com.jio.jpw.model.LogModel; import com.jio.jpw.utils.JsonUtils; import com.jio.jpw.utils.LogHelper; import com.jio.referencedatainquiry.controller.ReferenceDataInquiryController; import com.jio.referencedatainquiry.domain.DealerAddress; import com.jio.referencedatainquiry.proxy.RedisProxy; import com.jio.referencedatainquiry.services.LookupRelatedValueService; import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; import org.mockito.InjectMocks; import org.mockito.Mock; import org.springframework.boot.SpringApplication; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.context.ConfigurableWebApplicationContext; import javax.servlet.http.Cookie; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; /** * Created by gaurav13.singh on Jun, 2020 **/ @RunWith(PactRunner.class) @Provider("provider") @PactBroker(host = "host", port = "30953") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, properties = {"server.port=5009"}) @IgnoreNoPactsToVerify public class PactTest { private static ConfigurableWebApplicationContext application; @TestTarget public final Target target = new HttpTarget(5009); @Mock private RedisProxy mockRedisProxy; @Mock private MockHttpServletRequest servletRequest; @MockBean private LogModel logModel; @Mock private LookupRelatedValueService mockLookupRelatedValueService; @InjectMocks private ReferenceDataInquiryController referenceDataInquiryControllerUnderTest; @BeforeClass public static void start() { application = (ConfigurableWebApplicationContext) SpringApplication.run(ReferenceDataInquiryApplication.class); } @Before public void setUp() { initMocks(this); servletRequest = new MockHttpServletRequest(); servletRequest.setCookies(new Cookie("JPSSSessionID", "val"), new Cookie("authToken", "value")); when(mockRedisProxy.getData(any())).thenReturn(TestData.SESSION_DATA); servletRequest.addHeader("a", "1216"); logModel = LogHelper.createBasicLogModel(servletRequest); logModel.setSessionData(TestData.SESSION_DATA); } @State("with session") public void withSession() throws JPWException { final DealerAddress expectedResult = JsonUtils.getBeanByJson(TestData.DealerAddress, DealerAddress.class); when(mockLookupRelatedValueService.lookupRelatedValue(any(), any())).thenReturn(expectedResult); final DealerAddress result = referenceDataInquiryControllerUnderTest.lookupRelatedValue("673020", servletRequest); assertEquals(expectedResult, result); System.out.println("with session"); } @State("without session") public void withoutSession() { System.out.println("without session"); } @After public void after() { } }```

gauravsingh1095
2020-06-30 08:23
am I doing something wrong?

chandanakurumeti27
2020-06-30 10:52
@phil.endsley is it possible while using pact js as well?

chandanakurumeti27
2020-06-30 10:52
some example link please?

chandanakurumeti27
2020-06-30 11:51
Hi, How can i return value from provider states to the request body in the contract before running provider tests when th consumer service is javascript based one. I couldnt find ?valuefromproviderstate? feature in pact JS, so how can i actually accomplish this ? FYI, my consumer is javascript based service and provider is java based service

chandanakurumeti27
2020-06-30 11:51
Kindly someone please help me on this?


phil.endsley
2020-06-30 12:35
Try using `org.springframework.boot.test.mock.mockito.MockBean` instead. `@Mock` creates a plain old mock you can use. This is useful for unit tests where you're creating the objects yourself with constructors. `@SpringBootTest` is spinning up the Spring application context, so all the objects are being created through DI. `@MockBean` will create a Mockito mock and inject it into the Spring context for you.

phil.endsley
2020-06-30 12:47
What is the specific issue you're running into? Your JS Consumer will run tests against the contract it defines. The Consumer tests themselves don't do anything with the Provider. When you're writing the pact on the JS side, you're in charge of defining the state and response body. You're in control of all the data. If your Consumer tests need something from the state, won't you already know ahead of time what value you're expecting? On the Provider side, you can use the `valueFromProviderState` methods to get values for the response you're returning.

gauravsingh1095
2020-06-30 14:32
Thanks @phil.endsley, I?ll try this

mbieganski.infomatt
2020-06-30 20:18
Hi. I'm having problem with ZonedDateTime. On Consumer side everything looks and works fine with ```body.datetime("creationDate", "yyyy-MM-dd'T'HH:mm[:ss.SSS]XXX'['VV']'", Instant.ofEpochMilli(1592317859528L));``` When running provider tests I'm getting below. I'm using version 4.1.4 ``` Unable to parse "2020-05-08T15:25:30+09:00[Japan]" with yyyy-MM-dd'T'HH:mm[:ss.SSS]XXX'['VV']' using java.time.format.DateTimeFormatter. Attempting to parse using org.apache.commons.lang3.time.DateUtils to guarantee backwards compatibility with versions < 4.1.1. Please update your patterns in your pact tests as this may not be supported in future versions. Request Failed - Format 'V' not supported``` Any ideas?

antonello
2020-06-30 20:33
Did this work with previous versions of pact-jvm? Or is it a new test?

mbieganski.infomatt
2020-06-30 20:39
I have initially created issue #1107 and have been using work around. Recently have switched to 4.1.4 and decided to update tests and discovered this issue. Also looks like `or` and `and` PM matchers are missing `datetime` handling.

antonello
2020-06-30 20:42
This one for @uglyog I reckon. We had problems when switching to 4.1.x and had to implement the fall back that you see mentioned in the warning

antonello
2020-06-30 20:43
To me if looks like your date cannot be parsed with that format by neither DateTimeFormatter nor DateUtils

antonello
2020-06-30 20:46
I am by no means an expert of date formats, but are you sure that format can ever work with that date?

antonello
2020-06-30 20:47
Didn?t mean to send the message above to the channel :man-facepalming::skin-tone-2:

mbieganski.infomatt
2020-06-30 20:48
yeah it works just fine on consumer side and was suggested by @uglyog https://github.com/DiUS/pact-jvm/issues/1107#issuecomment-640160063

antonello
2020-06-30 20:50
The consumer side doesn?t attempt to parse as far as I?m aware - it will just put the format and the example in the pact

antonello
2020-06-30 20:50
The format suggested by @uglyog is different from the one you?re using though

mbieganski.infomatt
2020-06-30 21:06
the error clearly points to `Format 'V' not supported` unless the message is misleading. Consumer is parsing the the example `Instant.ofEpochMilli(1592317859528L)` and puts `"2020-06-16T16:30:59.528+02:00[Europe/Warsaw]"` to pact so format should be working just fine

uglyog
2020-06-30 23:18
@mbieganski.infomatt You need to quote the square brackets in `[:ss.SSS]`

mbieganski.infomatt
2020-07-01 06:03
@uglyog it doesn't work. `JSON conversion problem: Text '2020-06-16T16:30[:ss.SSS]+02:00[Europe/Warsaw]' could not be parsed at index 16;`

uglyog
2020-07-01 06:04
Sorry, I meant the brackets only

uglyog
2020-07-01 06:04
`'[':ss.SSS']'`

mbieganski.infomatt
2020-07-01 06:07
`JSON conversion problem: Text '2020-06-16T16:30[:59.528]+02:00[Europe/Warsaw]' could not be parsed at index 16;` I don't think so that when using optional section I need quote https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html ?

uglyog
2020-07-01 06:12
Ah, yes, you're correct

uglyog
2020-07-01 06:15
I think the error is misleading, we've lost the original error when it tries the fallback

uglyog
2020-07-01 06:18
The problem may be that Japan is not a valid timezone ID, it should be `Asia/Tokyo`

mbieganski.infomatt
2020-07-01 06:20
hmm I think I tried with `Europe/Warsaw` but might try again. Have you added `datetime` handling for `and/or` matching rules?

uglyog
2020-07-01 06:23
The datetime handling was changed that if DateTimeFormatter fails to parse, it falls back to trying the older parser which is based on SimpleDateFormat. But the issue is the first error is lost, and it is showing the error from SimpleDateFormat which does not support time zone IDs

mbieganski.infomatt
2020-07-01 06:26
I tried with valid timezone but same error. Would you like me to raise an issue? ```Unable to parse "2020-05-08T15:25:30+09:00[Asia\/Tokyo]" with yyyy-MM-dd'T'HH:mm[:ss.SSS]XXX'['VV']' using java.time.format.DateTimeFormatter.```

uglyog
2020-07-01 06:31
Why is there a backslash in the zone id?

uglyog
2020-07-01 06:31
I tested Japan, and it works as a zone ID

uglyog
2020-07-01 06:32
```groovy:000> DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm[:ss.SSS]XXX'['VV']'").parse('2020-07-01T16:29:35.574+10:00[Australia/Melbourne]') ===> {OffsetSeconds=36000, InstantSeconds=1593584975},ISO,Australia/Melbourne resolved to 2020-07-01T16:29:35.574 groovy:000> DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm[:ss.SSS]XXX'['VV']'").parse('2020-07-01T16:29:35.574+09:00[Asia/Tokyo]') ===> {OffsetSeconds=32400, InstantSeconds=1593588575},ISO,Asia/Tokyo resolved to 2020-07-01T16:29:35.574 groovy:000> DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm[:ss.SSS]XXX'['VV']'").parse('2020-07-01T16:29:35.574+09:00[Japan]') ===> {OffsetSeconds=32400, InstantSeconds=1593588575},ISO,Japan resolved to 2020-07-01T16:29:35.574```

uglyog
2020-07-01 06:33
But your datetime fails

uglyog
2020-07-01 06:33
```groovy:000> DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm[:ss.SSS]XXX'['VV']'").parse('2020-05-08T15:25:30+09:00[Asia/Tokyo]') ERROR java.time.format.DateTimeParseException: Text '2020-05-08T15:25:30+09:00[Asia/Tokyo]' could not be parsed at index 16```

uglyog
2020-07-01 06:34
Because you don't have any milliseconds, I'm guessing

uglyog
2020-07-01 06:34
```groovy:000> DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm[:ss][.SSS]XXX'['VV']'").parse('2020-05-08T15:25:30+09:00[Asia/Tokyo]') ===> {OffsetSeconds=32400, InstantSeconds=1588919130},ISO,Asia/Tokyo resolved to 2020-05-08T15:25:30```

uglyog
2020-07-01 06:35
:point_up: You need to have the seconds and milliseconds as different optionals

mbieganski.infomatt
2020-07-01 06:41
awesome great :slightly_smiling_face: thanks! should it also work with AND/OR matching rules e.g PM.timestamp ?

uglyog
2020-07-01 06:41
Yes, it should (in theory)

antonello
2020-07-01 07:10
How about this to show the first exception? https://github.com/DiUS/pact-jvm/pull/1152

mbieganski.infomatt
2020-07-01 08:30
@uglyog not sure if expected but when I have contract defined as below for request body ```body.or("creationDate", INSTANT_TIME, PM.nullValue(), PM.timestamp("yyyy-MM-dd'T'HH:mm[:ss][.SSS]XXX'['VV']'"));``` when I send POST with creationDate being null I'm getting ```Unable to parse null with yyyy-MM-dd'T'HH:mm[:ss][.SSS]XXX'['VV']' using java.time.format.DateTimeFormatter.``` I would expect that using multiple matchers I can send null?

chandanakurumeti27
2020-07-01 09:36
When both consumer and provider services are java based, it is in the consumer service where we define the expectations before running the consumer tests,right. And Its needed to mention this`"valuefromproviderstate"` keyword in the expected request body. only then before running provider tests if i return something from my provider `statechange()` method, The value returned will replace the value exists request body in the contract.Atleast thats how i understand the flow is. Right now, My issue is as i said my consumer service is javascript based one and am using pactJS to write consumer tests and I could really use ?valuefromproviderstate? feature there as it doesnt exist in pact js framework(got this info from pact JS channel).So how could i make sure that, the value in the request body will be replaced by the value which i return from my provider statechange() method. Pointing it again,My provider service is java based one here.

chandanakurumeti27
2020-07-01 09:40
Here the value i want to replace is `sessionuid` with the one which is returned from the provider state and i actually generate this sessionuid inside the providerstate change method by sending the request to `start the session` api and i want that sessionuid(which i got when i start the session inside statechange method and not the one i have in contract) to use in the request body while running the provider states

rafael.espillaque
2020-07-01 11:37
Can I split Message Contracts Verification methods into different Test Classes? Currently I have 2 Consumers with 1 Interaction each and 1 Provider that needs to verify those 2 Contracts. In the Provider codebase I have 2 different Test Classes. I?m seeing that the first test class finds the 2 Contracts and it?s somehow instantiating the second class and calling the PactVerifyProvider method but since it wasn?t run by JUnit, some fields in that class are null.

antonello
2020-07-01 11:42
Hey @rafael.espillaque. Yes, you can split your state change methods into different classes/interfaces. https://github.com/DiUS/pact-jvm/tree/master/provider/junit#using-multiple-classes-for-the-state-change-methods

rafael.espillaque
2020-07-01 12:57
Thanks @antonello but not sure how to do that with Messages. I don?t have @State annotations, just @PactVerifyProvider

antonello
2020-07-01 12:58
Ah sorry - I misread your message

rafael.espillaque
2020-07-01 12:58
no problem, was useful

rafael.espillaque
2020-07-01 12:59
this could be the key: ```/** * Test target for use with asynchronous providers (like with message queues). * * This target will look for methods with a @PactVerifyProvider annotation where the value is the description of the * interaction. * * @property packagesToScan List of packages to scan for methods with @PactVerifyProvider annotations. Defaults to the * full test classpath. */ open class AmpqTestTarget(val packagesToScan: List<String> = emptyList()) : TestTarget {```

rafael.espillaque
2020-07-01 13:12
:confused: it?s not enough ```context.setTarget(new AmpqTestTarget(Collections.singletonList(getClass().getPackageName())));``` after adding that, now it only finds one of the @PactVerifyProvider method but it?s still trying to verify the contract

rafael.espillaque
2020-07-01 13:39
I understand the design could be that different classes have different @PactVerifyProvider so only 1 Pact test is needed but I?m finding that those classes don?t have its @Before called, nor its Spring Context initialised.

jgfarias42
2020-07-02 07:23
[can-i-deploy] Hi all, I?m having problems figuring out what is the equivalent in the JVM / Maven tools to https://docs.pact.io/pact_broker/can_i_deploy_https://docs.pact.io/pact_broker/can_i_deploy_ step, to be performed after the _mvn pact:can-i-deploy_ is successful. I?ve found this issue talking about setting _pact.provider.tag_ on the POM, but my understanding is that it would be static, rather than defined on the fly by the deployment script, just like I do with _mvn pact:can-i-deploy_. https://github.com/DiUS/pact-jvm/issues/823 I?ve also tried _mvn pact:publish -Dpact.publish.tag=_MyEnv, but this particular service I have doesn?t consume data, so no Pacts exist and this command fails. Would I need to have the Pact Broker itself available to perform this?

wesleythomaswilliams
2020-07-02 08:14
We do this in a pipeline stage: ```' mvn -B -f pom.xml pact:publish' + ' -Dpact.consumer.version=' + env.GIT_COMMIT + ' -Dpact.tag=' + env.GIT_BRANCH```

giuseppe.salvatore
2020-07-02 08:38
has joined #pact-jvm

giuseppe.salvatore
2020-07-02 08:39
Sweet, this was exactly what I was looking for :+1: I was asking this question in the #general channel just yesterday

jgfarias42
2020-07-02 09:42
@wesleythomaswilliams I still got the same error: ?myservice/target/pacts does not exist, skipping uploading of pacts?, because I am working on a provider that has no downstream dependencies - therefore it doesn?t define any consumer contract, only verifies itself against upstream dependencies Does this command of yours add this tag to the *provider* of a particular verification in the Matrix? Screenshot 2020-07-02 at 11.36.37

wesleythomaswilliams
2020-07-02 10:02
Our provider tagging happens when the provider tests are run: ```' mvn -B -f pom.xm test -Pcontract-tests' + ' -Dpact.provider.version=' + env.GIT_COMMIT + ' -Dpact.verifier.publishResults=true' + ' -Dpact.provider.tag=' + env.GIT_BRANCH```

wesleythomaswilliams
2020-07-02 10:06
We have a generic pipeline that runs for both our consumers and providers, so there's some conditional elements based on if a service is a consumer or provider. e.g. a provider service doesn't do the pact:publish, a consumer doesn't do the provider piece above.

jgfarias42
2020-07-02 11:16
I didn?t get how / when you push a tag for the environment that the service was deployed. The building phase flow I was able to do: 1 - Create the consumer contracts; 2 - Verify the contracts on the provider; Now I am moving to the deployment phase. What I was able to do was to run can-i-deploy: ```mvn pact:can-i-deploy -Dpacticipant='MyService' -DpacticipantVersion=${myService.version}-SNAPSHOT -DtoTag=${envName}``` This will look for failed verifications for the other services in the environment ?envName?. However, for this to work, as mentioned in the documentation above, I need to simply add an additional tag for the environment, not both run the verification *and* upload a tag.

jgfarias42
2020-07-02 11:18
The Ruby / Pact Broker Client steps are as follows: https://docs.pact.io/pact_broker/can_i_deploy#summary I did the first one, but I?m stuck in doing the second.

kristine.jetzke
2020-07-02 13:12
You need to run this step manually. So to answer the original question: > Would I need to have the Pact Broker itself available to perform this? Yes

kristine.jetzke
2020-07-02 13:15
manually = using the pact broker CLI


kristine.jetzke
2020-07-02 13:19
since it?s not usually done during a build but after a deployment maven might also not be the best tool (unless you do your deployment with maven)

jgfarias42
2020-07-02 13:20
I am able to save my pom as artefact and then run maven plugins there. It adds a bit of time to the builds, but I think it?s worth given that I can block builds at the beginning with can-i-deploy.

kristine.jetzke
2020-07-02 13:22
I did not get that. Can?t you block build independent of the tool you use? But I guess this kind of a different topic. From what I can see in the code I would say that the maven plugin currently does not support this separate tagging step. But since there is a `can-i-deploy` step maybe you can create a PR and add it. What do you think @uglyog

jgfarias42
2020-07-02 15:35
Thanks for the diagnosis @kristine.jetzke I will take a look at how to create this Mojo, sounds fun :smile:

antonello
2020-07-02 15:58
@phil.endsley Have you been using `4.1.5`? Because we?ve just tried it and it doesn?t work for us. It can?t find any pacts.

phil.endsley
2020-07-02 16:20
I have not yet. It was on my list, but other items came up this week. I can give it a shot right now though

phil.endsley
2020-07-02 16:20
@antonello Did you switch to version selectors, or are you still using tags?

antonello
2020-07-02 16:21
still using tags

antonello
2020-07-02 16:42
from a second test, it seems to be working for me

antonello
2020-07-02 16:42
but I need to check with my colleague who I was pairing with as it wasn?t working on his machine

phil.endsley
2020-07-02 16:47
It fails for me as well

phil.endsley
2020-07-02 16:47
I see the issue

phil.endsley
2020-07-02 16:49
I added a default value for `consumerVersionSelectors` to support system properties. We fall back to using `tags` if `consumerVersionSelectors` is empty, but it never is now

phil.endsley
2020-07-02 16:52
As a workaround, you can set `consumerVersionSelectors = {}` . There's still another issue to figure out though, since it should be falling back to getting the latest version if nothing is specified

rafael.espillaque
2020-07-02 16:52
Any ideas please?

phil.endsley
2020-07-02 16:53
I think I'll have time later tonight to take a look and work on a fix

antonello
2020-07-02 17:01
we?re definitely missing some tests on `pact-jvm`

antonello
2020-07-02 17:02
we shouldn?t be able to release something that doesn?t work to this extent

antonello
2020-07-02 17:02
the tests should tell you

antonello
2020-07-02 17:03
workaround doesn?t really work for us as we have far too many providers

antonello
2020-07-02 17:03
my suggestion would be to revert your changes

antonello
2020-07-02 17:04
until they?re fixed and definitely working

antonello
2020-07-02 17:04
otherwise we can?t release

antonello
2020-07-02 17:04
your changes are incredibly important though

antonello
2020-07-02 17:07
and 4.1.5 should be deprecated

phil.endsley
2020-07-02 17:10
So do I just open a pr against master with the change reverted?

antonello
2020-07-02 17:12
@uglyog is sleeping, but I?d say yes, unless you can fix it by the end of the day

antonello
2020-07-02 17:15
I think we should re-release a version that works ASAP because otherwise 4.1.5 is pretty borked for anyone who installs it.

antonello
2020-07-02 17:19
what?s your github handle?

phil.endsley
2020-07-02 17:19
pendsley

emanuele.ivaldi
2020-07-02 17:21
marked as a WIP as we haven't had the chance to test it locally - will remove the WIP from the title when it's tested :thumbsup:

antonello
2020-07-02 17:22
@phil.endsley

phil.endsley
2020-07-02 19:13
Appreciate you bringing this up. Apologies for any inconveniences it's causing :disappointed:

antonello
2020-07-02 19:13
No worries!

antonello
2020-07-02 19:15
If nothing imho this is highlighting that it?d be great to look into whether more/different tests might help us spot issues before releasing. Perhaps something external to the repo as @bethskurrie suggested.

antonello
2020-07-02 19:32
Saw your PR @phil.endsley :muscle: . Some tests are failing.

phil.endsley
2020-07-02 19:32
Just pushed a fix for the tests

antonello
2020-07-02 20:50
verified locally and it works!

kristine.jetzke
2020-07-02 21:12
Do you have a minimal example you can provide?

phil.endsley
2020-07-02 21:16
I haven't personally done this. But it's mentioned in the junit docs as being possible. https://docs.pact.io/implementation_guides/jvm/provider/junit/#returning-values-that-can-be-injected https://github.com/pact-foundation/pact-specification/tree/version-3#introduce-example-generators > You can have values from the provider state callbacks be injected into most places (paths, query parameters, headers, *bodies*, etc.). This works by using the V3 spec generators with provider state callbacks that return values. It _sounds like_ (the way I'm interpreting it) you can use a generator on the js side to create the Pact, then use the state callback on the Java side to fill it in with the value you really want. I haven't had to do this before though. Maybe @uglyog or @matt.fellows can answer this better?

antonello
2020-07-02 22:46
@uglyog if we could get these two reviewed/approved, I can release 4.1.6 first thing tomorrow morning. https://github.com/DiUS/pact-jvm/pull/1156 https://github.com/DiUS/pact-jvm/pull/1158

uglyog
2020-07-02 23:22
@chandanakurumeti27 Javascript doesn't support any of the V3 features, so it will not generate a Pact file with the correctly configured generators for this to work

uglyog
2020-07-02 23:25
I don't think we can re-release 4.1.5, the only thing we can do is release 4.1.6 and update the release notes on Github to state it has an issue.

bethskurrie
2020-07-03 03:19
It's the moment I know you've all been waiting for - the docs now have a comparison between Pact and Spring Cloud Contract. :party_parrot: Kristine has made it happen https://docs.pact.io/getting_started/comparisons#how-does-pact-differ-from-spring-cloud-contract

antonello
2020-07-03 10:51
I?ve released 4.1.6 this morning and added a note to 4.1.5 https://github.com/DiUS/pact-jvm/releases/tag/4_1_5

dattasai.chunduru
2020-07-03 13:40
Hi I have to pass 2 query parameters in my URL and I am passing them like this

dattasai.chunduru
2020-07-03 13:40
is this the right way of adding the query parameters


dattasai.chunduru
2020-07-03 15:03
Hi When I am trying to run the provider side verification I am getting error as Execution default-cli of goal au.com.dius:pact-jvm-provider-maven_2.12:3.5.10:verify failed: No signature of method: static http://au.com.dius.pact.model.PactReader.queryStringToMap() is applicable for argument types: (java.util.LinkedHashMap) values: [[city_id:[4487042], key:[1c7fdbc64572463f9ebe140ff3909050]]] [ERROR] Possible solutions: queryStringToMap(java.lang.String), queryStringToMap(java.lang.String, boolean)


dattasai.chunduru
2020-07-03 15:05
and my provider side code is

dattasai.chunduru
2020-07-03 15:05
can anyone please help me on this

kristine.jetzke
2020-07-03 20:35
It looks like the query has the wrong format. It is a map but needs to be a string. Can you paste the code that generates the contract?


kristine.jetzke
2020-07-03 20:39
instead of ```.query("city_id=4487042) .query("key=1c7fdbc64572463f9ebe140ff3909050")``` try ```.query("city_id=448704&key=1c7fdbc64572463f9ebe140ff3909050")```

uglyog
2020-07-04 03:17
No, the second will overwrite the first. Just append a `&` between them with one call

uglyog
2020-07-04 03:18
This looks like a defect. Can you raise a Github issue for it?

uglyog
2020-07-06 07:11
@phil.endsley @antonello I'm going to be working on an implementation of handling different types of objects in lists (i.e. polymorphic collections). I might leave the 4.1.x branch to now stabilise, and move development when I start that work on 4.2.x. It does mean that master may track 4.2.x at some point, and we would need to backport fixes to 4.1.x

antonello
2020-07-06 07:13
So any new releases for the time being from 4.1.x?

uglyog
2020-07-06 07:14
We can do releases from both branches when needed

antonello
2020-07-06 07:14
:ok_hand::skin-tone-2:

antonello
2020-07-06 07:14
I didn?t update 4.1.x after my release last week by the way

uglyog
2020-07-06 07:15
Should be ok, will only be a fast forward because there shouldn't be other commits on that branch

francesco.bartoli
2020-07-06 08:05
has joined #pact-jvm

hadjaliabir
2020-07-06 15:15
Hello ! how can i resolve "failed to invoke pact method " . i use java/junit/eclipse, i added the jars using build path

uglyog
2020-07-06 23:11
A little bit more information will help. How are you running things, what are you running and what jars did you add using the build path?

dattasai.chunduru
2020-07-07 06:58
@kristine.jetzke I have taken this site as reference https://docs.pact.io/getting_started/matching/

dattasai.chunduru
2020-07-07 07:01
@kristine.jetzke This is my consumer side code

ashish_garg5
2020-07-07 09:57
Hi All, @PactBroker(host = "${pact.broker.host}", port = "${pact.broker.port}") I have added this annotation in my test class and i was passing these values while doing maven clean install. How i can configure these host and port in my pom.xml ? Thanks.

matt.fellows
2020-07-07 10:10
Aren't they references to environment variables?

matt.fellows
2020-07-07 10:10
Presumably however you normally would expose env vars

ashish_garg5
2020-07-07 10:18
they references to ENV variables but if someone only wants to do mvn clean install locally then in that case it will fail

matt.fellows
2020-07-07 10:28
If they aren't sensitive or dynamic then you could just hard code them

fernando.martin
2020-07-07 14:39
has joined #pact-jvm

uglyog
2020-07-07 23:39
They are JVM system properties, not env vars

matt.fellows
2020-07-07 23:54
cool. Same difference

dattasai.chunduru
2020-07-08 08:17
Hi All

dattasai.chunduru
2020-07-08 08:18
I am trying to do the validation for response body by using PactDslJsonBody my response looks like this [ { "id": 54365477, "name": "Wils", "phone": "" } ] and my validation code looks like .body(new PactDslJsonBody() .array() .object() .numberValue("id", 54365477) .closeObject() .closeArray()).toPact()

dattasai.chunduru
2020-07-08 08:19
It is showing error for me stating can not initiate PACT method. Can anyone tell me how can we write an array without any name

abubics
2020-07-08 08:22
From memory, it's not supported . . . I'm not sure of the official reason. The reason I would recommend against such an API is it's inextensible from the root, and not self-describing.

antonello
2020-07-08 08:37
With your array being on the root, if you?re happy to use matchers, which would be my advice anyway, you should be able to do this: https://github.com/DiUS/pact-jvm/tree/master/consumer#root-level-arrays-that-match-all-items

dattasai.chunduru
2020-07-08 08:44
Actually I got the output

dattasai.chunduru
2020-07-08 08:44
Thankyou @antonello for your quick reply in both the places

antonello
2020-07-08 08:45
You?re welcome :slightly_smiling_face:

ashish_garg5
2020-07-08 10:57
Hi All, I have added basic auth in my pact broker using the below commands. PACT_BROKER_BASIC_AUTH_USERNAME: PACT_BROKER_BASIC_AUTH_PASSWORD: Now how can i pass these in my mvn clean install command ?

francislainy.campos
2020-07-08 11:02
Sorry if my question doesn't make much sense, but I have a situation where I've access to a contract as a .json file but it's not published yet and it may take some time for this to happen. I want to start writing the verification tests for it, so was thinking of pasting this file manually under the pact/folder and connect to it rather than an online broker? I think I've seen something like this done somewhere before. Is this really possible? If so, could I get a sample please? Thanks very much.

hadjaliabir
2020-07-08 11:05
I had a problem with maven because of my company restrictions, so i had to add jars manually to the project , it turns out that i have a missing jar and duplicated versions ... Now i am able to run a maven projet (added cacerts), and everything is fine ... thank you :blush:

francislainy.campos
2020-07-08 11:10
I've tried something like this (with and without / at the start) but I'm be missing something else since it won't work.

ashish_garg5
2020-07-08 11:26
i think you have to give target folder as well. target/pacts

wesleythomaswilliams
2020-07-08 11:26
Our provider tests contain this: ```@PactBroker( host = "${pact.broker.host}", scheme = "https", port = "443", authentication = @PactBrokerAuth(token = "${pact.broker.token}"))``` So we use a token rather than username/password. And we store that token in our POM (in our surefire plugin for the provider and the pact plugin for our consumer) and our jenkinsfile to pass to can-i-deploy during our pipeline. It's a bit messy at the moment as I'd like to store it in one location.

wesleythomaswilliams
2020-07-08 11:27
```<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <pact.broker.host>url</pact.broker.host> <pact.broker.token>xyz</pact.broker.token> <pact.verifier.publishResults>false</pact.verifier.publishResults> <pact.provider.version>${pact.provider.version}</pact.provider.version> <pact.provider.version.trimSnapshot>false</pact.provider.version.trimSnapshot> </systemPropertyVariables> </configuration> </plugin>```

francislainy.campos
2020-07-08 11:27
Yes, just tried that too. Both target/pacts and /target/pacts but same error I'm afraid. Tried also the absolute path for the .json file but same issue.

wesleythomaswilliams
2020-07-08 11:28
```<plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>${pact.version}</version> <configuration> <projectVersion>${pact.consumer.version}</projectVersion> <pactDirectory>${project.build.directory}/pacts</pactDirectory> <pactBrokerUrl>url</pactBrokerUrl> <pactBrokerToken>xyz</pactBrokerToken> <pactBrokerAuthenticationScheme>Bearer</pactBrokerAuthenticationScheme> <skipPactPublish>false</skipPactPublish> <tags> <!--suppress UnresolvedMavenProperty --> <tag>${pact.tag}</tag> </tags> </configuration> </plugin>```

antonello
2020-07-08 11:28
Have you tried just `pact`

antonello
2020-07-08 11:28
without the slash

francislainy.campos
2020-07-08 11:29
Yeah

ashish_garg5
2020-07-08 11:30
so in consumer we don't have @PactBroker annotation so only we have to add in pom.xml ?

wesleythomaswilliams
2020-07-08 11:32
For our consumer, we have it in the POM in the Pact plugin as above, which I believe is where it's used by the `mvn pact:publish` command.

antonello
2020-07-08 11:32
which package is `PactSource` coming from?

ashish_garg5
2020-07-08 11:33
ok thanks, so instead of token if i have to add username and password then there is anyway or any useful link if you are aware ?

francislainy.campos
2020-07-08 11:33
I believe is the pacts folder with the .json file?

antonello
2020-07-08 11:33
It has to be `http://au.com.dius.pact.provider.junitsupport.loader.PactFolder` as mentioned here: https://pact-foundation.slack.com/archives/C9UN99H24/p1592924865155700

antonello
2020-07-08 11:34
where are you importing the `PactFolder` annotation from?

francislainy.campos
2020-07-08 11:36
```import au.com.dius.pact.core.model.annotations.PactFolder;```

antonello
2020-07-08 11:36
Se my message above then

francislainy.campos
2020-07-08 11:37
I'm trying to add this here but getting an error

antonello
2020-07-08 11:37
it?s the wrong one

antonello
2020-07-08 11:37
You need to use `http://au.com.dius.pact.provider.junitsupport.loader.PactFolder`

francislainy.campos
2020-07-08 11:37
Yes, this one that I mean.

antonello
2020-07-08 11:37
which version of pact-jvm are you using?

francislainy.campos
2020-07-08 11:38
4..0.5

wesleythomaswilliams
2020-07-08 11:38
Looking now, but I think it's, `pactBrokerUsername` and `pactBrokerPassword`

francislainy.campos
2020-07-08 11:38
Sorry, 4.0.1

antonello
2020-07-08 11:38
ok, so then the package structure would be different

ashish_garg5
2020-07-08 11:38
yeah i got it thanks :slightly_smiling_face:

francislainy.campos
2020-07-08 11:40
I just tried it this way too ../pacts

antonello
2020-07-08 11:40
it should be in `http://au.com.dius.pact.provider.junit.loader.PactSource`

francislainy.campos
2020-07-08 11:42
Thanks so much! It worked now. :slightly_smiling_face:

antonello
2020-07-08 11:43
:ok_hand:

francislainy.campos
2020-07-08 11:43
Have a great day and appreciate your help.

antonello
2020-07-08 11:48
You?re welcome! Enjoy your day!


dattasai.chunduru
2020-07-08 18:13
Hi Can anyone please provide the yaml file for PACTBROKER with authentication

kristine.jetzke
2020-07-08 19:44
hm I cannot reproduce it even when I downgrade to version _3.5.10_

kristine.jetzke
2020-07-08 19:45
how does the generated contract look like?

kristine.jetzke
2020-07-08 19:46
Is it an option for you to upgrade to a newer version and see if it works? If not, could you post a minimal example that reproduces the problem? Preferable as a GitHub issue.

kristine.jetzke
2020-07-08 19:50
@antonello Do you know why there are those two annotations btw? Someone else recently contacted my about the same issue - they pacts were not loaded and in the end it turned out they used the import from the wrong package.

antonello
2020-07-08 19:54
I don?t know off the top of my head - I?d have to have a look at the implementation

kristine.jetzke
2020-07-08 20:34
I just realized it?s even in one of the the workshops wrong? https://github.com/pactflow/example-provider-java-kafka/pull/1 :slightly_smiling_face:

kristine.jetzke
2020-07-08 20:36
:thinking_face: should I create a ticket for pact-jvm to look into it? Especially if you?re just starting out with pact it might lead to unnecessary frustration

phil.endsley
2020-07-08 20:56
@uglyog mentioned wanting to change when it was brought up a week or so ago

kristine.jetzke
2020-07-08 21:10
How about adding the https://github.com/DiUS/pact-jvm/tree/master/provider/junit#filtering-by-consumer annotation to the respective classes? I don?t know though if that affects the possibility to publish results or has any other side effects. From a quick check I did I would say no side effects. The main drawback I would say is that you have to remember to add new consumers.

kristine.jetzke
2020-07-08 21:12
In general I also find the use of `@PactVerifyProvider` across multiple classes confusing. It can only work if the annotated methods don?t need any fields from the class. And it?s also confusing to me that if there are two classes with `AmpqTestTarget` targets and `@PactVerifyProvider` each that each class calls the other classes methods.

kristine.jetzke
2020-07-08 21:17
Maybe it?s worth it to create a bug?

uglyog
2020-07-09 00:04
The one is for defining the pact source for verifying a provider, the other to overwrite the directory where the pacts get written to in a consumer test. It's unfortunate they ended up with the same name.

matt.fellows
2020-07-09 00:06
Can you elaborate on why the publishing is going to take so long?

matt.fellows
2020-07-09 00:06
Are you waiting for a broker to be setup or something?

francislainy.campos
2020-07-09 08:00
It's done by another team and they will submit it after they are finished with the contract for some other apis that are still being done.

matt.fellows
2020-07-09 08:14
do they not publish the contract on every build and just tag it as a feature?

rafael.espillaque
2020-07-09 11:00
will try the annotation and create the bug, thanks @kristine.jetzke !

uglyog
2020-07-11 23:57
/github subscribe list features

praneethkumar
2020-07-12 17:45
Hi , Does anyone have a good example of a POST test for consumer I can refer to please ?

aliaksandr.valadzko
2020-07-14 09:49
has joined #pact-jvm

aliaksandr.valadzko
2020-07-14 09:49
Hello:slightly_smiling_face: I try to set up Pact Provider tests in java using `@RunWith(PactRunner.class)` To initialize Spring beans I have to use `BeforeClass` section: ``` @BeforeClass public static void contextSetUp() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(PactContext.class); context.refresh(); SomeServiceMockStubs = context.getBean(SomeServiceMockStubs.class); ... }``` Is there a chance to simplify it, and use `Autowired` annotation like it is done in `@RunWith(SpringJUnit4ClassRunner.class)` ? ``` @Autowired protected SomeServiceMockStubs someServiceMockStubs;``` Thanks in advance!

jason
2020-07-14 10:17
has joined #pact-jvm

kristine.jetzke
2020-07-14 12:14
Are you using junit 4 or 5?


kristine.jetzke
2020-07-14 12:21
I don?t think there is a `HttpTarget` yet for Junit 5. Instead you can do this: ```@LocalServerPort private int port; @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", port)); }```

aliaksandr.valadzko
2020-07-14 13:12
Hello, thanks a lot for responding! I use `JUnit4` Assume *SpringRestPactRunner* will help I used `pact-jvm-provider-junit`, will try to integrate using `pact-jvm-provider-spring`

aliaksandr.valadzko
2020-07-14 13:29
Actually getting `null` as well: ```@ContextConfiguration(classes = {PactContext.class}, loader = AnnotationConfigContextLoader.class) @RunWith(SpringRestPactRunner.class) public class PactProviderBaseTest { @Autowired protected SomeServiceMockStubs someServiceMockStubs; @Autowired protected SomeBean bean; ... }```

uladzislau_danilchyk
2020-07-15 08:14
has joined #pact-jvm

uladzislau_danilchyk
2020-07-15 08:14
Hi all! Is there any example how to write a contract for a negative scenario with 4xx errors? I faced the issue that HttpClientErrorException is thrown instead.

matt.fellows
2020-07-15 08:32
I answered in general but this is the right place to ask

uglyog
2020-07-15 09:24
HTTP clients generally throw exceptions on errors. You need to deal with that in your test

dattasai.chunduru
2020-07-15 16:49
Hi I want have a Jenkins pipeline code with shell script which looks like below ``` stage('Publish Pacts') { steps { sh './mvnw pact:publish -Dpact.consumer.version=${GIT_COMMIT} -Dpact.tag=${BRANCH_NAME}' } }``` can any one please give me the Windows bat commands for same I tried this stage('Publish Pacts') { steps { bat 'mvn pact:publish ' -Dpact.consumer.version=${GIT_COMMIT} -Dpact.tag=${BRANCH_NAME} ' } } but it is failing. can anyone please help me on this

matt.fellows
2020-07-16 02:31
this looks like Windows/Jenkins specific question. What is failing about it? Are the variables not coming through? Is maven not being executed?

dineshkr9090
2020-07-16 09:18
has joined #pact-jvm

dineshkr9090
2020-07-16 09:18
Hi Team, Please let me know which version of Java supports Pact framework. I am doing Pact contract testing but getting error like "java.util.function.supplier can not resolved" Thanks, Dinesh Kumar


os.shulyak
2020-07-16 14:50
has joined #pact-jvm

aditi.puri
2020-07-17 08:03
has joined #pact-jvm

maciej.olko
2020-07-17 09:01
has joined #pact-jvm

maciej.olko
2020-07-17 09:02
Hello, is there a way to make pact-jvm generate v2 specs?

borwoj
2020-07-17 09:39
has joined #pact-jvm

borwoj
2020-07-17 09:40
```@PactTestFor(pactVersion = PactSpecVersion.V2)``` :slightly_smiling_face:

phil.endsley
2020-07-17 13:09
Were you still looking for an example? If you have other requests working (ex: GET), they're pretty much the same, just change `.method("GET")` to `.method("POST")` The jvm workshop has examples of a GET. https://github.com/DiUS/pact-workshop-jvm#step-3---pact-to-the-rescue

dattasai.chunduru
2020-07-18 14:20
Hi Matt

dattasai.chunduru
2020-07-18 14:23
Got the Issue . The Issue is with Maven commands I changed it. It is working fine. I had another query. I know we can use mvn pact:verify is used to verify the published pact and mvn pact:publish for publishing pacts . But I had a case where I want to publish only one Pact file to Pactbroker is there any mvn command for this ?coz my scripts will generate PACT file for POST GET and DELETE when I execute them . But while publishing I want to publish only POST Pact file to PACT broker.

dattasai.chunduru
2020-07-18 15:26
Hi I'm using the below Webhook Creation for my consumer so that when ever it is changed it will trigger the Prpvider build Jenkins file from my jenkins. But When I am trying to execute it is showing error as BAD Request can anyone help me on this . The WebHook code I am using :- { "consumer": { "name": "ConsumerDataReceiver" }, "provider": { "name": "CitizenProvider" }, "request": { "method": "POST", "url": "http://localhost:8080/job/<Pbuildpipeline>/build", "headers": { "Accept": "application/json" } }, "events": [ { "name": "contract_content_changed" } ] } I am copy and pasting this code in pb:create part of my consumer. When I am clicking on Make a Request it is showing me error as 404 BAD Request . Please find the below screen shot .

antonello
2020-07-18 17:17
This is a question for the #pact-broker channel. But from the code you?ve pasted and from the error, it?s clear that the url is incorrect.

antonello
2020-07-18 17:18
Pbuildpipeline needs to be an actual value.

charu.agarwal
2020-07-18 21:39
has joined #pact-jvm

matt.fellows
2020-07-18 22:10
Are they separate files or interactions within the same file?

matt.fellows
2020-07-18 22:11
Why would you not publish all of them?

dattasai.chunduru
2020-07-20 06:00
@antonello I am not able to get by your word. May I know what is meant by Pbuildpipeline needs to be an actual value.?

dattasai.chunduru
2020-07-20 06:15
They are seperate files

dattasai.chunduru
2020-07-20 06:19
I have tried my code like this also @antonello { "consumer": { "name": "ConsumerDataReceiver" }, "provider": { "name": "CitizenProvider" }, "request": { "method": "POST", "url": "http://localhost:8080/job/Pbuildpipeline/build", "headers": { "Accept": "application/json" } }, "events": [ { "name": "contract_content_changed" } ] } but I am getting error like this

matt.fellows
2020-07-20 06:22
Hang on, you have separate files for GET, POST and DELETE? all for the same provider?

os.shulyak
2020-07-20 08:11
Hey all. I'm trying to implement Message testing with Kotlin for the Provider side. This is my code: ```@ActiveProfiles("test") @Provider("PACT_PROVIDER_PAYROLL_GATEWAY") @PactBroker(host = PACT_BROKER_URL, scheme = PACT_BROKER_SCHEME) internal class EmployeeHandlerTest(dataSource: DataSource) : BaseActionTest(dataSource) { @TestTarget val target = AmqpTarget(listOf("io.reflectoring")) private val awsProperties = mockk<AwsProperties>().apply { every { topicArn } returns "abc_topic" } private var snsClient = SnsClient(awsProperties = awsProperties) @PactVerifyProvider("message from Gateway") fun employeeMessage() { snsClient.createPublishRequest( CompanyId(1), EventName.PAYROLL_EMPLOYEE_SNAPSHOT_GENERATED, mapOf("employeeId" to 1, "entity" to "attribute") ) } }``` I've struggled with the running of the test itself. `@TestTarget` doesn't recognize that it is a test and i can't run it with IDE. If i add `@Test` annotation before `@PactVerifyProvider` , test is running, but it doesn't go to Broker and always returns true. So what is the way to make this test run properly? Googling didn't help a lot ;(

antonello
2020-07-20 08:21
It needs to be a unique identifier for the job you want to trigger.

antonello
2020-07-20 08:21
Have a look at the docs for the API of your CI system

dattasai.chunduru
2020-07-20 08:39
yeah now I am able to build the Webhook

dattasai.chunduru
2020-07-20 08:40
but it is showing as Retrying when there is a Change in Pact file but not getting verified

kristine.jetzke
2020-07-20 08:50
Maybe you?re missing a class level annotation?

kristine.jetzke
2020-07-20 08:51
The runner/extension

os.shulyak
2020-07-20 09:05
you mean this one? `@RunWith(PactRunner.class)`

os.shulyak
2020-07-20 09:08
I've got this error after trying:

abubics
2020-07-20 09:14
Does it want `PactRunner::class.java` instead?

os.shulyak
2020-07-20 09:15
@abubics

abubics
2020-07-20 09:17
Oh ok, it does want a `KClass`, sorry :sweat_smile:

abubics
2020-07-20 09:18
I don't have a Kotlin codebase handy, would you try without `.java` ? (i.e. `PactRunner::class`)

os.shulyak
2020-07-20 09:19
worked! thanks! will try to run test now :slightly_smiling_face:

os.shulyak
2020-07-20 09:21
ok, now i get this one: Here is the code: ``` @State("SomeProviderState") @PactVerifyProvider("message from Gateway") fun employeeMessage() { snsClient.createPublishRequest( CompanyId(11), EventName.PAYROLL_INTEGRATION_DISABLED, mapOf("employeeId213" to 12, "entity123" to "attribute") ) }``` and somehow i get this error: `0 - No annotated methods were found for interaction 'message from Gateway'. You need to provide a method annotated with @PactVerifyProvider("message from Gateway") on the classpath that returns the message contents.`

os.shulyak
2020-07-20 09:22
which is very strage for me because i do have method with correct annotation

os.shulyak
2020-07-20 09:23
is that something wrong with TestTarget? ```@TestTarget val target = AmqpTarget(listOf("io.reflectoring"))```

abubics
2020-07-20 09:50
Sorry, I haven't had a Kotlin provider to work on in over a year, and I haven't used this annotation workflow :< hopefully someone else can help with your specific errors :pray:

os.shulyak
2020-07-20 09:51
ok, got it. thanks for help anyway!

abubics
2020-07-20 09:51
gl ^^ I can still help with general Qs and Kotlin Qs :upside_down_face:

mark.abrahams
2020-07-20 11:50
has joined #pact-jvm

mark.abrahams
2020-07-20 11:50
Dear Pact friends, I am currently looking at the pact-jvm-server (https://docs.pact.io/implementation_guides/jvm/pact-jvm-server/)  for implementing the pact framework with a low code tool. Currently I am able to start the server and register some interactions via the /create endpoint. As mentioned in the documentation you have to define a state and path while doing so. Should I only register one interaction per /create call or can I add multiple? I noticed it works to add multiple interactions to the json however what should be the state filled in in the /create call then since the json contains multiple? And while running the tests how can I set the state the mock server should be in? For example state "user 1 does not exist" should return 404 on GET /user/1 and state "user 1 exists" should return 200 on GET /user/1. Can someone over here tell me how the pact-jvm-server is designed to be used? (register one interaction per /create call or is there some endpoint where I can specify the state the mock server should be in?) Looking forward to your answer!

mr.manish22d
2020-07-20 19:02
has joined #pact-jvm

uglyog
2020-07-20 22:52
For the method to be found, it has to be public. Try removing the `internal` from the class and add public to the method.

uglyog
2020-07-20 23:01
States are only defined, and are used when verifying the provider, not in the consumer tests were the mock server is used.

uglyog
2020-07-20 23:04
Looks like the state parameter is not actually used for anything. It may have been a key to store the pacts against.

uglyog
2020-07-20 23:05
Treat it more like a namespace

uglyog
2020-07-20 23:06
You can add as many interactions as you want, the provider state values are defined in the interactions.

mr.manish22d
2020-07-21 06:41
Hi Pact friends, I stucked with one issue, need help! Scenario: My API is Post request, which is having one token in body. I want to generate this token in provider state using provider state. In consumer test, I want to use method valuefromProviderState. But I am not getting any approach where I can add above method in my payload string. I am using Java, springboot for pact. If anyone have seen such scenario or I should follow some other approaches, please let me know. Thanks in advance. Regards, Manish

uglyog
2020-07-21 06:44
valuefromProviderState is used on the provider side when verifying the provider, not in the consumer test

uglyog
2020-07-21 06:46
It works by putting an example value that is used in the consumer test, and then the value is replaced when verifying the provider by the value returned from the provider state

mr.manish22d
2020-07-21 06:51
Hi @uglyog, thanks for your reply. Is it possible to use valuefromProviderState, if I am reading request body from a json file as string? If yes can you please share one example with me?

uglyog
2020-07-21 06:53
No, you'll need to use the Java DSL

mr.manish22d
2020-07-21 06:55
Thanks @uglyog


mark.abrahams
2020-07-21 09:01
Hi Ronald, thanks for your reply. Is there a specific reason why not to use the states at the consumer side? It would be very usefull in cases like the example I gave earlier.

uglyog
2020-07-21 23:17
The mock server is stateless, and behaves based on the interactions provided to it. For a test where you want there to be no users, you configure it to return a 404 and that is what it does. For the other test, you configure the same request to return the 200 response. What would it use the state for?

ranjanayush03
2020-07-22 06:15
has joined #pact-jvm

mark.abrahams
2020-07-22 06:15
If I register both interactions at once (get /user/1 with the no user exist state and with the user exists), I would need to be able to set the state to specify which of the two responses it should return.

mamtha.3687
2020-07-22 06:16
has joined #pact-jvm

uglyog
2020-07-22 06:19
That's why they are done in different tests

mark.abrahams
2020-07-22 06:37
So before every test you call the /create endpoint with the interaction for that test and /complete after the test is done?


mark.abrahams
2020-07-22 07:32
Ok thanks! if that is how it should be used then we do it like that

ukrainian1991
2020-07-22 08:28
has joined #pact-jvm

ukrainian1991
2020-07-22 08:58
Hi, I faced with a strange ConsumerVersionSelector behaviour (I use latest pact-jvm version and gradle plugin 4.1.6). I have several versions of Consumer mr85 mr86 mr87 and I want to verify Provider against *all* of this versions. According to docs I assigned for all of this versions the same tag "admin-client" and disable option *latest.* Here is the Gladle plugin pactVerify task config ```serviceProviders { iPaaS_CPE { ... fromPactBroker { selectors = [ new ConsumerVersionSelector("admin-client", false)] // specify your tags here. You can leave this out to just use the latest pacts }``` Also, I have tried to do this via Providers tests ```@PactBroker(host="0.0.0.0", port = "9292", consumerVersionSelectors = { @VersionSelector(tag = "admin-client", latest = "false")}) public class PactProviderPaaSTest {``` In both cases, only latest version of Consumer verified against the Provider. Could you point me how to achieve my goal?

uladzislau_danilchyk
2020-07-22 11:59
Hi all! I have the following provider test. But I need to pass config for HttpTarget retrieved from properties. I can't to move HttpTarget creation to SetUp method due to Nullpointer exception occurs. ``` @RunWith(SpringRestPactRunner.class) @TestPropertySource(locations = "classpath:application-test.properties") @Provider("My-Provider") @PactBroker(host = "${pact.broker.host}", scheme = "${pact.broker.scheme}", port = "${pact.broker.port}", authentication = @PactBrokerAuth(token = "${pact.broker.authentication.token}")) public class PactProviderVerificationTest { @Value("${test.target.protocol}") private String testTargetProtocol; @Value("${test.target.host}") private String testTargetHost; @Value("${test.target.port}") private Integer testTargetPort; @TestTarget //public Target target = new HttpTarget(testTargetProtocol, testTargetHost, testTargetPort); @State("gallery data exists") public void galleryDataExistsState() { } }```

phil.endsley
2020-07-22 12:37
```@PactBroker(host="0.0.0.0", port = "9292", consumerVersionSelectors = { @VersionSelector(tag = "admin-client", latest = "false")}) public class PactProviderPaaSTest {``` We're using this, and it's working for us... Can you try calling the pact broker endpoint that retrieves the pacts directly? ```curl --location --request POST 'http://0.0.0.0:9292/pacts/provider/[yourProvider]/for-verification' \ --header 'Content-Type: application/json' \ --data-raw '{ "consumerVersionSelectors": [{"tag": "admin-client", "latest": true}] }' ``` And also try with latest: false?

uladzislau_danilchyk
2020-07-22 12:38
Do you have any suggestions?

phil.endsley
2020-07-22 12:51
Trying to make sure I'm on the same page. Are these system properties? And you want to create `new HttpTarget` without using `@Value` (since you said you don't want to use Spring Boot)?

ukrainian1991
2020-07-22 13:12
Stranger things...

ukrainian1991
2020-07-22 13:12
Via API provided by you, everything as expected

ukrainian1991
2020-07-22 13:13
latest = false - two versions(all), latest = true only one

ukrainian1991
2020-07-22 13:14
Could you please share how you run pactVerify ?

phil.endsley
2020-07-22 13:16
We run our pact verifications with junit tests ```@PactBroker( host = pactBrokerHost, scheme = "https", consumerVersionSelectors = { @VersionSelector(tag = "develop"), @VersionSelector(tag = "prod", latest = "false") } ) @Provider("providerName")```

ukrainian1991
2020-07-22 13:23
=( the same code, verify only latest version

ukrainian1991
2020-07-22 13:23
Could you please share your version of pact broker

phil.endsley
2020-07-22 13:23
```2.57.0```

phil.endsley
2020-07-22 13:24
Your Pact Broker appears to be working, based on the api results you saw above.

ukrainian1991
2020-07-22 13:26
What about versions ```implementation 'au.com.dius.pact.consumer:junit5:4.1.6' implementation 'au.com.dius.pact.provider:junit5:4.1.6' implementation 'au.com.dius.pact.consumer:java8:4.1.6'```

phil.endsley
2020-07-22 13:27
```testImplementation("au.com.dius.pact.provider:junit5:4.1.6")```

ukrainian1991
2020-07-22 13:29
Is it possible to enable debug for pact broker? I want to see what request is comming to pact broker when I run junit tests

ukrainian1991
2020-07-22 13:29
docker logs shows nothing

phil.endsley
2020-07-22 13:30
Not sure about that one

ukrainian1991
2020-07-22 13:34
Anyway, thanks for help

phil.endsley
2020-07-22 13:35
Did your contracts change between versions?

ukrainian1991
2020-07-22 13:36
For my current config - yes

ukrainian1991
2020-07-22 13:36
One contract has 1 additional API method

ukrainian1991
2020-07-22 13:37
Also, my contract files are huge

ukrainian1991
2020-07-22 13:38
But do not thinks this is the case, because if I explicitly specify tags MR85 MR86, everything is ok

phil.endsley
2020-07-22 13:38
Hmm...I'm lost...I can see similar behavior if the consumer contract didn't change between its versions. But, that's intentional because pact de-duplicates contracts for you. Also, if that was the case, I would have expected the verified time to update for both versions, even if it was verified once (assuming they were the same)

ukrainian1991
2020-07-22 13:39
Yes, I read about this point in docs

phil.endsley
2020-07-22 13:40
Might need to wait for @bethskurrie to see if there's debug logging to enable on the pact broker side, or @uglyog to see if there's debug logging on the jvm side

ukrainian1991
2020-07-22 13:41
I created an issue earlier https://github.com/DiUS/pact-jvm/issues/1174 :smiley:

phil.endsley
2020-07-22 13:42
But I see it running all our tests like it's supposed to :confused: latest = "false" vs latest = "true"

ukrainian1991
2020-07-22 13:43
```4:31:27 PM: Executing tasks ':cleanTest :test --tests io.swagger.client.api.PactProviderPaaSTest'... > Task :cleanTest > Task :compileJava UP-TO-DATE > Task :processResources NO-SOURCE > Task :classes UP-TO-DATE > Task :compileTestJava > Task :processTestResources UP-TO-DATE > Task :testClasses > Task :test start iPaaS SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Verifying a pact between PortaBilling and iPaaS_CPE for tag porta-admin-client [from Pact Broker http://0.0.0.0:9292/pacts/provider/iPaaS_CPE/consumer/PortaBilling/version/MR86 (Tag porta-admin-client)] request correct get_devices_metainfo returns a response which has status code 200 (OK) has a matching body (OK) Verifying a pact between PortaBilling and iPaaS_CPE for tag porta-admin-client [from Pact Broker http://0.0.0.0:9292/pacts/provider/iPaaS_CPE/consumer/PortaBilling/version/MR86 (Tag porta-admin-client)] request correct get_profile_metainfo returns a response which has status code 200 (OK) has a matching body (OK) Verifying a pact between PortaBilling and iPaaS_CPE for tag porta-admin-client [from Pact Broker http://0.0.0.0:9292/pacts/provider/iPaaS_CPE/consumer/PortaBilling/version/MR86 (Tag porta-admin-client)] request generate full profile returns a response which has status code 200 (OK) has a matching body (OK) Verifying a pact between PortaBilling and iPaaS_CPE for tag porta-admin-client [from Pact Broker http://0.0.0.0:9292/pacts/provider/iPaaS_CPE/consumer/PortaBilling/version/MR86 (Tag porta-admin-client)] request get_devices_list returns a response which has status code 200 (OK) has a matching body (OK) Verifying a pact between PortaBilling and iPaaS_CPE for tag porta-admin-client [from Pact Broker http://0.0.0.0:9292/pacts/provider/iPaaS_CPE/consumer/PortaBilling/version/MR86 (Tag porta-admin-client)] request missing get_devices_metainfo returns a response which has status code 404 (OK) has a matching body (OK)```

ukrainian1991
2020-07-22 13:44
code is also pretty simple

ukrainian1991
2020-07-22 13:44
```@Provider("iPaaS_CPE") @PactBroker(host="0.0.0.0", port = "9292", consumerVersionSelectors = { @VersionSelector(tag = "porta-admin-client", latest = "false") }) public class PactProviderPaaSTest { @BeforeAll public static void enablePublishingPact() { System.setProperty("pact.verifier.publishResults", "true"); System.setProperty("pact.provider.version", "1.0.0"); System.setProperty("pact.provider.tag", "cpe_branch"); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) throws MalformedURLException { context.setTarget(HttpTestTarget.fromUrl(new URL("http://0.0.0.0:10000"))); // or something like // context.setTarget(new HttpTestTarget("localhost", myProviderPort, "/")); } }```

ranjanayush03
2020-07-22 14:07
Hi team ,like I am quite new to pact but I want to integrate it with Jenkins , so can someone please help regarding this..?

phil.endsley
2020-07-22 14:29
Have you checked out the docs? They're really thorough and very well written! The FAQ section has a question specifically about Jenkins. https://docs.pact.io/faq/#is-there-a-jenkins-plugin-for-pact You can also try checking out the CI/CD workshop, which walks through setting up the whole system. It uses Travis in the workshop, but the same concepts can be applied to any CI server. https://docs.pactflow.io/docs/workshops/ci-cd/

ranjanayush03
2020-07-22 15:37
Thank you Phil.. will surely look into it..

uglyog
2020-07-22 23:05
If you enable debug level logs, you will see the requests being made to the pact broker. The easiest way to do that is to add logback to the test classpath

uglyog
2020-07-22 23:08
You can try something like `Systsem.getProperty('test.target.host')`

uglyog
2020-07-22 23:08
Pass that to the constructor. Or you can extend the HttpTestTarget class.

uladzislau_danilchyk
2020-07-23 08:11
@uglyog do you have an example on how to extend?

ukrainian1991
2020-07-23 09:02
@uglyog Hi, thanks for pointing out) It was not easy, coze I dont use log4j) However here is part of the logs: ``` [DEBUG] 2020-07-23 11:58:13.052 [Test worker] PactVerificationInvocationContextProvider - provideTestTemplateInvocationContexts called [DEBUG] 2020-07-23 11:58:13.064 [Test worker] PactVerificationInvocationContextProvider - Verifying pacts for provider 'iPaaS_CPE' and consumer 'null' [DEBUG] 2020-07-23 11:58:13.065 [Test worker] PactVerificationInvocationContextProvider - Pact source on test class: null [DEBUG] 2020-07-23 11:58:13.439 [Test worker] PactVerificationInvocationContextProvider - Pact loaders on test class: [@au.com.dius.pact.provider.junitsupport.loader.PactBroker(scheme=${pactbroker.scheme:http}, valueResolver=class au.com.dius.pact.core.support.expressions.SystemPropertyResolver, port=9292, enablePendingPacts=${pactbroker.enablePending:false}, host=0.0.0.0, includeWipPactsSince=${pactbroker.includeWipPactsSince:}, consumers=[${pactbroker.consumers:}], consumerVersionSelectors=[@au.com.dius.pact.provider.junitsupport.loader.VersionSelector(latest=false, tag=porta-admin-client)], tags=[${pactbroker.tags:}], authentication=@au.com.dius.pact.provider.junitsupport.loader.PactBrokerAuth(password=${pactbroker.auth.password:}, username=${pactbroker.auth.username:}, token=${pactbroker.auth.token:}), providerTags=[${pactbroker.providerTags:}])] [DEBUG] 2020-07-23 11:58:13.462 [Test worker] PactBrokerLoader - Loading pacts from pact broker for provider iPaaS_CPE and consumer version selectors [ConsumerVersionSelector(tag=porta-admin-client, latest=false)] [DEBUG] 2020-07-23 11:58:13.466 [Test worker] PactBrokerLoader - Authentication: None [DEBUG] 2020-07-23 11:58:13.472 [Test worker] HalClient - Fetching: / [DEBUG] 2020-07-23 11:58:13.848 [Test worker] HalClient - Fetching: / [DEBUG] 2020-07-23 11:58:13.873 [Test worker] HalClient - Fetching: http://0.0.0.0:9292/pacts/provider/iPaaS_CPE/latest/porta-admin-client [DEBUG] 2020-07-23 11:58:13.983 [Test worker] HalClient - Fetching: http://0.0.0.0:9292/pacts/provider/iPaaS_CPE/consumer/PortaBilling/version/MR86 io.swagger.client.api.PactProviderPaaSTest > pactVerificationTestTemplate(PactVerificationContext)[1] STANDARD_OUT```

ukrainian1991
2020-07-23 09:04
As I can see latest option is correctly parsed ``` [DEBUG] 2020-07-23 11:58:13.462 [Test worker] PactBrokerLoader - Loading pacts from pact broker for provider iPaaS_CPE and consumer version selectors [ConsumerVersionSelector(tag=porta-admin-client, latest=false)] <<<``` However request to brocker is the same as with latest=true ```http://0.0.0.0:9292/pacts/provider/iPaaS_CPE/latest/porta-admin-client```

paul.stitt
2020-07-23 09:24
has joined #pact-jvm

phil.endsley
2020-07-23 13:27
It's acting like your broker doesn't support the provider-pacts-for-verification endpoint :confused: This troubleshooting isn't very pretty, but not sure if there's another way... First, make sure your broker supports it. Based on the version you said you're using, and the curl commands you did earlier, I would expect it to, but I'm not sure what else to try at this point... From your broker UI, go to your API Browser, then under Links, make sure you have `provider-pacts-for-verification` I was able to put a breakpoint in the Pact code that downloads the pacts. This will be in `PactBrokerClient.fetchConsumersWithSelectors` and see if `pactsForVerification` is null.

phil.endsley
2020-07-23 13:30
If the Pact code doesn't think your broker can support the `provider-pacts-for-verification` it will use the `latest-provider-pacts-with-tag` endpoint, which is what your logs are indicating it's calling. The jvm libraries were updated a while ago to use `provider-pacts-for-verification` even if you're not using the new `consumerVersionSelectors` as long as that endpoint is supported

ukrainian1991
2020-07-23 14:37
I checked and there is no `provider-pacts-for-verification` link on Brocker. I've updated docker image from 2.57.1 to 2.58.3 and the same

phil.endsley
2020-07-23 14:41
Aha! I guess this is still a beta feature you need to opt into. In Pact Broker, you need to enable the feature with an environment variable `PACT_BROKER_FEATURES: pacts_for_verification`

phil.endsley
2020-07-23 14:48
:tada::tada::tada:

ukrainian1991
2020-07-23 14:48
Thanks) Now it's working like a charm

komeershettyvinod
2020-07-24 03:11
Hi Team

komeershettyvinod
2020-07-24 03:12
I have a very large json body that i need to verify at consumer side, I mean to say its very large , it has lot of fields to verify and having that raw json in test file is not looking clean, is there any way we can store that in json file and verify

uglyog
2020-07-24 03:17
Are you trying to verify that the consumer can process a very large JSON file? This doesn't feel like the kind of thing you use Pact to test for.

matt.fellows
2020-07-24 04:12
what are you trying to achieve? That will help us provide the best advice

matt.fellows
2020-07-24 04:13
Perhaps if you could share the test case, or a representative one, then we?ll be able to tell you what you could do

komeershettyvinod
2020-07-24 06:31
```package studentservice //import au.com.dius.pact.consumer.Pact import au.com.dius.pact.consumer.PactVerificationResult import au.com.dius.pact.consumer.groovy.InvalidMatcherException import au.com.dius.pact.consumer.groovy.Matchers import au.com.dius.pact.consumer.groovy.PactBuilder import au.com.dius.pact.model.Pact import au.com.dius.pact.model.matchingrules.DateMatcher import au.com.dius.pact.model.matchingrules.MatchingRuleGroup import au.com.dius.pact.model.matchingrules.RegexMatcher import au.com.dius.pact.model.matchingrules.TimeMatcher import au.com.dius.pact.model.matchingrules.TimestampMatcher import groovy.json.JsonSlurper //import au.com.dius.pact.core.model.matchingrules.TimestampMatcher import groovyx.net.http.RESTClient import org.junit.Test class StudentServiceConsumerPactTest { @Test void "Post User service test"() { PactBuilder student_service = new PactBuilder() // Create a new PactBuilder student_service { serviceConsumer "StudentConsumer1" // Define the service consumer by name hasPactWith "StudentProducer" // Define the service provider that it has a pact with port 9000 // The port number for the service. It is optional, leave it out to // to use a random one given('test post call for with student details') // defines a provider state. It is optional. uponReceiving('student details') // upon_receiving starts a new interaction // withAttributes(method: 'post', path: '/api/v1/student', body: '{"id":22, "firstName":"vinod", "lastName":"komeershetty"}') withAttributes(method: 'post', path: '/api/v1/student') withBody { firstName 'vinod' lastName 'komeershetty' email '' } willRespondWith( // define the response we want returned status: 200, headers: ['Content-Type': 'application/json'] ) // body: "{\"id\":2,\"firstName\":\"vinod\",\"lastUpdated\":\"2020-04-15T12:24:31Z\",\"lastName\":\"komeershetty\"}" // body: "{\"id\":2,\"firstName\":\"vinod\",\"lastUpdated\":\"2020-04-15T12:24:31Z\",\"lastName\":\"komeershetty\"}" withBody { // id(integer) firstName("vinod") lastName("komeershetty") email('') } } // Execute the run method to have the mock server run. // It takes a closure to execute your requests and returns a PactVerificationResult. PactVerificationResult result = student_service.runTest { def client = new RESTClient('http://localhost:9000/') def alice_response = http://client.post(path: '/api/v1/student', body: '{"firstName":"vinod", "lastName":"komeershetty", "email":""}', requestContentType: 'application/json',) assert alice_response.status == 200 def data = alice_response.data assert data.firstName == "vinod" assert data.lastName == "komeershetty" // assert data.lastUpdated ==~ /\d{4}\-\d{2}\-\d{2}/ assert data.email == '' } assert result == PactVerificationResult.Ok.INSTANCE // This means it is all good } }```

komeershettyvinod
2020-07-24 06:31
This is my sample test

komeershettyvinod
2020-07-24 06:32
withBody here has few fields

komeershettyvinod
2020-07-24 06:32
but ideally it has lots more 300 fields say

komeershettyvinod
2020-07-24 06:34
But i do not want to keep all the with body in the test

komeershettyvinod
2020-07-24 06:34
instead i want to make it in .json file

komeershettyvinod
2020-07-24 06:34
is there a way pact accepts .json file

komeershettyvinod
2020-07-24 06:35
instead of whole body in test

matt.fellows
2020-07-24 06:40
I don?t know groovy sorry, but what your asking seems like a pretty basic question unrelated to Pact. Presumably you can create a separate groovy file that has the Pact matchers you need, which you can simply import that into your test

uglyog
2020-07-24 06:41
Or just load the JSON file

matt.fellows
2020-07-24 06:42
That wouldn?t allow you to create specific matchers though, right?

matt.fellows
2020-07-24 06:42
(assuming you needed them)

matt.fellows
2020-07-24 06:43
Just be aware - do you actuallly need _all_ of the response values or are you importing the values simply because that?s what the provider is returning? Make sure you only include what you actually need

komeershettyvinod
2020-07-24 06:49
No i need to verify all those fields coming from provider,

matt.fellows
2020-07-24 06:50
is your consumer using them? I note that you are using `http://client.post` (perhaps that?s just to get the test moving forward)

komeershettyvinod
2020-07-24 06:54
no its a get call, i just gave example

poojashree_gopal
2020-07-24 11:06
has joined #pact-jvm

giuseppe.salvatore
2020-07-24 11:07
Hi everyone... I know this is a long shot and I haven't seen this in the documentation but

giuseppe.salvatore
2020-07-24 11:07
does PACT support contracts between SOAP enpoints?

matt.fellows
2020-07-24 11:09
It supports XML matching, and is namespace aware - so you should be able to

matt.fellows
2020-07-24 11:09
That being said, I?m not sure where it?s documented

matt.fellows
2020-07-24 11:09
https://github.com/DiUS/pact-jvm/issues/243 gives a hint, so perhaps that helps?


giuseppe.salvatore
2020-07-24 12:06
Brilliant thanks very much @matt.fellows

sidhartha.k.subudhi
2020-07-24 16:57
has joined #pact-jvm

bzifkin
2020-07-24 18:38
has joined #pact-jvm

bzifkin
2020-07-24 19:07
Hi All, I'm a software engineer for a startup in Chicago, USA and im doing a pov on pact. Im having issues publish to my pact broker (even though i had it working yesterday :disappointed: )

bzifkin
2020-07-24 19:07
I've got my broker running in docker ```postgres: image: postgres ports: - "9191:9191" volumes: - /var/lib/postgresql/data environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: password POSTGRES_DB: postgres pact_broker: image: pactfoundation/pact-broker ports: - "9292:9292" depends_on: - postgres environment: PACT_BROKER_DATABASE_USERNAME: postgres PACT_BROKER_DATABASE_PASSWORD: password PACT_BROKER_DATABASE_HOST: postgres PACT_BROKER_DATABASE_NAME: postgres PACT_BROKER_PORT: "9292"```

bzifkin
2020-07-24 19:08
in my root build.gradle i bring in and apply the plugin and also have this block: ```pact { publish { //pactBrokerUrl = "http://pact.us-central1.stage.project44.com/" //local pact broker pactBrokerUrl = "http://localhost:9292" } }```

bzifkin
2020-07-24 19:09
in build.gradle where my pact test is i just have: ``` testImplementation group: 'au.com.dius.pact.consumer', name: 'java8', version: '4.1.0' testImplementation group: 'au.com.dius.pact.consumer', name: 'junit', version: '4.1.0' testImplementation group: 'au.com.dius.pact', name: 'provider', version: '4.1.0'```

bzifkin
2020-07-24 19:10
When i run the test it passes and i see a pact file generated, however it does not showup in `localhost:9292` as it was yesterday. There are no warnings or errors telling me what may have happened

bzifkin
2020-07-24 19:11
would anyone have any thoughts?

phil.endsley
2020-07-24 19:18
Are you running the publish task after your tests? The consumer tests will generate the pact files, but you need to run the publish task separately. Should be something like `gradlew pactPublish`

phil.endsley
2020-07-24 19:19
You might also need to specify `pactDirectory = 'the/path/to/pact/files'` inside the publish block?

bzifkin
2020-07-24 19:20
from my reading of the docs the pactUrl should be equivalent to pactDirectory

bzifkin
2020-07-24 19:20
one sec

phil.endsley
2020-07-24 19:21
Also, in your post in general, you mentioned your pact verify results. Are you trying to publish the pact files (consumer), or the verification results (provider)

bzifkin
2020-07-24 19:24
pact files, excuse me

bzifkin
2020-07-24 19:25
ah i got it! im such a doofus

bzifkin
2020-07-24 19:25
my `./gradlew pactPublish` wasnt running because i had undone a change to the script i was using to run the tests

phil.endsley
2020-07-24 19:25
:tada:

bzifkin
2020-07-24 19:26
i had been tearing my hair out trying to figure out what was different haha. Thanks @phil.endsley wouldnt have checked if you hadnt mentioned it

phil.endsley
2020-07-24 19:31
> i had been tearing my hair out trying to figure out what was different Been there more times that I'd like to admit :slightly_smiling_face:

scwang
2020-07-27 01:40
has joined #pact-jvm

scwang
2020-07-27 01:41
Hi Guys, when I am running target , I always got "Request Failed - Unrecognized SSL message, plaintext connection?" , How I can make a https request ? ```@RunWith(PactRunner.class) @Provider("CM API Provider") @PactUrl(urls = {"file:///C:\\Scott\\PactProvider\\GetCampaignsConsumer-CMAPIProvider.json"}) public class ProviderTest { @State("I have a List of Campaigns") // Method will be run before testing interactions that require "with-data" state public void setupCampaign() { System.out.println("get a List of Campaigns" ); } @TestTarget // Annotation denotes Target that will be used for tests public final Target target = new HttpTarget("https", "hosr", 80); // Out-of-the-box implementation of Target (for more information take a look at Test Target section) @Before public void before() { //initialize your mocks using your mocking framework } @TargetRequestFilter public void requestFilter(HttpRequest request) { }```

uglyog
2020-07-27 01:43
Use HttpsTarget

matt.fellows
2020-07-27 01:46
why does `HttpTarget` accept a protocol if there is an HttpTarget? or is that incorrect use of the class?

uglyog
2020-07-27 01:51
PRs are welcome to fix it. But `HttpsTarget` extends `HttpTarget` so you can provide a keystore

scwang
2020-07-27 03:42
I have got 301 redirect , how can I make provide to have auto redirect ?

uglyog
2020-07-27 03:44
It should follow redirects. You might have to raise an issue for that

scwang
2020-07-27 04:12
before I raise a issue , can you please help check if I am on the right track ?

scwang
2020-07-27 04:13
```@RunWith(PactRunner.class) @Provider("CM API Provider") @PactUrl(urls = {"file:///C:\\Scott\\PactProvider\\GetCampaignsConsumer-CMAPIProvider.json"}) public class ProviderTest { HashMap<String,String> headers ; @State("I have a List of Campaigns") // Method will be run before testing interactions that require "with-data" state public void setupCampaign() { CMLogin cmLogin = new CMLogin ("xx","xx","xx"); headers = cmLogin.login(); } @TestTarget // Annotation denotes Target that will be used for tests public final Target target = new HttpTarget("http", "hostname", 80); // Out-of-the-box implementation of Target (for more information take a look at Test Target section) @Before public void before() { //initialize your mocks using your mocking framework } @TargetRequestFilter public void requestFilter(HttpRequest request) { request.addHeader("API-XSRF-TOKEN", headers.get("API-XSRF-TOKEN")); } }```

matt.fellows
2020-07-27 04:15
Is the problem that your provider isn?t responding with a 301?

scwang
2020-07-27 04:16
No, I should got 200 OK but I always got 301

scwang
2020-07-27 04:16
I am wondering how can I set pact provider to auto redirect

matt.fellows
2020-07-27 04:18
Interesting

matt.fellows
2020-07-27 04:18
why is it `301` ing?

matt.fellows
2020-07-27 04:18
I haven?t actually thought too much about that use case. Should the `301` be part of the contract? I can see arguments either way

scwang
2020-07-27 04:19
there is a nginx in front of the server

matt.fellows
2020-07-27 04:19
oh, are you pointing at a local service or one deployed somewhere?

scwang
2020-07-27 04:19
```httpclient = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()).build(); HttpPost httpPost = new HttpPost(url);```

scwang
2020-07-27 04:19
this is what I did using my java client talk to the server

scwang
2020-07-27 04:20
I need to set setRedirectStrategy

matt.fellows
2020-07-27 04:20
gotcha

scwang
2020-07-27 04:20
any ideas ?

matt.fellows
2020-07-27 04:20
I mean, if you know the URL will always be 301'd, can you just update your consumer test to hit the right location?

matt.fellows
2020-07-27 04:21
but no, sorry (I don?t know the Java DSL very well). I suspect it?s the java verifier not following the redirect

matt.fellows
2020-07-27 04:21
perhaps there?s a way to configure that http client?

scwang
2020-07-27 04:21
my pure java client works but I as I said I need to setRedirectStrategy

scwang
2020-07-27 04:22
Yes , can you please let me know how can I set provider to auto redirect?

matt.fellows
2020-07-27 04:22
As I said, I?m not sure I was just guessing/hoping!

matt.fellows
2020-07-27 04:22
Let?s see what others think

scwang
2020-07-27 04:22
thanks

scwang
2020-07-27 04:23
should I raise a bug ?

matt.fellows
2020-07-27 04:23
but my main point was - can you not go back and update the consumer test to hit the correct URL rather than the 301 resource?

matt.fellows
2020-07-27 04:23
I mean, you now have to incur a 301 on every call - why not just update that side of the contract?

scwang
2020-07-27 04:25
I am sorry I got confused, my expected code should be 200 OK , I have no issues to use the url for functional tests

scwang
2020-07-27 04:26
the only thing I did is set http client to auto redirect , I am wondering if there is a way to set redirect in pact provider part

matt.fellows
2020-07-27 04:27
Now I?m confused. Can you please share the pact file?

matt.fellows
2020-07-27 04:30
Ron might have to step in here to clarify the verification behaviour. But your consumer test expects a 200. When the verifier runs, it goes of to hit (say) `/cm-api/clients/0A050891038CFAFC/mailings/bulk/draft`. That endpoint is returning a `301`. So it?s a different response code

matt.fellows
2020-07-27 04:30
Where is it redirecting you to?

scwang
2020-07-27 04:31
Yes , this path /cm-api/clients/0A050891038CFAFC/mailings/bulk/draft gives me 200OK

scwang
2020-07-27 04:31
api/clients/0A050891038CFAFC/mailings/bulk/draft gives me 301

matt.fellows
2020-07-27 04:31
ok, so where does it redirect you to?

matt.fellows
2020-07-27 04:32
That?s what should be in the contract in the first place

scwang
2020-07-27 04:32
Sorry I got confused, I thought when provider calls this URL it should give me 200 OK

scwang
2020-07-27 04:33
because I tried on chrome it gives me 200 OK

matt.fellows
2020-07-27 04:33
> api/clients/0A050891038CFAFC/mailings/bulk/draft gives me 301 then something else is wrong

matt.fellows
2020-07-27 04:33
you might need to look at your log files on the server and in your tests (turn on verbose/debug mode) and see what the request/response looks like

scwang
2020-07-27 04:34
it confuses me, it works on chrome dev tools

matt.fellows
2020-07-27 04:34
sure

matt.fellows
2020-07-27 04:34
there must be something different about the way the test is being setup and is causing a 301

matt.fellows
2020-07-27 04:34
maybe a header is missing etc.

matt.fellows
2020-07-27 04:35
are you the developer who manages that API? If not, might be worth a quick chat with whoever owns it to find out why it?s 301 ing

scwang
2020-07-27 04:35
cool, thanks

bruno
2020-07-27 10:18
has joined #pact-jvm

bzifkin
2020-07-27 18:24
hey all, I'm getting an error when trying to verify a pact

bzifkin
2020-07-27 18:24
I get this `Exactly one pact source should be set`

bzifkin
2020-07-27 18:25
this is my import and test class, very simple: ```import au.com.dius.pact.provider.junit.State; import au.com.dius.pact.provider.junit.target.HttpTarget; import au.com.dius.pact.provider.junit.target.Target; import au.com.dius.pact.provider.junit.target.TestTarget; import au.com.dius.pact.provider.junit.Provider; import au.com.dius.pact.provider.junitsupport.loader.PactBroker; import au.com.dius.pact.provider.spring.SpringRestPactRunner; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Import; @RunWith( SpringRestPactRunner.class ) @Provider( value = "capacity-provider-service" ) @PactBroker( host = "http://pact.us-central1.stage.xxxxx.com" ) @Import( { RibbonConfig.class, FeignClientConfig.class } ) public class CapacityProviderPactTest { // private static final String PORT = System.getenv( "CAPACITY-PROVIDER-SERVICE_TCP_9112" ); //3 @TestTarget public Target target = new HttpTarget( Integer.valueOf( PORT ) ); //4 @Autowired public CapacityProviderFeignClient capacityProviderFeignClient; //5 @State( "A request to find the capacity provider for a given id" ) public void prepareState() { } @Test public void runTest() { final CapacityProviderDto attributes = capacityProviderFeignClient.getCapacityProvider( 990029239L, 1L, 1L ); } }```

bzifkin
2020-07-27 18:25
in my build.gradle i have this ``` testImplementation group: 'au.com.dius.pact', name: 'provider', version: '4.1.0' testImplementation group: 'au.com.dius', name: 'pact-jvm-provider-spring_2.12', version: '3.5.19'```

bzifkin
2020-07-27 18:26
as far as i can tell from the docs the pactBroker annotation is the only place the source is specified so im not sure where its grabbing this second one

bzifkin
2020-07-27 20:24
is it possible that this a version issue?

bzifkin
2020-07-27 21:45
figured it out - i was importing unnecessary packages in my gradle and those brought in the wrong version of the models

uglyog
2020-07-27 23:01
@bzifkin please don't mix major versions of the pact jvm libs, they are not compatible (4.1.0 and 3.5.19)

bzifkin
2020-07-27 23:13
lesson learned haha, thank you

joaquin
2020-07-27 23:14
has joined #pact-jvm

pulgupta
2020-07-28 04:07
has joined #pact-jvm

guilherme.correa-ext
2020-07-28 22:54
has joined #pact-jvm

gcoradini
2020-07-28 22:55
has joined #pact-jvm

guilherme.correa-ext
2020-07-28 23:00
Hello i have one question regarding the publish results to pact io using java spring The scenario is i have on http://pact.io two consumers for my provider and each consumer have 2 tags wip and master i want to when i run the build in java pass a variable to tell if if have to get the pacts from the two consumers with tag that are on my parameter i try put this parameter on the PactBroker annotation on tags variable but when i run my build the application validate all tags from my consumers. My question is how can i get my provider to validate only the specific tag from all my consumers ?

uglyog
2020-07-28 23:11
How are you specifying the tag parameter? Also, are the pacts with the two tags the same?

guilherme.correa-ext
2020-07-28 23:14
```@PactBroker(scheme = "https", host = "${pactbroker.host}", authentication = @PactBrokerAuth(token = "${pactbroker.auth.token}"), tags = {"${pactbroker.tags}"})``` i have the consumer 1 with tag wip and master and a consumer 2 with tag wip and master the provider for both is my java application

uglyog
2020-07-28 23:16
And the tagged pacts, do they have different content? I.e., if I fetch the pact for wip tag and the pact for master tag, are they the same or different?

guilherme.correa-ext
2020-07-28 23:16
they are equal

uglyog
2020-07-28 23:16
Can you also let us know the versions of Pact-JVM you are using and the pact broker

guilherme.correa-ext
2020-07-28 23:18
```<dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-spring</artifactId> <version>4.0.10</version> </dependency>``` the pact jvm is the above and the pack broker is https://ab-inbev.pact.dius.com.au/

uglyog
2020-07-28 23:35
Can you try where the content is different? The broker links everything to pact file versions, so it may be returning all the tags that are linked to that version of the pact file.

guilherme.correa-ext
2020-07-28 23:36
the content of the pact are the same but the version for each tag is different

javier.molina
2020-07-29 08:43
has joined #pact-jvm

javier.molina
2020-07-29 09:08
Hello! I just https://stackoverflow.com/questions/63149128/how-to-verify-stringified-json-in-pact, and I hope some of you in here will be able to answer it. Thank you!

daniele.scillia
2020-07-29 09:34
has joined #pact-jvm

marco.dallagiacoma
2020-07-29 09:41
has joined #pact-jvm

jan.krejci
2020-07-29 12:29
has joined #pact-jvm

josue.boix
2020-07-29 13:32
Hello everybody! I?m struggling to create a contract for a POST with multi-part form data. I managed to do it in the past using `.withFileUpload` when having just a file. This time I have a file with a few other params, and I can?t find any good examples for such thing. Any ideas?

josue.boix
2020-07-29 14:27
I found this. I guess this feature is not yet supported: https://github.com/DiUS/pact-jvm/issues/668

phil.endsley
2020-07-30 01:40
I think it might already be working how you want it to. If you have pacts that are identical in content, your verification results are applied to all of those, because behind the scenes, they're the same. This is a feature of pact broker. Or, are you seeing each tag tested against in your build logs? I don't think that should be happening, because pact broker should de-duplicate any identical pacts when the provider fetches them for testing

ivan.lombardiborgia
2020-07-30 06:52
has joined #pact-jvm

fernando.martin
2020-07-30 11:39
Hey, @phil.endsley Thanks for you attention, @uglyog helped us and the behavior was exactly what you said about the identical content :slightly_smiling_face: Thanks, all!

matias.waterloo
2020-07-30 12:18
has joined #pact-jvm

amer.mohammed
2020-07-30 12:28
has joined #pact-jvm

amer.mohammed
2020-07-30 12:32
Hi there! I'm trying to verify the pact at producer end. I'm using JUnit5, Spring Boot and ```au.com.dius.pact.provider:junit5:4.1.6``` I've to add some authentication headers before the request is sent. I've got to know that TargetRequestFilter is the way to achieve it. But when I tried this, the request still missing the headers I'm trying to add. I have asked this on here - https://stackoverflow.com/questions/63118545/pact-jvm-provider-junit5-spring-unable-to-add-authorization-headers Can you please point out what I'm doing wrong? Thanks!

matias.waterloo
2020-07-30 19:43
Hi! I have a question regarding junit provider tests and WIP pacts. Is it possible to configure the test to validate against the latest version of a given fix tag and any WIP pacts (doesn?t matter the tag)? I tried the next example but it didn?t work. The broker has a WIP pact (created today) with tag feat-x and I?m trying to run the provider test with this config ```pactbroker.tags = "develop" pactbroker.enablePending = true pactbroker.providerTags = feat-x pactbroker.includeWipPactsSince = "2020-07-01" (since last month)``` Any ideas how to make this work? is it possible? Thanks!

phil.endsley
2020-07-30 19:53
Yes, this is possible. The only thing that looks suspicious is the `pactbroker.providerTags = feat-x` line. `pactbroker.providerTags` should be set to the tag(s) of the current provider branch that is being built. Based on what you have above, this would mean the branch you're running on the provider side is tagged with `feat-x`. In order for WIP Pacts to be picked up by your provider tests, Pact Broker must have at least one version with the given provider tag already published. If the `feat-x` does not exist for your provider in Pact Broker, it will not pick up any WIP pacts.


matias.waterloo
2020-07-30 21:13
I could make it work. Thanks!!

amer.mohammed
2020-07-31 07:11
It worked! :smile: Many thanks Phil!

bruno.penha
2020-08-03 08:21
has joined #pact-jvm


bzifkin
2020-08-03 21:07
I'm having issues publishing to the pact broker when the verification actually runs....however if creating provider state fails then the results are published

bzifkin
2020-08-03 21:08
i put a breakpoint in InteractionRunner.java where it checks to see if publishing is enabled and when i break method that creates the provider state (adding a field to the object that should be null) then its set to publish the results

bzifkin
2020-08-03 21:08
But when the provider state method works (field is actually null) it is somehow not enabled anymore

bzifkin
2020-08-03 21:08
i have tried to set it w/ this in the gradle command line args `-Dpact.verifier.publishResults=true`

bzifkin
2020-08-03 21:09
also in other places that properties can be set, but no luck.....makes no sense that it would be set in one and not the other though. Please let me know if you have any insite

uglyog
2020-08-03 23:08
What version of Pact-JVM are you using?

uglyog
2020-08-03 23:09
For Gradle, you need to use `-P` not `-D`

scwang
2020-08-04 05:33
Hi, I am wondering , does pact provider side support custom verification, we do not want to everything in the contract. is there anyway to do customized verification ?

matt.fellows
2020-08-04 05:39
what do you mean, sorry?

scwang
2020-08-04 05:55
I am wondering if I can control the provider verification ?

scwang
2020-08-04 05:56
in our contract there are some fields which are constantly changed (like timestamp ), I am wondering if there is a way to ignore these field

antonello
2020-08-04 06:07
I think you need to consider using matchers in order to verify certain fields by type rather than by value. Have a look here https://docs.pact.io/getting_started/matching/

scwang
2020-08-04 06:09
thanks

matt.fellows
2020-08-04 06:31
> in our contract there are some fields which are constantly changed (like timestamp ), I am wondering if there is a way to ignore these field ignoring a field is definitely a smell. If your consumer needs a field, then ignoring it is a recipe for disaster and removes the value of Pact tests in the first place.

matt.fellows
2020-08-04 06:32
But as Anto points out, matchers will make this less painful

ukrainian1991
2020-08-04 07:03
Hi, could you please point me to the docs or examples of using Pact Matchers. I have checked the official docs (https://docs.pact.io/implementation_guides/jvm/matching) and it's hard to understand) I have a huge request and it has one variable. I need to match this request for stubbing. Maybe someone has useful links. Thanks


matt.fellows
2020-08-04 07:09
perhaps if you could share a code example

ukrainian1991
2020-08-04 07:18
```.uponReceiving("request generate full profile") .path("/cpe/generate_profile/200") .method("POST") .headers(headersRequest) .body(Resources().getContent("request/generate_profile_full.json")) .willRespondWith() .status(200) .headers(headersResponse) .body(Resources().getContent("response/generate_profile_full.json")) .toPact()``` request/generate_profile_full.json raw json where in "ports info" i have one non static id

ukrainian1991
2020-08-04 07:19
As you can see "profile_data" is a huge key-value array. But it static

ukrainian1991
2020-08-04 07:24
code is on Kotlin

scwang
2020-08-04 08:21
thanks

ukrainian1991
2020-08-04 12:09
Please help with minArrayLike case. Koltin, pact-jvm 4.1.6. I want to match a json request with 13000 items in array. I use the following ``` newJsonObject { stringValue("api_version", "v1") minArrayLike("profile_data", 13191) { stringType("value", "60") stringType("name", "account.35.max_time") } ...``` Test fails with BodyMismatch ```BodyMismatch: Expected form post parameter '{"name":"account.35.reg_failed_retry_max_time","profile_data":[{},{},{},{}...{},{},{},{},{}],"api_version":"v1","value":"60"}' but was missing```

ukrainian1991
2020-08-04 12:10
Here is the raw json ```{ "api_version": "v1", "profile_data": [ { "value": "0", "name": "account.9.timeout_fwd.enable" }, { "value": "0", "name": "account.95.nat.rport" } ... ] }```

william.isaksson795
2020-08-04 13:15
has joined #pact-jvm

bzifkin
2020-08-04 14:23
Yes i tried it w/ that as well

bzifkin
2020-08-04 14:24
```testImplementation group: 'au.com.dius', name: 'pact-jvm-provider-spring_2.12', version: '3.5.23'```

bzifkin
2020-08-04 19:06
hey everyone, still trying to get my provider to publish verification results to the broker. Before was trying to do via running the tests, wasnt working, even when i had `-Ppact.verifier.publishResults=true` set in various places. Now trying to do it w/ the plain old `./graldew pactVerify` but running into issues there as well

bzifkin
2020-08-04 19:08
```pact { serviceProviders { "p44-capacity-provider-service" { protocol = 'http' host = 'http://pact.us-central1.stage.project44.com/' port = 80 path = '/' hasPactWith('carrier-service') { // currently supports a file path using file() or a URL using url() pactSource = url('http://pact.us-central1.stage.xxxxxx.com/pacts/provider/p44-capacity-provider-service/consumer/carrier-service/latest') } } } }```

bzifkin
2020-08-04 19:10
suspect im using the wrong url....it should be pointing to the contract itself correct?

bzifkin
2020-08-04 19:11
that url puts me here:

bzifkin
2020-08-04 19:12
i think its the wrong url because of the complaint it gives me: ```1) Verifying a pact between carrier-service and p44-capacity-provider-service - A request to find the capacity provider for a given id Given Find a Capacity Provider 1.1) StatusMismatch: expected status of 200 but was 404 1.2) HeaderMismatch: Expected 'application/hal+json' to match 'application/json(;\s?charset=[\w\-]+)?' 1.3) BodyTypeMismatch: Expected a response type of 'application/json' but the actual type was 'application/hal+json'``` I've tried a bunch of other urls but those dont really get me anywhere either

bzifkin
2020-08-04 21:18
============ ok switching gears a bit =============

bzifkin
2020-08-04 21:20
whats the benefit of using the gradle plugin vs the junit/spring plugin to verify pacts?

bzifkin
2020-08-04 21:22
does one offer more flexibility than the other? slash would one be better suited to use in a CI/CD pipeline? my thought is that the gradle plugin would be better but im not sure

francis.lobo
2020-08-04 22:48
has joined #pact-jvm

uglyog
2020-08-04 22:55
That is a lot of items. Is there a reason you are testing that with Pact and not a unit test?

uglyog
2020-08-04 22:58
@bzifkin for unit tests, you need the system property set for the unit test process. The `-P` parameter sets the value for the Gradle process, but when the tests are run. Gradle will start a new JVM process to run the tests. You need to apply the system property on the test task.

uglyog
2020-08-04 23:00
Different people have different options on this. With unit tests you have more control, and can easily mock out other collaborators in the test.

francis.lobo
2020-08-05 06:11
Hello folks, I am quite new to JVM/gradle world I am trying to debug a issue when running pact provider tests. Is there a way to make the logging a bit verbose (like DEBUG or INFO)? I just can't figure out how to do it in Gradle world. I couldn't find anything related to this in the Pact docs either

uglyog
2020-08-05 06:26
For Gradle tasks, `-d` option sets debug level logging, and `-i` info level

uglyog
2020-08-05 06:26
If you are using JUnit tests, you will need to configure SLF4J to set the log level

ukrainian1991
2020-08-05 06:30
Our monolithic app sends request to our microservice. So I want to verify contract. Huge request contains list of parameters. Based on these parameters microservice generates profile and return it in response.

uglyog
2020-08-05 06:36
But why do you need to test with 13000 items? Won't they be all the same? The idea with Pact tests is to test the shape of things are correct. You're using `minArrayLike`, which will check all the values from the provider match the example value. So you really only need one in your consumer test.

ukrainian1991
2020-08-05 06:37
Maybe you could give me an advice how to workaroud this. For example? Is it possible to specify part of the body as raw Json (fille) - list of params. And the part with variables as matchers

uglyog
2020-08-05 06:40
No, the DSL doesn't have anything like that

ukrainian1991
2020-08-05 06:41
In fact, all 13000 parameters are unique and I want just one test and check contract based on full profile generation

ukrainian1991
2020-08-05 06:41
Seems the only way is template strings for raw json with variables substitution

uglyog
2020-08-05 06:42
This doesn't feel like a thing to use Pact for. Something like JSON Schema might be a better option.

ukrainian1991
2020-08-05 06:50
I've thought about schema... But I found PACT more applicable to this workflow. Maybe I end up with json schema) Thanks for your time

tim.den.dulk
2020-08-05 08:07
has joined #pact-jvm

uladzislau_danilchyk
2020-08-05 14:09
@uglyog I have found following solution. You can define method with `@PostConstruct` and inside of it create `HttpTarget` instance.

bzifkin
2020-08-05 17:41
yeah, i realized i had to set it in the test gradle block....i used the intellij runner for the gradle task which allows you to add properties for the gralde process, which i thought would be the same but it isnt :confused:

bzifkin
2020-08-05 17:41
thank you, good to know

bzifkin
2020-08-05 17:45
it seemed like it may be easier to do the versioning stuff for the provider through the gradle plugin but maybe not

francis.lobo
2020-08-05 21:09
thanks @uglyog

matt.fellows
2020-08-06 11:40
Mike just so we?re clear

matt.fellows
2020-08-06 11:41
if the shape of the data is the same (i.e. it?s always a `name` and `value` ) then Pact is best suited to saying ?for this list of items, do they all have those two properties and are they the correct type - such as a string or a number?. If you need to check specific values for 13,000 items, this is a bit more of a functional test which Pact is not designed for

matt.fellows
2020-08-06 11:42
Pact is trying to catch issues where a structural change in an API will break one of the API collaborators

matt.fellows
2020-08-06 11:42
Looking at the example you shared, there?s no reason why you couldn?t use Pact for it at all

matt.fellows
2020-08-06 11:42
?but if you can reduce the data it validates it will probably be helpful in making the test suites run faster!

aditi.puri
2020-08-07 05:42
@aditi.puri has left the channel

ranjanayush03
2020-08-07 08:43
This is my Jenkins log

ranjanayush03
2020-08-07 08:43
Unable to run the command ./gradlew pactVerify in the Jenkins step

ranjanayush03
2020-08-07 08:45
Actually the service needs to be up for running the test cases but I tried providing it as a part of integration test like this .

ranjanayush03
2020-08-07 08:45
I am providing the @springboottest annotation also..

abubics
2020-08-07 08:46
Pretty sure `gradle` ran fine. A warning says "there is no stateChange URL".

abubics
2020-08-07 08:47
And connection refused

abubics
2020-08-07 08:48
Could I suggest not taking photos of the screen, but copying & pasting your logs and/or code into code blocks or snippets?

ranjanayush03
2020-08-07 08:48
Yup I guess so I tried running ./gradlew pactVerify command.. in the build stages. But the issue I think that I have not started the server..

ranjanayush03
2020-08-07 08:49
From next time I will keep that in mind..

abubics
2020-08-07 08:51
There are code samples to help you start up and shut down the provider using gradle, if that's what you need. You shouldn't have to manually start & stop a separate process by hand :)

ranjanayush03
2020-08-07 08:52
The startproviderTask and terminateProvidertask

ranjanayush03
2020-08-07 08:52
I was going through the documents I saw these two steps to run..

ranjanayush03
2020-08-07 08:56
Is this the one you are talking about ?

abubics
2020-08-07 09:08
that's right :slightly_smiling_face:

abubics
2020-08-07 09:08
I feel like the annotations you're using in the provider code shouldn't need the gradle integration, though

abubics
2020-08-07 09:09
I always use gradle, and no annotations, so I can't really help you beyond this amount of hinting :pray:

sidhartha.k.subudhi
2020-08-10 14:17
I am getting "PactMismatchesException" error. Need help in this. here is the code: ```public class Post_AddPetType { private final String PROVIDER = "pet_petType_provider"; private final String CONSUMER = "pet_petType_consumer"; @Rule public PactProviderRuleMk2 mockProvider = new PactProviderRuleMk2(PROVIDER, "localhost", 8081, this); @Pact(provider=PROVIDER, consumer=CONSUMER) public RequestResponsePact addPetType(PactDslWithProvider builder) { return ConsumerPactBuilder .consumer(CONSUMER) .hasPactWith(PROVIDER) .uponReceiving("a POST request to create a pet type.") .path(String.format(Constants.PETTYPE))// GET http://localhost:9966/petclinic/api/pettypes .method("POST") .willRespondWith() .status(200) .matchHeader("Content-Type", "application/json; [Cc]harset=UTF-8") //; [Cc]harset=UTF-8 // .body(new PactDslJsonBody() //// .object() // .integerType("id",8) // .stringValue("name", "Hatch") // .closeObject()) .body("{\n" + " \"id\": 8,\n" + " \"name\": \"Hatch1\"\n" + "}") .toPact(); } @Test @PactVerification(value=PROVIDER, fragment = "addPetType") public void shouldBeAbleToAddPetType() { given() .baseUri("http://localhost:8081") .header("Content-Type", "application/json; [Cc]harset=UTF-8") // .header("Accept-Encoding","gzip, deflate, br") // .pathParam("id",8) .body("{\n" + "\"id\": 8,\n" + "\"name\": \"Hatch1\"\n" + "}") .post("/petclinic/api/pettypes") .then() .assertThat() .statusCode(200); } }```

sidhartha.k.subudhi
2020-08-10 14:17
Error message is: java.lang.AssertionError: Pact Test function failed with an exception, possibly due to Mismatches(mismatches=[UnexpectedRequest(request= method: POST path: /petclinic/api/pettypes query: [:] headers: [Accept-encoding:[gzip,deflate], Accept:[*/*], Connection:[Keep-Alive], Host:[localhost:8081], User-agent:[Apache-HttpClient/4.5.5 (Java/1.8.0_144)], Content-type:[text/plain; charset=ISO-8859-1], Content-length:[29]] matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: PRESENT({ "id": 8, "name": "Hatch1" }))]) at http://au.com.dius.pact.consumer.junit.JUnitTestSupport.validateMockServerResult(JUnitTestSupport.kt:54) at http://au.com.dius.pact.consumer.BaseProviderRule.validateResult(BaseProviderRule.java:175) at http://au.com.dius.pact.consumer.BaseProviderRule$1.evaluate(BaseProviderRule.java:80) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53) Caused by: java.lang.AssertionError: 1 expectation failed. Expected status code <201> but was <500>. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:80) at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:74) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:237) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:249) at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure.validate(ResponseSpecificationImpl.groovy:494) at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure$validate$1.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127) at io.restassured.internal.ResponseSpecificationImpl.validateResponseIfRequired(ResponseSpecificationImpl.groovy:656) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:190) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:58) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:156) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:168) at io.restassured.internal.ResponseSpecificationImpl.statusCode(ResponseSpecificationImpl.groovy:125) at io.restassured.specification.ResponseSpecification$statusCode$0.callCurrent(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:156) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:168) at io.restassured.internal.ResponseSpecificationImpl.statusCode(ResponseSpecificationImpl.groovy:133) at io.restassured.internal.ValidatableResponseOptionsImpl.statusCode(ValidatableResponseOptionsImpl.java:119) at com.sap.icn.mlp.consumer.petClinic.Post_AddPetType.shouldBeAbleToAddPetType(Post_AddPetType.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at http://au.com.dius.pact.consumer.BaseProviderRule.lambda$runPactTest$2(BaseProviderRule.java:161) at http://au.com.dius.pact.consumer.BaseMockServer.runAndWritePact(MockHttpServer.kt:181) at http://au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest(ConsumerPactRunner.kt:13) at http://au.com.dius.pact.consumer.BaseProviderRule.runPactTest(BaseProviderRule.java:159) at http://au.com.dius.pact.consumer.BaseProviderRule.access$100(BaseProviderRule.java:23) at http://au.com.dius.pact.consumer.BaseProviderRule$1.evaluate(BaseProviderRule.java:79) ... 15 more Picked up JAVA_TOOL_OPTIONS: -Djava.vendor="New Oracle" Process finished with exit code -1

joao
2020-08-10 15:48
On @Pact, you are defining the body as a response, not as an expected request; whereas on the @Test you sending a JSON body on the request.

bzifkin
2020-08-10 16:27
hey all - all of our provider projects are spring boot and dockerized, even so some of them take upwards of 10 minutes to build

bzifkin
2020-08-10 16:29
Right now the verification tests are in the integration tests module, meaning the full docker image gets built and run....I was thinking about just making a separate module that just has the db in the docker image since that would speed stuff up a bit

bzifkin
2020-08-10 16:29
I was curious if others had had this issue and what they did to solve it

wesleythomaswilliams
2020-08-10 21:32
@bzifkin All of our tests run at the unit test phase of our build so they're one of the first things to run.

bzifkin
2020-08-10 21:34
thanks @wesleythomaswilliams...does the app have to build at that time?

wesleythomaswilliams
2020-08-10 21:37
Yeah, we haven't separated the tests out into a separate jenkins job or anything, so they're part of a full build of the provider service. We have connectivity issues preventing us from having consumer builds trigger provider builds right now, so speed of verification isn't a priority right now. If/when the connectivity issue is solved, then I might look to separate it.

bzifkin
2020-08-10 21:53
ok gotcha, yeah we're pretty early in our implementation as well, a lot of our consumers have multiple providers....looks like we're just gonna have to be ok w/ the fact that stage of the pipeline will only be as fast as the slowest provider

scwang
2020-08-11 00:54
Hey I am wondering how to verify a dynamic json key in pact ?

matt.fellows
2020-08-11 00:56
Ah, that?s a good question. I?m not sure if JVM supports it or not, but this issue is relevant: https://github.com/pact-foundation/pact-specification/issues/47


scwang
2020-08-11 00:58
Ye, I have looked trough the this and tried workaround but it does not work for me , do you have any idea on how can I develop a workaround for the issue ?

matt.fellows
2020-08-11 00:58
I don?t, sorry

scwang
2020-08-11 00:59
let me check, thanks

scwang
2020-08-11 01:03
does js pact support this ?

matt.fellows
2020-08-11 01:18
no it doesn?t

scwang
2020-08-11 04:54
I am wondering are you going to add the feature for V4 ?

matt.fellows
2020-08-11 05:08
that?s the plan

scwang
2020-08-11 05:19
Thanks a lot

matt.fellows
2020-08-11 05:31
Also, if you need it, please vote on the issue. It helps us prioritise

vit.barabash
2020-08-11 06:52
has joined #pact-jvm

ivangsa
2020-08-11 08:51
Hi, versions 4.1.x for pact-jvm-provider-maven are published to maven-central? I can only find up to version 4.0.10.... We would like to use functionality from this PR https://github.com/DiUS/pact-jvm/pull/1135 which is posterior..

rafael.espillaque
2020-08-11 09:25
the groupId and artifactId changed, look for: ```<groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.1.6</version>```

francislainy.campos
2020-08-11 14:04
Hi, sorry for the simple question but struggling to find a sample on how to set a contract with specific params sent to a POST api? Most samples I see all use GET with no need for this so a bit stuck at the moment.

francislainy.campos
2020-08-11 14:05
Will open a thread with what I have so far. Thank you.

francislainy.campos
2020-08-11 14:06
```@ExtendWith(PactConsumerTestExt.class) public class PACTConsumerEdUiCrsTest { Map<String, String> headers = new HashMap<>(); String getRecommendations = "/api/v1/getRecommendations"; @Pact(provider = "CRS-SERVICE", consumer = "Ed UI") public RequestResponsePact createPact(PactDslWithProvider builder) { headers.put("Content-Type", "application/json"); .maxArrayLike("skills", 1) .stringType("id", "7810fb5f-a45d-41af-baeb-ac08dd10546b") .stringType("title", "Read Words with Consonant \\\"r\\\" /r/") .stringType("skillRecommendationReason", "Progressing: this student is progressing towards proficiency with the following standards and will benefit from additional instructions and practice.") .array("students") .closeArray() .eachLike("contentRecommendations") .stringType("identifier", "l_479ac4a4-6fc3-4323-9609-ca614c672016_ac54bcae-235c-4d50-a5d8-bca2767dabe7") .decimalType("score", 1.2450236288128311) .array("contentRecommendationReason") .string("The next items in the TOC matching the skill") .closeArray() .closeArray() .closeArray(); return builder .uponReceiving("getRecommendations") .path(getRecommendations) .method("POST") .headers(headers) .body("{\"hello\": \"harry\"}") .willRespondWith() .status(200) .body(body) .toPact(); } @Test @PactTestFor(providerName = "CRS-SERVICE", port = "8080") public void runTest() { //Mock url RestAssured.baseURI = "http://localhost:8080"; Response response = RestAssured .given() .headers(headers) .when() .post(getRecommendations); assert (response.getStatusCode() == 200); } }```

francislainy.campos
2020-08-11 14:07
And need to set this as for the params to have a valid request.

francislainy.campos
2020-08-11 14:07
``` {"discipline": "ED18_RLA","programs": ["ELA_IR_G1_NA"], "sectionId": "357e6a22-ea67-458f-8d1a-7e15ec8d4cce" }```

francislainy.campos
2020-08-11 14:15
Ah, nevermind. Thanks. I think I figured out what I was missing. It seems I need to give the params both here ```return builder .uponReceiving("getRecommendations") .path(getRecommendations) .method("POST") .headers(headers) .body(" { \"discipline\": \"ED18_RLA\", \"programs\": [\"ELA_IR_G1_NA\"], \"sectionId\": \"357e6a22-ea67-458f-8d1a-7e15ec8d4cce\" }") .willRespondWith() .status(200) .body(body) .toPact();```

francislainy.campos
2020-08-11 14:15
And here

francislainy.campos
2020-08-11 14:15
```Response response = RestAssured .given() .headers(headers) .when() .body(" { \"discipline\": \"ED18_RLA\", \"programs\": [\"ELA_IR_G1_NA\"], \"sectionId\": \"357e6a22-ea67-458f-8d1a-7e15ec8d4cce\" }") .post(getRecommendations);```

francislainy.campos
2020-08-12 07:15
Hi, good morning. Sorry, me again. I have this json response that starts with an array rather than an object. However, my contract gets generated with two square brackets rather than only the one for the root. Tried a few combinations using either object or array but they're all failing on me if I can get some help to see what I'm missing please. Thanks very much. ```DslPart body = new PactDslJsonArray() .maxArrayLike(1) .stringType("studentId", "1cd1bfa6-87a7-4bea-8025-fb7cd159f1fb") .eachLike("skills", 2) .stringType("id", "544c07c1-75b4-4a9b-b6fe-50f5a0708457") .stringType("name", "") .booleanType("primary", true) .closeArray() .closeArray();``` This is what I've been getting for my contract. ```"body": [ [ { "studentId": "1cd1bfa6-87a7-4bea-8025-fb7cd159f1fb", "skills": [ { "name": "", "id": "544c07c1-75b4-4a9b-b6fe-50f5a0708457", "primary": true }, { "name": "", "id": "544c07c1-75b4-4a9b-b6fe-50f5a0708457", "primary": true } ] } ] ],```

uglyog
2020-08-12 07:24
`new PactDslJsonArray()` creates a new array, and then `.maxArrayLike(1)` adds a new array as the first item

francislainy.campos
2020-08-12 07:25
Hi uglyog, thanks for reaching out. Yes, however, if I remove the .maxArray piece it complains to me on the next line and it won't compile.

uglyog
2020-08-12 07:25
Use `PactDslJsonArray.arrayMaxLike(1)` (static method)

uglyog
2020-08-12 07:26
That just creates a new array

uglyog
2020-08-12 07:27
But, with `.maxArrayLike(1)` removed it should work

uglyog
2020-08-12 07:28
```DslPart body = new PactDslJsonArray() .stringType("1cd1bfa6-87a7-4bea-8025-fb7cd159f1fb") .eachLike("skills", 2) .stringType("id", "544c07c1-75b4-4a9b-b6fe-50f5a0708457") .stringType("name", "") .booleanType("primary", true) .closeArray();```

francislainy.campos
2020-08-12 07:29
Thanks. Sure. Let me try it here.

uglyog
2020-08-12 07:29
Use the static method, it will do what you want

francislainy.campos
2020-08-12 07:32
Maybe I need to sit on this a bit more but now it's giving me a null error.

francislainy.campos
2020-08-12 07:33
When I try this instead.

francislainy.campos
2020-08-12 07:33
```DslPart body = new PactDslJsonArray() .stringType("1cd1bfa6-87a7-4bea-8025-fb7cd159f1fb") .eachLike("skills", 2) .stringType("id", "544c07c1-75b4-4a9b-b6fe-50f5a0708457") .stringType("name", "") .booleanType("primary", true) .closeArray();```

francislainy.campos
2020-08-12 07:33
It gives me this different message.

francislainy.campos
2020-08-12 07:35
And if I change to my studentId key I get this.

francislainy.campos
2020-08-12 07:36
And without the studentId key and using empty eachlike it compiles but the contract would be missing this key.

francislainy.campos
2020-08-12 07:40
```import au.com.dius.pact.consumer.dsl.*; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; import au.com.dius.pact.core.model.RequestResponsePact; import au.com.dius.pact.core.model.annotations.Pact; import io.restassured.RestAssured; import io.restassured.response.Response; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import java.util.HashMap; import java.util.Map; @ExtendWith(PactConsumerTestExt.class) public class PACTConsumerCrsSgmTest { Map<String, String> headers = new HashMap<>(); String recommendedSkills = "/recommendedSkills"; @Pact(provider = "SGM", consumer = "CRS-SERVICE") public RequestResponsePact createPact(PactDslWithProvider builder) { headers.put("Content-Type", "application/json"); // DslPart body = PactDslJsonArray.arrayMaxLike(1) //// .maxArrayLike(1) // .stringType("studentId", "1cd1bfa6-87a7-4bea-8025-fb7cd159f1fb") // .eachLike("skills", 2) // .stringType("id", "544c07c1-75b4-4a9b-b6fe-50f5a0708457") // .stringType("name", "") // .booleanType("primary", true) // .closeArray() // .closeArray(); DslPart body2 = new PactDslJsonArray() .maxArrayLike(1) .stringType( "studentId", "1cd1bfa6-87a7-4bea-8025-fb7cd159f1fb") .eachLike("skills", 2) .stringType("id", "544c07c1-75b4-4a9b-b6fe-50f5a0708457") .stringType("name", "") .booleanType("primary", true) .closeArray(); return builder .uponReceiving("recommendedSkills") .path(recommendedSkills) .method("POST") .headers(headers) .body("{ \"disciplineCode\": \"ED18_RLA\", \"studentIds\": [\"1cd1bfa6-87a7-4bea-8025-fb7cd159f1fb\"]}") .willRespondWith() .status(200) .body(body2) .toPact(); } @Test @PactTestFor(providerName = "SGM", port = "8080") public void runTest() { //Mock url RestAssured.baseURI = "http://localhost:8080"; Response response = RestAssured .given() .headers(headers) .when() .body("{ \"disciplineCode\": \"ED18_RLA\", \"studentIds\": [\"1cd1bfa6-87a7-4bea-8025-fb7cd159f1fb\"]}") .post(recommendedSkills); assert (response.getStatusCode() == 200); } }```

francislainy.campos
2020-08-12 07:40
This is my whole file as of now.

francislainy.campos
2020-08-12 07:41
This piece worked. ```DslPart body = PactDslJsonArray.arrayMaxLike(1) .stringType("studentId", "1cd1bfa6-87a7-4bea-8025-fb7cd159f1fb") .eachLike("skills", 2) .stringType("id", "544c07c1-75b4-4a9b-b6fe-50f5a0708457") .stringType("name", "") .booleanType("primary", true) .closeArray();```

francislainy.campos
2020-08-12 07:42
Had to remove the second closeArray that was there.

francislainy.campos
2020-08-12 07:42
Thanks a lot @uglyog. Your help is greatly appreciated. Have a lovely day.

amer.mohammed
2020-08-12 09:09
Hello, I'm going through the GitHub documentation and some of the issues reported. I've noticed that they have some broken links to the examples under discussion, like the one mentioned below. Can you please let me know if the examples are gone from the repository or renamed or the path is changed? Thanks! https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-junit#example-of-amqp-message-test


javier.molina
2020-08-13 13:04
Hi, I?m following the instructions from https://docs.pact.io/implementation_guides/jvm/provider/maven/ to perform provider verification, but i have the requirement of publishing mutiple tags. As far as I can see, it only supports `-Dpact.provider.tag` variable, and this is only for a single value. Can I do something to add more than one tag? Thank you!

uglyog
2020-08-13 22:50
Can you raise an issue for that at the Github project

javier.molina
2020-08-14 06:33
:ok_hand:

ivangsa
2020-08-14 07:09
Hi, using PactProviderRule with junit... after upgrading from version 4.0.5 to version 4.1.7 *mockServer is null and not started* anymore... I'm missing something on this upgrade or shall investigate this as a bug?

andrea.spina
2020-08-14 07:36
has joined #pact-jvm

ivangsa
2020-08-14 07:58
sorry, it's ok... a typo slid through on provider name doing some quick test

amer.mohammed
2020-08-14 08:03
Thanks!

ukrainian1991
2020-08-14 11:54
@matt.fellows Thanks for your response. I've read and watched a lot for pact and json schema approaches. I agree that checking exact values an overhead for contract testing, but in my case all these parameters are static(dictionary). Want to try it out how it would work in a strict manner

matt.fellows
2020-08-14 13:19
We can't stop you :wink:

tom.wilson
2020-08-14 19:20
has joined #pact-jvm

ziadtawfeek05
2020-08-17 08:16
has joined #pact-jvm

tomas.bruhn
2020-08-17 13:33
has joined #pact-jvm

tomas.bruhn
2020-08-17 13:42
Hi, is it possible to specify the identity of a queue when writing message pacts? Basically the client stating which queue should receive the message so the provider knows where to produce the message.

bzifkin
2020-08-17 20:56
is it possible to set tags/versions of consumers when running `pactPublish` in the gradle plugin? I know pactVerify has all of those arguments like `-Ppact.provider.version` but those dont seem to work on ./gradlew pactPublish

bzifkin
2020-08-17 20:56
ive been able to get consumer versions to work by putting it in the pact publish closure though

bzifkin
2020-08-17 20:58
```pact { publish { providerVersion = getCommitSha() //tags = ['tags'] pactBrokerUrl = "http://localhost:9292" }``` but when i have tags in there like that i get this message `Link 'pb:pacticipant-version-tag' was not found in the response`

jarmy
2020-08-17 21:00
I?m able to do this with the following ``` publish { tags = [project.git.branchName] // https://docs.pact.io/getting_started/versioning_in_the_pact_broker // overrides the project.version def gitSha = "git rev-parse --short HEAD".execute().text.trim() version = gitSha }```

bzifkin
2020-08-17 21:01
yeah thats more or less what i have... and that works when you do `./gradlew pactPublish` ?


bzifkin
2020-08-17 21:02
interesting

bzifkin
2020-08-17 21:04
we must be using different versions because if i switch providerVersion to version it doesnt work for me....what version are you on in your consumer?

bzifkin
2020-08-17 21:04
```plugins { id 'au.com.dius.pact' version '4.1.6' apply false }``` ```apply plugin: 'au.com.dius.pact'```

bzifkin
2020-08-17 21:05
thats at my root build.gradle

phil.endsley
2020-08-17 21:08
Yeah, we do the same. ```pact { publish { pactDirectory = 'pact/dir' pactBrokerUrl = 'https://pactbroker/' tags = [project.gitBranch] providerVersion = "${project.version}-${gitRevision}" } }``` Using classpath 'au.com.dius.pact.provider:gradle:4.1.6'

jarmy
2020-08-17 21:08
`classpath "gradle.plugin.au.com.dius:pact-jvm-provider-gradle:4.0.10"`

bzifkin
2020-08-17 21:11
oh weird

bzifkin
2020-08-17 21:12
if i switch my pactBrokerUrl from the hosted one to the one at `localhost:9292` it works

phil.endsley
2020-08-17 21:12
Difference in version of hosted vs local pact broker maybe?

bzifkin
2020-08-17 21:12
must be hosting a different version

bzifkin
2020-08-17 21:12
yeah think so

matt.fellows
2020-08-17 21:15
Yes, you can add metadata to a message pact


matt.fellows
2020-08-17 21:16
When you say hosted do you mean Pactflow or your own?

bzifkin
2020-08-17 21:17
our own

matt.fellows
2020-08-17 21:17
You can check the hosted version by looking at the response headers

matt.fellows
2020-08-17 21:17
Ahh

matt.fellows
2020-08-17 21:17
There should be a git sha you can use to see how old it is

bzifkin
2020-08-17 21:18
gotcha thank you...ill talks to our devops people about updating the hosted instance

bzifkin
2020-08-17 21:19
okie doke well now that ive got that figured out that leads me to another question. Since it looks like `pactPublish` only takes in arguments from the closure rather than cli properties how would i set a tag on a deploy to an env name? Basically once a consumer has been verified we want to deploy it qa or test or prod

bzifkin
2020-08-17 21:22
the situation being this - a consumer branch is pushed, our build runs pactPublish and we take the branch name and commit sha from the closure. Then the build run continues and the contract is verfied, at that point the consumer is deployed to lets say `test` ....i wouldnt be able to use pactPublish to tag it here correct? The pact broker cli would be my only way correct?

jarmy
2020-08-17 21:24
The pact-broker cli would be able to handle this ``` stage('Prod: Tag pact contract with environment') { steps { sh "pact-broker create-version-tag --pacticipant=${PROVIDER} --broker-base-url=${BROKER_BASE_URL} --version=${gitReference} --tag=${PROD_ENV}" } }```

bzifkin
2020-08-17 21:25
awesome thank you, figured the cli was the way to go but wasnt sure if there was another way

uglyog
2020-08-17 22:31
What version of the pact broker are you using?

bzifkin
2020-08-18 17:18
i believe latest...this is my docker-compose for my local: ``` pact_broker: image: pactfoundation/pact-broker ports: - "9292:9292" depends_on: - postgres environment: PACT_BROKER_DATABASE_USERNAME: postgres PACT_BROKER_DATABASE_PASSWORD: password PACT_BROKER_DATABASE_HOST: postgres PACT_BROKER_DATABASE_NAME: postgres PACT_BROKER_PORT: "9292"``` Having trouble googling the right thing to confirm that docker-compose defaults to latest if image version isnt specified

os.shulyak
2020-08-19 11:34
Hey all. Is it possible to create pact contract without `"matchingRules"` using `MessagePactBuilder` for testing message queues?

brendan.donegan
2020-08-19 16:18
has joined #pact-jvm

brendan.donegan
2020-08-19 16:18
Hi. We are trying to add an interaction where there is an ID in the URL that needs to be replaced as the object which the requests acts on needs to be set up by the state handler. The consumer is using pact-js but the provider verification is using Junit and I cannot see any way to update the url. I have seen https://github.com/DiUS/pact-jvm/tree/master/provider/junit#returning-values-that-can-be-injected but it's a bit vague since it just mentions "There are methods on the consumer DSLs that can provider an expression that contains variables" but I can't find anything in the pact-js docs about this.

amer.mohammed
2020-08-20 08:58
Hi, I'm trying to verify the async pact in provider. The provider uses the Spring framework's AmqpTemplate's convertAndSend() method which looks like this: amqpTemplate is autowired ```@Override public void publish(String id, Product product) { amqpTemplate.convertAndSend(exchangeName, routingKey, product, new ProductMessagePostProcessor(id)); }``` How can I verify the message string prepared by this? Thanks.



matt.fellows
2020-08-20 09:14
Might be useful examples for you

amer.mohammed
2020-08-20 09:25
Hi Matt, thanks for your response. I've gone through the examples provided and I see that in ProductRepository we're preparing the Message object but in my case of using AmqpTemplate that's out of my hand. convertAndSend method is responsible for preparing the Message and sending it.

matt.fellows
2020-08-20 09:29
I can't give much more advice other than to say you need to be able to have control over how what the message looks like vs the specific protocol (in this case Kafka) that sends it

matt.fellows
2020-08-20 09:29
Because iact wants to see the message before sending (provider side) and after receiving on the provider side. It doesn't know about kafka

bzifkin
2020-08-20 13:20
@uglyog does the latest pactBroker allow you to use gradle arguments for the version?

uglyog
2020-08-20 21:48
No, the broker knows nothing about Gradle parameters

bzifkin
2020-08-20 22:51
gotcha, so then the way to set the version tag would just be through the gradle task correct

bzifkin
2020-08-20 22:51
it could also be done from the cli right?

uglyog
2020-08-20 23:02
Sorry, I still don't really understand why you are having an issue with this. The Gradle task allows you to configure the tag on the publish block. This is a code block, which means you can set it to anything. If you use a `-P` parameter, Gradle creates that as a property on the project. You can then assign that property to the tag list. Or, is you use `-D` Gradle will set it as a system property, and you can then use `System.getProperty` to assign the tag to the tag list. You might even be able to get the command line arguments as well, and then set the tag list from that.

bzifkin
2020-08-20 23:05
so my original issue was that i couldnt tag via the gradle closure: ```pact { publish { providerVersion = getCommitSha() //tags = ['tags'] pactBrokerUrl = "http://localhost:9292" }``` the `tags = ['tags']` portion would give me an error

bzifkin
2020-08-20 23:07
that turned out to be an issue w/ broker version. I was asking about doing it via the parameters on the `./gradlew pactPublish` command, but it didnt seemed like those worked....now that ive got it working in the closure though its a non-issue

uglyog
2020-08-20 23:09
`-PproviderVersion=value` will allow you to use `tags=[project.providerVersion]`

bzifkin
2020-08-20 23:14
ahhh so if i did something like `./gradlew pactPublish -PproviderVersion=value tags=[project.providerVersion]`that would allow me to tag my consumer?

uglyog
2020-08-20 23:24
No, `./gradlew pactPublish -PproviderVersion=value` and then in the publish block ```tags = [ project.providerVersion ]```

bzifkin
2020-08-21 00:58
gotcha, thanks @uglyog!

theuiser
2020-08-21 21:45
Curious if anyone else has run into lowered code coverage in Sonar when running provider pact verification tests. I was following the instructions on this page: https://github.com/DiUS/pact-jvm/tree/master/provider/junit5 Whenever we include the maven-surefire-plugin, our code coverage goes from 86% to 6%.

theuiser
2020-08-21 23:28
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> <configuration> <useSystemClassLoader>false</useSystemClassLoader> <systemPropertyVariables> <pact.broker.host>http://xx.xxx.xxx.xxx</pact.broker.host> <pact.provider.version>${version}</pact.provider.version> <pact.verifier.publishResults>true</pact.verifier.publishResults> </systemPropertyVariables> </configuration> <dependencies> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-surefire-provider</artifactId> <version>1.2.0</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.2.0</version> </dependency> </dependencies>

theuiser
2020-08-21 23:30
See my config below: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> <configuration> <useSystemClassLoader>false</useSystemClassLoader> <systemPropertyVariables> <pact.broker.host>http://xx.xxx.xxx.xxx</pact.broker.host> <pact.provider.version>${version}</pact.provider.version> <pact.verifier.publishResults>true</pact.verifier.publishResults> </systemPropertyVariables> </configuration> <dependencies> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-surefire-provider</artifactId> <version>1.2.0</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.2.0</version> </dependency> </dependencies>

ranjanayush03
2020-08-22 18:33
Hi All, I am using m/gradlew test --info to verify the results and publish it on to the broker but however while I am able to set provider.publish.results in the Gradle command to true but the provider.version property is not reflecting the correct version that I am setting on the command line..it is unable to pick the version (showing as 0.0) Like is there a way to do set the version on ./gradlew test

matt.fellows
2020-08-22 23:43
mm is it possible that the pact phase is overwriting the other unit tests? (just guessing, I don?t really know the Maven ecosystem all that well)

uglyog
2020-08-22 23:52
Could also be `useSystemClassLoader` is causing that. You might need to split you test run in two, normal unit tests with code coverage, and then the pact tests


ranjanayush03
2020-08-24 03:32
Thank you @uglyog

anddreiu
2020-08-24 09:10
Hi. I am trying to implement Pact tests for a case where the provider uses certificates. I've set the provider maven plugin to use the truststore, but the error that I get is: "sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target". I've used mvn pact:verify on the provider side. On the consumer side I did not set anything related to certificates. Do I need to do something on the consumer? Are there any examples on how to implement this kind of tests? Thank you.

amer.mohammed
2020-08-24 09:11
shouldn't pact intercept the final message sent from the publisher just like pact intercepts the REST requests and maches the stubs defined and proceed? I don't see any way I can grab the message string by using AmqpTemplate abstraction.

matt.fellows
2020-08-24 10:19
Any reason you have to use https?

matt.fellows
2020-08-24 10:20
Where possible avoid. Assuming you can't tho no nothing on the consumer side to do

anddreiu
2020-08-24 10:26
I've tried to use insecure=true in HttpTarget for the Provider test, but it looks like the request fails

dianaszaharia
2020-08-24 13:32
Hi all, I'm trying to use `pathFromProviderState`so my pact has a generator that looks something like ``` Generators(categories={PATH={=ProviderStateGenerator(expression=/operations/{id}, type=STRING)}})``` and my provider state method returns a map of "id" and its UUID value; but for some reason the path generator generates a null path, any known issue on this side? using pact-jvm 4.0.10

dianaszaharia
2020-08-24 14:35
never mind, I was missing the $ in expression `/${id}` :grin::woman-facepalming:

bzifkin
2020-08-24 16:34
@phil.endsley @uglyog sorry i keep asking variations of the same question: how to set consumer versions... when i run a PR build i want to set the version to commit sha and tag w/ branch name. I can do both of these easily by properties in the gradle closure

bzifkin
2020-08-24 16:37
however when a pr is merged i want to tag w/ `master` and set the version to the new version of the app. I know the tag through the `./pact-broker create-version-tag` cli command....and i know i could also do the same w/ setting the consumer version w/ the `./pact-broker publish` cli command

bzifkin
2020-08-24 16:38
problem w/ the publish command though is that you need to specify the individual pacts, which would be a pain for consumers w/ multiple providers.....is there another way to set the consumer version more dynamically?

bzifkin
2020-08-24 17:13
hey all - im having trouble understanding how to use tags w/ consumer feature branches. When I open a PR for a feature branch and tag it I want it to go to the broker and check for a provider w/ tag = `branch_name`. If the tag doesnt exist then it should fall back and verify against the master branch of the provider

bzifkin
2020-08-24 17:18
I know how to do this from the provider side - set consumerVersionSelectors w/ the tag `branch_name` and set the fallBack as `master`

bzifkin
2020-08-24 17:18
not sure how to do w/ consumer though....seems like webhooks would be the way to go?

bzifkin
2020-08-24 17:26
or is pending pacts the solution here?

phil.endsley
2020-08-24 17:34
Why do you need to do this from the consumer side? What are you checking broker for? I thought the only thing the consumer should do with broker is publishing the pact after it's generated

bzifkin
2020-08-24 17:41
hmmm....you know actually i think youre right i dont need it

bzifkin
2020-08-24 17:45
to confirm my understanding of how the flow should be: 1. consumer published contract tagged w/ `branch_name`and tests against master of provider. It fails, turning consumer build red, but b/c pending pacts, keeps provider green. `branch_name` is marked as pending 2. make a branch on provider and set the consumer version selector to `branch_name`. Push the provider branch and it will make a call to retrieve the consumer `branch_name` and publish the results. If it's green then `branch_name` will be marked as verified. 3. merge provider and consumer

bzifkin
2020-08-24 17:50
correct?

phil.endsley
2020-08-24 18:02
> consumer published contract tagged w/ `branch_name`and tests against master of provider. If you're using web hooks, yes > It fails, turning consumer build red, but b/c pending pacts, keeps provider green.  No. If providers fail, their builds will fail. Pending pacts will keep providers green if verification fails (assuming it is a pending pact) Consumers will only fail if their own tests (the ones used to generate the actual pact) are failing. If this happens, the contract won't be created/published. > `branch_name` is marked as pending I'm pretty sure the pending state is calculated by the broker itself. Pacts themselves aren't marked as pending, because it depends on which provider tag is running verification. A pact is pending if the provider tag has never had a successful verification against it. For example, it's possible for `branch_name` to NOT be pending for provider tag `feature-x` , but it IS pending for provider tag `main_branch` > make a branch on provider and set the consumer version selector to `branch_name`. Push the provider branch and it will make a call to retrieve the consumer `branch_name` and publish the results. If it's green then `branch_name` will be marked as verified. Yes > merge provider and consumer Yes

phil.endsley
2020-08-24 18:04
> It fails, turning consumer build red, but b/c pending pacts, keeps provider green. To elaborate a little further: The consumer build will be green, provider will also be green (with pending pacts). `can-i-deploy` will fail though, when trying to deploy the ocnsumer. This is the safety net that prevents bad deployments. The failed verification will also still be published to the broker. This is what tells the teams that there is an issue, and something needs to change (either consumer or provider)

bzifkin
2020-08-24 18:15
Thanks Phil. As far as the consumer build turning red i guess i was imagining that when the failed verification was published to the broker we would have it alert the CI jobs and turn the build red. Probably not that simple, will just use can-i-deploy w/ a retry. I'm confused by what you mean w/ > A pact is pending if the provider tag has never had a successful verification against it. For example, it's possible for `branch_name` to NOT be pending for provider tag `feature-x` , but it IS pending for provider tag `main_branch` if the consumer publishes the tagged branch and that tag does not yet exist on the provider side what happens?

phil.endsley
2020-08-24 18:25
> if the consumer publishes the tagged branch and that tag does not yet exist on the provider side what happens? You don't _have_ to name/tag branches the same between consumer/provider. When you run provider verifications, you have to specify the `providerTags` attribute when using pending pacts. If that provider tag does not have any successful verifications for the consumer pact, the pact is pending. If it has had at least one successful verification, it is not pending. So let's say we haver a consumer pact tagged `consumer-new-feature` . We have a provider tagged `main_branch` Since `main_branch` does not have any successful verifications, `consumer-new-feature` is pending for `main-branch`. If provider verifications fail, the build stays green, and a failed verification is published to broker If we have a provider tagged `provider-new-feature`, the same holds true. Let's say we then commit a change that makes the tests pass. A successful verification would then be published to broker between `consumer-new-feature` and `provider-new-feature`. Because it has now been verified, it is no longer pending. So, if you make another change to the provider, you will get a failed verification, and the build will turn red.

phil.endsley
2020-08-24 18:26
If the `providerTags` does not exist in broker, I am pretty confident it will not pick up the pending pact. It has to be explicitly included in the consumer version selectors

phil.endsley
2020-08-24 18:27
But, in the example above, even if `consumer-new-feature` and `provider-new-feature` have a successful verification, `consumer-new-feature` is still pending for `main-branch` , because `main-branch` has never published a successful verification for that pact

phil.endsley
2020-08-24 18:40
> however when a pr is merged i want to tag w/ `master` and set the version to the new version of the app Do you build master when you merge into it? If not, I would recommend doing that. If yes, branch name should just be reused when publishing, and be correct (`master`). So that part should just work. For the version, you might have to do some special gradle logic to determine what the property value should be in the closure

sudhachilamakuri
2020-08-24 20:02
has joined #pact-jvm

sudhachilamakuri
2020-08-24 20:03
Hi Guys, I need some help I am at the early stage of implementing Pact, I have scenario where I will get a code from the response of one request and I want to use that code in the request body of next request to get access token in the response , how can I write provider tests , did some one worked this kind of scenario, if yes can you provide some examples pls

sudhachilamakuri
2020-08-24 20:03
I am using Pact Junit5

phil.endsley
2020-08-24 20:28
At an abstract level, I think you would have two separate pacts for this. One for making a request and getting some response (i.e. the code). And another for a request that sends some data (i.e. the code). Ideally, you can leverage provider states to put the provider in such a state that it is expecting the code you're sending with the request. This would let you decouple the tests from expecting the same code between them. Is this by chance for authentication using OAuth? If so, give this a read: https://docs.pact.io/provider/handling_auth/

sudhachilamakuri
2020-08-24 21:36
@phil.endsley thanks for quick response

sudhachilamakuri
2020-08-24 21:36
~I will go through the document~

sudhachilamakuri
2020-08-24 21:44
yes they are two separate pacts, one is generating code and I want to use this code in the next request to get accessToken in the response

sudhachilamakuri
2020-08-24 21:52
if possible could you please share an example how to use provider states in this scenario

sudhachilamakuri
2020-08-24 21:52
thanks in advance

abubics
2020-08-24 23:56
One important fundamental here (not sure where it is in the docs): Pact tests are not for behaviour (i.e. they're stateless). They are specific, isolated, and deterministic. You don't want to share responses from one test in another, because then the tests are coupled and have to be run in order :slightly_smiling_face:

uglyog
2020-08-25 00:30
That error means the certificate is not trusted. Is the provider using a self-signed certificate?

matt.fellows
2020-08-25 02:23
Look for the Pact JVM workshop in the docs. It had an example of how to deal with auth

matt.fellows
2020-08-25 02:23
In Pact every single interaction is independent of the other. In fact, the order of execution should not be relied upon

matt.fellows
2020-08-25 02:24
Provider states is how we deal with this

heytaco
2020-08-25 03:57
has joined #pact-jvm

heytaco
2020-08-25 03:57
Hi there! My name is HeyTaco!, and you can use me to give people tacos to show your appreciation. My tacos will spread joy through Slack!

anddreiu
2020-08-25 06:06
yes

anddreiu
2020-08-25 06:08
I am using the same certificate to make a call using SoapUI and it works, so I am doing something wrong in the Pact tests

uglyog
2020-08-25 06:15
How are you running the verification?

anddreiu
2020-08-25 06:15
mvn pact:verify

anddreiu
2020-08-25 06:16
and I tried also with Junit runner

uglyog
2020-08-25 06:52
`mvn pact:verify` is for verifying a pact file against a running server.

uglyog
2020-08-25 06:53
If you use a unit test, you don't use that command.

uglyog
2020-08-25 06:53
The tests will run as part of `mvn verify`

anddreiu
2020-08-25 06:55
yes, I was trying to verify a pact file against the provider


anddreiu
2020-08-25 06:57
yes, that's what I tried

uglyog
2020-08-25 06:57
And you still got that error?

anddreiu
2020-08-25 06:59
now I get `Request Failed - null`

anddreiu
2020-08-25 06:59
`1.1) org.apache.http.client.ClientProtocolException`


robert.strehli
2020-08-25 07:53
has joined #pact-jvm

anddreiu
2020-08-25 07:58
```Caused by: org.apache.http.ProtocolException: The server failed to respond with a valid HTTP response```

uglyog
2020-08-25 08:02
Probably need to enable debug logging to see what is going on. `-X` parameter should do that

sudhachilamakuri
2020-08-25 09:05
`thanks for the response every one

dianaszaharia
2020-08-25 09:42
hey, is `valueFromProviderState` available when building json bodies with LambdaDSL?


anddreiu
2020-08-25 11:09
yeah, I tried that. still not found the problem even if I enabled debug logging. when I use http (like below), I get `Caused by: org.apache.http.ProtocolException: The server failed to respond with a valid HTTP response` ```<protocol>http</protocol> <insecure>true</insecure>``` when I use https, I get `http://javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target` ```<protocol>https</protocol> <insecure>false</insecure>```


anddreiu
2020-08-25 12:20
I think the problem is the fact that I am using the keystore and not the truststore. when using the SoapUI I set the keystore and then I am able to submit the request. But in Pact I think that I need to set the truststore... it's a bit of a mess in my head...

dee_n
2020-08-25 14:58
has joined #pact-jvm

dee_n
2020-08-25 15:13
Hello, I have two Pact Consumer test classes (see this : https://github.com/DiUS/pact-jvm/issues/1194) which should run during the integration tests. But one of them always fail. How can I tear down the server after the test ran ?

phil.endsley
2020-08-25 15:56
This isn't really a Pact question. It's more of a Spring Boot question. Spring should do this automatically. I suspect the tests are being ran in parallel. You should be able to fix this by telling your Spring Boot test to use a random (unused) port when it spins up the application context. Spring Boot Docs: https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-testing-spring-boot-applications (Look for RANDOM_PORT) Spring Boot Code Example: https://spring.io/guides/gs/testing-web/

phil.endsley
2020-08-25 16:39
Can you use `getPactDslObject().valueFromProviderState` ?

dee_n
2020-08-25 16:57
Thanks @phil.endsley ! Sorry for asking this question here. The strange thing is that both Pact tests works fine when performing "*mvn install*" in IntelliJ but not when executing it in standalone Maven/Jenkins.

dianaszaharia
2020-08-25 17:57
Yep, I got around it by casting it to PactDslJsonBody and then applying valueFromProviderState. `getPactDslObject()` works better, was not aware of it. Thanks! :taco:

uglyog
2020-08-25 22:53
```<protocol>https</protocol> <insecure>true</insecure>``` :point_up: protocol must https when using insecure

sathisan
2020-08-26 04:30
has joined #pact-jvm

sathisan
2020-08-26 04:57
Hi All Is there a Way to check for type e.g Stringtype if my contenttype is text/plain.... So far i Think the stringtype, integertype etc. can only be checked when used in combination with PactDslJsonbody or PactDslJsonArray?

matt.fellows
2020-08-26 05:03
I don?t think it has matching on text/plain but I might be wrong. Is the response JSON encoded as text/plain?

matt.fellows
2020-08-26 05:03
What are you trynig to match - just strings in general? Regex matcher might be a thing

sathisan
2020-08-26 05:38
Yes the response is encoded as text/plain..at the Moment I can only check for concrete values which I want to avoid Yes Strings and other Custom types which I defined in classes

matt.fellows
2020-08-26 06:39
ok, sorry I?m not sure about the JVM dsl and if it can do that. but for the benefit of others, it would be ideal to understand what the req/responses should look like to help you

uglyog
2020-08-26 06:41
I think the issue is that PactDslJsonbody or PactDslJsonArray are meant to be used with JSON bodies. They don't work with plain text

matt.fellows
2020-08-26 06:42
yes, sorry I thought that was clear from an earlier response

anddreiu
2020-08-26 06:51
`Request Failed - Received fatal alert: bad_certificate`


uglyog
2020-08-26 06:58
> You need to add the root cert to the keystore as well.

anddreiu
2020-08-26 07:00
thanks. my question is: do I need to use the keystore or the truststore? because the property is <trustStore>, but I thought that I should use the keystore because I am the client

uglyog
2020-08-26 07:02
The keystore should have your private key for the cert, while the truststore needs to have the root cert in it

uglyog
2020-08-26 07:03
You can either supply a truststore to use, or put the root cert in the JVM default one

uglyog
2020-08-26 07:04
But the `insecure` option should bypass all that

anddreiu
2020-08-26 07:04
yes, but it looks like with insecure=true it doesn't work

uglyog
2020-08-26 07:05
Sorry, keystore just needs the public key, not the private

anddreiu
2020-08-26 08:23
@uglyog - is it possible to set the truststore for the provider and to specify the keystore for the client?

anddreiu
2020-08-26 08:25
I am thinking that using this we are setting the truststore on the provider side: ```<plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.1.0</version> <configuration> <serviceProviders> <serviceProvider> <name>provider1</name> <pactFileDirectory>path/to/pacts</pactFileDirectory> <trustStore>relative/path/to/trustStore.jks</trustStore> <trustStorePassword>changeit</trustStorePassword> </serviceProvider> </serviceProviders> </configuration> </plugin>``` But wouldn't be needed also the keystore to be set somewhere for making the request?

anddreiu
2020-08-26 09:20
I was trying now to set the keystore using maven parameters, but still no luck ```-Djavax.net.ssl.keyStore= -Djavax.net.ssl.keyStorePassword=```

amer.mohammed
2020-08-26 09:54
Hi, For async communication, we're using rabbitMq. The type of payload is a domain object. How can we define a pact for that? And how can we verify it? The examples I've found are implemented for stringified json.

amer.mohammed
2020-08-26 09:56
Payload and it's properties looks like this in rabbitMQ headers: __TypeId__: com.domain.basket.Product e2eData: 1234123412341243124321413421341 content_encoding: UTF-8 content_type: application/json payload: {"id":"242342", ...}

sathisan
2020-08-26 12:31
Hi guys I have one question regarding the provider Test If i verify the contract on the provider Side, what is the difference between verifying against the MockMVC Target and the target which is specified as HttpTarget?

francislainy.campos
2020-08-26 14:08
Hi, is there anything that one can do to beautify the logs a bit so they are a bit easier to read?

uglyog
2020-08-26 23:13
Could you raise an issue for this at the github project? The `insecure` parameter is meant to not require any of this and work with self-signed certs.

uglyog
2020-08-26 23:14
Until this is fixed, is there an option to not use HTTPS?

anddreiu
2020-08-27 06:44
no, can't using it without HTTPS

anddreiu
2020-08-27 06:45
> Could you raise an issue for this at the github project? The `insecure` parameter is meant to not require any of this and work with self-signed certs. I think it won't work with self-signed certs. I need to find a way to send that client certificate to the server, otherwise it won't be accepted

uglyog
2020-08-27 06:47
Does it require MASSL?

anddreiu
2020-08-27 06:49
not sure, it's something new also for me and I am trying to find out more

uladzislau_danilchyk
2020-08-27 09:57
Hi everyone! I'm trying to publish pacts to Pact Broker (https) which do not have authentication. How to deal with it? I received error for the PUT request when pacts are publishing: ```ERROR] [au.com.dius.pact.core.pactbroker.HalClient] PUT JSON request failed with status HTTP/1.1 301 Moved Permanently```

matt.fellows
2020-08-27 10:20
Can you please share the verbose http logs ? 301 is interesting, is there a proxy or something in front of it?

francislainy.campos
2020-08-27 11:43
Hi, I have a post request that takes date as a param. ```return builder .uponReceiving("A request to create a Zoom meeting") .path(createMeeting) .method("POST") .headers(headers) .body("{\"title\":\"My title\",\"start_time\":\"2020-08-28T14:30:00Z+01:00\",\"duration\":30,\"provider\":\"ZOOM\"}") .willRespondWith() .body(body) .toPact();``` But I'd like this to be dynamic, having perhaps today's or tomorrow's date, otherwise it would have an expired date. Could you please advise on how to do do this and if possible to keep it from the consumer side. Many thanks.


phil.endsley
2020-08-27 12:46
There was actually a blog written about this exact thing. I think this is what you're looking for. Though it uses the dsl, and it looks like you're defining the body as a raw json string https://pactflow.io/blog/dealing-with-relative-dates-in-contract-tests/

phil.endsley
2020-08-27 12:47
> You can now use the `dateExpression` function to have an expression be evaluated at runtime when the provider is verified. So our snippet becomes:

uladzislau_danilchyk
2020-08-27 13:20
I attached logs with DEBUG level.

uladzislau_danilchyk
2020-08-27 13:25
@matt.fellows, pay attention that first call is going to HTTPS. but after that call is going to HTTP on 26 line.

uladzislau_danilchyk
2020-08-27 13:33
@matt.fellows. we are just deployed pact broker into Kubernetes where balancer is on front of top of it. No proxy.

francislainy.campos
2020-08-27 15:08
Thank you. I can try that. I actually use the body as raw string as when try to use it with dsl for some reason it won't work for me.

francislainy.campos
2020-08-27 15:08
```@ExtendWith(PactConsumerTestExt.class) public class PACTConsumerEdUiVcTest { Map<String, String> headers = new HashMap<>(); String createMeeting = "/manage/create-meeting"; @Pact(provider = VC, consumer = ED_UI) public RequestResponsePact createPact(PactDslWithProvider builder) { headers.put("Content-Type", "application/json"); DslPart body = new PactDslJsonBody() .stringValue("start_time", "2020-08-28T14:30:00Z+01:00"); return builder .uponReceiving("A request to create a Zoom meeting") .path(createMeeting) .method("POST") .headers(headers) .body(new PactDslJsonBody() .stringValue("title", "My title") .stringValue("start_time", "2020-08-28T14:30:00Z+01:00") .stringValue("provider", "ZOOM") .numberValue("duration", 30)) // .body("{\"title\":\"My title\",\"start_time\":\"2020-08-28T14:30:00Z+01:00\",\"duration\":30,\"provider\":\"ZOOM\"}") .willRespondWith() .body(body) .toPact(); } @Test @PactTestFor(providerName = VC, port = "8080") public void runTest() { //Mock url RestAssured.baseURI = "http://localhost:8080"; Response response = RestAssured //todo: dynamic start time that won't expire. 27/08/2020 .given() .headers(headers) .when() .body(new PactDslJsonBody() .stringValue("title", "My title") .stringValue("start_time", "2020-08-28T14:30:00Z+01:00") .stringValue("provider", "ZOOM") .numberValue("duration", 30)) // .body("{\"title\":\"My title\",\"start_time\":\"2020-08-28T14:30:00Z+01:00\",\"duration\":30,\"provider\":\"ZOOM\"}") .post(createMeeting); assert (response.getStatusCode() == 200); } }```

francislainy.campos
2020-08-27 15:11
Would you be able to tell me what I'm missing on this part @phil.endsley and then I'd try the dynamic date as per the blog post you shared? Thank you very much again.

phil.endsley
2020-08-27 15:23
I'm not very familiar with RestAssured. Only used it a couple times when playing around with it. I'm guessing it's because you're using `PactDslJsonBody` in the RestAssured `.body` method. Maybe try the raw json there like you had before, but keep using the `PactDslJsonBody` in the pact builder.

phil.endsley
2020-08-27 15:23
Maybe start by proving it out with a hard coded date/time, and then make it work dynamically?

francislainy.campos
2020-08-27 15:30
Yeah, you're right. Keeping RestAssured as it was fixed the issue to create the contract with DSL. Will get back to the blog post and see about the dynamic date.

francislainy.campos
2020-08-27 15:31
This is actually another and related question I've been having for some time: Why do we need to send a body post twice, under the builder and within the runTest piece?

phil.endsley
2020-08-27 15:33
The builder is defining the expected contract, it's not sending the request, rather defining what it should look like. The runTest (the second body) is you building a real request to send

francislainy.campos
2020-08-27 15:35
Cool, so then only the RestAssured part actually interacts with the call and I'd probably then add the dynamic date only to it if I'm understanding it properly.

francislainy.campos
2020-08-27 15:35
I'll try and work on it and see what happens.

phil.endsley
2020-08-27 15:40
The pact builder will definitely need a change. Not sure about the rest assured part. Essentially, the pact builder will change to allow more flexibility for the consumer's request, vs expecting exactly `"2020-08-28T14:30:00Z+01:00"`

francislainy.campos
2020-08-27 15:43
You mean the difference between stringValue and stringType? This is amended now. ```headers.put("Content-Type", "application/json"); DslPart body = new PactDslJsonBody() .stringType("topic", "My title") .stringType("id", "94668716626") .stringType("join_url", "https://zoom.us/j/94668716626?pwd=S3pldTFmdjcwYnZRZS80UzBidlBMQT09") .numberType("duration", 30) .stringType("password", "Hello"); return builder .uponReceiving("A request to create a Zoom meeting") .path(createMeeting) .method("POST") .headers(headers) .body(new PactDslJsonBody() .stringType("title", "My title") .stringType("start_time", "2020-08-28T14:30:00Z+01:00") .stringType("provider", "ZOOM") .numberType("duration", 30)) .willRespondWith() .body(body) .toPact();```

phil.endsley
2020-08-27 15:45
Also, to offer some unsolicited feedback, based on your code above, it looks like you're using RestAssured for your consumer tests. This doesn't follow best practices, because it allows your actual code base to drift from your contract. Instead, you should be calling the method from your code base that would actually make the web call. This couples your code base to the contract, since it makes sure your code is actually doing what you're contract is doing.

phil.endsley
2020-08-27 15:46
If you change the implementation of what your consumer is, your test will still pass, because it's not calling the actual method that invokes the web call

francislainy.campos
2020-08-27 15:49
I get you. I'd need to learn how to do this way you're suggesting, as I'm not the person who does the development but the automation engineer instead. But can try and figure it out.

sathisan
2020-08-27 16:33
Hi everyone As far as I understood, with mockmvc the contract is verified against the weblayer( controller) and with Httptarget the contract is verified against the whole Server with Application context. But in the official documentation, it is stated that pact is testing messages between two Applications at HTTP Level. So if I am testing at Http Level, does it have an impact for my testing if service Layer is mocked or not mocked?

francislainy.campos
2020-08-27 17:49
``` @Test @PactTestFor(providerName = VC, port = "8080") public void runTest() { //Mock url RestAssured.baseURI = "http://localhost:8080"; Map<String, Object> map = new HashMap<>(); map.put("title", "MyTitle"); map.put("start_time", new Date().toString()); map.put("duration", 30); map.put("provider", "ZOOM"); Response response = RestAssured //todo: dynamic start time that won't expire. 27/08/2020 .given() .headers(headers) .when() .body(map) .post(createMeeting); assert (response.getStatusCode() == 200); }```

francislainy.campos
2020-08-27 17:50
Still with RestAssured but I was able to pass a dynamic date like this.

phil.endsley
2020-08-27 17:50
:tada:

francislainy.campos
2020-08-27 17:51
:slightly_smiling_face:

francislainy.campos
2020-08-27 17:52
For your suggestion I'll try to learn that, but I think for this specific scenario may not be able to implement it as I'm actually doing the consumer tests from outside the consumer codebase, which means I would not have access to the method that does the web call.

matt.fellows
2020-08-27 23:44
I?m going to guess that your load balancer or some configuration is redirecting it to http


matt.fellows
2020-08-27 23:46
Yousaf also wrote an interesting post that might be helpful: https://medium.com/@you54f/securing-the-pact-broker-with-nginx-letsencrypt-624a890be9a8

matt.fellows
2020-08-27 23:47
See also https://github.com/DiUS/pact_broker-docker/issues/58. It?s possible that the response body shows http links in the response, because of a misconfiguration at the LB. If the application doesn?t know it?s on http, it can?t write the relations into the body of the hypermedia response, which defaults to http

matt.fellows
2020-08-27 23:48
all of those would point to incorrect configuration -> *TL;DR if your LB terminates SSL and sends traffic to the pact broker on port 80 and doesn?t set appropriate headers, you?ll get this issue*

abubics
2020-08-28 01:55
Yeah, that's not ideal. If your tests aren't exercising the actual code, they don't provide much value :thinking_face:

francislainy.campos
2020-08-28 06:10
Hi, they are exercising the actual code but not coded directed from the same consumer code base. They use RestAssured to do the api call and check the response against the contract.

francislainy.campos
2020-08-28 06:12
We have the specs on what the consumer needs and write both the consumer contract and verification from the same provider codebase.

phil.endsley
2020-08-28 12:50
Oh, maybe I misinterpreted/assumed the wrong thing. Do you have your consumer application running at port 8080? I thought you were using RestAssured to call the mock server directly

francislainy.campos
2020-08-28 17:11
We do the mocking when generating the contract by running it against the port 8080 but do the real testing against our services when verifying it from the provider side.

francislainy.campos
2020-08-28 17:13
As there's no resources available to write PACT from the UI team, we do both the consumer and verification from the provider codebase based on the specs they send us saying what the answer should look like, which they usually write on Confluence or similar page.

phil.endsley
2020-08-28 17:24
> We do the mocking when generating the contract by running it against the port 8080 Ok, so I think I assumed right then. The consumer pacts are tested against the mockserver (port 8080 is not a real instance of the consumer, right?). If that's the case, your consumer tests are not exercising the actual consumer code. It's essentially doing: ```ServiceA serviceA = mock(ServiceA.class); when(serviceA.doThing()).thenReturn("Success"); assert(serviceA.doThing().equals("Success");``` So if `doThing()` ever changes, the test will keep passing, and the contract will keep being published. This is the "drift" I was talking about before. It sounds like your provider is testing the actual code base, which is great. But, it's still not safe, because you're validating the provider response against a "hand written" contract. For the example above, you would ideally test it against a real version of `ServiceA`. This would ensure that the real behavior of `ServiceA` matches your defined contract. What you're doing bypasses some key features that (in my opinion) are what makes Pact better than other tools. It could also lead to the possibility of breaking changes being deployed without any tests failing. Ultimately, the tests are probably better than nothing. And it's up to you to weigh the risks/benefits you're getting out of it. If nothing else, now you're aware of the gap this leaves.

francislainy.campos
2020-08-28 17:28
Yes, exactly. We don't manage the consumer code base from our side and this opens the possibility of us being verifying fields that are part of this hand written contract by only believing they are all being used by the UI, which may not be always true if things changes and these specs are not updated accordingly.

francislainy.campos
2020-08-28 17:31
Thank you for the detailed feedback by the way. I always appreciate coming to this channel and talking to you guys as feel I learn something new and insightful every time.

phil.endsley
2020-08-28 17:55
If I'm not mistaken, you can still use mockmvc with the whole application context stood up. Either one should be fine for verification, since mockmvc is still making calls to your endpoint via http. Whether you mock the service layer or not is up to you to weigh the cost/benefits of doing so. I think there have been a couple threads in slack talking about where/when to mock, not sure if they're gone now though. The more you mock at higher levels (ex: service layer vs data layer) the more you're relying on that mocking being correct when verifying the contract. The more real instances you have, the more accurate your verifications will be. There's also warnings in the docs that make sure to distinguish between contract vs functional tests. https://docs.pact.io/consumer/contract_tests_not_functional_tests/

abubics
2020-08-31 01:37
Glad it's helpful, and thanks for your thorough explanations, @phil.endsley :confetti_ball: The best outcome would be if you can convince the consumer dev team to get contract tests into the actual codebase?that's really how it's intended to be used, and will deliver the best value :thumbsup: If nothing else, this thread could help convince them that the gap is very significant.

abubics
2020-08-31 01:39
I'm interested in this problem: > there's no resources available to write PACT from the UI team Is it just that they aren't currently devoting effort to writing these kinds of tests, or that their architecture makes it difficult to write these kinds of tests?

komeershettyvinod
2020-08-31 13:46
Hi I want to make a post request call to get the bearer token(used in authorization header) ,Since every time I run the provider tests, bearer token changes

komeershettyvinod
2020-08-31 13:46
I am using gradle for this

komeershettyvinod
2020-08-31 13:46
I went through the http://read.me

komeershettyvinod
2020-08-31 13:47
I am not sure how to use requestFilter object for post call and generate ouath key(in my case bearer)

komeershettyvinod
2020-08-31 13:47
dynamically and send for pact while run

komeershettyvinod
2020-08-31 13:48
any help please/

uglyog
2020-08-31 22:53
The request filter is just a callback that is invoked before the request is made. You can put whatever code you need in there, including making a HTTP request to get a token. But I would recommend fetching the token once before the test, and then just reusing it in the request filter.

komeershettyvinod
2020-09-01 06:16
ok thanks

komeershettyvinod
2020-09-01 06:19
Hi Team

komeershettyvinod
2020-09-01 06:20
I have a Get call for a contract to be made say the url is "http://dummyurl.com/id"

komeershettyvinod
2020-09-01 06:20
Here the id is dynamic

komeershettyvinod
2020-09-01 06:21
I want id to be ignored as part of verification both at consumer and provider side

uglyog
2020-09-01 06:21
You can use regular expressions for the paths

komeershettyvinod
2020-09-01 06:32
I do not see proper examples for regex for paths

komeershettyvinod
2020-09-01 06:32
Is it possible to share some examples?


komeershettyvinod
2020-09-01 06:42
ok thank you so much

francislainy.campos
2020-09-01 11:00
```@BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpsTestTarget(BASE_PACT_VC_URL, 443, "/")); getAuthorizationToken(UserType.TEACHER); }``` .. ```public static String getAuthorizationToken(UserType userType) { SUS_LOGIN = SUS_LOGIN_INT; String username = "QATeacher2_92025082_int"; String password = "E!1jmka1p62h"; String tenantPid = "92025081"; Map<String, Object> map = new HashMap<>(); map.put("username", username); map.put("password", password); map.put("tenantPid", tenantPid); Requests request = new Requests(); RequestSpecification rq = request.getRequestSpecification(""); Response r = rq.body(map).post(SUS_LOGIN); AUTHORIZATION_TOKEN = r.getBody().jsonPath().get("sifToken"); return AUTHORIZATION_TOKEN; }``` .. ```public class Requests { public RequestSpecification getRequestSpecification(String authorizationToken) { RequestSpecification rq = given() .contentType(OAuth.ContentType.JSON) .contentType("application/json\r\n") .header("Accept", "application/json").and() .header("Content-Type", "application/json") .header("Authorization", authorizationToken) .when() .log() .everything(); return rq; } }``` We're using Maven and RestAssured but this is how we do this if it can help you somehow.

komeershettyvinod
2020-09-01 11:40
Yeah, Thank you so much, But I am using Gradle as a provider

francislainy.campos
2020-09-01 14:07
Hi, maybe more of a Java question than PACT but I was looking for a sample where I'd validate whether the string returned is a valid email address if anyone has any please? Thanks a lot in advance.

phillip.lo
2020-09-01 16:34
has joined #pact-jvm

lzyzy1996
2020-09-01 17:09
has joined #pact-jvm

abagraw3
2020-09-01 21:45
has joined #pact-jvm

abagraw3
2020-09-01 21:45
Hi All! I'm trying to write a provider test using junit. I've contract files and I want to run them on multiple environment and hence a particular field in request body needs to be modified which is env specific. Is there any way to modify the value of an attribute in request body?

uglyog
2020-09-01 22:49
You'll need to use a regular expression. You can probably find one with a quick search with Google.

uglyog
2020-09-01 22:52
Pact has been designed to test the structure of requests. Unless the structure changes between environments (which would be pretty silly thing to do), you should not test the actual value but that the value is the correct type.

abubics
2020-09-02 00:10
At the same time, I'd advise against trying to definitively validate email addresses (with a regex or otherwise) . . . the spec is notoriously free, and many assumptions about how email addresses should be structured are wrong. For example, more TLDs may exist in the future, and many special characters are valid before the `@` . . . practically, with a regex, the most useful thing you can validate is that there are characters before and after the `@`, and that's it.

abubics
2020-09-02 00:10
(also, it's kinda not the point of a pact test, that's more a unit testing thing)


matt.fellows
2020-09-02 00:14
what Ron said

francislainy.campos
2020-09-02 00:55
Cool, thank you both. :+1:

ashley.graf101
2020-09-02 01:49
has joined #pact-jvm

abagraw3
2020-09-02 04:09
```{ "provider": { "name": "stationlogin" }, "consumer": { "name": "desktoplogin" }, "interactions": [ { "description": "station login post request", "request": { "method": "POST", "path": "/ra/v1/login", "headers": { "Content-Type": "application/json" }, "body": { "teamName": "string", "channelCount": { "social": 100, "telephony": 100, "chat": 100, "email": 100 }, "chatCount": "string", "voiceCount": "string", "teamId": "string", "siteId": "string", "dn": "string", "usesOtherDN": true, "skillProfileId": "AXLxBfMapN8jdS1B8654", "emailCount": "string", "auxCodeId": "string" }, "matchingRules": { "body": { "$.dn": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.siteId": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.teamId": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.teamName": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.chatCount": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.emailCount": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.voiceCount": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.usesOtherDN": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.auxCodeId": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.skillProfileId": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.channelCount.telephony": { "matchers": [ { "match": "number" } ], "combine": "AND" }, "$.channelCount.email": { "matchers": [ { "match": "number" } ], "combine": "AND" }, "$.channelCount.chat": { "matchers": [ { "match": "number" } ], "combine": "AND" }, "$.channelCount.social": { "matchers": [ { "match": "number" } ], "combine": "AND" } } } }, "response": { "status": 202 } } ], "metadata": { "pactSpecification": { "version": "3.0.0" }, "pact-jvm": { "version": "3.5.23" } } }```

abagraw3
2020-09-02 05:16
``` import au.com.dius.pact.provider.junit.Consumer; import au.com.dius.pact.provider.junit.PactRunner; import au.com.dius.pact.provider.junit.Provider; import au.com.dius.pact.provider.junit.TargetRequestFilter; import au.com.dius.pact.provider.junit.loader.PactFolder; import au.com.dius.pact.provider.junit.target.HttpTarget; import au.com.dius.pact.provider.junit.target.Target; import au.com.dius.pact.provider.junit.target.TestTarget; import com.cdc.ccc.ra.functest.PactHelper; import org.apache.http.HttpRequest; import org.junit.Before; import org.junit.runner.RunWith; @RunWith(PactRunner.class) @Provider("stationlogin") @Consumer("desktoplogin") @PactFolder("pacts") public class AgentNewStationLoginPact { @TestTarget public final Target target = new HttpTarget("https", "http://ra.intgus1.myService.com", 443); private HttpRequest request; @Before public void before() { System.out.println("run before tasks..."); } @TargetRequestFilter public void requestFilter(HttpRequest request) { request.addHeader("Authorization", PactHelper.userAccessToken()); } }```

abagraw3
2020-09-02 05:48
I had generators in the contract file but I removed it since it generated random data and the test was failing.

robert.strauch_slack
2020-09-03 09:52
I'd like to implement a Pact consumer test in our Java EE application. This test shall invoke a consumer service method which would trigger the actual REST call. Here's the Pact test so far: ```java @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "my-service") public class MyServiceConsumerTest { @Inject private MyService myService; @Pact(consumer = "myConsumer") public RequestResponsePact mail(PactDslWithProvider builder) { Map<String, String> headers = new HashMap<>(); headers.put("Content-Type", ContentType.getJSON().asString()); PactDslJsonBody jsonBody = new PactDslJsonBody() .stringValue("emailAddress", "") .stringValue("subject", "Test subject") .stringValue("content", "Test content") .asBody(); return builder .given("DEFAULT_STATE") .uponReceiving("request for sending a mail") .path("/mail") .method("POST") .headers(headers) .body(jsonBody) .willRespondWith() .status(Response.Status.OK.getStatusCode()) .toPact(); } @Test @PactTestFor(pactMethod = "mail") public void sendMail() { MailNotification mailNotification = MailNotification.builder() .emailAddress("") .subject("Test subject") .content("Test content") .build(); myService.sendNotification(mailNotification); } }``` The interesting part is this line: `myService.sendNotification(mailNotification);` As I'm running a consumer unit test, the injection of `MyService` does not work, i.e. results in `myService` being `null`. Moreover I think it would be necessary to tell the service to send its request against the Pact mock server? Of course I could just fire the final REST request in the test but that would ignore the service logic. I guess I'm missing something here?

matt.fellows
2020-09-03 10:42
> As I?m running a consumer unit test, the injection of `MyService` does not work, i.e. results in `myService` being `null`. Moreover I think it would be necessary to tell the service to send its request against the Pact mock server? Yes you?re spot on - both of those things are correct

matt.fellows
2020-09-03 10:42
> Of course I could just fire the final REST request in the test but that would ignore the service logic. and yes, do not do this! this test will forever pass if you ever change the details of `MyService`

matt.fellows
2020-09-03 10:43
I?m not familiar with the details of `Inject`, but I guess the test context is not aware of the annotation. I?m sure there are other ways to get that dependency injected, but if not, can you just create and instantiate it directly?

robert.strauch_slack
2020-09-03 11:05
That's what I was also thinking of. The problem is that this service has several other dependencies which I would need to mock/inject somehow. As you mentioned I'll probably need to check the injection mechanism...

matt.fellows
2020-09-03 11:09
Sorry I can?t help much more - when I last wrote Java the JSR 330 proposal (I think) was just becoming a thing

matt.fellows
2020-09-03 11:09
I can do it in spring, but only because I recently did a demo using that

robert.strauch_slack
2020-09-03 11:10
Yeah, Spring is so musch easier on this.

abagraw3
2020-09-03 13:45
Am I missing something here?

uglyog
2020-09-03 23:00
Generators will generate random values. If you're matchers are correctly configured, random values should not fail your test

uglyog
2020-09-03 23:02
You're using an old version of Pact-JVM. You should upgrade to a newer version.

abagraw3
2020-09-04 05:25
Thank you @uglyog & @matt.fellows for the inputs. I'm using pact-jvm-provider-junit v4.0.10.

uglyog
2020-09-05 03:21
That sounds like it might be a defect. Please raise an issue for it.

maciej.olko
2020-09-05 13:46
@lucaseverain :point_up:

lucaseverain
2020-09-05 13:46
has joined #pact-jvm

ashish_garg5
2020-09-08 10:50
Hi All, Just want to know whether pact version 4.0.x works with Spring boot 2.2 ? Thanks.

joao
2020-09-08 15:45
It should work, you just need to setup your MockMVCs object properly. What error have you encounter?

dabs1234
2020-09-09 07:59
has joined #pact-jvm

dabs1234
2020-09-09 07:59
Hello All, I am new to PACT and just did a POC with JUnit5 on simple microservice consumer and provider. Now I need to implement it on real springboot microservice which uses oauth2. What is the best way of achieving this? Any sample code would be a great help.

ashish_garg5
2020-09-09 11:15
no errors i did the POC using 4.0.x with Spring boot 1.x so just wanted to ask if there is any compatibility chart for pact version so that we make sure we are using the right version of pact. Thanks :slightly_smiling_face:

matt.fellows
2020-09-09 12:09
howtolearn

2020-09-09 12:09
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

matt.fellows
2020-09-09 12:10
in case you missed it in general, good JVM workshop with auth there

copalco
2020-09-10 12:55
has joined #pact-jvm

vit.barabash
2020-09-14 15:50
Hi all! I?m trying to implement provider test (spring+junit5) for the controller which uses reactive webClient. I?ve noticed that WebFlux controllers are supported since 4.1.7, but I can?t find any guide/example how to deal with it. Digging into WebFluxTarget implementation within the pact-jvm repo didn?t help yet. I was expecting something similar to the one with MockMvc with a replacement of the MockMvcTestTarget to WebFluxTarget, but it doesn?t seem to work :slightly_smiling_face: Can someone help with it or point me to the proper place in the documentation? Thanks in advance!

komeershettyvinod
2020-09-15 13:34
Hi

komeershettyvinod
2020-09-15 13:35
I am unable to follow the pact broker work flow, can any one help me what does Unverified means here and how to make it verified

komeershettyvinod
2020-09-15 13:37
I followed below steps 1. Consumer side - Generated a contract file (say consumer_pact.json) 2. At Producer side - Using above contract file, ran the publisher side tests(It passed) 3. Uploaded the common contract file generated in step 1 to pact broker using 'pactPublish' task

komeershettyvinod
2020-09-15 13:37
My question is how to verify the producer side tests

matt.fellows
2020-09-15 13:40
Steps should be: 1. Generate contract 2. Publish contract to pact broker 3. Verify the provider by configuring it to download from the broker 4. ?ensuring verification results are set to publish

matt.fellows
2020-09-15 13:40
if you don?t enable verification results, it won?t send the results back to the broker


matt.fellows
2020-09-15 13:41
howtolearn

2020-09-15 13:41
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

matt.fellows
2020-09-15 13:42
:point_up: useful pact jvm workshop there if you haven?t run

komeershettyvinod
2020-09-15 13:42
ok thanks Matt, one question from your steps , ideally the step 2 should always be from consumer side right?

matt.fellows
2020-09-15 14:11
Yes! The provider can't publish a contract on behalf of a consumer

matt.fellows
2020-09-15 14:11
(or rather it shouldn't, that would be like marking your own exam :joy:)

komeershettyvinod
2020-09-15 14:24
@matt.fellows Thank you, this helps

giuseppe.salvatore
2020-09-15 15:21
Hello everyone

giuseppe.salvatore
2020-09-15 15:22
has anybody ever done contract testing with apigee as a proxy between providers and consumers?

komeershettyvinod
2020-09-15 16:51
Hi Are there any proper examples, where I want to verify my contract at producer side using gradle with pact broker having some setup(like adding authorization headers), i tried using the documentation , but it did not worked, it always gave me unauthorized

komeershettyvinod
2020-09-15 16:51
any proper examples would be helpful

komeershettyvinod
2020-09-15 17:11
My sample code is

komeershettyvinod
2020-09-15 17:11
how to re-write this , can any 1 please help

komeershettyvinod
2020-09-15 17:11
Thanks

matt.fellows
2020-09-16 00:07
@komeershettyvinod I?ve deleted that code snippet as you pasted credentials

matt.fellows
2020-09-16 00:07
could you please try again with any credentials redacted?

matt.fellows
2020-09-16 00:07
I?d also suggest you rotate your API credentials for your Pactflow account immediately

komeershettyvinod
2020-09-16 04:52
@matt.fellows ah I missed changing the creds there, anyways did you got my prblm what I am trying to say?

matt.fellows
2020-09-16 04:59
I didn?t I?m afraid. Unfortunately I don?t know the gradle interface all that well

matt.fellows
2020-09-16 05:00
feel free to share again, and perhaps somebody else will know better!

francislainy.campos
2020-09-16 07:55
Hi, is it possible to assert for an empty array? I just want to make sure the key is there. Thank you.

matt.fellows
2020-09-16 07:57
Yes, you should be able to

matt.fellows
2020-09-16 07:57
but if data comes back in the response, it will fail

francislainy.campos
2020-09-16 08:03
Hi Matt, good morning. Thank you for the reply. It shouldn't come back no, but when I use `eachLike(participants) closeArray` it creates me an array with an empty object inside rather than an empty array.

francislainy.campos
2020-09-16 08:04
So `participants [{}]` rather than `participants []`

wesleythomaswilliams
2020-09-16 08:37
Would this work? ```.array(pacticipants) .closeArray()```

francislainy.campos
2020-09-16 08:49
Yeah, that's it exactly! Worked perfectly. Thanks a lot Wes!! :slightly_smiling_face: :slightly_smiling_face:

wesleythomaswilliams
2020-09-16 08:49
Haha, good guess on my part :smile:

young
2020-09-17 01:35
has joined #pact-jvm

sathisan
2020-09-17 10:09
Hi everybody, I am trying to set up Contract testing for https server. For the Consumer Test, I could find the following example: @Rule public PactProviderRule mockTestProvider = new PactProviderRule("test_provider", "localhost", 8443, true, "/path/to/your/keystore.jks", "your-keystore-password", PactSpecVersion.V2, this); Is this still supported? If there are any Updates for contract testing with https, i would appreciate any help

matt.fellows
2020-09-17 10:26
I can?t comment on how to setup the JVM tests, but just triple check that you actually really need to do https on the consumer side _test_ - there is rarely a good reason to do it, the only one that springs to mind is a really inflexible client code base that means switching out the protocol is really hard to do or there is a stupid organisational policy preventing http interactions (even in local dev)

matt.fellows
2020-09-17 10:26
https doesn?t add anything valuable to the contract test, but it may complicate it

sathisan
2020-09-17 10:50
Hi Matt, Thank you for your Feedback, . I tried the whole setup ignoring the security context. Bu the Problem on the provider Side was that I get an Error that request Processing failed. Userdetails is a Parameter Read from the certificate used for https and is used as a Parameter for my provider, but in provider Side it fails because of this parameter

mmotornyi.consultant
2020-09-17 11:44
has joined #pact-jvm

mmotornyi.consultant
2020-09-17 11:45
Does anybody have an example of Koltin + Gradle project with contract tests?

christopher.lampert
2020-09-17 12:07
has joined #pact-jvm

matt.fellows
2020-09-17 12:49
interesting

matt.fellows
2020-09-17 12:49
I may be wrong here, so hopefully somebody else can clarify, but I don?t think you can capture aspects of the certificate in the contract

matt.fellows
2020-09-17 12:50
I think what you need is to setup a custom security context on the provider verification step (use SSL there with a custom certificate), or to relax the authentication for the provider setup (e.g. stub out some behaviour) during test

matt.fellows
2020-09-17 12:50
you might be in the edge case scenario here


mmotornyi.consultant
2020-09-17 14:00
Nice! Thnx a lot!

saurabhapd
2020-09-17 15:27
has joined #pact-jvm

abubics
2020-09-17 23:41
Oh wow... I might have newer Android tests in Kotlin, but they'll still be >1 year old.

matt.fellows
2020-09-18 02:31
Thanks past Boris :stuck_out_tongue:

mmotornyi.consultant
2020-09-18 06:57
@abubics Are your tests available in public repo?

abubics
2020-09-18 07:13
oh, no . . . only the ones Matt linked earlier

tjones
2020-09-18 07:14
(@mmotornyi.consultant, the code Matt linked above was written by @abubics)

abubics
2020-09-18 07:14
I've posted them in this Slack workspace before, but I guess they're lost to the free message limit

abubics
2020-09-18 07:15
I can dig them up and post them again here :slightly_smiling_face:

abubics
2020-09-18 07:15
Oh right, I see . . . the consumer in that repo is a tiny groovy class

abubics
2020-09-18 07:15
gimme a sec

tjones
2020-09-18 07:16
Taco for @abubics :taco: !

abubics
2020-09-18 07:20
So, I had a base Pact test class for reusable helpers: ```open class PactBase : StringSpec() { val builder: PactDslWithProvider = ConsumerPactBuilder .consumer("MyRedacted Android") .hasPactWith("MyRedacted BFF") private val authToken = "valid_token" val getToken = { authToken } val authHeaders = mapOf("Authorization" to "Bearer $authToken") val contentTypeHeaders = mapOf("Content-Type" to "application/json;charset=utf-8") val firebase: Firebase? = null fun verify(pact: RequestResponsePact, func: MyRedactedConnector.() -> Unit) { val config = MockProviderConfig.createDefault() val result = runConsumerTest(pact, config, object : PactTestRun { override fun run(mockServer: MockServer) { buildMyRedacted(mockServer.getUrl(), getToken, firebase).func() } }) result shouldBe PactVerificationResult.Ok } companion object { const val GET = "GET" const val POST = "POST" } }```

abubics
2020-09-18 07:21
And then tests like this: ```class PactAccountTests : PactBase() { init { "fetches Accounts and converts them to AccountReferences" { val pact = builder .given("a member with some accounts") .uponReceiving("a request for the list of all accounts").run { headers(authHeaders) method(GET) path("/member/12345/account") } .willRespondWith().run { headers(contentTypeHeaders) status(200) body(newJsonBody { container -> with(container) { minArrayLike("accounts", 1) { with(it) { stringType("id", "S01-01") stringType("name", "Access Account TestOne") stringMatcher("type", "savings|investment|loan", "savings") numberType("availableBalance", BigDecimal("5.00")) numberType("currentBalance", BigDecimal("5.67")) } } } }.build()) } .toPact() verify(pact) { fetchAccountList( AccountsRequest( userId = "12345" ) ) shouldBe Response.Success( listOf( AccountReference( id = "S01-01", type = AccountType.Savings, name = "Access Account TestOne", availableBalance = BigDecimal("5.00"), currentBalance = BigDecimal("5.67") ) ) ) } } ...```

abubics
2020-09-18 07:22
It would be nice to turn this into a generic sample with a full app & build structure

abubics
2020-09-18 07:22
But this is the core of the pertinent bits, anyway :pray:

mmotornyi.consultant
2020-09-18 07:23
Great, thanks! I need to sort out all the things

abubics
2020-09-18 07:25
all g, ping us again if you have any other questions/issues ^_^ the weekend is just starting here (almost 5:30pm on Friday), but people should still be available for a few hours :innocent:

abubics
2020-09-18 07:25
This sample is using the java8 DSL, but I think there's a Kotlin DSL now, too

sathisan
2020-09-18 08:02
Hi everyone, Can someone Please tell me if this Consumer Test with pact JvM for https is still up-to-date? I could Not Retrieve the PactproviderRule used in this example with path and password of the keystore https://github.com/DiUS/pact-jvm/blob/master/consumer/junit/src/test/java/au/com/dius/pact/consumer/junit/pactproviderrule/PactProviderHttpsKeystoreTest.java

uglyog
2020-09-18 08:25
That example is on the master branch, which corresponds to version 4.1.7

sathisan
2020-09-18 09:21
Hi Ron, Thank you for your answer, do Dou have an example for using Pact for verifying HTTPS endpoint ?

sathisan
2020-09-18 09:24
I found the PactHttpsProviderRule with different implementations, but only the One which contains https boolean flag seems to set up a Mockhttps Server? Where ja the difference between PactproviderRule and PactHttpsProviderRule without containing the https boolean flag ?

francislainy.campos
2020-09-18 09:25
Hi, not sure your specific needs but all our endpoints are https and this is how we do it here from our side. ```@Provider(VC) /** Uncomment this and comment @PactBroker instead to test locally by pasting a .json file for the contract under the target/pacts folder */ @PactFolder("target/pacts") public class PactProviderTest { @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactTestTemplate(PactVerificationContext context, HttpRequest request) { request.addHeader("Authorization", AUTHORIZATION_TOKEN); context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpsTestTarget(getBasePactEndpoint(), 443, "/")); getAuthorizationToken(UserType.TEACHER); } @State("A request to retrieve the meeting list for a user") public void sampleState() { } }```

sathisan
2020-09-18 09:58
Thank you Francislainly Can you also Show me the corresponding the Consumer Test, currently I am stuck at setting up the Consumer Test for accessing the https Mock Server?

francislainy.campos
2020-09-18 09:58
```import au.com.dius.pact.consumer.dsl.DslPart; import au.com.dius.pact.consumer.dsl.PactDslJsonBody; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; import au.com.dius.pact.core.model.RequestResponsePact; import au.com.dius.pact.core.model.annotations.Pact; import io.restassured.RestAssured; import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; import static com.hmhco.vcservice.config.Constants.ED_UI; import static http://com.hmhco.vcservice.config.Constants.VC; /** * * mvn -Dtest=com.hmhco.vcservice.pact_tests.consumer.*Test test */ @ExtendWith(PactConsumerTestExt.class) public class PactConsumerTest { Map<String, String> headers = new HashMap<>(); String storeMeetingPath = "/vcservice/store/meeting"; DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); String nowAsISO = df.format(new Date()); @Pact(provider = VC, consumer = ED_UI) public RequestResponsePact createPact(PactDslWithProvider builder) throws ParseException { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); DslPart bodyReceivedStoreMeetingList = new PactDslJsonBody() .integerType("totalMeetings", 3) .integerType("totalPages", 1) .integerType("pageSize", 20) .integerType("pageNumber") .eachLike("meetings") .integerType("id", 93) .stringType("title", "My new title") .date("startDateTime", "yyyy-MM-dd'T'HH:mm:ss'Z'", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(nowAsISO)) .integerType("duration", 0) .stringType("attributes", "string") .stringType("provider", "ZOOM") .object("creator") .integerType("id", 1) .stringType("hmhUserRefId", "d7af5c68-fcee-4eab-8977-1d800a8b818e") .object("attributes") .closeObject() .closeObject() .array("participants") .closeArray(); return builder .given("A request to retrieve the meeting list for a user") .uponReceiving("A request to retrieve the meeting list for a user") .path(storeMeetingPath) .method("GET") .headers(headers) .willRespondWith() .body(bodyReceivedStoreMeetingList) .status(200) .toPact(); } @Test @PactTestFor(providerName = VC, port = "8080") public void runTest() { //Mock url RestAssured.baseURI = "http://localhost:8080"; RequestSpecification rq = RestAssured .given() .headers(headers) .when(); rq.get(storeMeetingPath); } }```

francislainy.campos
2020-09-18 09:59
Sure, here you go.


francislainy.campos
2020-09-18 10:00
And here an article I recently wrote talking about how we do Pact here from our side.

sathisan
2020-09-18 11:01
Thank you will go through these materials, i was Sticking to pact JvM with junit 4

francislainy.campos
2020-09-18 11:18
Yeah, I think better to do it with junit5 as more current.


abubics
2020-09-18 12:42
:taco: to @francislainy.campos for being a great helper buddy while also still being a fresh face :tada:

francislainy.campos
2020-09-18 12:44
Haha, thank you! Always good to get something to eat at lunch time. :wink:

sathisan
2020-09-18 12:44
@francislainy.campos One question regarding your Consumer test: If you want to test an HTTPS endpoint, why didn't you Set the https=True on the @PactTestFor annotation?

francislainy.campos
2020-09-18 12:45
I didn't need this as it worked regardless.

francislainy.campos
2020-09-18 12:45
To be honest, first time I see the mention of using this..

sathisan
2020-09-18 12:47
It is recommended doing so in the pact documentation for junit5: Using HTTPS# You can enable a HTTPS mock server by setting https=true on the @PactTestFor annotation. Note that this mock server will use a self-signed certificate, so any client code will need to accept self-signed certificates.Using HTTPS# You can enable a HTTPS mock server by setting https=true on the @PactTestFor annotation. Note that this mock server will use a self-signed certificate, so any client code will need to accept self-signed certificates.

francislainy.campos
2020-09-18 12:50
Uhhmm, well, we're verifying against our real https endpoints when triggering through the provider side.

francislainy.campos
2020-09-18 12:50
Not sure still why we'd needed to do a mocking using self signed certificates if that's not the real testing.

francislainy.campos
2020-09-18 12:53
I could be wrong but as far as I see it, the mock server on the consumer side is just to validate the contract has been set properly.

sathisan
2020-09-18 12:55
Yes agree with you, thank you :relaxed::+1:

phil.endsley
2020-09-18 13:15
Try using `.pathFromProviderState` on the consumer. That will let you template the id (with a default value) on the consumer. When your provider state is executed, it can create a new id, and inject that into the url before the request is made. The provider state method then just needs to return a map with the key and value Consumer: https://github.com/DiUS/pact-jvm/tree/master/consumer#having-values-injected-from-provider-state-callbacks Provider: https://github.com/DiUS/pact-jvm/tree/master/provider/junit#returning-values-that-can-be-injected

francislainy.campos
2020-09-18 13:28
:clap:

francislainy.campos
2020-09-18 13:29
That's so cool! Thanks Phil, that worked perfectly. I'll update my so question with the answer for this.

francislainy.campos
2020-09-18 13:29
```@State("A request to retrieve a Zoom meeting with one participant") public Map sampleState() { Map<String, Integer> map = new HashMap<>(); map.put("id", 391); return map; }```

francislainy.campos
2020-09-18 13:30
```return builder .given("A request to retrieve a Zoom meeting with one participant") .uponReceiving("A request to retrieve a Zoom meeting with one participant") .pathFromProviderState("/vcservice/store/meeting/${id}", "/vcservice/store/meeting/500") .method("GET")```

francislainy.campos
2020-09-18 13:39
Update done.

komeershettyvinod
2020-09-18 15:39
can we achieve same through gradle?

komeershettyvinod
2020-09-18 15:39
Thanks for asking this @francislainy.campos




komeershettyvinod
2020-09-18 16:06
consumer side its fine

komeershettyvinod
2020-09-18 16:26
i dont see example at provider side i.e how to declare/use

komeershettyvinod
2020-09-18 16:26
:disappointed:

phil.endsley
2020-09-18 16:29
I haven't used the gradle stuff, but it looks like it should work the same. Just return a map of {templateKey: value} from the provider state callback. Where templateKey is the same variable name used from the consumer template

komeershettyvinod
2020-09-18 16:39
How to return a

komeershettyvinod
2020-09-18 16:40
service { given('User harry exists') uponReceiving('a request for user harry') withAttributes(method: 'get', path: fromProviderState('/api/user/${id}', '/api/user/100')) withBody { name(fromProviderState('userName', 'harry')) // looks up the value using the userName key }

komeershettyvinod
2020-09-18 16:40
how to return a path here

komeershettyvinod
2020-09-18 16:41
from build.gradle , can you share small snippet how to achieve plz

phil.endsley
2020-09-18 16:41
That's from the consumer. The first link I sent has a code snippet

phil.endsley
2020-09-18 16:42
```service { given('User harry exists') uponReceiving('a request for user harry') withAttributes(method: 'get', path: fromProviderState('/api/user/${id}', '/api/user/100')) withBody { name(fromProviderState('userName', 'harry')) // looks up the value using the userName key } }```

phil.endsley
2020-09-18 16:43
Ah. Didn't realize that's what you posted as well... ```withAttributes(method: 'get', path: fromProviderState('/api/user/${id}',``` Isn't that what this is doing?

komeershettyvinod
2020-09-18 17:00
No issues with consumer side I am using exactly this way

komeershettyvinod
2020-09-18 17:01
How to call from producer side?

komeershettyvinod
2020-09-18 17:01
in gradle

phil.endsley
2020-09-18 17:12
I'm not very confident with groovy, so this may not work :sweat_smile: But I would think something like: ```stateChange = { providerState -> // providerState is an instance of ProviderState def fixture = loadFixtuerForProviderState(providerState) setupDatabase(fixture) {"id": 123} }``` Is what you would want to use a value of 123 for {id} I just tweaked the example from https://github.com/DiUS/pact-jvm/tree/master/provider/gradle#using-a-closure If this doesn't work, might need to just experiment or wait for @uglyog or someone else that's done it

komeershettyvinod
2020-09-18 17:23
is loadFixtuerForProviderState and setupDatabase are predefined?

phil.endsley
2020-09-18 17:24
No. You can remove those lines. Presumably, those are separate functions that would actually configure the provider state and set up the database with seed data, respectively

uglyog
2020-09-19 02:01
@phil.endsley has it correct

matt.fellows
2020-09-20 11:48
@phil.endsley :taco:

matt.fellows
2020-09-20 11:51
@francislainy.campos please help yourself to a :taco: for answering on SO

young
2020-09-21 07:15
Hi Pact team, where should I add the './gradlew pactVerify' action to the Provider in a deploy pipeline? position1, or position 2? I think the position 1 is preferred, any suggestions? Thanks.

matt.fellows
2020-09-21 07:18
I?d run it as part of the test phase, so (1)

young
2020-09-21 07:20
Thank you @matt.fellows

sathisan
2020-09-21 07:57
@francislainy.campos I tried the same setup like you, but currently have some issue with the certification Is the port 443 you give as Parameter the same One where your actual Application will listen to it ?

francislainy.campos
2020-09-21 10:04
No, 443 is just a number so that it doesn't generate random ones. I think it may not make much difference which one to use.

francislainy.campos
2020-09-21 10:07
Are you verifying against your hosted remote service? Are you able to do any other type of test against it? Maybe not an issue with Pact but something else? Can you trigger your apis from Postman? Can you do functional tests using Rest Assured or other? Which specific error do you get?

francislainy.campos
2020-09-21 10:12
Hi, good morning. Sorry, same question as last week but for an object rather than an array. Wanting to verify whether the key is there regardless of whether it's coming back as null. Thank you.

francislainy.campos
2020-09-21 10:16
Found it here!

francislainy.campos
2020-09-21 10:16
```.nullValue("attributes")```

sathisan
2020-09-21 11:21
I get a Connection refused Error, and could Not figure out why

francislainy.campos
2020-09-21 11:22
But why you're using localhost as the target?

francislainy.campos
2020-09-21 11:22
It should be the url you're testing against..

francislainy.campos
2020-09-21 11:24

francislainy.campos
2020-09-21 11:24
Like this, and without the https at the beginning.

sathisan
2020-09-21 11:31
There are different implementations of HttpsTestTarget, the One i Posted earlier is the One containing Host and port As the URL i am testing is: https://localhost:8448/auth/getTribeList?password=F67617, i Set my Host as localhost and port i Set randomly as you told

francislainy.campos
2020-09-21 11:32
I'm not sure how to test against localhost if this is not a url that is hosted outside your local computer.

francislainy.campos
2020-09-21 11:33
There may be a way but never done that and not sure why you need it this way?

francislainy.campos
2020-09-21 11:33
Is your api not hosted remotely?

sathisan
2020-09-21 11:39
The contract testing is applied here to test the REST APIs of the application itself Since it will be a microservices reference Application, they want to introduce contract testing as it is an additional Layer of testing in a microservices application

francislainy.campos
2020-09-21 11:44
Okay, maybe better to ping @matt.fellows or @phil.endsley in case they can better advise you. I'm not sure what you mean by testing the application itself, you mean, prior to deployment? Wouldn't they have a dev environment they could deploy against and verify it this way so that you'd still have access to a hosted url? Otherwise, I'm not sure how to do this connection to a localhost. The issue here doesn't seem to be Pact itself but this part.

francislainy.campos
2020-09-21 11:47
As far as I understand it, Pact comes as part of the integration layer, so not the same as unit tests which seems to be how you guys may be intending to use it.

sathisan
2020-09-21 11:47
I Test the correctness of the messages from the REST APIs in my Application, so i am using pact to check the interaction between the webclient and the apis

francislainy.campos
2020-09-21 11:48
Yeah, but I think you could do this outside localhost no?

francislainy.campos
2020-09-21 11:49
What is the url your consumers use? This is the one I think you should be using.

sathisan
2020-09-21 11:50
So far it Not deployed and only accessible via localhost

francislainy.campos
2020-09-21 11:52
Okay, yeah, I'm not sure how to do this connection through a localhost myself. Sorry, it may be possible, but never done it.

francislainy.campos
2020-09-21 11:53
Maybe wait till one of the guys can jump in on this thread or someone else or even post another question, asking how to do pact against localhost, since this is what you seem to be wanting.

sathisan
2020-09-21 11:53
Thank you for your help, Great article, i like your writing style, was Interactive while reading

francislainy.campos
2020-09-21 11:55
Thank you. Appreciate it. Sorry that couldn't help much more here. I'll try to write some more as I'm also learning and it's good to share so we can help each other.

francislainy.campos
2020-09-21 11:55
I'll keep checking on this thread if you can find the solution as would be curious to see what to do for your specific scenario.

francislainy.campos
2020-09-21 11:59
Ah! wait, thinking here now. Is your application running while you're trying to run your pact tests? Could this be the issue if it is not? I mean, within the same IntelliJ project are you able to trigger the same request you're trying to verify against using Pact?

francislainy.campos
2020-09-21 12:06
If you try the same api on postman is it working?

sathisan
2020-09-21 12:09
Yes i Run my pact tests while my Application was Running, but does it matter ? The Application context is generated while executing But for my use Case, i found a Good example in the repo: package au.com.dius.pact.provider.junit5; import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.State; import au.com.dius.pact.provider.junitsupport.loader.PactFolder; import com.github.tomakehurst.wiremock.WireMockServer; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import ru.lanwen.wiremock.ext.WiremockResolver; import ru.lanwen.wiremock.ext.WiremockUriResolver; import java.util.Map; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static java.lang.String.format; @Provider("myAwesomeService") @PactFolder("pacts") @ExtendWith({ WiremockResolver.class, WiremockUriResolver.class }) public class HttpsContractTest { private static final Logger LOGGER = LoggerFactory.getLogger(HttpsContractTest.class); @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(PactVerificationContext context) { context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context, @WiremockResolver.Wiremock(factory = WiremockHttpsConfigFactory.class) WireMockServer server) { // Rest data // Mock dependent service responses // ... http://LOGGER.info("BeforeEach - " + server.httpsPort()); context.setTarget(new HttpsTestTarget("localhost", server.httpsPort(), "/", true)); server.stubFor( get(urlPathEqualTo("/data")) .willReturn(aResponse() .withStatus(204) .withHeader("Location", format("http://localhost:%s/ticket/%s", server.port(), "1234") ) .withHeader("X-Ticket-ID", "1234")) ); } @State("default") public void toDefaultState() { // Prepare service before interaction that require "default" state // ... http://LOGGER.info("Now service in default state"); } @State("state 2") public void toSecondState(Map params) { // Prepare service before interaction that require "state 2" state // ... http://LOGGER.info("Now service in 'state 2' state: " + params); } }

francislainy.campos
2020-09-21 12:36
Yeah, I think it would matter otherwise there wouldn't be a response to be verified against.

phil.endsley
2020-09-21 12:51
@sathisan Are you still having issues? And if so, what are they? Testing against localhost is perfectly fine, and is what I encourage. That way, you can run verifications as part of your build pipeline, and you don't have to wait for your application to deploy before running verifications.

sathisan
2020-09-21 14:22
Hi @phil.endsley Thank you for your Feedback I found the Code i Posted above for contract testing with https and junit5. Maybe if you are familiar, you can help me with the following questions: Why do we need to inject a mockserver, is it Not possible to verify against the Running Application if i have an Https endpoint?

phil.endsley
2020-09-21 14:41
I don't think you need to. The example you found is in the unit testing package of the jvm pact source code. I'm pretty sure this is actual tests for the library itself to ensure it all works as expected. Back to your earlier comment: > i Set my Host as localhost and port i Set randomly as you told The port you use should match the port of your running application. Just making sure you're setting that to the actual port being used, and not a random number. > As the URL i am testing is: https://localhost:8448/auth/getTribeList?password=F67617, If 8448 is always the port being used when your provider tests are ran, you should set the port to 8448 on https target

phil.endsley
2020-09-21 14:45
I haven't done any pact tests with https, because we don't have that need. One assumption I'm making, is when your application is running on localhost for your tests, you're serving it over https with tls certificates. If your tests are not starting your application on localhost with tls, you don't need https for your pacts. You may already know this, just want to reiterate that point.

sathisan
2020-09-21 15:51
Thank you @phil.endsley I am Not Sure if I understand your point correctly, but in my use Case the endpoints do Not get invoked if I use httptarget, always get 400 status,because the certificates used for https authorise the User for invoking the endpoint. And Now if I use your setup as suggested, I get a message about the certification.

phil.endsley
2020-09-21 15:52
What message about certification?

phil.endsley
2020-09-21 15:55
Can you put the whole reason here? You can remove proprietary info if need be Looks like the error message is "Unable to find..."

sathisan
2020-09-21 15:57
i am unable to Copy and paste

francislainy.campos
2020-09-21 15:58
Hi, what would be the best way to have the body passed as params for my post api as specified on the consumer contract printed back to me when verifying it from the provider side please. Thought it would be there under the interaction object but it doesn't seem to be the case.

sathisan
2020-09-21 16:00
Hope you can still read it, would appreciate any help I am Not Sure is, the certificate used for application needs to be created once again for Test purposes to invoke my endpoint ?

phil.endsley
2020-09-21 16:03
Yeah, no problem. So good news and bad news. Good news: it looks like the pact stuff is all working correctly. Your test runs, it finds interactions, and looks like a request is being made to the provider. Bad news: This doesn't look like a pact problem, so help here may be limited...

phil.endsley
2020-09-21 16:04
My guess is your application instance when running tests is not correctly setting up the certificates

phil.endsley
2020-09-21 16:04
Like you said, if you're not configuring the certificates for your tests, that's something you need to do

phil.endsley
2020-09-21 16:13
It's probably under interaction.request At this point in the flow, the http request has already been made, so the request body you specified should be part of the request object

francislainy.campos
2020-09-21 16:22
Thanks a lot, Phil. Yeah, that worked.

sathisan
2020-09-21 16:23
The certificate is already in use for application, and for Test purposes I Need to have corresponding certificates to invoke the endpoint I can overcome these issues with the mvctesttarget right?

phil.endsley
2020-09-21 16:36
I'm not sure what mvctesttarget would give you that whatever you're using now doesn't. As I understand it, the issue you're running into now seems to be that your mechanism for authenticating users is not setup/configured correctly for your provider tests. If you have to have that working, and it works by using certificates, I don't see a way around it without using certificates with your tests

phil.endsley
2020-09-21 16:37
It's been hinted at a few times, but if you can mock out/bypass the auth process when running your provider tests locally, you can probably bypass the https requirement. Sometimes, this is not possible though, and it's completely dependent on your individual use case. https://docs.pact.io/provider/handling_auth/

sathisan
2020-09-21 19:58
Hi @phil.endsley Thank you for your help, Really appreciate it the mvc setup supports the use @ WithMockUser which mocks the authentication

francislainy.campos
2020-09-21 20:02
That's really great it seems to be working for you now, Sathish. Well done! Could you share the full code for your provider as would be interested in having a look at your final working implementation if it's okay with you.

sathisan
2020-09-21 20:58
Thank you Francislainly :relaxed: Will summarize my approach and present it in the channel

abubics
2020-09-22 00:02
:taco: for @phil.endsley, who has the patience of a saint :innocent:

phil.endsley
2020-09-22 00:51
You're too kind :grin: I just like helping people

kflo
2020-09-22 01:18
has joined #pact-jvm

aaron.ramirez
2020-09-22 03:35
has joined #pact-jvm

francislainy.campos
2020-09-22 10:59
```public static void logCurlFromPact(PactVerificationContext context, HttpRequest request) throws IOException { String bodyParam = ((RequestResponseInteraction) context.getInteraction()).getRequest().getBody().valueAsString(); http://log.info(bodyParam); String bodyResponse = ((RequestResponseInteraction) context.getInteraction()).getResponse().getBody().valueAsString(); String method = ((RequestResponseInteraction) context.getInteraction()).getRequest().getMethod(); String baseUrl = ""; if (method.equals("POST")) { baseUrl = ((HttpPost) request).getURI().toString(); } else if (method.equals("GET")) { baseUrl = ((HttpGet) request).getURI().toString(); } Header[] headers = request.getAllHeaders(); String headersString = ""; for (Header s : headers) { headersString = headersString + "--header " + "'" + s.getName() + ": " + s.getValue() + "'" + "\\" + "\n"; } String curl = "" + "curl " + "'" + baseUrl + "' \\" + "\n" + headersString + "--data-binary " + "'" + bodyParam + "' \\" + "\n" + "--compressed \\" + "\n" + "--insecure \\" + "\n" + "--verbose" + ""; System.out.println(curl + "\n\n " + bodyResponse + " \n ---- \n"); }```

francislainy.campos
2020-09-22 11:02
```@TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactTestTemplate(PactVerificationContext context, HttpRequest request) throws IOException { request.addHeader("Authorization", AUTHORIZATION_TOKEN); logCurlFromPact(context, request); context.verifyInteraction(); }``` There may be better ways to do this but got this method working when wanting to print a curl for my Pact tests.


francislainy.campos
2020-09-22 11:17
Turned it a SO post in case helpful to someone else.

giuseppe.salvatore
2020-09-22 12:48
Hi everyone, I am having a slightly annoying problem I have not been able to figure out how to solve Consumer is pact-jvm, Provider is node-js In the contract the Consumer is publishing, the response header has ```"headers": { "Content-Type": "application/json; charset=UTF-8" }``` but when the node-js service verifies the contract it produces ```"Content-Type": "application/json; charset=utf-8"``` (note utf in lowercase) Is there a way to perform a case insensitive match? I was trying to change the way the consumer produces the response so that it could have it as lower case but using the RestTemplate I don't seem to be able to change that in the response

matt.fellows
2020-09-22 13:04
I'm not sure. A regex matcher may be able to do it with a case insensitive check. I would just use a regex matcher that checks for the content type and ignores the charset parameter See also https://github.com/pact-foundation/pact-specification/tree/version-3

giuseppe.salvatore
2020-09-22 13:05
yeah the problem is that on the provider side it looks to me like the verification is ran automatically with very little input from me

giuseppe.salvatore
2020-09-22 13:09
but I can see there are links with similar discussions around the Content-Type failures.... I will take a look at it

giuseppe.salvatore
2020-09-22 13:09
thanks @matt.fellows always useful stuff!!

giuseppe.salvatore
2020-09-22 13:19
Ahh... now I understand what you mean Matt!! It makes sense, I just need to find how to do it

giuseppe.salvatore
2020-09-22 15:37
@matt.fellows looks like I managed to make a bit of progress and to express the content-type as a regex in the response

giuseppe.salvatore
2020-09-22 15:37
```pactRequestWithPath .willRespondWith() .matchHeader("Content-Type", "application/json; charset=(utf|UTF)-8") .status(200)```

giuseppe.salvatore
2020-09-22 15:38
which in fact produces

giuseppe.salvatore
2020-09-22 15:38
```"matchingRules": { "header": { "Content-Type": { "matchers": [ { "match": "regex", "regex": "application/json; charset=(utf|UTF)-8" } ], "combine": "AND" } },```

giuseppe.salvatore
2020-09-22 15:38
which seems to be correct

giuseppe.salvatore
2020-09-22 15:39
but for some reasons it looks like it keeps complaining with the same error

giuseppe.salvatore
2020-09-22 15:39
on the provider

giuseppe.salvatore
2020-09-22 15:39
and if I provide an example in the matchHeader function

giuseppe.salvatore
2020-09-22 15:40
```.matchHeader("Content-Type", "application/json; charset=(utf|UTF)-8", "application/json; charset=UTF-8")```

giuseppe.salvatore
2020-09-22 15:40
like the above it fails

giuseppe.salvatore
2020-09-22 15:41
```.matchHeader("Content-Type", "application/json; charset=(utf|UTF)-8", "application/json; charset=utf-8")```

giuseppe.salvatore
2020-09-22 15:41
with this example instead succeeds

giuseppe.salvatore
2020-09-22 15:41
seems to me like it's ignoring the regex and going straight to the example

giuseppe.salvatore
2020-09-22 15:48
your idea was good and thought it would have worked :confused:

uglyog
2020-09-22 22:50
This needs to be fixed in pact-js. I've had this issue as well and it is annoying. Can you raise an issue on the Pact-JS project?

matt.fellows
2020-09-23 01:23
I?d say it is the way the underlying Ruby binary interprets the regex

matt.fellows
2020-09-23 01:23
Might be doable, but I recall regexes being funny in Ruby

matt.fellows
2020-09-23 01:23
in any case, please raise an issue and we?ll look at it

matt.fellows
2020-09-23 01:24
I would do this for the time being (ignore the charset in the regex for now, unless it?s really important): ```.matchHeader("Content-Type", "application/json", "application/json; charset=utf-8")```

uglyog
2020-09-23 01:25
Not a problem with regex, problem with matching headers

uglyog
2020-09-23 01:26
It should accept `application/json; charset=UTF-8` and `application/json; charset=utf-8`

uglyog
2020-09-23 01:26
They are the same value

giuseppe.salvatore
2020-09-23 07:42
ok thanks guys I will raise a bug in JS project :+1:

komeershettyvinod
2020-09-23 16:16
Does pact 4.1.x requires junit 5 version as a pre-req

komeershettyvinod
2020-09-23 16:17
I want to use 4.1.x but already whole lot of tests are dependent on junit 4

komeershettyvinod
2020-09-23 16:17
in my framewrk

komeershettyvinod
2020-09-23 16:18
I want to know if 4.1.x works with junit 4 as well?

phil.endsley
2020-09-23 16:44
It works with both. There are separate libraries you can import depending on which one you want (junit 4 vs 5)

mbbush
2020-09-23 22:18
has joined #pact-jvm


francislainy.campos
2020-09-24 07:27
I had the same issue when started with Pact and here how it got solved. You can run both JUnit4 and 5 on the same project using a most recent version for the maven surefire plugin.

christiaan
2020-09-24 08:31
has joined #pact-jvm

giuseppe.salvatore
2020-09-24 09:52
@uglyog @matt.fellows sorry it took so long


christiaan
2020-09-24 10:56
Hi all.  Two newbie questions: 1) Can somebody explain me the actual reason/rational about why when you use maven that, after running your unit tests, the producer needs to verify the pact in a seperate step "`mvn pact:verify"` against a running provider?  2 If my producer application already exdcutes junit in the "normal maven verify goal", which is also triggered during e.g mvn clean install, can I then skip this "`mvn pact:verify"` alltogether?

wesleythomaswilliams
2020-09-24 11:32
Hi Christiaan, not sure I can answer the question specifically, more talk about our configuration. Our junit tests do the verification, so we don't use pact:verify. See the note in the attached image from the below link.


matt.fellows
2020-09-24 11:44
Just closing out the thread here for those not following the GH issue - TL;DR - the pact is a v3 generated Pact, and Pact JS currently supports 2. See ticket for more

christiaan
2020-09-24 12:06
Thanks Wes for replying. I saw this passage indeed. So this means that if my application uses junit as wel as maven, then I do not have to use pact:verify. Check!

phil.endsley
2020-09-24 12:33
Correct! You just have to set a system property to make sure you're publishing the results. https://docs.pact.io/implementation_guides/jvm/provider/junit/#publishing-verification-results-to-a-pact-broker

adrianojedabenitez
2020-09-24 13:01
has joined #pact-jvm

komeershettyvinod
2020-09-24 13:54
Provider Test

komeershettyvinod
2020-09-24 13:54
import http://au.com.dius.pact.provider.junit.Consumer import http://au.com.dius.pact.provider.junit.Provider import http://au.com.dius.pact.provider.junit.State import http://au.com.dius.pact.provider.junit.loader.PactBroker import http://au.com.dius.pact.provider.junit.loader.PactBrokerAuth import http://au.com.dius.pact.provider.junit5.HttpTestTarget import http://au.com.dius.pact.provider.junit5.PactVerificationContext import http://au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider import org.apache.http.HttpRequest import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.TestTemplate import org.junit.jupiter.api.extension.ExtendWith @Provider("A Service") @PactBroker(host = "xxxx", authentication = @PactBrokerAuth(token = "dfgxx5tA8J0viAUfzOOZldrsAzzzzzzzzzz")) @Consumer("B Service") public class ProviderTest { @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", 8084, "/")); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactTestTemplate(PactVerificationContext context, HttpRequest request) { request.addHeader("Authorization", ApiUtil.getAuthorizationToken()); request.addHeader('X-Auth-Scheme', 'CERBERUS') context.verifyInteraction(); } @State("test Get call marketing plan details") public def sampleState() { } @State('marketingplan details') public def sampleState1() { Map<String, String> map = new HashMap<>(); map.put("id", "123"); return map; } }

komeershettyvinod
2020-09-24 13:54
Consumer Test:

komeershettyvinod
2020-09-24 13:55
`import http://au.com.dius.pact.consumer.PactVerificationResult` import http://au.com.dius.pact.consumer.groovy.PactBuilder import groovy.json.JsonSlurper import http://groovyx.net.http.ContentType import http://groovyx.net.http.RESTClient import org.junit.Test class ContractServiceSpec1 { protected static FORECAST_DATA_JSON_FILE_PATH = '/inputs/marketingPlanData1.json' URL getResourceFile(String resourceFilePath) { this.getClass().getResource(resourceFilePath) } String readJsonFileText(String jsonFilePath) { URL jsonFile = getResourceFile(jsonFilePath) return jsonFile?.text } @Test void "Post User service test"() { String s= readJsonFileText(FORECAST_DATA_JSON_FILE_PATH) def fs= new JsonSlurper().parseText(s) print "dddd"+fs def MP_FRService = new PactBuilder() // Create a new PactBuilder MP_FRService { serviceConsumer "AService" // Define the service consumer by name hasPactWith "B Service" // Define the service provider that it has a pact with port 9000 // The port number for the service. It is optional, leave it out to given('test Get call marketing plan details') // defines a provider state. It is optional. uponReceiving('marketingplan details') // upon_receiving starts a new interaction withAttributes( path: fromProviderState('/api/v1/marketingPlanDetails/${id}','/api/v1/marketingPlanDetails/5f591924089d2c4fdc64e0bd'), method: 'get' ) willRespondWith( // define the response we want returned status: 200, headers: ['Content-Type': 'application/json'], body: fs ) } // Execute the run method to have the mock server run. // It takes a closure to execute your requests and returns a PactVerificationResult. PactVerificationResult result = MP_FRService.runTest { def client = new RESTClient('http://localhost:9000') def alice_response = client.get( path: '/api/v1/marketingPlanDetails/5f591924089d2c4fdc64e0bd') assert alice_response.status == 200 print alice_response.contentType == 'application/json' print "--------------->"+alice_response.data print "--------------->"+alice_response.responseData def data = alice_response.responseData assert data == fs } assert result == PactVerificationResult.Ok.INSTANCE // This means it is all good } // }

komeershettyvinod
2020-09-24 13:57
I was not able to pass the id from producer side to the contract file

komeershettyvinod
2020-09-24 13:58
any one can please help me what is missing :disappointed:

thomas.hibbard
2020-09-24 15:09
has joined #pact-jvm

komeershettyvinod
2020-09-24 16:48
plz ignore the msg , i was able to figure out i was using lower version

adrianojedabenitez
2020-09-25 21:36
hey dear friends! I?m facing with a weird issue, not finding any solution in the doc :sleepy:. I?m using `junit5 http://au.com.dius.pact.provider version 4.1.1 ` to build my providers pacts. The providers are being run from the build process and also when is triggered by a web-hook. I want to enable the pending contracts (because is something that we need) as per doc I?m running this command to run my verification tests ``` mvn -Dpact.verifier.publishResults=true -Dpactbroker.enablePending=true -Dpactbroker.tags=develop -Pcicdprofile clean install -s config/ci_settings.xml ``` in my code I have the next annotations. @IgnoreNoPactsToVerify // otherwise the build fails when is called from a webhook with the -Dpact.filter.pacturl filter @AllowOverridePactUrl // this as per doc to enable the Dpact.filter.pacturl (used by webhook as well) The issue with this is when I run the build from normal flow, it fails here ``` @BeforeEach void setupTestTarget(PactVerificationContext context) { context.setTarget(new HttpTestTarget(?localhost?, serverPort)); } ``` getting a NullPointer exception. Do you guys have any idea what is going on?

phil.endsley
2020-09-25 22:22
Is the npe in your before each method? If there aren't any pacts being verified, context will be null

adrianojedabenitez
2020-09-25 22:27
yup, the npe is exactly here -> context.setTarget(new HttpTestTarget(?localhost?, serverPort));

adrianojedabenitez
2020-09-25 22:28
seems that -Dpactbroker.enablePending=true causes that issue

adrianojedabenitez
2020-09-25 22:28
but I need it, because I will be able to pass the build with pending pacts

adrianojedabenitez
2020-09-25 22:31
so you mean ```HttpTestTarget("localhost", serverPort)```

adrianojedabenitez
2020-09-25 22:32
is not needed if I?m going to enable pending tests?

phil.endsley
2020-09-25 23:04
If you're getting a npe there, your provider probably isn't finding any pacts to verify. You should be able to confirm that from the logs

phil.endsley
2020-09-25 23:05
Also, if you're using enable pending pacts, you must set the provider tags property

phil.endsley
2020-09-25 23:07
pactbroker.providerTags system property

adrianojedabenitez
2020-09-26 01:50
thanks for reply buddy! yeah provider tag is defined, I?d consider the fact that there is no pact to verify but if I remove the enablePending it works.. I will research and let you know if you want.

phil.endsley
2020-09-26 01:58
When using pending pacts, if there are not any verification results published by the provider that are also tagged with whatever you define as providerTags, you won't get any pacts back... Note that providerTags I was talking about is not the same property used to tag your verification results

adrianojedabenitez
2020-09-26 02:24
wow that was fast! thanks man! will try! you are my hero!

adrianojedabenitez
2020-09-26 22:53
just as heads up, I could fix this issue as per Phil?s suggestions in the thread, but then I got the build fail (even if the test was pending) researching in the slack history I found that issue was fixed on version 4.1.3 I was using 4.1.1 just as suggestion, please update the documentation here https://www.screencast.com/t/dDSiT9GF4 so another user with version < 4.1.3 won?t have the same issue. Thanks guys!

uglyog
2020-09-26 23:28
Can you raise an issue for this on the Github project

adrianojedabenitez
2020-09-26 23:36
for sure!


dabs1234
2020-09-29 07:06
Guys I trying to test the api which needs access tocken. Following is the code ```@TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context, HttpRequest request) { request.addHeader("Authorization", "Bearer " + getClientOAuthToken()); context.verifyInteraction(); System.setProperty("pact.verifier.publishResults", "true"); }``` Getting following 400 error: 1.1) StatusMismatch: expected status of 200 but was 400 1.2) BodyMismatch: $ BodyMismatch: Expected name='name' but was missing { - "name": "name", - "id": 2000 + "timestamp": 1601355640376, + "status": 400, + "error": "Bad Request", + "message": "Missing request header 'Authorization' for method parameter of type String", + "path": "/portal/movie" } What might be wrong here? Any sample with JUnit5 would be a great help.


phil.endsley
2020-09-29 14:18
@uglyog Any chance of re-enabling notifications just for new issues created in the github repo (I'm ok with leaving PRs and everything else off)? Not sure how others feel, but I liked new issue reports for keeping a pulse on the current state of things

phil.endsley
2020-09-29 15:14
Are you using Spring Boot (Message matches, and follows the format of their responses)? What you have is what we're doing (Spring Boot with junit 5). And I just tested by adding the auth header as a parameter to the rest controller, and it still works. Pact provider test ```@TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(HttpRequest request, PactVerificationContext context) { // ... irrelevant setup request.addHeader("Authorization", "Bearer someTestToken"); context.verifyInteraction(); }``` Rest controller ``` @GetMapping ResponseEntity<List<Object>> getAllThings(@RequestHeader Map<String, String> headers, @RequestHeader(value = "Authorization") String authHeader) { System.out.println("Got auth header: " + authHeader);``` In our logs: ```Verifying a pact between my-consumer and my-provider Given some state a request to do something Got auth header: Bearer someTestToken <--- From the console out above returns a response which has status code 200 (OK) includes headers "Content-Type" with value "application/json" (OK) has a matching body (OK)```

raghanag
2020-09-29 17:36
has joined #pact-jvm

uglyog
2020-09-29 23:03
Hmm, the problem would be that every comment on the issue will be posted here. But let's see what we can do.

uglyog
2020-09-29 23:03
I'll see if we can get only new notifications

phil.endsley
2020-09-29 23:12
Gotcha. If it's too noisy, I totally get it. I'm just trying to be lazy and make this a one stop shop for me

uglyog
2020-09-29 23:15
/github subscribe list

uglyog
2020-09-29 23:15
/github subscribe list features

uglyog
2020-09-29 23:18
/github subscribe DiUS/pact-jvm issues

abubics
2020-09-30 00:15
Could make a separate notifications channel if it's too noisy for most people :slightly_smiling_face:

anddreiu
2020-09-30 09:45
Hi. I've just updated the pact provider junit library in my project from 4.1.1 to 4.1.7 and it looks like I have some issues when running the provider tests for _some_ (not all of them) pact files. I get the bellow error. Using 4.1.1, it's working fine. Any hints on what could be the problem? Thanks. ```au.com.dius.pact.core.support.json.JsonException: Invalid JSON (1:2), found unexpected character '<' at au.com.dius.pact.core.support.json.JsonLexer.unexpectedCharacter(JsonParser.kt:88) at au.com.dius.pact.core.support.json.JsonLexer.nextToken(JsonParser.kt:79) at au.com.dius.pact.core.support.json.JsonParser.nextTokenOrThrow(JsonParser.kt:278) at au.com.dius.pact.core.support.json.JsonParser.parse(JsonParser.kt:151) at au.com.dius.pact.core.support.json.JsonParser.parseString(JsonParser.kt:131) at au.com.dius.pact.core.model.RequestResponseInteraction$Companion.setupBodyForJson(RequestResponseInteraction.kt:123) at au.com.dius.pact.core.model.RequestResponseInteraction$Companion.requestToMap(RequestResponseInteraction.kt:85) at au.com.dius.pact.core.model.RequestResponseInteraction.toMap(RequestResponseInteraction.kt:37) at au.com.dius.pact.provider.reporters.JsonReporter.interactionDescription(JsonReporter.kt:132) at au.com.dius.pact.provider.ProviderVerifier.reportInteractionDescription(ProviderVerifier.kt:502) at au.com.dius.pact.provider.junit.InteractionRunner.interactionBlock(InteractionRunner.kt:218) at au.com.dius.pact.provider.junit.InteractionRunner.run(InteractionRunner.kt:162) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:150) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:56) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:363)```

anddreiu
2020-09-30 10:40
just verified now that on 4.1.1 is working fine, but when I use 4.1.2 it fails with the above error

sathisan
2020-09-30 11:19
Hello everyone, I have one question regarding Contract testing with Pact: I have Not used the pact Broker in my setup, since Consumer and provider reside in the same repository. Locally, build is successful, but after merging my pipeline fails because the pacts are not found. I am using maven as build tool and jenkins for pipeline setup. Can someone help me? How do i make Sure that consumer tests ade executed before provider tests?

wesleythomaswilliams
2020-09-30 11:21
Are your consumer and provider tests junit tests?

sathisan
2020-09-30 11:23
Yes i am using juni5

wesleythomaswilliams
2020-09-30 11:27
So one of the things we've done in our tests is to separate our unit, contract and component tests by maven profiles, so that we can execute them in different stages of our jenkins pipelines. This could be a way for you to separate your consumer and provider tests, but I'm sure there are others too.

wesleythomaswilliams
2020-09-30 11:28
```<profiles> <profile> <id>consumer-tests</id> <!-- consumer tests --> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <excludes> <exclude>**/*ConsumerTest.java</exclude> </excludes> </configuration> </plugin> </plugins> </build> </profile> <profile> <id>provider-tests</id> <!-- only provider tests --> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <includes> <include>**/*ProviderTest.java</include> </includes> </configuration> </plugin> </plugins> </build> </profile> </profiles>```

wesleythomaswilliams
2020-09-30 11:30
```mvn test -Pconsumer-tests mvn test -Pprovider-tests```

sathisan
2020-09-30 11:31
Thank you, in the section for Consumer tests, why do Dou exclude ConsumerTest.java, does it Not need to be included if the Profile is consumer-tests?

abubics
2020-09-30 11:49
Judging by the error message: > Invalid JSON (1:2), found unexpected character '<' in my experience, that usually means XML is going somewhere that expects JSON.

abubics
2020-09-30 11:50
If you can breakpoint where the exception is thrown, you might have more luck debugging :upside_down_face:

abubics
2020-09-30 11:51
Not sure why it would've changed behaviour over that version range, though :s

anddreiu
2020-09-30 11:51
yep, that's also my question

abubics
2020-09-30 11:53
Someone like @uglyog may have an answer for you tomorrow :slightly_smiling_face: it's almost 10pm here, so you might have to wait 10+ hours :pray:

anddreiu
2020-09-30 11:53
sure, no worries :slightly_smiling_face:

giuseppe.salvatore
2020-09-30 17:51
Hi guys, I was looking at the PACT contracts in the broker and for some reasons I can't see the given clause printed in the list (in fact I had to add it manually to give it more sense)

giuseppe.salvatore
2020-09-30 17:51
my code looks like this

giuseppe.salvatore
2020-09-30 17:52
```return builder .given("Average usage is not available for existing MSISDN " + mobileNumber2) .uponReceiving("A GET request to /" + mobileNumber2 + "/average-usage given average usage not available for existing MSISDN " + mobileNumber2) .method("GET") .headers(headers.toSingleValueMap()) .path("/" + mobileNumber2 + "/average-usage") .willRespondWith() .status(200) .body(bodyObject) .toPact();```

giuseppe.salvatore
2020-09-30 17:59
and this is what I get in the broker

giuseppe.salvatore
2020-09-30 17:59
which is fine as a workaround but the given should really be before

phil.endsley
2020-09-30 18:09
What version of the jvm libs and pact broker are you using? Our givens show up correctly

giuseppe.salvatore
2020-09-30 18:16
yeah I suspect is the pact version that is not understood by the broker

giuseppe.salvatore
2020-09-30 18:17
so I have got pact-jvm-consumer: 3.5.24 (I am updating it now to 4.0.10)

giuseppe.salvatore
2020-09-30 18:17
not sure how to check the broker version

giuseppe.salvatore
2020-09-30 18:17
let me see

phil.endsley
2020-09-30 18:18
If you look at the API browser in broker, it will show as a response header

giuseppe.salvatore
2020-09-30 18:21
ah sweet... it was right in front of my face

giuseppe.salvatore
2020-09-30 18:21
```x-pact-broker-version: 2.32.0```

giuseppe.salvatore
2020-09-30 18:21
bit old?

giuseppe.salvatore
2020-09-30 18:22
here is the repo I have used and it was deployed using helm


phil.endsley
2020-09-30 18:23
A bit :slightly_smiling_face:

phil.endsley
2020-09-30 18:23
I would try updating versions and seeing if that fixes it. A lot can change in a year and a half :grin:

giuseppe.salvatore
2020-09-30 18:36
that makes sense... I have just seen the example PACT that I published a while ago and that works

giuseppe.salvatore
2020-09-30 18:37
```Given there is an alligator named Mary, upon receiving a request for an alligator from Example App, with```

giuseppe.salvatore
2020-09-30 18:37
but I can see the PACT contract version is 2.0

giuseppe.salvatore
2020-09-30 18:38
```"metadata": { "pactSpecification": { "version": "2.0.0" }```

giuseppe.salvatore
2020-09-30 18:39
but yeah I will try updating it

giuseppe.salvatore
2020-09-30 18:39
thanks @phil.endsley :+1:

giuseppe.salvatore
2020-09-30 18:39
appreciated

giuseppe.salvatore
2020-09-30 18:48
do I need to redeploy with helm to update it?

giuseppe.salvatore
2020-09-30 18:49
I am worried about losing the current contracts

giuseppe.salvatore
2020-09-30 19:15
is there a way to force the pact to be at a specific version?

giuseppe.salvatore
2020-09-30 19:18
ah found it

giuseppe.salvatore
2020-09-30 19:18
in pact provider rule

phil.endsley
2020-09-30 19:18
> do I need to redeploy with helm to update it? However you want to do it. That's certainly one way of doing it though > I am worried about losing the current contracts https://docs.pact.io/pact_broker/upgrading/#pact-broker-versions--210 Might be best to ask in #pact-broker if you have any concerns around upgrading

giuseppe.salvatore
2020-09-30 19:19
:+1:

giuseppe.salvatore
2020-09-30 19:19
I was only worried as I have demo tomorrow.... after that I can wipe it all

jarmy
2020-09-30 19:33
Hi. I?m having difficulty coming up with a `PactDslJsonBody` that replicates the `containers` array in the below response for my consumer test.

jarmy
2020-09-30 19:33
```{ "sduiVersion": "1", "itemId": "8NKxTe5NVYD0LTTdT7Vd556hhrO4CYIvoO8YgcHthnjXqtTtkDV7OPKWBcDHewMNh3V5hFcEMWJ8MVTt", "wallClock": 1600732583943, "page": { "itemId": "vTmP4bTE1WFEOsuGJhfpJaYWlGBvopVVGGXITgDqeR27BFuDaq0bAgo97VBlnQhnSF5H3DvyLQ8wr0qwSNjbB4mSvOebZUkBd", "type": "CONTAINER", "view": "PAGE", "containers": [ { "itemId": "vTmP4bTE1WFEOsuGJhfpJaYWlGBvopVVGGXITgDqeVANKYkqGdGHGD4BpSpuiema4pJAEDYRCIHvGYH78zxuyG8YKNM74rPrt", "type": "CONTAINER", "component": "page-header", "items": [ { "itemId": "KNLPoAiSQztjy0hWVdlnBGJu1I81cCzQDHDaZ3YwbmtWQfkKZwON2KuRw8GAUiEdvmMuy6jp9IEtHOhEHLqsVx6Y891eRdl0dQD76RwRLBYv", "component": "title", "texts": { "title": { "value": "Today", "scheme": "LITERAL" } } } ] }, { "itemId": "3N223Jbz6ia0BmXTSUXpo1oWufmexKZ0XDHaXLTZT76s1p6q2y8aHHzgwvLYCWVOP0ErMcpri46CkWrbmFGzwZ0V3VM59pJ", "type": "CONTAINER", "component": "bottom-nav", "items": [ { "itemId": "8CUfQp10B6aDL0QX77TidM9TbTbiEefovnPelSCOOszTYtCh2PtTzGkAJRPdtsoNDlecuGZqbhLnHUR8QL1qCC72LW2qjJC32llecUsLjHqj9xnHqEOZJ2wKyHR", "type": "ITEM", "component": "bottom-nav-item", "selected": "SELECTED_1", "texts": { "title": { "value": "For You", "scheme": "LITERAL" } }, "images": { "icon": { "value": "ForYou", "scheme": "BINDING" } }, "actions": { "default": [ { "context": "displayPage", "type": "PRIMARY", "intentType": "VIEW", "intentId": "KNLPoAiSQztjy0hWVdlnBGJu1I81cCzQDHDaZ3YwdsT98XEKnB0a8Da8R26ZCJqInCQmKPKO02CEeuVGqxGqb33LG8Ggmw0iqSryvCs4iCQD" }, { "context": "selectItem", "type": "PRIMARY", "intentType": "LOCAL", "intentId": "selectItem" } ] } }, { "itemId": "TpBmBLYzEdkkezmDogEjnq1Hjs2FzIw5VZPG39E1Y8LmHh09dv5ECS1UPFMPkLrPN9gHuBaPruxy7lRjak9LXxEeQFn7lCZhjZQZNwnwqvSpg0WUUATZfICn", "type": "ITEM", "component": "bottom-nav-item", "texts": { "title": { "value": "Live", "scheme": "LITERAL" } }, "images": { "icon": { "value": "Live", "scheme": "BINDING" } }, "actions": { "default": [ { "context": "displayPage", "type": "PRIMARY", "intentType": "VIEW", "intentId": "1C6HDlEXfLYj64bVDovqL5fS8T5HcdHfDJLLdUoK7ShBQEDTBpv8bmFOYeW9Nz4nJVsP5OHoP7jsTCAdbaOv80GE1hEhDwbtOKcOlBkYPp" }, { "context": "selectItem", "type": "PRIMARY", "intentType": "LOCAL", "intentId": "selectItem" } ] } }, { "itemId": "8CUfQp10B6aDL0QX77TidM9TbTbiEefovnPelSCOOszTYtCh2PtTzGkAJRPdynJzHheHTF1rb8XBPRKMB4Mwawf7MzvpLYnUDmercFoLChCOSZqxivJjoDHzEML", "type": "ITEM", "component": "bottom-nav-item", "texts": { "title": { "value": "Search", "scheme": "LITERAL" } }, "images": { "icon": { "value": "Search", "scheme": "BINDING" } }, "actions": { "default": [ { "context": "displayPage", "type": "PRIMARY", "intentType": "VIEW", "intentId": "KNLPoAiSQztjy0hWVdlnBGJu1I81cCzQDHDaZ3YwdsT98XEKVEtpM4dCKHZHKlfMO41pQEgv6DXcmQItSiTWCDPkjgSktqV18IfNpIadaWvB" }, { "context": "selectItem", "type": "PRIMARY", "intentType": "LOCAL", "intentId": "selectItem" } ] } }, { "itemId": "Xrad4ke8jrBX4jlYjOsiIVT8EkFieVwgIe1wJwRAkl3q43wPhyv5oz8caHBlHADNbsIDenYdZ9P3G9cmxDcwFuvkOBrrGFBVjLr12elqbvGJDjxCvDxJfzPbjKQ5", "type": "ITEM", "component": "bottom-nav-item", "texts": { "title": { "value": "My Stuff", "scheme": "LITERAL" } }, "images": { "icon": { "value": "MyStuff", "scheme": "BINDING" } }, "actions": { "default": [ { "context": "displayPage", "type": "PRIMARY", "intentType": "VIEW", "intentId": "1M8OQZAFZPTa9nmtiEeDL4VOBJKr8fldcEp66ykiI8euLjFDcczChmPISl8x4mlXv4RD8N5jyEJXgQyetQjMAPO9zxd3tygJm8Mea7rnZZojpR" }, { "context": "selectItem", "type": "PRIMARY", "intentType": "LOCAL", "intentId": "selectItem" } ] } } ] } ] } }```

jarmy
2020-09-30 19:33
I?m currently using the below code but the response it?s generating is insufficient. Does anyone have a suggestion as to how to properly build this body? ``` val jsonBody = PactDslJsonBody() .stringType("sduiVersion") .stringType("itemId") .`object`("page") .stringType("itemId") .stringValue("type", "CONTAINER") .stringValue("view", "PAGE") .minArrayLike("containers", 1) .stringType("itemId") .stringValue("type", "CONTAINER") .stringType("component") .minArrayLike("items", 1) .stringType("itemId") .stringType("component") .`object`("texts") .`object`("title") .stringType("value") .stringType("scheme") .closeObject() .closeObject() .closeArray() .closeObject() .closeArray()```

giuseppe.salvatore
2020-09-30 20:02
yeah forcing version V2 for Pact Spec fixed it

giuseppe.salvatore
2020-09-30 20:02
I will update the broker next

giuseppe.salvatore
2020-09-30 20:02
thanks again Phil for your support

wesleythomaswilliams
2020-09-30 21:56
My mistake, that was a typo

uglyog
2020-09-30 22:45
The JSON parser was changed. Can you provide the pact file (prob in a Github issue)

matt.fellows
2020-09-30 22:47
more :taco: for @phil.endsley

matt.fellows
2020-09-30 22:55
thanks @wesleythomaswilliams :taco:

phil.endsley
2020-10-01 00:37
> I will update the broker next > Major upgrades the day before a demo? I see you like to live dangerously :sweat_smile:

phil.endsley
2020-10-01 00:37
Good luck with it!

anddreiu
2020-10-01 07:09
Hi @uglyog. I've just seen the problem here. I am using XML request in body and the error appears if the content type "text/xml" is not specified for the interaction request

anddreiu
2020-10-01 07:10
with the previous versions it was not mandatory to add: ``` "headers": { "Content-Type": "text/xml" }```

anddreiu
2020-10-01 07:11
I will raise a Github issue for this


aliaksandr.valadzko
2020-10-01 08:20
Hey guys! Should be popular question, however can?t find the answer I use PactDslWithProvider to generate consumer expectations of GET request Let the path will be GET api/message/{Id}/words From Provider side I use State to generate necessary message resource However from Provider side it is not known what Id of resource would be generated As path of CREATE is POST api/message So, message id is dynamic How can I deal with it? Is it possible to pass id from state to pact? Thanks in advance

aliaksandr.valadzko
2020-10-01 09:12
Found the answer It is possible to modify uri using TargetRequestFilter

matt.fellows
2020-10-01 11:10
You could use that, but it?s better to use provider states - have you come across that concept yet?

wesleythomaswilliams
2020-10-01 11:29
@jarmy this may be a typo, but you have some quotes around your object declaration for `page`. You're also missing your declaration for `wallClock` I'm just looking at the rest now.

wesleythomaswilliams
2020-10-01 11:39
I think the main problem is the last closeObject and closeArray are the wrong way around. I've written up how I'd do the whole thing, which is slightly different, as I tend to use stringType over stringValue, but you may have a specific reason for that. See if this works: ```val jsonBody = PactDslJsonBody() .stringType("sduiVersion", "1") .stringType("itemId", "8NKxTe5NVYD0LTTdT7Vd556hhrO4CYIvoO8YgcHthnjXqtTtkDV7OPKWBcDHewMNh3V5hFcEMWJ8MVTt") .integerType("wallClock", 1600732583943) .object("page") .stringType("itemId", "vTmP4bTE1WFEOsuGJhfpJaYWlGBvopVVGGXITgDqeR27BFuDaq0bAgo97VBlnQhnSF5H3DvyLQ8wr0qwSNjbB4mSvOebZUkBd") .stringType("type", "CONTAINER") .stringType("view", "PAGE") .minArrayLike("containers", 1) .stringType("itemId", "vTmP4bTE1WFEOsuGJhfpJaYWlGBvopVVGGXITgDqeVANKYkqGdGHGD4BpSpuiema4pJAEDYRCIHvGYH78zxuyG8YKNM74rPrt") .stringType("type", "CONTAINER") .stringType("component", "page-header") .minArrayLike("items", 1) .stringType("itemId", "KNLPoAiSQztjy0hWVdlnBGJu1I81cCzQDHDaZ3YwbmtWQfkKZwON2KuRw8GAUiEdvmMuy6jp9IEtHOhEHLqsVx6Y891eRdl0dQD76RwRLBYv") .stringType("component", "title") .object("texts") .object("title") .stringType("value", "Today") .stringType("scheme", "LITERAL") .closeObject() .closeObject() .closeArray() .closeArray() .closeObject()```

wesleythomaswilliams
2020-10-01 11:40
I always use example values, as I find it a good reference for myself and others when looking at the DSL.

aliaksandr.valadzko
2020-10-01 11:43
I use provider state Problem is that during creation of resource within provider state, resource will have some not known id


aliaksandr.valadzko
2020-10-01 12:04
Hey @uglyog! I saw this article, however I couldn't find any suitable solution for my case In the article it is advised to use `queryParameterFromProviderState("accountNumber", "\${accountNumber}", "100")` instead of `query("accountNumber=100")` My case: *Consumer:* ``` @Pact(consumer = "some_consumer") public RequestResponsePact pactForCreateGroup(PactDslWithProvider builder) { Map<String, String> responseHeaders = new HashMap<>(); responseHeaders.put("Content-Type", "application/json"); PactDslJsonBody pactBodyJson = new PactDslJsonBody() .stringType("id") ... .asBody(); return builder .given("message is created state") .uponReceiving("get words request") .matchPath(String.format("/api/messages/$s/words", "someIdThatINeedToCreateInProvider")) .method(HttpMethod.GET.name()) .willRespondWith() .status(HttpStatus.OK.value()) .headers(responseHeaders) .body(pactBodyJson).toPact(); }``` *Provider:* ``` private String createdInStateMessageId; @TargetRequestFilter public void changeResourceId(HttpRequestBase request) throws URISyntaxException { if (Objects.nonNull(createdInStateGroupId)) { String uri = request.getRequestLine().getUri(); if (uri.contains("someIdThatINeedToCreateInProvider")) { uri = uri.replace("someIdThatINeedToCreateInProvider", createdInStateMessageId); } request.setURI(new URI(uri)); } } @State("message is created state") public void messageExistsState() { Response<JsonObject> createMessageResponse = ... createdInStateMessageId = createMessageResponse.getMessageId(); }``` Could you please advice me how can I pass value from provider state in this case? Thanks

aliaksandr.valadzko
2020-10-01 12:26
I'm asking because `PactDslRequestWithPath` doesn't have `queryParameterFromProviderState` method (using group: 'http://au.com.dius', name: 'pact-jvm-consumer-junit_2.11', version: '3.5.24')

phil.endsley
2020-10-01 12:33
https://docs.pact.io/implementation_guides/jvm/consumer/junit#having-values-injected-from-provider-state-callbacks-3611 Looks like you'll need to upgrade the version you're using. Then in consumer: ```... .pathFromProviderState("/api/messages/${messageId}/words", "/api/messages/placeholderMessageId/words") ...``` And in provider: ``` @State("message is created state") public Map<String, Object> messageExistsState() { Response<JsonObject> createMessageResponse = ... return Map.of("messageId", createMessageResponse.getMessageId()); }```

aliaksandr.valadzko
2020-10-01 12:40
Oh, got it, thanks However it looks like I use latest version Damn, it looks like I need to change lib from `pact-jvm-consumer-junit_2.11` to `pact-jvm-consumer-junit`

phil.endsley
2020-10-01 12:43
The latest version is 4.1.7. The package names changed a while ago with 4.1.0 (I think) when the project converted to java 9 modules. https://mvnrepository.com/artifact/au.com.dius.pact.consumer/junit

phil.endsley
2020-10-01 12:44
Note there are breaking changes, but I'm pretty sure it's all just package changes. So you should only need to fix your imports when you do upgrade

aliaksandr.valadzko
2020-10-01 12:44
Thanks a lot!

aliaksandr.valadzko
2020-10-01 13:21
Everything works as expected, thanks!

antonello
2020-10-01 15:27
:taco: :taco: for @phil.endsley!

jarmy
2020-10-01 16:08
Hi Wes. I appreciate the assistance. Regarding the `.`object`("page")` , that?s the syntax IntelliJ makes me use :shrug:. I?ve deliberately left out `wallClock` because I?ve had a tough time getting it verified on the provider side with whatever I?ve tried.

jarmy
2020-10-01 16:49
In fact, if I include `wallClock`, the verification test fails with ```1.1) BodyMismatch: $ BodyMismatch: $ Expected a Map with at least 4 elements but received 3 elements``` That said, when I use your above code _without_ wallClock, the pact passes verification

jarmy
2020-10-01 16:50
Great point about using examples in the contract. I was completely ignorant of using them.

jarmy
2020-10-01 18:34
So, back to my original question. How do I construct the PactDslJsonBody to include the additional response items? Specifically, the 2nd item in the containers array.

jarmy
2020-10-01 18:34
```{ "sduiVersion": "1", "itemId": "8NKxTe5NVYD0LTTdT7Vd556hhrO4CYIvoO8YgcHthnjXqtTtkDV7OPKWBcDHewMNh3V5hFcEMWJ8MVTt", "wallClock": 1600732583943, "page": { "itemId": "vTmP4bTE1WFEOsuGJhfpJaYWlGBvopVVGGXITgDqeR27BFuDaq0bAgo97VBlnQhnSF5H3DvyLQ8wr0qwSNjbB4mSvOebZUkBd", "type": "CONTAINER", "view": "PAGE", "containers": [ { "itemId": "vTmP4bTE1WFEOsuGJhfpJaYWlGBvopVVGGXITgDqeVANKYkqGdGHGD4BpSpuiema4pJAEDYRCIHvGYH78zxuyG8YKNM74rPrt", "type": "CONTAINER", "component": "page-header", "items": [ { "itemId": "KNLPoAiSQztjy0hWVdlnBGJu1I81cCzQDHDaZ3YwbmtWQfkKZwON2KuRw8GAUiEdvmMuy6jp9IEtHOhEHLqsVx6Y891eRdl0dQD76RwRLBYv", "component": "title", "texts": { "title": { "value": "Today", "scheme": "LITERAL" } } } ] }, { "itemId": "3N223Jbz6ia0BmXTSUXpo1oWufmexKZ0XDHaXLTZT76s1p6q2y8aHHzgwvLYCWVOP0ErMcpri46CkWrbmFGzwZ0V3VM59pJ", "type": "CONTAINER", "component": "bottom-nav", "items": [ { "itemId": "8CUfQp10B6aDL0QX77TidM9TbTbiEefovnPelSCOOszTYtCh2PtTzGkAJRPdtsoNDlecuGZqbhLnHUR8QL1qCC72LW2qjJC32llecUsLjHqj9xnHqEOZJ2wKyHR", "type": "ITEM", "component": "bottom-nav-item", "selected": "SELECTED_1", "texts": { "title": { "value": "For You", "scheme": "LITERAL" } }, "images": { "icon": { "value": "ForYou", "scheme": "BINDING" } }, "actions": { "default": [ { "context": "displayPage", "type": "PRIMARY", "intentType": "VIEW", "intentId": "KNLPoAiSQztjy0hWVdlnBGJu1I81cCzQDHDaZ3YwdsT98XEKnB0a8Da8R26ZCJqInCQmKPKO02CEeuVGqxGqb33LG8Ggmw0iqSryvCs4iCQD" }, { "context": "selectItem", "type": "PRIMARY", "intentType": "LOCAL", "intentId": "selectItem" } ] } }, { "itemId": "TpBmBLYzEdkkezmDogEjnq1Hjs2FzIw5VZPG39E1Y8LmHh09dv5ECS1UPFMPkLrPN9gHuBaPruxy7lRjak9LXxEeQFn7lCZhjZQZNwnwqvSpg0WUUATZfICn", "type": "ITEM", "component": "bottom-nav-item", "texts": { "title": { "value": "Live", "scheme": "LITERAL" } }, "images": { "icon": { "value": "Live", "scheme": "BINDING" } }, "actions": { "default": [ { "context": "displayPage", "type": "PRIMARY", "intentType": "VIEW", "intentId": "1C6HDlEXfLYj64bVDovqL5fS8T5HcdHfDJLLdUoK7ShBQEDTBpv8bmFOYeW9Nz4nJVsP5OHoP7jsTCAdbaOv80GE1hEhDwbtOKcOlBkYPp" }, { "context": "selectItem", "type": "PRIMARY", "intentType": "LOCAL", "intentId": "selectItem" } ] } }, { "itemId": "8CUfQp10B6aDL0QX77TidM9TbTbiEefovnPelSCOOszTYtCh2PtTzGkAJRPdynJzHheHTF1rb8XBPRKMB4Mwawf7MzvpLYnUDmercFoLChCOSZqxivJjoDHzEML", "type": "ITEM", "component": "bottom-nav-item", "texts": { "title": { "value": "Search", "scheme": "LITERAL" } }, "images": { "icon": { "value": "Search", "scheme": "BINDING" } }, "actions": { "default": [ { "context": "displayPage", "type": "PRIMARY", "intentType": "VIEW", "intentId": "KNLPoAiSQztjy0hWVdlnBGJu1I81cCzQDHDaZ3YwdsT98XEKVEtpM4dCKHZHKlfMO41pQEgv6DXcmQItSiTWCDPkjgSktqV18IfNpIadaWvB" }, { "context": "selectItem", "type": "PRIMARY", "intentType": "LOCAL", "intentId": "selectItem" } ] } }, { "itemId": "Xrad4ke8jrBX4jlYjOsiIVT8EkFieVwgIe1wJwRAkl3q43wPhyv5oz8caHBlHADNbsIDenYdZ9P3G9cmxDcwFuvkOBrrGFBVjLr12elqbvGJDjxCvDxJfzPbjKQ5", "type": "ITEM", "component": "bottom-nav-item", "texts": { "title": { "value": "My Stuff", "scheme": "LITERAL" } }, "images": { "icon": { "value": "MyStuff", "scheme": "BINDING" } }, "actions": { "default": [ { "context": "displayPage", "type": "PRIMARY", "intentType": "VIEW", "intentId": "1M8OQZAFZPTa9nmtiEeDL4VOBJKr8fldcEp66ykiI8euLjFDcczChmPISl8x4mlXv4RD8N5jyEJXgQyetQjMAPO9zxd3tygJm8Mea7rnZZojpR" }, { "context": "selectItem", "type": "PRIMARY", "intentType": "LOCAL", "intentId": "selectItem" } ] } } ] } ] } }```

jarmy
2020-10-01 23:12
Has anyone been able to add `consumerVersionSelectors` to a Kotlin test class? https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors/ documentation says to use this code but the syntax doesn?t work. ```@PactBroker( host="pactbroker.local", port="8080", consumerVersionSelectors={ @ConsumerVersionSelector(tag = "master"), @ConsumerVersionSelector(tag = "test"), @ConsumerVersionSelector(tag = "production", latest = false) })```

uglyog
2020-10-01 23:16
Kotlin uses `[]` for arrays and you don't include the `@` on the child annotation

uglyog
2020-10-01 23:16
```@PactBroker( consumerVersionSelectors = [VersionSelector(tag = "test")] )```

jarmy
2020-10-01 23:20
Thanks!

giuseppe.salvatore
2020-10-02 10:10
@phil.endsley naaa will do it after!! I love danger but I also love to keep my job

giuseppe.salvatore
2020-10-02 10:10
:laughing:

nazar.khmil
2020-10-05 10:34
has joined #pact-jvm

xandebianchi
2020-10-05 13:05
has joined #pact-jvm

xandebianchi
2020-10-05 13:13
Hi guys! Could you help me please ? I?m starting with http://pact.io and pactflow, using Android, but it?s a generic doubt. I could create the classes and unit test, and generate the pact file. I published it using Gradle task. 1. My doubt is about the Provider. Do I need to create the provider part or this is a task for the Microservices responsibles? 2.  Also, how can I test to Verify a Pact? Where can I add the URL from Microservice for pactflow to analyze the results ? 3. For pactflow to execute correctly, do I need to put the tasks in CI ?

antonello
2020-10-05 14:20
Hi @xandebianchi, welcome! 1. From what you wrote I assume that you are involved in the development of a consumer (the Android app). Usually the developers / teams responsible for the provider would write the provider tests. However, nothing would stop you from doing it yourself, especially if you?re retrofitting tests for any pre-existing implementation. 2. Not sure I understand this question. A pact gets verified by provider tests. In what language is the provider written? 3. You can publish and retrieve from the pactflow broker even without having the tests setup in CI. If you want to adopt Pact seriously, you?d need to set up both consumer and provider tests to run on CI.

xandebianchi
2020-10-05 14:35
Ok!! thank you! If fact the second question I think I misunderstood the idea, I thought I was also responsible for testing the provider, but as a consumer and responsible only for the consumer-android part, I just need to publish contract, not test the backend response. Right?

antonello
2020-10-05 14:35
correct

xandebianchi
2020-10-05 14:35
Understood! thank you!

antonello
2020-10-05 14:36
NP

dorin.enache
2020-10-05 15:01
has joined #pact-jvm

jarmy
2020-10-05 18:47
@wesleythomaswilliams Do you have any suggestions for the above situation?

thomas.hibbard
2020-10-05 19:29
@thomas.hibbard has left the channel

matt.fellows
2020-10-06 01:18
You got it @xandebianchi!

aaron.ramirez
2020-10-06 04:22
Hi everyone, I'm looking into using pactjvm for contract testing between a couple microservices developed using Scala. I know that there is support for https://github.com/DiUS/pact-jvm/tree/4_1_7/provider/specs2. However, I'm having trouble understanding how to setup integration with a pact broker, as I'm using SBT for building these projects. How can I configure this? And the _scala-pact_ project doesn't seem viable, as the last release was in 2018. Any help would be appreciated :slightly_smiling_face:

aaron.ramirez
2020-10-06 04:26
I guess one thing I'm wondering about is if the use of a gradle or maven plugin required by pactjvm?

uglyog
2020-10-06 04:31
SBT support is only for a very old version. Your best bet is to use Maven or Gradle if you can. Specs2 support is quite rudimentary as well.

uglyog
2020-10-06 04:32
If you're able to help update it, that would be awesome because I don't use Scala so have not really supported it.

aaron.ramirez
2020-10-06 04:33
ah, bummer to hear. As changing buildtools is not really an option for these projects, or at least, it would be a very painful one. I'll take a look at the sourcecode of the deprecated SBT plugin though, to see if I can wrap my head around that

aaron.ramirez
2020-10-06 04:40
Okay, so I'll see if I can quickly get pactjvm `3.6.15` integrated with the microservices I'm working with. As that appears to be the last version with SBT support. @uglyog I took a quick look at the source for the plugin, and it doesn't appear too complicated. So it might be possible for me to help add SBT support for pactjvm 4.x

uglyog
2020-10-06 04:55
It will address the oldest open issue: https://github.com/DiUS/pact-jvm/issues/226

ledinhcuong99
2020-10-06 12:53
has joined #pact-jvm

ruth
2020-10-06 13:52
has joined #pact-jvm

giuseppe.salvatore
2020-10-06 14:15
Hi guys... is there any easy way to override the consumer version when publishing the contracts to the broker? I am able to do so in the provider with `-Dpact.provider.version=<version>` but this doesn't seem to work with `-Dpact.consumer.version=<version>` on the consumer side

giuseppe.salvatore
2020-10-06 14:15
It picks up the version from project version in pom.xml

adrianojedabenitez
2020-10-06 14:18
on the consumer side I added the parameter `--consumer-app-version` to the broker

adrianojedabenitez
2020-10-06 14:18
to specify the consumer version

giuseppe.salvatore
2020-10-06 14:18
ah you are using cli to publish... ok

giuseppe.salvatore
2020-10-06 14:19
I am using `mvn pact:publish`

giuseppe.salvatore
2020-10-06 14:20
I mean I can switch to the cli it that's the only way... but I am pretty sure there must be a way, I just haven't found it google-ing around

giuseppe.salvatore
2020-10-06 14:20
thanks @adrianojedabenitez

phil.endsley
2020-10-06 14:23
I think the property name was wrong until a recent release. We're on 4.1.6 and have to specify providerVersion. Using Gradle ```pact { publish { pactDirectory = 'proj/build/pacts' pactBrokerUrl = 'https://pactbroker.arcus.coop/' tags = [project.gitBranch] providerVersion = "${project.version}-${gitRevision}" } }```

phil.endsley
2020-10-06 14:29
_NOTE:_ The pact broker requires a version for all published pacts. The `publish` task will use the version of the project by default, but can be overwritten with the `projectVersion` property. Make sure you have set one otherwise the broker will reject the pact files.


giuseppe.salvatore
2020-10-06 14:35
Like that? `mvn pact:publish -DprojectVersion=1.2-SNAPSHOT`

giuseppe.salvatore
2020-10-06 14:36
I was looking for a way to do it not from the pom

giuseppe.salvatore
2020-10-06 14:36
to override the ci with a param

giuseppe.salvatore
2020-10-06 14:36
I can still do a search and replace in the pom but I guess it's overkilling

giuseppe.salvatore
2020-10-06 14:36
ah... that didn't work :disappointed:

phil.endsley
2020-10-06 14:39
ah...Not sure then. Might not be supported?

giuseppe.salvatore
2020-10-06 14:43
oh well... I will use `sed` to override the version number in the pom.xml, that will be picked up for sure

giuseppe.salvatore
2020-10-06 14:43
or can use the cli

antonello
2020-10-06 16:12
@giuseppe.salvatore doesn?t `-DprojectVersion=1.2-SNAPSHOT` work?

antonello
2020-10-06 16:15
it should work

antonello
2020-10-06 16:15
but if it really doesn?t there is no need to use `sed`

antonello
2020-10-06 16:19
You can just create your own custom property in your pom under `<properties>`, for example in our case it has a default value `<pact.pacticipantVersion>${project.version}-${git.commit.id.abbrev}</pact.pacticipantVersion>` Then in the configuration of pact maven plugin you can do something like ```<configuration> <projectVersion>${pact.pacticipantVersion}</projectVersion> </configuration>``` And then you can just pass `-Dpact.pacticipantVersion=your_version` to `mvn`

antonello
2020-10-06 16:28
where?s my :taco:, @matt.fellows? :smile:

giuseppe.salvatore
2020-10-06 16:33
@antonello thanks for that... yeah I am surprised as well it's not working.

giuseppe.salvatore
2020-10-06 16:34
yeah mine was a brute force approach I admit yours is more elegant

giuseppe.salvatore
2020-10-06 16:35
:upside_down_face:

phil.endsley
2020-10-06 21:12
When running provider tests, I'm getting a failed verification and am not where/how to start troubleshooting. > Published verification result of 'Failed(results=[{message=Request to provider failed with an exception, exception=java.lang.AssertionError: Unexpected end event for Pact between [consumer] (version) and [provider] - [Given] <PENDING> I get this when running verification tests with pending and wip pacts enabled with ```testCompile group: 'au.com.dius.pact.provider', name: 'spring', version: '4.1.7'``` Running without pending/wip, everything is all good

antonello
2020-10-06 21:42
Have you recently upgraded to 4.1.7?

uglyog
2020-10-06 21:52
What version of the Maven plugin are you using?

uglyog
2020-10-06 21:53
Can you provide the stack trace and debug logs?

phil.endsley
2020-10-06 22:56
I can get logs in 12ish hours :grin: First time adding pacts for the application. Didn't even think to try an older version...obvious in hindsight...

matt.fellows
2020-10-06 23:17
Eventual consistency? :stuck_out_tongue:

matt.fellows
2020-10-07 00:28
LOL yass, got a taco :stuck_out_tongue:

matt.fellows
2020-10-07 00:28
@antonello please have a :taco: for demanding a taco

dothetan.040490
2020-10-07 09:14
has joined #pact-jvm

phil.endsley
2020-10-07 17:08
Instead of pasting a bunch of stuff here, I just raised an issue with all the info. https://github.com/DiUS/pact-jvm/issues/1221

dagostino.remy
2020-10-07 23:03
has joined #pact-jvm

abhi.nandan
2020-10-08 06:38
has joined #pact-jvm

rarora
2020-10-08 11:54
has joined #pact-jvm

przemyslaw.dabrowski
2020-10-08 12:36
has joined #pact-jvm

emiliano.righi
2020-10-08 13:25
has joined #pact-jvm

phil.endsley
2020-10-08 19:59
@uglyog I talked with @wilkinsweiqiangliang about updating the jvm workshop. Since they won't be available for a couple weeks, I'm taking a swing at it. I wanted to talk about how best to tackle it...I just created a new repo and am pushing branches for each step, with the intent to merge the last one into master. I guess my question is how do you want to handle giving feedback on it, since it's a lot of steps that keep building onto each other, but won't be finished until the very end


cariaga.bh
2020-10-08 21:03
has joined #pact-jvm

phil.endsley
2020-10-08 21:25
Got to step 3, which adds consumer pacts. So any feedback on best practices/what methods you want to showcase in the workshop/anything else would be great to get now

uglyog
2020-10-08 22:15
That's awesome! I'll have a look today. @matt.fellows should also take a look.

matt.fellows
2020-10-08 22:17
Amazing!!


matt.fellows
2020-10-08 22:37
The idea is that each step has a specific learning objective

matt.fellows
2020-10-08 22:37
It covers the main use cases that most people encounter

matt.fellows
2020-10-08 22:37
if we can keeep the use case consistent (product API) and the steps the same, it will really help with teams running their own internal training programs

matt.fellows
2020-10-08 22:38
I?ve got a workshop PDF that we can eventually get online to accompany said workshop, so that teams can run training themselves

phil.endsley
2020-10-08 22:45
So something I think would be really neat is if all the projects update their workshops to be the same. Then, replace all the code blocks with a language toggle, and let people mix and match consumer/provider languages. There's one page of the docs like this already, but I think that would be really neat

phil.endsley
2020-10-08 22:46
That way, I could do a workshop with js consumer and java provider without having to jump between repos


matt.fellows
2020-10-08 23:56
yes agreed! good idea

matt.fellows
2020-10-08 23:56
If everyone uses the same process to do the workshop, that will be a lot easier!

campellcl
2020-10-09 00:06
has joined #pact-jvm

elenitsaa043
2020-10-09 10:00
has joined #pact-jvm

adriangabrieloros
2020-10-09 11:05
has joined #pact-jvm

mmotornyi.consultant
2020-10-09 11:49
In spite the fact everything is up and running I have annoying warning in gradle. Maybe somebody know what to do with that?


young
2020-10-10 01:33
Hi dear pact team, sorry to bother, please help with the minArrayLike case. Pact-JVM(latest version), I want to match a JSON request with multiple items(actually they are the same) in the array. I use the following code: ```DslPart responseBody = new PactDslJsonBody() .array("data") .object() .stringType("city") .minArrayLike("stations",1,1) .numberType("id") .stringType("name") .stringType("city") .decimalType("latitude") .decimalType("longitude") .numberType("gpsRadius") .object("photoView") .stringType("large") .stringType("small") .closeObject() .closeObject() .closeArray() .minArrayLike("scooters",1,1) .numberType("id") .stringType("qrCode") .booleanType("helmetLock") .stringType("status") .decimalType("latitude") .decimalType("longitude") .decimalType("remainingBattery") .stringType("generation") .numberType("remainingRange") .closeObject() .closeArray() .minArrayLike("geoFences",1,1) .stringType("type") .numberType("maxSpeed") .stringType("city") .minArrayLike("coordinates",1,1) .decimalType("latitude") .decimalType("longitude") .closeObject() .closeArray() .object("center") .decimalType("latitude") .decimalType("longitude") .closeObject() .closeObject() .closeArray() .closeObject();``` But the test failed with BodyMismatch: `1.1) BodyMismatch: $.data.0.geoFences.1 BodyMismatch: Expected a Map with at least 5 elements but received 4 elements` { - "city": "LMnLbaMprlzTEAA7WKKn", - "center": { - "latitude": 2697217322, - "longitude": 9562908377 - }, + "type": "NO_PARKING", + "city": "DRW", "coordinates": [ { - "latitude": 98711053, - "longitude": 1182569935 + "latitude": 30.480313917533394, + "longitude": 114.3992253676513 }, { - "latitude": 3039307861, - "longitude": 9936988536 + "latitude": 30.48007948024251, + "longitude": 114.4016283055347 + }, + { + "latitude": 30.478203961567303, + "longitude": 114.402036351591 + }, + { + "latitude": 30.47824303523717, + "longitude": 114.39927070610605 + }, + { + "latitude": 30.480313917533394, + "longitude": 114.3992253676513 } ], - "maxSpeed": 74619602, - "type": "Vz45icPKycaGImQiaC9C" + "center": { + "latitude": 30.47919300342641, + "longitude": 114.40061002625403 + } } ..........

young
2020-10-10 01:35
I think the 'minArrayLike' can ensure that each item in the list matches the provided example, but it seemed that it didn't work. And what's the error of my code? Thx.

sh.ilgam_pact
2020-10-11 16:12
has joined #pact-jvm

young
2020-10-12 04:07
Just ignore, Some of them were not same. Fixed

ranjanayush03
2020-10-12 10:57
Hello all.. actually I am trying to fetch pact from a URL via @PactUrl notation but I guess the API which I am calling needs some authorization so I was unable to find a way so as to include the headers .. Any help will be much appreciated..

antonello
2020-10-12 11:01
is the url a url to the broker?

ranjanayush03
2020-10-12 11:02
Not actually a broker

ranjanayush03
2020-10-12 11:02
But where we are storing pacts there

antonello
2020-10-12 11:06
I have a feeling this might not be possible out of the box. @uglyog might confirm, but I can?t find anything that would suggest you can. A workaround might be to have some kind of proxy that can add any authentication headers for you.

anastasiia.bielik
2020-10-12 11:13
has joined #pact-jvm

ranjanayush03
2020-10-12 12:48
Okay then for that it should be added for every providers that we have.

deepika.krishnakumar
2020-10-12 15:03
has joined #pact-jvm

deepika.krishnakumar
2020-10-12 15:11
Hi. I am using @PactBroker but I want to be able to connect to the pact broker using a http proxy

phil.endsley
2020-10-12 21:25
@uglyog @matt.fellows Finished all the steps and merged into master. There's a couple minor things I still want to do (link all the branches with each step, add the LEARNING.md like Matt linked, minor readme cleanup, stuff like that). I was going to transfer ownership to pactfoundation, but it looks like I have to have permission to create repos to transfer it. I added both of you as collaborators to my repo to see if you can do it? I'll be available in 3-4ish hours from now if I need to do something on my end

matt.fellows
2020-10-12 21:39
Awesome! I'll get onto that this morning. Might be fastest to create a new repo and get you to PR Tobit (so you get Hacktoberfest cred)

matt.fellows
2020-10-12 21:39
I'll discuss with @uglyog

uglyog
2020-10-12 22:11
@PactUrl has no option for adding headers. I assume you need the authorization header set, ot are you using other headers?

anbansal27
2020-10-12 23:02
has joined #pact-jvm

uglyog
2020-10-12 23:27
I've created https://github.com/pact-foundation/pact-workshop-jvm-spring with the hacktoberfest topic. You can create a PR there off master branch. We will still need to update all the step branches as well, which will be a bit of a pain.

phil.endsley
2020-10-12 23:34
If you create blank branches for each step, I can just pr branch to branch? Idk how else to do it/an easier way

uglyog
2020-10-12 23:35
Yeah, that will work

uglyog
2020-10-12 23:36
Do you need to do PRs for all the branches. We could just push the branches from your repo using git CLI

phil.endsley
2020-10-12 23:41
Oh, that works too as long as it will let me

phil.endsley
2020-10-12 23:41
And you're a collaborator, so worst case, you just have to do it I guess

uglyog
2020-10-12 23:43
I've created the branches

matt.fellows
2020-10-13 00:06
On the plus side, the 11 branches should get you your hacktoberfest tee (just make sure we add the appropriate label to the PR!)

ranjanayush03
2020-10-13 03:45
Yes @uglyog the authorization headers I need to set.. so in the pact url is there a method like @TestRequestHeader where we can modify the headers before replaying the requests..


uglyog
2020-10-13 03:54
Can you raise an issue on the Github project to add authentication to that annotation?

ranjanayush03
2020-10-13 03:54
Yeah sure...

ranjanayush03
2020-10-13 03:54
In the pact-jvm one..or the pact-broker one

uglyog
2020-10-13 04:03
pact-jvm

prabhakar.thippa
2020-10-13 04:58
has joined #pact-jvm

giadinhluong
2020-10-13 06:24
has joined #pact-jvm

pavank
2020-10-13 08:41
has joined #pact-jvm

stephane.meng
2020-10-13 09:06
has joined #pact-jvm

abirlal.bose
2020-10-13 09:45
has joined #pact-jvm

pavank
2020-10-13 09:53
Hi All, I am new to Pact. I want to implement contact testing using Pact JVM, can anyone help with steps to start with?

antonello
2020-10-13 10:24
Hi @pavank . Have you familiarised yourself with the documentation already? I?d recommend you start from there. Read Getting Started and Guides, and then have a look at the pact workshop for pact-jvm.

antonello
2020-10-13 10:24
Or are there any specific questions and doubts you have in mind already?

pavank
2020-10-13 10:31
Hi @antonello thanks for your response, I am referring the https://github.com/DiUS/pact-jvm which is there in the readme, but it is written using springboot and I am not aware of spring , just wanted to know is there any source where I get some PACT examples without springboot?

antonello
2020-10-13 10:38
most of what?s done in pact-jvm workshop doesn?t have much to do with SpringBoothttps://github.com/DiUS/pact-workshop-jvm

pavank
2020-10-13 11:03
awesome , thanks for your time @antonello

prabhakar.thippa
2020-10-14 04:49
I have two consumers (one REST and one Message) and both have contract with the same provider. When I run my verification on provider side for the REST contract, the message contract tries to use http target and fails. Bur if I run just the message contract verification the REST contract test fails. How should I resolve this? Should I use different provider name for each of the contract?

uglyog
2020-10-14 04:59
Yes, there is a current limitation with Pact that different types of contracts need to be associated with different named interactions. The easiest way to get around that is to suffix the provider name for the message interactions to make it distinct.

prabhakar.thippa
2020-10-14 05:12
ThankYou @uglyog

ashish_garg5
2020-10-14 09:11
Hi All, I get this error in some of my provider class. In my consumer while building the contract i haven't given any header but still i can see in my expected response. "headers": { "Content-Type": "application/json; charset=UTF-8" } So when i run my provider i get this error. java.lang.AssertionError: 0 - Expected a header 'Content-Type' but was missing 1 - expected status of 200 but was 401 2 - Expected a response type of 'application/json' but the actual type was 'text/plain' Is there any way to avoid this ? Thanks.

mamtha.3687
2020-10-14 09:16
Hi, we are trying to access the pact filename at the provider side when a specific interaction runs. We tried to implement InteractionRunner but were unable to initialise its constructor. Any thoughts or ideas?

mateusz.mrzyglod
2020-10-14 09:32
has joined #pact-jvm

antonello
2020-10-14 09:46
0 - With regard to the header, it?s probably the client in your consumer that is adding the header when making the request, even if you?re not adding it specifically in your pact consumer test.

antonello
2020-10-14 09:47
1 - 401 suggests that you are missing some form of authentication that the provider expects

antonello
2020-10-14 09:48
2 - what is the provider meant to respond with? a json boy or a text body?

ashish_garg5
2020-10-14 09:50
it expects text/plain

antonello
2020-10-14 09:51
Are you setting an Accept header in your consumer test?

ashish_garg5
2020-10-14 09:51
so is there any way i can publish expected header as text/plain so that my provider matches with the same

ashish_garg5
2020-10-14 09:51
.matchHeader("Content-Type", "text/plain") will this help

antonello
2020-10-14 09:52
content-type would be about the body of the request

antonello
2020-10-14 09:53
I think you?ll have to specify an Accept header of text/plain

ashish_garg5
2020-10-14 09:58
how m not sure

antonello
2020-10-14 09:58
in the same way as above

ashish_garg5
2020-10-14 09:58
ok let me try

ashish_garg5
2020-10-14 10:00
Access-Control-Request-Headers this u r saying to use instead of Content-Type or only Accept ?

antonello
2020-10-14 10:01
you need to set a an Accept header for that specific interaction on the pact

antonello
2020-10-14 10:01
matcHeader is not the right method anyway, because it expects a regex

ashish_garg5
2020-10-14 10:02
ohh k thanks

ashish_garg5
2020-10-14 10:02
i will try

antonello
2020-10-14 10:03
As you can see here, there is a `headers` map you can set in the request object https://github.com/DiUS/pact-jvm/tree/master/consumer/junit#using-the-base-consumerpacttest

ashish_garg5
2020-10-14 10:05
yeah i did that

ashish_garg5
2020-10-14 10:05
building now

antonello
2020-10-14 10:09
before trying to run the provider test, I?d suggest you have a look at the pact and see whether it makes sense.

ashish_garg5
2020-10-14 10:21
my response body format is coming in a string now after adding expected header

ashish_garg5
2020-10-14 10:22
it was in proper format before "body": { "oldestTimestamp": 100, "count": 100, "countsBySeverity": [ { "severity": { "raw": "string", "text": "string" }, "count": 100 }, { "severity": { "raw": "string", "text": "string" }, "count": 100 }, { "severity": { "raw": "string", "text": "string" }, "count": 100 }, { "severity": { "raw": "string", "text": "string" }, "count": 100 } ] }

ashish_garg5
2020-10-14 10:23
now it is coming like this "body": "{\"oldestTimestamp\":100,\"count\":100,\"countsBySeverity\":[{\"severity\":{\"raw\":\"string\",\"text\":\"string\"},\"count\":100},{\"severity\":{\"raw\":\"string\",\"text\":\"string\"},\"count\":100},{\"severity\":{\"raw\":\"string\",\"text\":\"string\"},\"count\":100},{\"severity\":{\"raw\":\"string\",\"text\":\"string\"},\"count\":100}]}"

cathleen.yuan
2020-10-14 11:16
has joined #pact-jvm

antonello
2020-10-14 11:26
Sorry, I?m not following - I thought you said that the provider returns text/plain

dorin.enache
2020-10-14 14:01
Hi :slightly_smiling_face:. I have a problem trying when publishing: [ERROR] Failed to execute goal au.com.dius.pact.provider:maven:4.1.0:publish (default-cli) on project transaction-api: Execution default-cli of goal au.com.dius.pact.provider:maven:4.1.0:publish failed: Plugin http://au.com.dius.pact.provi der:maven:4.1.0 or one of its dependencies could not be resolved: The following artifacts could not be resolved: io.github.microutils.kotlin-logging:kotlin-logging:jar:1.6.26, io.github.microutils.kotlin-logging:kotlin-logging-commo n:jar:1.6.26, io.github.microutils.kotlin-logging:kotlin-logging-js:jar:1.6.26: Failure to find io.github.microutils.kotlin-logging:kotlin-logging:jar:1.6.26 in https://repo.maven.apache.org/maven2 was cached in the local repository , resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

dorin.enache
2020-10-14 14:01
it seems that maven is unable to find this artifact(io.github.microutils.kotlin-logging:kotlin-logging-js:jar:1.6.26) in central repo. Do you have any idea from where to pick this?

sh.ilgam_pact
2020-10-14 14:23
Hi all! I?m using pact gradle plugin for verifying pacts against a provider. I want to configure plugin to properly trigger builds for ?contract content changed? webhook. Actually I want to do exact the same thing as described in CI/CD workshop: https://github.com/pactflow/example-provider/blob/f1c91ec/src/product/product.pact.test.js#L23-L28 . but for gradle plugin. I was able to do that by using a command line project property `pact.filter.pacturl` which is described in the https://github.com/DiUS/pact-jvm/tree/4_1_7/provider/gradle#allowing-just-the-changed-pact-specified-in-a-webhook-to-be-verified-406. But in this case https://github.com/shilgam/pact-demo-provider/blob/4da668d/Makefile#L24-L34: one - for build triggered by webhook, second - for ?normal? provider build. I would like to move this logic inside gradle task definition so that I will need single command for both builds. Is it possible?

saurabhapd
2020-10-14 15:09
Update: I finally used pact-broker-client binary to upload and its working now.

ramana.jaladurgam
2020-10-14 16:10
has joined #pact-jvm

yann.courtel
2020-10-14 16:38
has joined #pact-jvm

phil.endsley
2020-10-14 18:36
I started submitting PRs. Just did step 1 & 2 for the branches for now. Rebasing my branches so it plays nice with the initial commit. Only doing a couple at first to see if its feasible. If these go without issue, I can do the rest all at once, then do step11 -> main

alik.berezovsky
2020-10-14 18:38
has joined #pact-jvm

a.robecke
2020-10-14 19:24
has joined #pact-jvm

mikahchapman
2020-10-14 21:47
has joined #pact-jvm

uglyog
2020-10-14 22:02
Why do you need the pact filename? Is this coming from a Pact Broker or some other store? The pact files on disk are normally stored as `<consumer>-<provider>.json`.


uglyog
2020-10-14 22:04
Are you going through a proxy, or are using a local repository like Artifactory?

uglyog
2020-10-14 22:59
Once `pact.filter.pacturl` is set, it is set at the JVM level and will affect how the pacts are fetched. You will need to have two separate Gradle builds running to achieve that, one with the value set and one without.

hem_kec
2020-10-15 00:44
has joined #pact-jvm

uglyog
2020-10-15 01:04
PRs merged

sh.ilgam_pact
2020-10-15 05:44
@uglyog thank you for response! And is it possible to move this logic (I.e. running webhook build if `$PACT_URL` env var set. Otherwise running ?normal? build) inside the `build.gradle` file ? In the same way that it was shown in this example: https://github.com/pactflow/example-provider/blob/f1c91ec/src/product/product.pact.test.js#L23-L28 . Does pact gradle plugin allows to do the same thing?

abubics
2020-10-15 05:47
fyi, if you get a status of 401 back, there's probably something wrong with the request. I wouldn't bother trying to fix the content type until you get the right status code.

uglyog
2020-10-15 05:49
No, it does not. The only thing that may work is creating a Gradle task that sets the system property, then runs the build, then deletes the system property and runs it again. Or spawn two builds as seperate processes.

sh.ilgam_pact
2020-10-15 05:50
@uglyog got it. Thank you a lot!

antonello
2020-10-15 08:14
Even if someone tested with the new api both on and off, it doesn?t seem to work with pact broker 2.59

anddreiu
2020-10-15 08:25
so you think there is a mismatch between the versions of Pact Broker and pact junit library? didn't have any problems with the previous versions

antonello
2020-10-15 08:27
in short - there have been api changes in the pact broker, but it seems that pact-jvm was changed to support the new api without maintaining full backward compatibility with the old broker API

dorin.enache
2020-10-15 09:58
Aparently the maven plugin is unable to find that jar in Maven central and this is why is fails. As a solution, I have edited my settings.xml file and add a pluginRepository to point to that location and it works to find those dependencies.

dorin.enache
2020-10-15 09:59
The plugin I am referring is this one:

dorin.enache
2020-10-15 09:59
```<plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.1.0</version>```

dorin.enache
2020-10-15 10:01
I am running this with Maven 3.5.4 and publish of pacts to pact-broker(V2.66.0.0) is working fine. The other colleagues of mine who uses a newer version of Maven 3.6.1+ are receiving an exception running the same publish on the same code

dorin.enache
2020-10-15 10:11
[ERROR] Failed to execute goal au.com.dius.pact.provider:maven:4.1.0:publish (default-cli) on project transaction-api: Execution default-cli of goal au.com.dius.pact.provider:maven:4.1.0:publish failed: Expected a HAL+JSON response from the pact broker, but got a response with no '_links'. URL: '<http://...>, LINK: 'pb:pacticipant-version-tag' -> [Help 1]

marco.cordeiro
2020-10-15 10:54
has joined #pact-jvm

betty.he
2020-10-15 14:32
has joined #pact-jvm

rodrigocs
2020-10-15 16:19
has joined #pact-jvm

uglyog
2020-10-15 22:05
Does your broker have authentication or some proxy server in front of it? The plugin is not getting a correctly formatted response from it.

mamtha.3687
2020-10-16 01:14
Trying to fetch from a different rest service through custom pact source.

francislainy.campos
2020-10-16 08:10
Hi, in case still trying to work out a solution for this, could you please post your code with only the parts that are problematic so that's a bit easier to read, otherwise this json file is a bit too long and hard to understand what is it that is still missing.

francislainy.campos
2020-10-16 08:34
You could for example perhaps remove the repeated array items as seeing one of them only would be enough to give an idea on how to translate this file into a contract. If you can create a MVP for this it would make it a bit easer to try and help identify what the issue is. Thanks.

tamer
2020-10-16 09:08
has joined #pact-jvm

tamer
2020-10-16 09:10
hello! I have a strange behaviour I can't understand

tamer
2020-10-16 09:10
we have a lot of pact already set up in the system via our broker

tamer
2020-10-16 09:10
now I'm getting this

tamer
2020-10-16 09:10
``` Verifying a pact between payments-service and payments-scheduling-service-messaging the scheduler created a dunning request 2020-10-16 11:07:21.946 WARN 60600 --- [ Test worker] org.reflections.Reflections : given scan urls are empty. set urls in the configuration Verification Failed - No annotated methods were found for interaction 'the scheduler created a dunning request'. You need to provide a method annotated with @PactVerifyProvider("the scheduler created a dunning request") that returns the message contents. Failures: 0) the scheduler created a dunning request No annotated methods were found for interaction 'the scheduler created a dunning request'. You need to provide a method annotated with @PactVerifyProvider("the scheduler created a dunning request") that returns the message contents.```

tamer
2020-10-16 09:11
but this is my test class.. the annotated method is there

tamer
2020-10-16 09:11
````@RunWith(SpringMessagePactRunner.class) @Provider("payments-scheduling-service-messaging") @PactBroker(host = "pact-broker.....", tags = '${pactbroker.tags:master}') @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) class PaymentsSchedulingMessagingProviderPact implements PactsTrait { @Autowired private ObjectMapper objectMapper @SuppressWarnings("unused") @TestTarget public final Target target = new AmqpTarget() @PactVerifyProvider("the scheduler created a payment transaction request") String scheduledPaymentTransactionEventCreated() { def message = PaymentTransactionRequestMessage.builder() ... .build() return toJson(message, objectMapper) } @PactVerifyProvider("the scheduler created a dunning request") String scheduledDunningRequestEventCreated() { def message = DunningRequestMessage.builder() ... .build() return toJson(message, objectMapper) } }```

tamer
2020-10-16 09:11
using gradle + spock + spring runner

tamer
2020-10-16 09:11
```testImplementation "au.com.dius:pact-jvm-provider-spring_2.12:3.6.15"```

tamer
2020-10-16 09:11
any idea?

dorin.enache
2020-10-16 09:41
It doesn`t have any authentication yet, but what I don`t understand is that the same codebase build and published from my machine with maven 3.5.4 works successfully and the same codebase published from another machine with maven 3.6.1+ receives that error message. To be honest I don`t understand how the Maven version influences the publish operation.

mario.gioiosa
2020-10-16 18:57
has joined #pact-jvm

uglyog
2020-10-17 01:22
That is an old version of Pact-JVM. Try the latest instead `implementation 'au.com.dius.pact.provider:spring:4.1.7'`

uglyog
2020-10-17 01:25
Yeah, there is something odd going on there. Maybe classpath loading has changed in Maven 3.6.x, and that is impacting things.

uglyog
2020-10-17 01:26
If you can look at the dependency tree to make sure the correct versions of the JAR files are being loaded

uglyog
2020-10-17 01:26
That might help diagnose the issue.

pavank
2020-10-17 19:47
Hi All, I am trying to generate pact file in XML format just by changing application/xml, when I checked the pact file only body is in xml format and rest all content is in json format only Can anybody let me know that am I following right approach or not? This is how my createPact() looks like ```@Pact(consumer = "JunitRuleConsumer") public RequestResponsePact createPact(PactDslWithProvider builder) { Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/xml;charset=UTF-8"); return builder .given("") .uponReceiving("Pact JVM example Pact interaction") .path("/information") .query("name=Miku") .method("GET") .willRespondWith() .headers(headers) .status(200) .body("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<Information>\n" + " <salary>45000</salary>\n" + " <name>Hatsune Miku</name>\n" + " <nationality>Japan</nationality>\n" + " <contact>\n" + " <Email>hatsune.miku@ariman.com</Email>\n" + " <Phone_Number>9090950</Phone_Number>\n" + " </contact>\n" + "</Information>") .toPact(); }```

matt.fellows
2020-10-17 21:30
What are you expecting to see?

matt.fellows
2020-10-17 21:31
It's still an HTTP request with XML over the wire. The pact format is JSON so it encodes the XML

pavank
2020-10-18 06:36
hi @matt.fellows thanks a lot for your response, actually I am very new to Pact and I was expecting generated pact file with .xml format. I do not know my expectation is correct or not. please correct me if I am wrong. Please let me know if below pact is correct.

matt.fellows
2020-10-18 10:26
The pact file is just the where the contract details are stored. Unless you're having issues I wouldn't be worried about. Are you having issues?

lior.baber
2020-10-19 07:33
has joined #pact-jvm

mmotornyi.consultant
2020-10-19 07:49
I can't get how to define consumerVersion for each pact in gradle script. Does anybody knows how to do that? I've set `providerVersion` in `publish` section. But I need to create pacts for few different providers with different versions. It's not supported yet ?

antonello
2020-10-19 07:58
`providerVersion` is to set the version when publishing verification results. `consumerVersion` is to set the version when publishing pacts. Are you saying that you want `consumerVersion` to be different for the same consumer depending on the provider?

mmotornyi.consultant
2020-10-19 08:06
I have IntelliJ IDEA project with contract tests. I'm planing to use this project for making pacts for 3 different providers. This three providers very similar to each other that's why there will be a lot of common code. Providers use different versions. I can specify version only once and looks like it means that all three providers will use the same version. I'd like to specify 3 different versions

mmotornyi.consultant
2020-10-19 08:07
Probably I can try to create gradle modules for different providers

mmotornyi.consultant
2020-10-19 08:28
@antonello There are no such kind of property like `consumerVersion`:

mmotornyi.consultant
2020-10-19 08:55
when I use providerVersion property it actually sets consumerVersion :smiley:

antonello
2020-10-19 09:31
Interesting, it says here: https://github.com/DiUS/pact-jvm/blob/master/provider/gradle/README.md#publishing-pact-files-to-a-pact-broker > _NOTE:_ The pact broker requires a version for all published pacts. The `pactPublish` task will use the version of the gradle project by default. You can override this with the `consumerVersion` property. Make sure you have set one otherwise the broker will reject the pact files.

mmotornyi.consultant
2020-10-19 09:33
Yeah, exactly. I've read that and tried to use `consumerVersion` but it doesn't work. Either the mistake in gradle plugin or in documentation.

antonello
2020-10-19 09:35
just to clarify - do you have 1 consumer and 3 providers?

jeffbdye
2020-10-19 17:10
has joined #pact-jvm

jace
2020-10-19 19:22
has joined #pact-jvm

uglyog
2020-10-19 22:13
What version are you using?

young
2020-10-20 02:13
Hi everyone, Could someone share the 'provider state' example(Gradle, java)? Thanks in advance!


matt.fellows
2020-10-20 02:20
does it need to be a gradle provider test?


young
2020-10-20 02:22
Thank you Matt

matt.fellows
2020-10-20 02:23
sorry I don?t have one then :stuck_out_tongue:


young
2020-10-20 02:24
Thanks. It helps a lot.

young
2020-10-20 05:35
`For each provider you can specify a state change URL to use to switch the state of the provider. This URL will receive the providerState description and all the parameters from the pact file before each interaction via a POST.` Must be a POST request?? Cannot be PUT or Delete? @matt.fellows

matt.fellows
2020-10-20 05:48
POST, is that a problem?

matt.fellows
2020-10-20 05:49
remember, this is a test specific endpoint that will receive the state as JSON. That endpoint can then do what it likes with that message

matt.fellows
2020-10-20 05:49
It can?t know to do a DELETE in advance, because it doesn?t know what the state is trying to do

matt.fellows
2020-10-20 05:49
`POST /providerstatesetuppath` - create an endpoint like this, receive the JSON blog and use the description to configure your provider

matt.fellows
2020-10-20 05:50
or, use the gradle closure to handle the state

young
2020-10-20 05:56
Thank you Matt,

tamer
2020-10-20 07:57
Thanks! I ended up doing it anyway :slightly_smiling_face:

mmotornyi.consultant
2020-10-20 07:59
Yes, I have 1 consumer (backend driven app) and three providers (3 servers). ```// https://mvnrepository.com/artifact/au.com.dius/pact-jvm-consumer-junit testImplementation "au.com.dius:pact-jvm-consumer-junit:$pactVersion" // https://mvnrepository.com/artifact/au.com.dius/pact-jvm-consumer-junit testImplementation "au.com.dius.pact.consumer:junit:4.1.7" // https://mvnrepository.com/artifact/au.com.dius/pact-jvm-consumer-java8 testImplementation "au.com.dius:pact-jvm-consumer-java8:$pactVersion"``` where pactVersion == 4.0.10

antonello
2020-10-20 08:08
And you?re saying you?d want a different consumerVersion for each pact between that consumer and the 3 providers?

mmotornyi.consultant
2020-10-20 08:17
Yes. Since mobile app is backend driven it can proceed with any response. But servers can send totally different information. And each server has kind of different API versions. As soon as server move to the next version the contract between mobile app and the server will be slightly changed. So we need to update the version of a pact. For our purposes it doesn't matter is it consumerVersion or providerVersion. We treat it as a pact version in general. I guess we can just create gradle modules and treat them as different consumers. In this case it should be possible to define version for each module separately.

uglyog
2020-10-20 08:19
From the 4.1.7 release notes: > fix: renamed providerVersion to consumerVersion in Gradle publish task

uglyog
2020-10-20 08:20
So, before 4.1.7 you need to use providerVersion, but can use both afterwards


antonello
2020-10-20 08:24
@mmotornyi.consultant You need to look here https://mvnrepository.com/artifact/au.com.dius.pact

antonello
2020-10-20 08:25
the package structure has changes in 4.1.0

antonello
2020-10-20 08:25
bear in mind that if you upgrade you?ll need to make a few changes to migrate

mmotornyi.consultant
2020-10-20 08:27
I can understand what should I change

mmotornyi.consultant
2020-10-20 08:27
What should I use instead of ```classpath "gradle.plugin.au.com.dius:pact-jvm-provider-gradle:${pactVersion}"``` ?

uglyog
2020-10-20 08:30
You can use ```plugins { id 'au.com.dius.pact' version '4.1.8' }```

uglyog
2020-10-20 08:30
Or ```classpath 'au.com.dius.pact.provider:gradle:4.1.8'```

uglyog
2020-10-20 08:31
But that will need a `repositories` section in the `buildscript`

mmotornyi.consultant
2020-10-20 08:33
Maybe you can point me to the readme file where this process described?


mmotornyi.consultant
2020-10-20 08:35
Thanks! Seems it works

antonello
2020-10-20 08:36
Great! I am still a bit confused about what you?re trying to achieve with regard to your original point. It smells a bit. But it sounds like you do have a clear idea, so that?s all that matters. :slightly_smiling_face:

mmotornyi.consultant
2020-10-20 08:38
Well, I guess my idea with only 1 consumer was wrong. Probably I need to treat app as 3 different consumers then everything should be fine.

mmotornyi.consultant
2020-10-20 08:38
Thanks a lot for your help! @antonello @uglyog

antonello
2020-10-20 08:40
If there is one consumer but the consumer needs to work with different versions or the provider, that is what versioning and tagging is for.

almaak
2020-10-20 09:35
has joined #pact-jvm

andra.moraru
2020-10-20 14:13
has joined #pact-jvm

camila.coder91
2020-10-20 17:06
has joined #pact-jvm

julzelements
2020-10-21 05:25
has joined #pact-jvm

andra.moraru
2020-10-21 06:35
Hello! I was wondering if anyone here was able to integrate the Pact Mock Server with cucumber tests. At this moment, I create some mocked data using methods annotated with "@Pact" and test the contract with unit test methods annotated with "@PactVerification", but I need to reuse the mocked data also for functional tests built with cucumber. Some links with examples would also be great and I can study further. Thank you

kapil.mathur
2020-10-21 06:40
has joined #pact-jvm



andra.moraru
2020-10-21 08:27
thanks, I will take a look

dorin.enache
2020-10-21 10:06
Actually, I was not paying enough attention to all logfile and somewhere earlier in the log before this message to be printed a connection timout between the machine that tries to do the publish and pact-broker server is thrown

dorin.enache
2020-10-21 10:08
it seems there are some conectivity problems between the server and its clients. Some machine have acquired a connection from the pool(like it is mine which works) and others get imediately a timeout

dorin.enache
2020-10-21 10:11
Publishing 'App1-App2.json' with tags 'master' ... [WARNING] Could not fetch the root HAL document org.apache.http.conn.HttpHostConnectException: Connect to pact-broker:80 failed: Connection timed out (Connection timed out) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)

mark.hudson
2020-10-21 10:45
has joined #pact-jvm

dianaszaharia
2020-10-21 12:38
Hey! I am currently upgrading pact jvm from 4.0.5 to 4.1.9 and am struggling with *provider state params* which don't seem to be serialized correctly anymore; e.g ```given("my custom object exists", "myObject", myObject)``` would get serialized in the pact file correctly ```"providerStates": [ { "name": "my custom object exists", "params": { "myObject": <serialized_form> } } ]``` and after migrating to 4.1.9 it gets serialized to null: ```"providerStates": [ { "name": "my custom object exists", "params": { "myObject": null } } ]``` Any ideas what could be happening? I noticed Gson was dropped in 4.1.0 in favor of custom json parser; is there a different approach for sending provider state params after this change?

antonello
2020-10-21 13:00
Is that `given` your custom code?

dianaszaharia
2020-10-21 13:18
it's a simplified example, point is that objects are not serialized in the pact file anymore; primitives seem to be working fine

viniciusribeirosp
2020-10-21 14:06
has joined #pact-jvm

antonello
2020-10-21 15:06
could you share how you?re currently using the `@State` annotation?

dianaszaharia
2020-10-21 15:22
not even reaching provider verification, this is just strictly about the pact file written after consumer tests are run

antonello
2020-10-21 15:25
ah right! of course, I was being super dumb here

antonello
2020-10-21 15:30
what type is `myObject`?

dianaszaharia
2020-10-21 15:40
it's a custom object type, but for example I can reproduce with ```given("my custom object exists", "id", UUID.randomUUID())``` this will be written to pact file as: ``` "providerStates": [ { "name": "my custom object exists", "params": { "id": null } } ]```

antonello
2020-10-21 15:43
interesting - does it work with primitives or string?

dianaszaharia
2020-10-21 15:46
yep, works with primitives or boxed primitives

antonello
2020-10-21 15:47
@uglyog would be in a better place to comment on whether it?s a desired side effect or not

antonello
2020-10-21 15:48
but I guess a workaround would be `toString`

antonello
2020-10-21 15:51
if the `UUID` is the only type you are using


dianaszaharia
2020-10-21 15:54
it's not the only type, but you do have a point; I could handle the serialization part (with jackson's ObjectMapper) and send the object already serialized as string. will give it a try

cluu
2020-10-21 17:16
has joined #pact-jvm

camila.campos
2020-10-21 21:35
has joined #pact-jvm

uglyog
2020-10-21 21:54
Can you raise an issue for that, it is a regression

dianaszaharia
2020-10-22 06:54
will do, thanks!

longlevan
2020-10-22 09:15
has joined #pact-jvm

mmotornyi.consultant
2020-10-22 10:29
Simple question. What is the difference between `stringValue` and `stringType` ?

antonello
2020-10-22 10:31
`stringValue` -> Match a string value (using string equality) `stringType` -> Will match all Strings https://github.com/DiUS/pact-jvm/tree/master/consumer#dsl-matching-methods

mmotornyi.consultant
2020-10-22 10:54
Thanks

pavank
2020-10-22 14:58
Hi All, I am trying to generate pact file for POST request but I am getting below error ```u.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: method: POST path: /PartnerConnect/PC_100097/AP_PRICE/AV_1.0/OG_1 query: {} headers: {Content-Type=[Content-Type: application/xml]} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: PRESENT(<?xml version="1.0" encoding="utf-8"?> <PriceUpdate> <Item> <SKU>8907411529088</SKU> <MRP>1111</MRP> <MOP>999</MOP> <SellerShippingInfo> <DeliveryType>HD</DeliveryType> <ShippingCharges>55</ShippingCharges> </SellerShippingInfo> <SellerShippingInfo> <DeliveryType>ED</DeliveryType> <ShippingCharges>55</ShippingCharges> </SellerShippingInfo> </Item> </PriceUpdate>)```

pavank
2020-10-22 14:59
Here is my test ```public class PricePactJunitRuleXmlTest { PriceProviderService priceProviderService = new PriceProviderService(); @Rule public PactProviderRule mockProvider = new PactProviderRule("IntegraPriceProvider", this); @Pact(consumer="IntegraPriceConsumer") public RequestResponsePact createPact(PactDslWithProvider builder) { Map<String, String> headersForeReq = new HashMap<String, String>(); headersForeReq.put("Content-Type", "Content-Type: application/xml"); Map<String,String> headersForResponse = new HashMap<>(); headersForResponse.put("X-Application-Context","OCTA-BRIDGE:swagger,no-liquibase,qa5:8080"); return builder .given("") .uponReceiving("Pact JVM example Pact interaction") .path("/PartnerConnect/PC_100097/AP_PRICE/AV_1.0/OG_1") .headers(headersForeReq) .method("POST") .body("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<PriceUpdate>\n" + " <Item>\n" + " <SKU>8907411529088</SKU>\n" + " <MRP>1111</MRP>\n" + " <MOP>999</MOP>\n" + " <SellerShippingInfo>\n" + " <DeliveryType>HD</DeliveryType>\n" + " <ShippingCharges>55</ShippingCharges>\n" + " </SellerShippingInfo>\n" + " <SellerShippingInfo>\n" + " <DeliveryType>ED</DeliveryType>\n" + " <ShippingCharges>55</ShippingCharges>\n" + " </SellerShippingInfo>\n" + " </Item>\n" + "</PriceUpdate>") .willRespondWith() .status(200) .headers(headersForResponse) .body("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<PriceUpdate>\n" + " <Item>\n" + " <SELLERID>100097</SELLERID>\n" + " <PRODUCTSKU>8907411529088</PRODUCTSKU>\n" + " <PRICE>1111</PRICE>\n" + " <OFFERPRICE>999</OFFERPRICE>\n" + " <HOMEDELIVERY>55</HOMEDELIVERY>\n" + " <EXPRESSDELIVERY>55</EXPRESSDELIVERY>\n" + " <STATUS>RECORD UPDATED</STATUS>\n" + " <REASON>RECORD CORRECT</REASON>\n" + " </Item>\n" + "</PriceUpdate>\n") .toPact(); } @Test @PactVerification public void runTest() throws JAXBException { priceProviderService.setBackendURL(mockProvider.getUrl()); } }```

pavank
2020-10-22 15:00
I guess I am going wrong while doing POST call , please can anybody help

paolaagudelo10
2020-10-22 15:21
has joined #pact-jvm

antonello
2020-10-22 15:34
Not really sure what you?re doing in `runTest()` but I suspect that the problem is there. Inside that method you should call whatever method makes the API request corresponding to the interaction you?ve set up.

pavank
2020-10-22 15:58
hi @antonello thanks for your quick response and input. yes I tried with API request now I am able to generate pact file.

justin.garfield
2020-10-22 16:15
has joined #pact-jvm

guppy0356.nakira
2020-10-23 00:34
has joined #pact-jvm

matt.fellows
2020-10-23 00:42
@antonello :taco: thanks!


ercalbwar
2020-10-24 19:24
has joined #pact-jvm

ercalbwar
2020-10-24 19:53
Hi everyone! I'm a bit new to this contract testing thing and I was wondering if someone could point me at a GitHub repo with a good example of asynchronous consumer tests in Java. Thanks!

antonello
2020-10-24 21:52
Hi Alberto! Have you seen already the examples in the readmes under provider/junit and consumer/junit?

ercalbwar
2020-10-24 22:37
Just found it after you mentioned it https://github.com/DiUS/pact-jvm/blob/master/consumer/junit5/src/test/java/au/com/dius/pact/consumer/junit5/AsyncMessageTest.java. Spent a fair amount of time on https://docs.pact.io/ but didn't see a reference there.

ercalbwar
2020-10-24 22:38
Do you mind if I ask you a follow up question?

ercalbwar
2020-10-24 22:39
The tests that are given as examples are not really exercising any code. They are asserting that the messages contain what it was setup above. Is this how I am supposed to write contract tests?

ercalbwar
2020-10-24 22:40
I suppose this will generate the pact file but I was expecting it would require to integrate with the business logic in order to validate the contract

ercalbwar
2020-10-24 22:41
I might be missing something

matt.fellows
2020-10-25 05:20
There are a number of examples here, including a Kafka one for Java: https://github.com/pactflow/


matt.fellows
2020-10-25 05:23
basically, you need to pass the message the consumer expects to have to the handler

matt.fellows
2020-10-25 05:24
It?s conceptually similar to the HTTP case - you still need to make sure your code can handle the message, absolutely

ercalbwar
2020-10-25 10:58
Found it! Thanks :thumbsup:

andrewshtamburg
2020-10-25 13:04
has joined #pact-jvm



francislainy.campos
2020-10-25 14:52
Perhaps these articles may help you

siad.ardroumli
2020-10-25 18:16
has joined #pact-jvm

ercalbwar
2020-10-25 20:09
Looks good indeed! Thanks @francislainy.campos

srikanthpmailid
2020-10-26 01:02
has joined #pact-jvm

photesthesis_geospiza
2020-10-26 15:10
has joined #pact-jvm

wesleythomaswilliams
2020-10-27 15:15
Having a bit a of a crisis of confidence with my contract tests and hoping someone can help (I think my brain has gone on holiday). If my provider publishes a schema which includes an array of objects and the consumer doesn't care if there are 0, 1 or X objects in the array. Does using `.eachLike` accurately represent that contract between consumer/provider? e.g. ```.eachLike("customers", 1) .stringType("name", "Bob") .closeObject() .closeArray()``` Where the consumer could receive: ```{ customers: [ ] }``` OR ```{ customers: [ { name: "Bob" } ] }```

wesleythomaswilliams
2020-10-27 15:29
Further to the above, if the provider published something like the example below, am I right to assume `eachLike` for `customers` isn't appropriate as their `outfits` can be an empty array, so is there any alternative or does this fall under pacts "no support for specifying optional attributes"? If so, does that change if size of the `customers` array is known to be fixed. i.e. the Bob and Karen objects will always be there. ```{ customers: [ { name: "Bob" outfits: [ ] }, { name: "Karen" outfits: [ { top: "blue t-shirt", bottom: "blue jeans" }, { top: "green t-shirt", bottom: "black skirt" } ] }```

antonello
2020-10-27 16:15
Imho, the most defensive option would be to have both interactions defined in your pact.

antonello
2020-10-27 16:18
but if you know that the consumer is fine with an empty array, it might not be worth it.

antonello
2020-10-27 16:25
In the case above, I would be inclined to have a nested `eachLike` for `outfits` inside the `customers` `eachLike`

antonello
2020-10-27 16:28
as above, if you wanted to be defensive and ensure that your client is indeed happy to deserialise the empty array and that the provider doesn?t stop supporting that case, you could have both interactions.

antonello
2020-10-27 16:28
clearly, depending on how much nesting and how many permutations of similar scenarios you have, your number of interactions might explode very quickly.

antonello
2020-10-27 16:29
in which case I would generally tend to stick to the most comprehensive example.

antonello
2020-10-27 16:30
regardless of optionals

antonello
2020-10-27 16:30
and leave it to some kind of non-pact tests on the consumer side to make sure that it can cope with empty arrays, optionals missing, etc.

wesleythomaswilliams
2020-10-27 16:31
@antonello mind if I contact you via DM, I've got contract tests in place for an example like this, but it'd be great to see what you think.

antonello
2020-10-27 16:32
I don?t mind at all, but it might be useful for other people to see too. I?m also keen to hear other opinions on this btw. :slightly_smiling_face:

jackbwheatley
2020-10-27 21:02
has joined #pact-jvm

carlosalmeida.xon
2020-10-27 22:06
has joined #pact-jvm

uglyog
2020-10-27 22:06
I would have 2 tests, one with an empty array and one using `minArrayLike` to ensure that the array is populated. See https://docs.pact.io/faq/#why-is-there-no-support-for-specifying-optional-attributes for more info

yousafn
2020-10-28 02:38
has joined #pact-jvm

francislainy.campos
2020-10-28 02:58
Yeah, I think you may need states for this, otherwise when you're expecting `name` to return and it will be null pact won't know whether it's a failure or just failing under the first scenario, so it'll fail always I believe.

nasir.amin
2020-10-28 11:07
has joined #pact-jvm

jimish.shah.-nd
2020-10-28 11:26
has joined #pact-jvm

adam_figgins
2020-10-28 14:20
has joined #pact-jvm

almaak
2020-10-28 15:15
hey all, I'm trying to run the pact-jvm-server as jar in my gradle project, but I think the server requires specific scala lib version. is it possible? I'm getting 2020-10-28T16:08:38.206+0100 [ERROR] [system.err] Exception in thread "main" java.lang.NoSuchMethodError: scala.App.$init$(Lscala/App;)V I have following dependencies dependency "org.scala-lang:scala-library:2.11.7" dependency "com.github.scopt:scopt_2.10:3.0.0" dependency "io.netty:netty-all:4.1.53.Final"

wesleythomaswilliams
2020-10-28 15:27
Using `minArrayLike` like this @uglyog: ```.minArrayLike("outfits", 0, 1) .stringType("top", "blue t-shirt") .stringType("bottom", "blue jeans")```

aperdomobo
2020-10-28 15:42
has joined #pact-jvm

almaak
2020-10-28 16:03
I was able to run it. got working library combo from the distribution. dependency "au.com.dius.pact:pact-jvm-server:4.1.9" dependency "org.scala-lang:scala-library:2.12.0" dependency "com.github.scopt:scopt_2.12:3.5.0" dependency "ws.unfiltered:unfiltered-netty-server_2.12:0.9.1"

diazguerra2
2020-10-28 16:06
has joined #pact-jvm

almaak
2020-10-28 16:07
now I have a strange behaviour - the server gets started multiple times from my gradle task. has anyone else had that issue?

jarmy
2020-10-28 17:31
Hi @francislainy.campos, just saw your responses?I?ve currently implemented the following function that only creates a _portion_ of the response body using `.minArrayLike("containers", 2)` ``` @Pact(provider = "pegasus", consumer = "android-sxmp-phone") @Suppress("MaxLineLength") fun createPact(builder: PactDslWithProvider): RequestResponsePact { val jsonBody = PactDslJsonBody() .stringType("sduiVersion", "1") .stringType("itemId", "8NKxTe5NVYD0LTTdT7Vd556hhrO4CYIvoO8YgcHthnjXqtTtkDV7OPKWBcDHewMNh3V5hFcEMWJ8MVTt") .numberType("wallClock", 1600732583943) .`object`("page") .stringType( "itemId", "vTmP4bTE1WFEOsuGJhfpJaYWlGBvopVVGGXITgDqeR27BFuDaq0bAgo97VBlnQhnSF5H3DvyLQ8wr0qwSNjbB4mSvOebZUkBd" ) .stringType("type", "CONTAINER") .stringType("view", "PAGE") .minArrayLike("containers", 2) .stringType( "itemId", "vTmP4bTE1WFEOsuGJhfpJaYWlGBvopVVGGXITgDqeVANKYkqGdGHGD4BpSpuiema4pJAEDYRCIHvGYH78zxuyG8YKNM74rPrt" ) .stringType("type", "CONTAINER") .stringType("component", "page-header") .minArrayLike("items", 1) .stringType( "itemId", "KNLPoAiSQztjy0hWVdlnBGJu1I81cCzQDHDaZ3YwbmtWQfkKZwON2KuRw8GAUiEdvmMuy6jp9IEtHOhEHLqsVx6Y891eRdl0dQD76RwRLBYv" ) .stringType("component", "title") .`object`("texts") .`object`("title") .stringType("value", "Today") .closeObject() .closeObject() .closeArray() .closeArray() .closeObject() return builder .uponReceiving("v1/view request") .path("/rest/v1/view") .query("deviceUuid=acctssp137-test-deviceUUID&platform=mobile") .method("GET") .willRespondWith() .status(200) .body(jsonBody) .toPact() }```

jarmy
2020-10-28 17:31
This creates the following body in the contract ``` "body": { "itemId": "8NKxTe5NVYD0LTTdT7Vd556hhrO4CYIvoO8YgcHthnjXqtTtkDV7OPKWBcDHewMNh3V5hFcEMWJ8MVTt", "wallClock": 1600732583943, "page": { "itemId": "vTmP4bTE1WFEOsuGJhfpJaYWlGBvopVVGGXITgDqeR27BFuDaq0bAgo97VBlnQhnSF5H3DvyLQ8wr0qwSNjbB4mSvOebZUkBd", "view": "PAGE", "containers": [ { "itemId": "vTmP4bTE1WFEOsuGJhfpJaYWlGBvopVVGGXITgDqeVANKYkqGdGHGD4BpSpuiema4pJAEDYRCIHvGYH78zxuyG8YKNM74rPrt", "component": "page-header", "type": "CONTAINER", "items": [ { "itemId": "KNLPoAiSQztjy0hWVdlnBGJu1I81cCzQDHDaZ3YwbmtWQfkKZwON2KuRw8GAUiEdvmMuy6jp9IEtHOhEHLqsVx6Y891eRdl0dQD76RwRLBYv", "component": "title", "texts": { "title": { "value": "Today" } } } ] }, { "itemId": "vTmP4bTE1WFEOsuGJhfpJaYWlGBvopVVGGXITgDqeVANKYkqGdGHGD4BpSpuiema4pJAEDYRCIHvGYH78zxuyG8YKNM74rPrt", "component": "page-header", "type": "CONTAINER", "items": [ { "itemId": "KNLPoAiSQztjy0hWVdlnBGJu1I81cCzQDHDaZ3YwbmtWQfkKZwON2KuRw8GAUiEdvmMuy6jp9IEtHOhEHLqsVx6Y891eRdl0dQD76RwRLBYv", "component": "title", "texts": { "title": { "value": "Today" } } } ] } ],```

jarmy
2020-10-28 17:36
If you compare it against the response I posted https://pact-foundation.slack.com/archives/C9UN99H24/p1601577250078800?thread_ts=1601494424.046900&cid=C9UN99H24, you?ll see it?s missing a number of `items` in the `containers` array. I?m not sure if it even matters?

xsamore
2020-10-28 19:52
has joined #pact-jvm

simon
2020-10-28 20:49
has joined #pact-jvm

antonello
2020-10-28 22:06
I always assumed that `eachLike` would fail if the array wasn?t populated.

uglyog
2020-10-28 22:43
It should be `.minArrayLike("outfits", 1)`

uglyog
2020-10-28 22:44
That will check the array has at least 1 item. `eachLike` only checks that each item in the array matches, it doesn't check the array length.

uglyog
2020-10-28 22:51
There is an application bundle for that that will be better to use because it has all the correct dependencies.

antonello
2020-10-28 22:58
But with `eachLike` there would have to be at least one item in the array, or otherwise it won?t match, correct?

wesleythomaswilliams
2020-10-28 23:00
@uglyog If I know that the provider will always create a message with the `customers` array exactly as presented above, with those two entries. How would you represent the array in the dsl?

uglyog
2020-10-28 23:10
@antonello `eachLike` will not generate any mismatches if there is nothing to match

uglyog
2020-10-28 23:11
@wesleythomaswilliams if they are always exactly like that, you can just use a normal array and it will check equality.

ruben.cagnie
2020-10-29 01:24
has joined #pact-jvm

ruben.cagnie
2020-10-29 01:29
Hi. We are exploring Pact at our company. So far, we've been able to set most of it up, but when we run the pact provider tests and we have a failure, the tests are marked as "skipped" (this is the output: `Pact between XXX (dev) and YYY - Upon a GET request to ... SKIPPED`). Is there a way to mark these as failed? Or is this part of the "Pending pacts" workflow?

matt.fellows
2020-10-29 01:34
The whole point of pending pacts is to _not_ fail the provider, but still send the failure results back to the broker so that the consumer will get the feedback (e.g. for can-i-deploy checks)

matt.fellows
2020-10-29 01:34
if you want to fail the provider, disable pending pacts

uglyog
2020-10-29 01:40
@ruben.cagnie how are you running the tests? The only way I know of getting skipped tests is there is no matching pacts that are fetched from the Pact Broker and you have added the `@IgnoreNoPactsToVerify` annotation to the test.

uglyog
2020-10-29 01:41
But then you would not get that output. Do you have normal `@Ignore` annotations on your tests?

matt.fellows
2020-10-29 01:41
Ah cool, I was wondering if the SKIPPED was a pact jvm specific artifact. The answer seems to be no (which is good, because that would be misleading)

uglyog
2020-10-29 01:42
I think the pending ones have `[PENDING] `

matt.fellows
2020-10-29 01:42
Could you share your provider verification code Ruben?

matt.fellows
2020-10-29 01:42
makes sense Ron

phil.endsley
2020-10-29 01:43
Might be mistaken, but I thought pending tests that failed showed the same as if you had @Ignore. To keep the build passing

ruben.cagnie
2020-10-29 01:44
So these test run fine normally, but I'm testing the scenario where we do a breaking change on the Provider side. After that, the test that fails (so the test actually did the work) gets the following message at the end: ```- Not all of the 2 were verified. The following were missing: - a GET request to get *** detail```

ruben.cagnie
2020-10-29 01:45
The test has ran, but failed: ```Failures: 1) a GET request to get *** summaries 1.1) BodyMismatch: $ BodyMismatch: Expected totalCount=2 but was missing { - "totalCount": 2, + "totalCountttt": 61,```

uglyog
2020-10-29 01:45
@phil.endsley you might be right. It triggers `notifier.fireTestIgnored(description)` for JUnit 4

ruben.cagnie
2020-10-29 01:46
What is the verification code? We are running our own pact broker, FWIW

matt.fellows
2020-10-29 01:48
the code you are using to verify the pacts on your provider side. e.g. your Pact Unit test or your gradle task settings

matt.fellows
2020-10-29 01:48
> We are running our own pact broker, FWIW we?ll forgive you :stuck_out_tongue:

uglyog
2020-10-29 01:49
@ruben.cagnie if it is due to pending pacts, there should be a notice in the standard output of the test as to why it is pending. You may need to look at the test report to see that.

ruben.cagnie
2020-10-29 01:52
sorry, I thought you were looking for a "verification code"... My bad, it's been a long day

ruben.cagnie
2020-10-29 01:53
Yeah, I'll anonymize it a bit

ruben.cagnie
2020-10-29 01:53
It's basically this: ```@RunWith(PactRunner::class) @PactBroker @Provider("ec-api") class PactContractIT { @TestTarget // Annotation denotes Target that will be used for tests val target: HttpTarget = HttpTarget(port, host, protocol) @TargetRequestFilter fun update(request: HttpRequest) { request.addHeader(ThreadLocalRequestMap.AUTHORIZATION_HEADER, generateJwt(scopes)) request.addHeader(Headers.CUSTOMER_UUID, defaultCustomerUuid) } @State("createFixtures") fun createFixtures() { FixtureFactory.createFixtures("root", "dev", "localhost") } }```

ruben.cagnie
2020-10-29 01:53
ok, will take a look

ruben.cagnie
2020-10-29 01:55
and I am using JUnit4

ruben.cagnie
2020-10-29 01:57
This is the output in standard out (I trimmed a bit) ```INFO 2020-10-29T01:54:45.253Z ec-api<unknown> "Test worker" [] a.c.d.p.p.DefaultVerificationReporter - Published verification result of 'Failed(results=[{message=Request to provider failed with an exception, exception=java.lang.AssertionError: Failures: 1) a GET request to get XXX summaries 1.1) BodyMismatch: $ BodyMismatch: Expected totalCount=2 but was missing ... PactContractIT > com.http.PactContractIT > app-bff - Upon a GET request to get XXX detail PASSED PactContractIT > com.http.PactContractIT > app-bff - Upon a GET request to get XXX summaries SKIPPED```

matt.fellows
2020-10-29 02:02
huh, have you enabled other system properties as well? Looks pretty basic

ruben.cagnie
2020-10-29 02:10
So I just tried with JUnit5 and this is behaving as expected

uglyog
2020-10-29 02:18
In the output higher up, there should be a notice section, just after where it shows what Pact URL it is running with

ruben.cagnie
2020-10-29 02:22
It is pretty basic. It just has some configs to set the broker url and some minor things

ruben.cagnie
2020-10-29 02:24
It seems like moving to JUnit5 it has the correct behavior

272939217
2020-10-29 05:33
has joined #pact-jvm

almaak
2020-10-29 08:28
thank you for taking the time! yes I've considered that but it has a lot of dependencies that we don't want to have in our repo and we still want to run the server through our gradle. is there a single jar, perhaps, that I can add to our build dependencies?

uglyog
2020-10-29 08:36
The jar you've added is the one

almaak
2020-10-29 08:53
hm, I've executed the main class http://au.com.dius.pact.server.Server with the java exec and it failed because all the other dependencies - scala, netty etc.

uglyog
2020-10-29 08:54
Yes, you will have to provide the correct dependencies.

uglyog
2020-10-29 08:55
Gradle can do it using the maven POM for it, but you will have to provide the correct classpath to the java exec

driloni92
2020-10-29 09:05
has joined #pact-jvm

almaak
2020-10-29 09:13
ok, thank you! I've tried that. and so far I've seen some of the libraries on the classpath. I'm missing the ws.unfiltered:unfiltered-netty-server_2.12 and the scopt for example, but it could be that there are hidden somewhere within other libs. :slightly_smiling_face: Unfortunately I can't run it at the moment, because I have a huge classpath and am getting an exception because of that. :face_with_rolling_eyes:

antonello
2020-10-29 11:02
@uglyog When would one want to use `eachLike` then?

pauloavra
2020-10-29 12:33
has joined #pact-jvm

ruben.cagnie
2020-10-29 12:45
Are there any examples of `pactPublish` using gradle with Kotlin DSL? I found an issue (https://github.com/DiUS/pact-jvm/issues/852) and a resolution, but I can't seem to find any examples

wesleythomaswilliams
2020-10-29 12:47
I'm curious now too on why someone would choose `eachLike` over `minArrayLike`

antonello
2020-10-29 12:48
we will have to go and change all our usages of `eachLike` to `minArrayLike`

ruben.cagnie
2020-10-29 13:13
I tried the following: ```pact.publish.pactDirectory = File(projectDir, "pacts") pact.publish.pactBrokerUrl = "http://localhost:8080" tasks.withType<Test>().configureEach { systemProperty("pact.rootDir", "./pacts") systemProperty("pact.writer.overwrite", "true") finalizedBy("pactPublish") }```

ruben.cagnie
2020-10-29 13:13
But get `Unresolved reference: pact`

almaak
2020-10-29 13:44
hm, which pom do you mean, in the pom in the pact-jvm-server there was only the library and no dependencies? <dependency> <groupId>http://au.com.dius.pact</groupId> <artifactId>pact-jvm-server</artifactId> <version>4.1.9</version> <type>pom</type> </dependency>

almaak
2020-10-29 13:50
I'm doing dependencies { runtimeClasspath(group: 'http://au.com.dius.pact', name: 'pact-jvm-server', version: '4.1.9') and not getting additional libs.

ruben.cagnie
2020-10-29 13:56
I found the solution. If anyone is interested: ```apply(plugin = "au.com.dius.pact") configure<au.com.dius.pact.provider.gradle.PactPluginExtension> { publish { pactDirectory = File(rootDir, "pacts") // defaults to $buildDir/pacts pactBrokerUrl = "http://localhost:8080" } } tasks.withType<Test>().configureEach { systemProperty("pact.rootDir", "./pacts") systemProperty("pact.writer.overwrite", "true") finalizedBy("pactPublish") }```

francislainy.campos
2020-10-29 16:46
Thank you Jason. Please don't get me wrong but I wonder whether I may have myself clear enough on the asking. The point is that this is still quite bit and hard to read and some of the things don't see to be part of the issue and could probably be removed so that the file is made a little bit smaller.

francislainy.campos
2020-10-29 16:47
It's not necessarily exactly about the sizing but it's hard to follow what the question is. Is the issue that you can't see the array of contents? Just some items inside it are missing, are the other items generating? If all of them are fine but one or two you could perhaps remove most of the ones who are alright and leave just one or two for the sake of comparison.

francislainy.campos
2020-10-29 16:48
Even the data inside the sample could also be made smaller.

francislainy.campos
2020-10-29 16:48
``` "items": [ { "itemId": "KNLPoAiSQztjy0hWVdlnBGJu1I81cCzQDHDaZ3YwbmtWQfkKZwON2KuRw8GAUiEdvmMuy6jp9IEtHOhEHLqsVx6Y891eRdl0dQD76RwRLBYv", "component": "title", "texts": { "title": { "value": "Today" } } }```

jarmy
2020-10-29 16:48
Ok, let me see if I can simplify things a bit. I?ll have something for you in the morning for you

francislainy.campos
2020-10-29 16:48
This here for example could be typed as ``` "items": [ { "itemId": "myid", "component": "title", "texts": { "title": { "value": "Today" } } }```

francislainy.campos
2020-10-29 16:49
As whether the id has 100 characters or only 4 it won't affect the outcome.


francislainy.campos
2020-10-29 16:50
This is called to produce a MVP (minimum viable product) which would be the smaller piece of code where the issue is still reproductible.

francislainy.campos
2020-10-29 16:51
And also the principal of divide and conquer, where by making a problem smaller it can get it easier to find the solution for it.

francislainy.campos
2020-10-29 16:52
I many times ended up finding the solutions for issues this way myself as may be able to figure where the issue is coming from more precisely.

francislainy.campos
2020-10-29 16:53
``` @Pact(provider = "pegasus", consumer = "android-sxmp-phone") @Suppress("MaxLineLength") fun createPact(builder: PactDslWithProvider): RequestResponsePact { val jsonBody = PactDslJsonBody() .stringType("sduiVersion", "1")```

francislainy.campos
2020-10-29 16:53
Here for example, on top of the file, we don't need to see the @Suppress annotation so you can delete that.

francislainy.campos
2020-10-29 16:54
So you can delete that

francislainy.campos
2020-10-29 16:57
``` @Pact(provider = "pegasus", consumer = "android-sxmp-phone") fun createPact(builder: PactDslWithProvider): RequestResponsePact { val jsonBody = PactDslJsonBody() .stringType("sduiVersion", "1") .stringType("itemId", "8") .numberType("wallClock", 1600732583943) .`object`("page") .stringType("itemId","v") .stringType("type", "CONTAINER") .stringType("view", "PAGE") .minArrayLike("containers", 2) .stringType("itemId","vT) .stringType("type", "CONTAINER") .stringType("component", "page-header") .minArrayLike("items", 1) .stringType("itemId","2") .stringType("component", "title") .`object`("texts") .`object`("title") .stringType("value", "Today") .closeObject() .closeObject() .closeArray() .closeArray() .closeObject() return builder .uponReceiving("v1/view request") .path("/rest/v1/view") .query("deviceUuid=acctsdeviceUUID") .method("GET") .willRespondWith() .status(200) .body(jsonBody) .toPact() }```

francislainy.campos
2020-10-29 16:58
Here, just by simplifying the ids would you agree that this becomes a bit easier to read?

francislainy.campos
2020-10-29 16:58
And let's suppose your question is just about the containers array you can simplify this even more.

francislainy.campos
2020-10-29 17:00
```@Pact(provider = "pegasus", consumer = "android-sxmp-phone") fun createPact(builder: PactDslWithProvider): RequestResponsePact { val jsonBody = PactDslJsonBody() .stringType("sduiVersion", "1") .`object`("page") .stringType("view", "PAGE") .minArrayLike("containers", 2) .stringType("itemId","vT) .minArrayLike("items", 1) .stringType("component", "title") .`object`("texts") .`object`("title") .stringType("value", "Today") .closeObject() .closeObject() .closeArray() .closeArray() .closeObject() return builder .uponReceiving("v1/view request") .path("/rest/v1/view") .query("deviceUuid=acctsdeviceUUID") .method("GET") .willRespondWith() .status(200) .body(jsonBody) .toPact() }```

francislainy.campos
2020-10-29 17:00
~And fixing the indentation~

francislainy.campos
2020-10-29 17:02
It could become even smaller but I'm not sure I understand the question but I think you get the idea and may be able to rephrase what you're trying to ask.

jarmy
2020-10-29 21:38
Ok @francislainy.campos here goes?

jarmy
2020-10-29 21:45
Here?s the simplified json response I?m trying to re-create ```{ "page": { "itemId": "1", "type": "CONTAINER", "view": "PAGE", "containers": [ { "itemId": "2", "type": "CONTAINER", "component": "page-header", "items": [ { "itemId": "2a", "component": "title", "texts": { "title": { "value": "Today", "scheme": "LITERAL" } } } ] }, { "itemId": "3", "type": "CONTAINER", "component": "bottom-nav", "items": [ { "itemId": "3a", "type": "ITEM", "component": "bottom-nav-item", "selected": "SELECTED_1", "texts": { "title": { "value": "For You", "scheme": "LITERAL" } }, "images": { "icon": { "value": "ForYou", "scheme": "BINDING" } }, }, { "itemId": "3b", "type": "ITEM", "component": "bottom-nav-item", "texts": { "title": { "value": "Live", "scheme": "LITERAL" } }, "images": { "icon": { "value": "Live", "scheme": "BINDING" } }, }, ] } ] } }``` As you can see, there are 2 `CONTAINER` types within the `containers` array with different bodies.

jarmy
2020-10-29 21:46
My question is how do I replicate the different CONTAINER types?

jarmy
2020-10-29 21:48
Here?s the current code I?m using ``` val jsonBody = PactDslJsonBody() .`object`("page") .stringType( "itemId", "1" ) .stringType("type", "CONTAINER") .stringType("view", "PAGE") .minArrayLike("containers", 2) .stringType( "itemId", "2" ) .stringType("type", "CONTAINER") .stringType("component", "page-header") .minArrayLike("items", 1) .stringType( "itemId", "2a" ) .stringType("component", "title") .`object`("texts") .`object`("title") .stringType("value", "Today") .closeObject() .closeObject() .closeArray() .closeArray() .closeObject()```

jarmy
2020-10-29 21:50
I think the problem is I can?t quite use `.minArrayLike("containers", 2)` since the containers are different

uglyog
2020-10-29 22:10
Hmm, I would have expected it to have all it's deps in there

uglyog
2020-10-29 22:12
Can you raise an issue for that on the Github project?

uglyog
2020-10-29 22:14
It's one of those things that happened and when you look back, you think: well, that is stupid

uglyog
2020-10-29 22:15
But I think that making the min rule explicit with `minArrayLike` is than better than being implicit.

antonello
2020-10-29 22:31
Understood. Would it make sense to deprecate `eachLike?`

francislainy.campos
2020-10-30 00:54
Much better!! Well done. Thanks.

francislainy.campos
2020-10-30 00:55
```val jsonBody = PactDslJsonBody() .`object`("page") .stringType("itemId","1") .stringType("type", "CONTAINER") .stringType("view", "PAGE") .minArrayLike("containers", 2) .stringType("itemId","2") .stringType("type", "CONTAINER") .stringType("component", "page-header") .minArrayLike("items", 1) .stringType("itemId","2a" ) .stringType("component", "title") .`object`("texts") .`object`("title") .stringType("value", "Today") .closeObject() .closeObject() .closeArray() .closeArray() .closeObject()```

francislainy.campos
2020-10-30 01:02
```{ "page": { "itemId": "1", "type": "CONTAINER", "view": "PAGE", "containers": [ { "itemId": "2", "type": "CONTAINER", "component": "page-header", "items": [ { "itemId": "2a", "component": "title", "texts": { "title": { "value": "Today", } } } ] }, { "itemId": "3", "type": "CONTAINER", "component": "bottom-nav", "items": [ { "itemId": "3a", "type": "ITEM", "component": "bottom-nav-item", "selected": "SELECTED_1", "texts": { "title": { "value": "For You", } }, "images": { "icon": { "value": "ForYou", } }, }, { "itemId": "3b", "type": "ITEM", "component": "bottom-nav-item", "texts": { "title": { "value": "Live", } }, "images": { "icon": { "value": "Live", } }, }, ] } ] } }```

francislainy.campos
2020-10-30 01:03
Just formatting and removing a bit more but I think I understand the question now. One of your containers have the images object whereas the other doesn't, yes?

francislainy.campos
2020-10-30 01:08
Assuming you have control on how to generate this data, you may want to use an api call where each and every item display that image object and create a contract for that situation. The verification for this contract would fail if the image is not there, but as long you use always the same params on your api and it always contains this param there, this shouldn't be much of an issue.

francislainy.campos
2020-10-30 01:17
But, if the structure is that your page-header never has the images icon but it's there only for the bottom-nav component (for each every and each item inside the bottom-nav component) and your call is always structured this way, it should be possible to include both on your contract.

francislainy.campos
2020-10-30 01:18
If you can please tell me what is the case here, I can detail this a bit more. Thank you.

uglyog
2020-10-30 03:11
Possibly, or at least update the javadoc comments and docs

almaak
2020-10-30 08:25
yes, right away.

jikogay728
2020-10-30 17:20
has joined #pact-jvm

jarmy
2020-10-30 17:32
I feel like we?re getting somewhere? In this case, the consumer doesn?t have control over the containers that are returned from the provider. The `page-header` component does _not_ have `images` and `actions` elements, but `bottom-nav-item` components do.

francislainy.campos
2020-10-30 17:42
Okay, just to be clear, by control what I mean is are you able to trigger a request that you know for sure how it's going to return back to you and that it wouldn't change too much. E.g. with some user or params you know you going to receive on page header and two bottom navs items, all of them with images, etc.

francislainy.campos
2020-10-30 17:43
If that's not the case, pact may not be the best solution to test this api..

jarmy
2020-10-30 17:48
This API is a Server Driven UI. Basically, the server controls the responses sent back to the clients by a page definition. If the provider changes the page definition, then the response can be different

francislainy.campos
2020-10-30 18:23
But when you trigger this api with some given params let's say on Postman, do you know what you're going to receive back?

francislainy.campos
2020-10-30 18:24
And if you trigger it again either immediately or after some time is that still the same?

jarmy
2020-10-30 18:25
Yes, it stays the same. I?ve had the contract in its current form running for about a month

francislainy.campos
2020-10-30 18:26
Okay, good

francislainy.campos
2020-10-30 18:26
So we can use pact for that

jarmy
2020-10-30 18:28
I sure hope so :slightly_smiling_face:. I?ve invested a lot of time into getting pact set up on 2 consumers with this provider already and I?m about to do another

francislainy.campos
2020-10-30 18:30
I'll draft something for you based on the mvp sample that we have

francislainy.campos
2020-10-30 18:39
```DslPart bodyReceived = new PactDslJsonBody() .object("page") .stringType("itemId", "1") .stringType("view", "PAGE") .eachLike("containers") .stringType("itemId", "2") .stringType("type", "CONTAINER") .stringType("component", "page-header") .eachLike("items") .stringType("itemId", "2a") .stringType("component", "title") .object("texts") .object("title") .stringType("value", "today") .closeObject() .closeObject() .closeArray() .closeArray() .closeObject();```

francislainy.campos
2020-10-30 18:40
Something like this..

francislainy.campos
2020-10-30 18:44
However, as the page-header and bottom-nav components both have the same keys (itemId, type, component, etc), I don't think we can include the images piece inside this unless we can have it also coming back for the page-header component or if you can perhaps get your backend to give you two different structures, maybe one object for page-header and another one for page-component. Otherwise, if we include the images on the array container when we're saying the each item (eachlike) should have that, then when it finds the page-header without it it will understand it as a failure.

francislainy.campos
2020-10-30 18:46
So the option I see here if this change is not possible and you're not able to have all the items come back with exact the same keys is that you may include on your contract only the keys that repeat for all items, so that you're at least asserting for them (some testing better than no testing).

jarmy
2020-10-30 20:55
that?s essentially that same idea I ended up with with the jvm test since we can?t guarantee that all the keys are the same

deepika.krishnakumar
2020-10-30 22:35
Hi. Pasting my question again. Is there a way to set http proxy before accessing a pact broker like pactflow from my provider. I?m trying from a java application. Any way of setting http.proxy. I was able to set it and publish to pactflow but the provider is unable to connect to it to read the pacts

matt.fellows
2020-10-30 22:46
If there is a standard answer we should add to the docs. I searched for proxy in Pact JVM to no avail

almaak
2020-10-31 11:23
not excatly right away, but still :slightly_smiling_face: https://github.com/pact-foundation/pact-jvm/issues/1239

blmlcu
2020-10-31 14:51
has joined #pact-jvm

uglyog
2020-10-31 23:42
You can use the standard proxy JVM system properties ```http.proxyHost http.proxyPort https.proxyHost https.proxyPort http.nonProxyHosts```

samuel.hodgkinson
2020-11-02 12:07
Hi. I'm using the groovy implementation for my Consumer, and I've set the spec version to 2.0, but it is still generating v3 matchers and features, which then breaks verification on the Provider side, as it's a golang provider, which only supports V2. Is this expected behaviour? Personally, I'd expected the Consumer code to throw an error if I set it to V2 and then tried using v3 matchers

aliaksandr.valadzko
2020-11-02 13:26
Hey guys! Could anyone help me please How can I specify `pact consumer version` when publishing to Broker? I used `tag`, however `tag` can not be used in _canIDeploy_ task - it requires `version`

aliaksandr.valadzko
2020-11-02 13:27
I use _gradle_ task `PactPublishTask` And then `PactCanIDeployTask`

aliaksandr.valadzko
2020-11-02 14:07
Found it - `providerVersion`

aliaksandr.valadzko
2020-11-02 14:08
I was a bit confused, as *consumer* version is called `providerVersion`

phil.endsley
2020-11-02 14:09
FYI - It was corrected to consumerVersion in a recent release

aliaksandr.valadzko
2020-11-02 14:09
Oh, cool, thanks

phil.endsley
2020-11-02 14:09
But yes, I've ran into this same issue

jamescourtoy
2020-11-02 21:04
has joined #pact-jvm

uglyog
2020-11-02 23:23
@matt.fellows I think we discussed this for V4

matt.fellows
2020-11-02 23:24
Yeah, I?ve added that to the (wip) golang provider. It won?t let you add matchers from a different spec

telmo.ferreira.costa
2020-11-03 11:32
has joined #pact-jvm

samuel.hodgkinson
2020-11-03 11:36
Ah sorry maybe I wasn't clear. My issue is that pact-jvm (using the groovy dsl) let's me use matchers from a different spec, not the go side

sergii.kopovskyi
2020-11-03 12:35
has joined #pact-jvm

samuel.hodgkinson
2020-11-03 13:28
So I set it to V2 on the groovy side, and it generated a pact which still had V3 matchers, without giving me an error

silverton.gimenes
2020-11-03 17:58
has joined #pact-jvm

colber16
2020-11-03 18:34
has joined #pact-jvm

cvoong
2020-11-03 18:55
has joined #pact-jvm

uglyog
2020-11-03 21:56
We understand this is an issue for you, what we are going to do moving forward is to make sure you get an error for future changes.

matt.fellows
2020-11-03 23:02
Sorry for the confusion Sam. Ron was including me in as we had recently discussed this whilst I was upgrading Golang. More of an ?FYI? to me than addressing your question

ashish_garg5
2020-11-04 06:02
Hi All, How do i run my provider against all consumer tags present in the pact broker ? I have consumer with 2 tags in broker and my provider is running against the latest one only and not the both. How i can make it to run and verify against all tags of consumer. Thanks in advance.

uglyog
2020-11-04 06:11
You need to provide the tags to use. How are you verifying your pacts?

ashish_garg5
2020-11-04 06:13
mvn clean install -Dpact.verifier.publishResults=true -Dpact.provider.version=0.0.0 -Dpact.provider.tag=test -Dpact.broker.host=<http://ciqpactdev.cec.lab.emc.com|<>host> -Dpact.broker.port=<port>

ashish_garg5
2020-11-04 06:14
this command i am using how to provide consumer tag in this ?


uglyog
2020-11-04 06:19
> pact.consumer.tags Overrides the tags used when publishing pacts [version 4.0.7+]


ashish_garg5
2020-11-04 06:20
ok thanks let me check

ashish_garg5
2020-11-04 06:21
i am using version 4.0.2 will both these doesn't work with this version ?

uglyog
2020-11-04 06:23
Probably better to upgrade to the latest

ashish_garg5
2020-11-04 06:23
ok thanks

ashish_garg5
2020-11-04 06:44
hi

ashish_garg5
2020-11-04 06:44
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <pact.provider.version>${project.version}</pact.provider.version> <pact.verifier.publishResults>${pact.verifier.publishResults}</pact.verifier.publishResults> <pact.provider.tag>${pact.provider.tag}</pact.provider.tag> <pact.consumer.tags>${pact.consumer.tags}</pact.consumer.tags> </systemPropertyVariables> </configuration> </plugin>

ashish_garg5
2020-11-04 06:45
i have added pact.consumer.tags also in this plugin but it is still not working

giuseppe.salvatore
2020-11-04 20:09
Hi everyone quick question... in the consumer (jvm with maven) do I need the provider plugin to publish the contracts to the broker? Do I have any other options?

giuseppe.salvatore
2020-11-04 20:10
I am asking because I have seen this dependency and was wondering if it's doable in another way other than running `mvn pact:publish`

giuseppe.salvatore
2020-11-04 20:10
```<dependency> <groupId>au.com.dius.pact</groupId> <artifactId>pact-publish</artifactId> <version>4.1.9</version> </dependency>```

matt.fellows
2020-11-04 20:38
I'd use the CLI tools


matt.fellows
2020-11-04 20:39
You could use curl or really any API client, but the CLI is the simplest way

giuseppe.salvatore
2020-11-04 20:46
Thanks Matt that helps

antonello
2020-11-04 20:51
I?d use the maven plugin if you?re already using maven though. Any reason why you may not want to?

uglyog
2020-11-04 22:01
You will have to enable debug level logs to see what is happening.

uglyog
2020-11-04 22:02
That's a test project to check that the publishing works.

marzieh312
2020-11-05 00:55
has joined #pact-jvm

aliaksandr.valadzko
2020-11-05 09:37
Hey guys! I've discussed it in *pact-broker* channel, and it looks like I should proceed here `CanIDeploy` can use `--retry-while-unknown` parameter to poll broker until verification result be published https://docs.pact.io/pact_broker/client_cli/readme#can-i-deploy Is it planned to add this feature to _gradle_ *PactCanIDeployTask* ? Thanks in advance!

uglyog
2020-11-05 09:40
Please raise an issue for that, there is no current plan

aliaksandr.valadzko
2020-11-05 09:47
Thanks, cool! Is my issue filed correct?

giuseppe.salvatore
2020-11-05 10:49
I can of course, I was just wondering if I needed the provider plugin in the consumer or there was a consumer plugin

antonello
2020-11-05 10:53
it?s a bit confusing, but yes - you do need it in the consumer to publish :slightly_smiling_face:

giuseppe.salvatore
2020-11-05 11:10
The only reason why we are thinking about using the CLI is because we are building pipelines in Jenkins X dynamically using a script when a service is created. If we can "reuse" a pipeline step configuration that is not dependent on the actual technology it would be much better and can be used as is not only for maven but also gradle, node.js, python

giuseppe.salvatore
2020-11-05 11:10
I am not entirely sure that is going to play nicely but I though it was worth to investigate

pavank
2020-11-05 17:29
Hi Team, Need help in matching the request body, I have request in which I have field like "fulfilmentType":["SSHIP"] can anyone help to write matching for this please

ukrainian1991
2020-11-05 18:07
Hi, I need to create two PACT interaction. They are quite similar. Ther only differency is one nested field. I have used LambdaDslJsonBody to specify it. Is there a way to create the second interaction without code duplication?

ukrainian1991
2020-11-05 18:49
I've written a method which provides the proper object, but may be there is more handy way, e.g. some lambla tricks

matt.fellows
2020-11-06 04:08
@wilkinsweiqiangliang :point_up:

wilkinsweiqiangliang
2020-11-06 04:08
has joined #pact-jvm

wilkinsweiqiangliang
2020-11-06 04:15
Thanks for the quick fix @uglyog @matt.fellows

linda.anthu
2020-11-06 11:52
has joined #pact-jvm

linda.anthu
2020-11-06 14:27
hello :slightly_smiling_face: can anyone help me ? I wanted to update a field on request but I always get timeout :(

linda.anthu
2020-11-06 14:28
```describe("get football market information", () => { let opts: any; before((done) => { opts = { providerBaseUrl: conf.provider[0].BASE_URL, pactBrokerUrl: conf.pact_broker.URL, provider: conf.provider[0].NAME, publishVerificationResult: true, providerVersion: conf.provider[0].VERSION, requestFilter: (req: any, _res: any, next: any) => { if (req.path.match("/api")) { const chunks: any[] = []; req.on("data", function (chunk: any) { chunks.push(chunk); }); req.on("end", function () { req.body = JSON.parse(Buffer.concat(chunks).toString()); if (req.body.params.filter.marketIds) { req.body.params.filter.marketIds = [marketId]; } next(); }); } else { next(); } }, }; done(); }); it("validates the expectations of Matching Service", (done) => { return new Verifier(opts).verifyProvider() .then(output => { done(); }) .catch((error) => { done(error); }); }); });```

chandanakurumeti27
2020-11-09 10:28
Hi, I am about to write provider tests for the service, Right now I can see the option of starting the provider service at some port using jar file and run the provider tests against that port where i start the service using jar file.

chandanakurumeti27
2020-11-09 10:28
Is this how pact provider tests needs to be done?

chandanakurumeti27
2020-11-09 10:29
My main question/doubt here is that do i really need to use the jar file to start the service before running the provider tests or any other option available?

chandanakurumeti27
2020-11-09 10:29
FYI, Am pointing this jar file to talk to some other mocks when it got some request call

chandanakurumeti27
2020-11-09 10:30
Please reply if i can provide any further info on my question here

chandanakurumeti27
2020-11-09 10:30
Looking forward to any usefull explanation :slightly_smiling_face:

chandanakurumeti27
2020-11-09 10:30
Thank you!

ukrainian1991
2020-11-09 10:40
Hi, what could be the reason when provider verification finishes with : There are no consumers to verify for provider 'Provider_Name' When I see this pact contact in Broker and even could get this pact via manual API execution ```http://xx.xx.xx.xx/pacts/provider/Provider_Name/consumer/Consumer_Name/``` gradle plugin 4.1.6

ukrainian1991
2020-11-09 10:41
Exactly the same code is working for one more provider (another one)

matt.fellows
2020-11-09 10:54
So that is just one option for verification. There are other ways of starting your service from within the context of a test framework. e.g. if you use a spring boot app, you can use the spring test annotations to start the service in say, a JUnit test

matt.fellows
2020-11-09 10:54
There is nothing wrong with doing it your way, and then using a CLI tool to do the verification either

matt.fellows
2020-11-09 10:57
See the spring examples at pactflowexamples


chandanakurumeti27
2020-11-09 11:17
Thank you @matt.fellows, Just wanted to confirm using jar file to start the service is a good option or not as am using pact jvm framework

chandanakurumeti27
2020-11-09 11:17
That helped :slightly_smiling_face:

ukrainian1991
2020-11-09 14:45
I've found that gradle pactVerify_A_B autogenerated task does not work

uglyog
2020-11-09 22:01
If there are filters applied. For instance, if you have added the `@Consumer` annotation with a different name than `Consumer_Name`

uglyog
2020-11-09 22:02
In what way does it not work?

pbobba
2020-11-09 23:03
has joined #pact-jvm

jun.li
2020-11-09 23:05
has joined #pact-jvm

jun.li
2020-11-09 23:08
is it possible to divide a single provider test into two different unit test files

jun.li
2020-11-09 23:10
let's say a provider has 6 states, is it possible to put 3 states in one file and the other 3 states in a different file

uglyog
2020-11-09 23:10
Yes, there is no requirement to have them all in the same file

pbobba
2020-11-10 03:08
Hi all, I'm a newbie to Java and pact testing I'm trying to write my first consumer-driven pact test. I have the endpoint, request body and response to my provider. Can someone please help me out with building `RequestResponsePact` for it. Thanks in advance. More in thread.


pbobba
2020-11-10 03:14
Specific question: Is there a way to specify request body in the builder? Are there any good examples out there which reaches out to providers with request bodies. The examples I found so far are using query parameter names Eg: https://github.com/Mikuu/Pact-JVM-Example


uglyog
2020-11-10 03:17
The request body is constructed in the same way as the response one


pbobba
2020-11-10 03:21
awesome. Thank you!

douweicai
2020-11-10 04:11
has joined #pact-jvm

jun.li
2020-11-10 05:08
But If I put 3 ABC states in file A and put 3 DEF states in file B, when I run the test on file A it will say i am missing states DEF

uglyog
2020-11-10 06:15
Put them in a base class or interface



jun.li
2020-11-10 06:22
thanks i will try it out

christian.huber
2020-11-10 09:20
has joined #pact-jvm

christian.huber
2020-11-10 09:46
Hi all, has anyone successfully used pact in an Android project? I am trying to create an instrumented test that uses the app?s client classes to parse the response. When calling `ConsumerPactBuilder#uponReceiving` the test crashes with this cause: ``` ... 40 more Caused by: org.xml.sax.SAXNotRecognizedException: http://javax.xml.XMLConstants/feature/secure-processing at org.apache.harmony.xml.parsers.SAXParserFactoryImpl.setFeature(SAXParserFactoryImpl.java:93) at org.apache.tika.mime.MimeTypesReader.newSAXParser(MimeTypesReader.java:392) ... 42 more``` After quite some debugging it seems to me that creating `TikaConfig` in `OptionalBody` causes a scan for available MimeTypes which requires a SaxParser. The implementation `org.apache.harmony.xml.parsers.SAXParserFactoryImpl` used by the android runtime does not recognize the feature `http://javax.xml.XMLConstants/feature/secure-processing` and fails with an exception. I tried the following dependencies: `au.com.dius.pact.consumer:junit`, `au.com.dius.pact.consumer:java8` and `au.com.dius.pact:consumer` all in Version 4.1..10 but all fail with the same error. So far I have not found a way to either change the factory implementation class or disable the feature. Is that a known issue? Am I missing something obvious? Any pointers would be greatly appreciated.

jun.li
2020-11-10 10:12
``` [from Pact Broker https://xxxxxx.pactflow.io/pacts/provider/xxxxxxxxxxxxxxxx] a xxxxxxxxxxx event generates a message which Verification Failed - com.xxxxx.xxxxxxxx.PactProviderInterface Failures: 1) a xxxxxxxx event 1.1) com.xxxxx.xxxxxxxx.PactProviderInterface 21:10:32.520 [Test worker] WARN a.c.d.p.p.DefaultTestResultAccumulator - Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')``` I just found the error message is not very clear

jun.li
2020-11-10 10:13
it didn't tell me where went wrong

vuttithatkrongyot
2020-11-10 10:57
has joined #pact-jvm

mmotornyi.consultant
2020-11-10 15:17
Is it possible to use kind of conditional verification. E.g. `if (array contains object with some filed) then verify this object like using exact matcher` ?

dan.iosif
2020-11-10 17:06
has joined #pact-jvm

uglyog
2020-11-10 22:07
Can you raise an issue for this with the full stack trace and any logging?


pbobba
2020-11-10 23:53
@uglyog Sorry for the direct ping but do you know at which point are we mocking the provider using pact in this example? https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit/src/test/java/au/com/dius/pact/consumer/junit/examples/ExampleServiceConsumerTest.java

abubics
2020-11-11 02:08
To answer your question, yes, I've used Pact in Android projects before :slightly_smiling_face: not for a couple of years, now, though.

abubics
2020-11-11 02:10
I've never had it set up as an instrumented test, always unit test. I would try to separate it from being platform-bound (unless you have some constraint that I haven't seen before).

pbobba
2020-11-11 05:05
Hi all, I'm seeing an issue while trying to write consumer-driven test in junit5 posted question in detail here: https://stackoverflow.com/questions/64780743/consumer-pact-test-pact-jvm-junit5-how-do-mock-the-provider-using-pact Any help is appreciated. Thanks in advance!

uglyog
2020-11-11 06:17
Not sure I understand the question. The mock server is provided by the test framework, and exists for the duration of the test method

anddreiu
2020-11-11 06:49
Hi all. I have an issue when using tags on my pact files and I don't know what's wrong in my implementation. I am using pact jvm 4.1.10, Pact Broker 2.68.1 and I am using JUnit to run the Provider tests. I am trying to use tags to retrieve the correct pact file when running the Provider tests for a specific consumer. So I've applied the below consumerVersionSelectors: ```@PactBroker(consumerVersionSelectors = { @VersionSelector(tag = "prod", consumer = "consumerName") }``` Unfortunately, the pact file retrieved is the latest one published in Pact Broker and it looks like it does not see the consumer that I've indicated above (also, it does not have prod tag): ```2020-11-11 06:39:28.637 DEBUG [PactBrokerLoader.kt] Loading pacts from pact broker for provider providerName and consumer version selectors [ConsumerVersionSelector(tag=prod, latest=true, consumer=null, fallbackTag=)] Verifying a pact between consumerName and providerName Notices: 1) The pact at https://pactbroker/pacts/provider/providerName/consumer/consumerName/pact-version/64fr34ca943bbg242432we3f9hwe43c34r25wef2 is being verified because it matches the following configured selection criterion: latest pact for a consumer version tagged 'prod'``` Does anybody know what I am doing wrong here? Thank you!

uglyog
2020-11-11 06:55
That looks like a defect ```[ConsumerVersionSelector(tag=prod, latest=true, consumer=null, fallbackTag=)]```

anddreiu
2020-11-11 07:09
ok, in this case I will raise a GitHub issue

christian.huber
2020-11-11 08:36
I was afraid that might be issue :wink: Thanks for the input. Will try to put up an issue.

francislainy.campos
2020-11-11 08:39
Hi, not sure if it would answer your question directly, but this article may help you a bit. https://hmh.engineering/how-to-write-and-validate-pact-contracts-using-junit5-and-restassured-72b578e7dd65

anddreiu
2020-11-11 09:11
I've just tried to use the deprecated version of this: ```@PactBroker(consumers = "consumerName", tags = "prod"``` In this case the right consumer is taken (see below), but the retrieved pact is not the correct one: ```2020-11-11 09:08:24.084 DEBUG [PactBrokerLoader.kt] Loading pacts from pact broker for provider providerName and consumerName version selectors [ConsumerVersionSelector(tag=prod, latest=true, consumer=consumerName, fallbackTag=null)]``` The retrieved pact is the latest one, even if this does not have 'prod' tag. Very weird

aliaksandr.valadzko
2020-11-11 09:28
Hello guys! Is there an opportunity to extract this _HttpTarget_ constructor parameters to _SpringContext_? ``` @TestTarget public final Target target = new HttpTarget("http", "localhost", 9080, "/api");``` I use `org.springframework.test.context.ContextConfiguration` : ```@ContextConfiguration(classes = {PactContext.class})``` However getting `nulls` for this variant: ``` @Value("${test.target.scheme}") String scheme; ..... @TestTarget public final Target target = new HttpTarget(scheme, host, port, path);```

aliaksandr.valadzko
2020-11-11 10:49
One more question: Do you know what might be reason of this failure? ```java.lang.NoSuchMethodError: java.lang.NoSuchMethodError: au.com.dius.pact.core.model.HttpPart.determineContentType()Lau/com/dius/pact/core/model/ContentType; java.lang.NoSuchMethodError: au.com.dius.pact.core.model.HttpPart.determineContentType()Lau/com/dius/pact/core/model/ContentType; at au.com.dius.pact.core.matchers.Matching.matchBody(Matching.kt:58) at au.com.dius.pact.core.matchers.ResponseMatching.responseMismatches(ResponseMatching.kt:21) at au.com.dius.pact.provider.ResponseComparison$Companion.compareResponse(ResponseComparison.kt:120) at au.com.dius.pact.provider.ProviderVerifier.verifyRequestResponsePact(ProviderVerifier.kt:480) at au.com.dius.pact.provider.ProviderVerifier.verifyResponseFromProvider(ProviderVerifier.kt:561) at au.com.dius.pact.provider.junit.target.HttpTarget.testInteraction(HttpTarget.kt:73) at au.com.dius.pact.provider.junit.InteractionRunner$interactionBlock$statement$1.evaluate(InteractionRunner.kt:204) at au.com.dius.pact.provider.junit.RunStateChanges.evaluate(RunStateChanges.kt:20) at au.com.dius.pact.provider.junit.RunStateChanges.evaluate(RunStateChanges.kt:20) at au.com.dius.pact.provider.spring.SpringBeforeRunner.evaluate(SpringInteractionRunner.kt:32) at au.com.dius.pact.provider.spring.SpringAfterRunner.evaluate(SpringInteractionRunner.kt:48) at au.com.dius.pact.provider.junit.InteractionRunner.run(InteractionRunner.kt:145) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:147) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:52) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)``` `au.com.dius.pact.consumer:junit:4.1.7` Thanks in advance

chandanakurumeti27
2020-11-11 11:09
Hi;

chandanakurumeti27
2020-11-11 11:10
Am trying to publish pacts to pact broker with tags using maven plugin

chandanakurumeti27
2020-11-11 11:11
And am sure that it is possible from this discussion https://github.com/pact-foundation/pact-jvm/issues/403

chandanakurumeti27
2020-11-11 11:11
Am using `pact-jvm-provider-maven 4.0.0` version plugin

chandanakurumeti27
2020-11-11 11:12
Can some one please provide me the examples to refer for tags setup

chandanakurumeti27
2020-11-11 11:12
Looking forward to any help!

chandanakurumeti27
2020-11-11 11:12
Thanks

chandanakurumeti27
2020-11-11 11:12
:slightly_smiling_face:

chandanakurumeti27
2020-11-11 11:13
My question/doubt is more like , where do i need to include the tags details inside the code

chandanakurumeti27
2020-11-11 11:13
is it in pom.xml or inside the consumer test file?

antonello
2020-11-11 11:15
Have you seen this in the docs? ```<plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.1.0</version> <configuration> <pactDirectory>path/to/pact/files</pactDirectory> <!-- Defaults to ${project.build.directory}/pacts --> <pactBrokerUrl>http://pactbroker:1234</pactBrokerUrl> <projectVersion>1.0.100</projectVersion> <!-- Defaults to ${project.version} --> <tags> <tag>feature/feature_name</tag> </tags> </configuration> </plugin>```


antonello
2020-11-11 11:23
You don?t have to hardcode the tag there though, as the value of `<tag>` can be a properties that you can pass to maven, e.g. ```<tags> <tag>${pactbroker.consumerTag}</tag> </tags>```

antonello
2020-11-11 11:23
then you can pass `-Dpactbroker.consumerTag=<your-tag>` to maven.

uladzislau_danilchyk
2020-11-11 11:51
@aliaksandr.valadzko I've got the same! But have found a solution. Try to use `@PostConstruct` like this: ``` @TestTarget public Target target; @PostConstruct private void before() { target = new HttpTarget(targetScheme, targetHost, targetPort); }```

aliaksandr.valadzko
2020-11-11 11:52
Cool, will try!

uladzislau_danilchyk
2020-11-11 11:52
it works for me.

chandanakurumeti27
2020-11-11 11:54
Thanks for your reply, will try that :slightly_smiling_face:

aliaksandr.valadzko
2020-11-11 11:57
Thanks a lot!!!

aliaksandr.valadzko
2020-11-11 11:57
It works!

uladzislau_danilchyk
2020-11-11 11:57
Great!

aliaksandr.valadzko
2020-11-11 12:14
Resolved - transitive issue :white_check_mark:

almaak
2020-11-11 13:33
hey all, is there a way to take some field from the consumer request and add it to the mocked response? thank you.

pbobba
2020-11-11 14:25
I see internal server error when trying to reach to the mock provider. I stated the problem clearly in this https://stackoverflow.com/questions/64780743/consumer-pact-test-pact-jvm-junit5-how-to-mock-the-provider-using-pact

ukrainian1991
2020-11-11 14:59
I updated gradle plugin version to 4.1.10 from 4.1.6 and it works

ukrainian1991
2020-11-11 15:01
Seems there was a bug, when two Service providers are described in build.gradle and you try to call task for the second one

almaak
2020-11-11 19:45
hey again, @uglyog, I'm having problems with the dependencies, apparently I'm not using the correct versions. do you have some pom with the correct versions of the dependencies for "au.com.dius.pact:pact-jvm-server:4.1.7"? thank you.

matt.fellows
2020-11-11 20:34
Can you elaborate as to why you couldn't do that already? A consumer test is a unit test, so you should already have full control over the mock and what request you're going to send

giuseppe.salvatore
2020-11-11 21:34
Hi guys... I keep getting this error: ```[ERROR] Failures: [ERROR] SubscriptionUsageHistoryMockConsumerVerificationTest 0 - Expected a response type of 'application/json' but the actual type was 'text/plain' 1 - Expected a header 'Content-Type' but was missing [INFO] [ERROR] Tests run: 9, Failures: 1, Errors: 0, Skipped: 0``` which makes sense because I believe it's default error response for SpringBoot when you are missing a mandatory header with curl I get ```* Mark bundle as not supporting multiuse < HTTP/1.1 400 Bad Request < Server: nginx/1.17.10 < Date: Wed, 11 Nov 2020 21:31:30 GMT < Content-Length: 0 < Connection: keep-alive < x-envoy-upstream-service-time: 3``` My question: is there a way to relax the check that PACT verification performs? After all I am happy if I get a 400 for a malformed request

abubics
2020-11-11 21:37
Is your test expecting a 400, and not specifying a content type? Or is this interaction failing, and the output is just confusing?

abubics
2020-11-11 21:42
I mean, whether it's instrumented or not, you should still be able to run it without exceptions :thumbsup: but reducing the number of moving parts may help you debug it. More as an aside, your API client is probably testable as a unit separate from Tika :innocent:


uglyog
2020-11-11 22:08
`pact.consumer.tags Overrides the tags used when publishing pacts [version 4.0.7+]`

uglyog
2020-11-11 22:08
You need version 4.0.7 or later

uglyog
2020-11-11 22:09
No pom, but you can refer to the Gradle build for it


uglyog
2020-11-11 22:10
The other option is to download the application archive for it and look at all the dependencies for it in there

uglyog
2020-11-11 22:10
> Page not found > This question was voluntarily removed by its author.

rodrigo.costa20
2020-11-12 00:59
has joined #pact-jvm

rodrigo.costa20
2020-11-12 01:01
Hello everyone! I'm new at using Pact... I'm having a problem that I would like to see if anyone know what am I doing wrong...

rodrigo.costa20
2020-11-12 01:01
I have just configurated the provider side on my tests

rodrigo.costa20
2020-11-12 01:01
however, when I try to run the tests, i keep getting the error "No tests were found"

rodrigo.costa20
2020-11-12 01:02
I'm using the Junit runner, its a Java EE application

rodrigo.costa20
2020-11-12 01:02
do you guys have any idea, about what I may be doing something wrong?

uglyog
2020-11-12 01:04
How are you running the tests? With Maven, Gradle or an IDE?

rodrigo.costa20
2020-11-12 01:07
IDE - intellij

rodrigo.costa20
2020-11-12 01:08
also, its a maven project

rodrigo.costa20
2020-11-12 01:24
this is the error that I'm getting

uglyog
2020-11-12 01:28
That means the classpath is not setup correctly in your IDE. Maybe look at the IntelliJ IDEA docs for using Maven projects.


rodrigo.costa20
2020-11-12 01:33
I'm able to run other kind of tests by IDE... do you have any suggestion, about what can be wrong in this case? Also, I've tried to run the pact tests from command line with maven... but in this case this is the error that I got: `pact-jvm-provider-maven:4.0.10:verify failed: lateinit property serviceProviders has not been initialized`

young
2020-11-12 03:34
Hi team, about provider state confused me for many days, and I had to ask for help here. Thanks in advance. The below is my code: ```ProviderStateRequest.java @Getter @Setter @NoArgsConstructor @ApiModel(description = "Provider state request") public class ProviderStateRequest { @ApiModelProperty(value = "provider state name") private String name; @ApiModelProperty(value = "provider state params") private Map<String,Object> params; }``` ```PactStateController.java @RestController @RequestMapping(path = "/api/pact") public class PactStateController { private final WalletService walletService; @Autowired public PactStateController(WalletService walletService) { this.walletService = walletService; } @PostMapping("/providerState") @ApiOperation(value = "Pact state change url to prepare the data") @NeuronSecured(permissions = PermissionConstants.WRITE, resource = PermissionConstants.RESOURCE_FINANCE) public BasicResponse<Boolean> stateChangeForRefund(@RequestBody ProviderStateRequest providerStateRequest) { int userId; switch (providerStateRequest.getName()) { case "wallet.balance=0": userId = Integer.parseInt(providerStateRequest.getParams().get("userId").toString()); walletService.emptyBalance((long)userId); break; default: return new BasicResponse<>(false); } return new BasicResponse<>(true); } }``` ```build.gradle ........ pact { broker { pactBrokerUrl = "http://xx.xx.xx.xxx" pactBrokerUsername = "admin" pactBrokerPassword = "admin" } serviceProviders { NeuronPublic { protocol = 'http' host = 'localhost' port = 8080 path = '/' requestFilter = { req -> req.addHeader('testmode','true') req.addHeader('X-Authorization','Bearer your token') } hasPactWith('local') { stateChangeUrl = new URL('http://localhost:8080/api/pact/providerState') pactSource = file("$rootDir/Pacts/NeuronShareQA-NeuronPublic.json") } } } }``` When I run the ./gradlew pactVerify, I will get the below error: ```1) Verifying a pact between local and NeuronPublic - /api/finance/v1/top-up 1.1) State change callback failed with an exception - State Change Request Failed - HTTP/1.1 400 > Task :pactVerify_NeuronPublic FAILED FAILURE: Build failed with an exception. * What went wrong: There were 1 non-pending pact failures for provider NeuronPublic``` I really don't know what's the root cause, Pls help. Thanks.:slightly_smiling_face:

uglyog
2020-11-12 03:35
You haven't specified any serviceProviders in your POM


uglyog
2020-11-12 03:38
The call to the state change URL returned a 400 error. You'll need to work out why it did that

uglyog
2020-11-12 03:38
Try turn on debugging, look at the Springboot logs, etc.

matt.fellows
2020-11-12 03:39
``` @ApiModelProperty(value = "provider state name") private String name;```

matt.fellows
2020-11-12 03:39
Is that a json attribute mapping?


matt.fellows
2020-11-12 03:41
The incoming payload will be more like: `{ "state" : "a provider state description", "params": { "a": "1", "b": "2" } }`

young
2020-11-12 03:44
Thanks will try

young
2020-11-12 03:45
Thanks Matt, But why the pact file indicated that "name"?

matt.fellows
2020-11-12 03:55
I?m not sure, sorry. that?s just how the pact file stores it.

young
2020-11-12 03:58
thank you all the same. I changed the "name" to "state", responsed http code 400 as well.

young
2020-11-12 04:08
Hi @uglyog Can you help to analyze this log if you are free? Thank you. ```12:04:08.480 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Opening connection {}->http://localhost:8080 12:04:08.481 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connecting to localhost/127.0.0.1:8080 12:04:08.481 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connection established 127.0.0.1:63400<->127.0.0.1:8080 12:04:08.482 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request POST /api/pact/providerState HTTP/1.1 12:04:08.482 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Target auth state: UNCHALLENGED 12:04:08.482 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Proxy auth state: UNCHALLENGED 12:04:08.828 [DEBUG] [au.com.dius.pact.provider.DefaultStateChange] Invoked state change http://localhost:8080/api/pact/providerState -> HTTP/1.1 400 12:04:08.829 [QUIET] [system.out] State Change Request Failed - HTTP/1.1 400 12:04:08.829 [DEBUG] [org.apache.http.impl.conn.DefaultManagedHttpClientConnection] http-outgoing-5: Close connection 12:04:08.829 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Connection discarded 12:04:08.829 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection released: [id: 5][route: {}->http://localhost:8080][total kept alive: 0; route allocated: 0 of 5; total allocated: 0 of 10] 12:04:08.829 [DEBUG] [au.com.dius.pact.provider.DefaultStateChange] State Change: "ProviderState(name=wallet.balance=0, params={userId=42404})" -> Err(java.lang.Exception: State Change Request Failed - HTTP/1.1 400 ) 12:04:08.830 [QUIET] [system.out] 12:04:08.830 [QUIET] [system.out] NOTE: Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true') 12:04:08.830 [QUIET] [system.out] 12:04:08.830 [QUIET] [system.out] 12:04:08.830 [QUIET] [system.out] Failures: 12:04:08.830 [QUIET] [system.out] 12:04:08.830 [QUIET] [system.out] 1) Verifying a pact between local and NeuronPublic - /api/finance/v1/top-up 12:04:08.830 [QUIET] [system.out] 12:04:08.830 [QUIET] [system.out] 1.1) State change callback failed with an exception - State Change Request Failed - HTTP/1.1 400 12:04:08.831 [QUIET] [system.out] 12:04:08.831 [QUIET] [system.out] 12:04:08.831 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Execute verifyPact for :pactVerify_NeuronPublic' 12:04:08.831 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute verifyPact for :pactVerify_NeuronPublic' completed 12:04:08.831 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context. 12:04:08.831 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':pactVerify_NeuronPublic' 12:04:08.831 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Task :pactVerify_NeuronPublic' 12:04:08.831 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Task :pactVerify_NeuronPublic' completed 12:04:08.831 [INFO] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] :pactVerify_NeuronPublic (Thread[Daemon worker Thread 13,5,main]) completed. Took 0.392 secs. 12:04:08.832 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Daemon worker Thread 13: released lock on : 12:04:08.832 [DEBUG] [org.gradle.internal.work.DefaultWorkerLeaseService] Worker lease root.1.19 completed (1 worker(s) in use) 12:04:08.832 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Daemon worker Thread 13: released lock on root.1.19 12:04:08.832 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Daemon worker Thread 13,5,main]] finished, busy: 0.395 secs, idle: 8.094 secs```

matt.fellows
2020-11-12 05:22
no worries

matt.fellows
2020-11-12 05:22
my point was, check the mapping :slightly_smiling_face:

matt.fellows
2020-11-12 05:23
Do you use JUnit by any chance? Because if you do, it might be easier to go down that path rather than the gradle path where you need to setup a state handler endpoint

matt.fellows
2020-11-12 05:23
You probably need to enable logs on your spring boot app. From this, we can?t see why your endpoint failed

matt.fellows
2020-11-12 05:24
you can see clearly the payload that was sent over `POST` to `/api/pact/providerState` but we can?t see what your app did, besides returning a `400`

young
2020-11-12 05:33
Thank you matt, the "Request params invalid" error shown, ```[A][2020-11-12 13:30:54,198][INFO ][http-nio-8080-exec-2][AccessLoggingFilter][doFilterInternal][] - {"clientIp":"127.0.0.1","method":"POST","uri":"/api/pact/providerState","processTime":60,"params":"{}","body":"{\"state\":\"wallet.balance\u003d0\",\"params\":{\"userId\":\"42404\"}}","headers":"{\"user-agent\":\"Apache-HttpClient/4.5.5 (Java/1.8.0_201)\"}","status":400,"response":"{\"message\":\"Request params invalid\",\"detailed\":\"Request params invalid\",\"errorCode\":\"INVALID_REQUEST\",\"timestamp\":\"2020-11-12T13:30:54+0800\"}"}```

young
2020-11-12 05:34
I will try again

yong.gong188
2020-11-12 09:13
has joined #pact-jvm

giuseppe.salvatore
2020-11-12 10:05
Yeah my test is expecting a 400 but doesn't specify anything about the content type. But the interaction is failing because it expects it to have a `Content-Type: application/json` . As I didn't specify that anywhere I though it was the framework doing that check, maybe given the request is in `application/json` it checks also the response is

anandhadeepak
2020-11-12 13:03
has joined #pact-jvm

abubics
2020-11-12 13:11
I feel like there was a query about that in the last few months, but I don't remember the outcome. I think it was suggested that defaulting to expect `application/json` was bad, but I'm not sure if it was going to be remedied or not. Maybe @bethskurrie or @uglyog remembers?

david.dias
2020-11-12 20:04
has joined #pact-jvm

uglyog
2020-11-12 22:02
What version of Pact-JVM are you using?

mmotornyi.consultant
2020-11-13 07:21
Ok, thank you.

almaak
2020-11-13 08:27
ok, thanks. I've listetd all the libs from the app archive.

billal.patel
2020-11-13 10:31
has joined #pact-jvm

wesleythomaswilliams
2020-11-13 12:18
@uglyog I'm curious, why does this method default the number of examples to 2? ``` public PactDslJsonBody minArrayLike(String name, Integer size, PactDslJsonRootValue value) { return this.minArrayLike(name, size, value, 2); }```

dattasai.chunduru
2020-11-13 12:54
Hi All can anyone please help me in doing provider side validation with Request headers. I am using the below code snippet . But system is showing me error as shown below

francislainy.campos
2020-11-13 13:46
Could you share your pom dependencies for pact and junit and the pact code?

uglyog
2020-11-14 02:43
That's a good question. I don't know.

uglyog
2020-11-14 02:44
Maybe having 2 instead of 1 examples was felt to be better representation of what a real array would have :man-shrugging:

uglyog
2020-11-14 02:46
You are getting connection refused on port 8083 because there is nothing running on that port. Have you started the provider you are trying to verify?

louis.oliver
2020-11-16 10:33
has joined #pact-jvm

billal.patel
2020-11-16 14:45
@billal.patel has left the channel

ashishkujoy
2020-11-16 15:08
has joined #pact-jvm

pradeepchoube
2020-11-17 03:49
has joined #pact-jvm

meng-lingtao
2020-11-17 14:39
has joined #pact-jvm

pabvidcal
2020-11-17 15:30
has joined #pact-jvm

magesh.nagamani
2020-11-18 05:15
has joined #pact-jvm




antonello
2020-11-18 07:05
For future reference, it is possible to do a search on the entire repository.

antonello
2020-11-18 07:06
Welcome @magesh.nagamani !

magesh.nagamani
2020-11-18 07:07
Appreciate the help @antonello Thank you!

matt.fellows
2020-11-18 07:50
Better yet, use the search on this site: https://docs.pact.io/implementation_guides/jvm

matt.fellows
2020-11-18 07:50
All of the language docs are copied there and the search is much better

ashish_garg5
2020-11-18 08:08
Hi All, Just wanted to confirm what this below method does. Does it checks the tag of consumer or it checks for provider ? `java.lang.String[]*tags*()` Tags to use to fetch pacts for, defaults to `latest` If you set the tags through the `pactbroker.tags` system property, separate the tags by commas. Thanks

matt.fellows
2020-11-18 09:05
It sounds like Consumer tags

matt.fellows
2020-11-18 09:06
What is the context of it being used

ashish_garg5
2020-11-18 10:35
* Tags to use to fetch pacts for, defaults to `latest` * If you set the tags through the `pactbroker.tags` system property, separate the tags by commas */ String[] tags() default "${pactbroker.tags:latest}";

ashish_garg5
2020-11-18 10:35
this method i was asking for which is there inside the PactBroker interface

ashish_garg5
2020-11-18 10:36
i think it is checking both consumer and provider

matt.fellows
2020-11-18 10:58
I think you?re referring to https://docs.pact.io/implementation_guides/jvm/provider/junit/#using-tags-with-the-pact-broker, which in that case, we are referring to the consumer tags. Provider tags are, unsurprisingly, referred to as `providerTags` (see https://docs.pact.io/implementation_guides/jvm/provider/junit/#pending-pact-support-version-413-and-later) and are used to calculate pending pacts

ashish_garg5
2020-11-18 11:02
yeah i was looking for this only... Thanks :slightly_smiling_face:

jstoebel
2020-11-18 13:53
has joined #pact-jvm

borsuk.artem034
2020-11-18 17:03
Hello, I can't decide what test should I use for consumer pact test unit or integration, for one side recommendation use unit tests, but I will test just mocks, for other side integration test give more coverage and log time execution. So I what to hear other opinion :slightly_smiling_face: add few examples in thead

borsuk.artem034
2020-11-18 17:04
```Unit @Test @PactVerification(fragment = "createPact") public void verifyPact() { eventConsumer.handleEvent(messageProvider.getMessage()); String json = "{someKey: \"someVale\"}"; assertEquals(json, messageProvider.getMessage()); }```

borsuk.artem034
2020-11-18 17:05
```Integration @Test @PactVerification(fragment = "createPact") public void verifyPact() { //init in-memory DB or testcontainers..... eventConsumer.handleEvent(messageProvider.getMessage()); assertEquals(dbRepository.getInfo(), messageProvider.getMessage()); }```

wilkinsweiqiangliang
2020-11-18 22:47
#pact-jvm i wonder if the consumer can make sure an ID field(String) type not returning `NULL` from provider?

wilkinsweiqiangliang
2020-11-18 22:48
```24  export const expectedObject = 25    { 26      id: uuid("da16494a-303a-463c-919a-e29e03a5b1de") 27 }```

uglyog
2020-11-18 22:54
That should not allow NULLs, only strings that match a UUID

wilkinsweiqiangliang
2020-11-18 22:55
in Java side, string is nullable

wilkinsweiqiangliang
2020-11-18 22:55
does it mean i need to enhance the test a bit to cover the nullable case?

uglyog
2020-11-18 22:58
You need two tests, one when it is not NULL, and one where it is

wilkinsweiqiangliang
2020-11-18 23:01
:+1:

daniel.sayer89
2020-11-19 10:33
has joined #pact-jvm

art.ptushkin
2020-11-19 10:34
has joined #pact-jvm

pact457
2020-11-19 10:36
has joined #pact-jvm

ajerthan.sivayoganath
2020-11-19 10:38
has joined #pact-jvm

philipchardwick
2020-11-19 11:05
has joined #pact-jvm

tanzmann
2020-11-19 11:09
has joined #pact-jvm

olivier.quere
2020-11-19 12:10
has joined #pact-jvm

wilfried.vandenberghe
2020-11-19 12:19
has joined #pact-jvm

alan.hanafy
2020-11-19 19:28
has joined #pact-jvm

michael.deutscher
2020-11-19 21:39
has joined #pact-jvm

gerry.power
2020-11-20 03:31
has joined #pact-jvm

alex900
2020-11-20 05:08
has joined #pact-jvm

tomas.panik
2020-11-20 08:28
has joined #pact-jvm

art.ptushkin
2020-11-20 08:56
Hey everyone! Any updates on merging HTTP and messaging pacts https://github.com/andreasevers/pact-demo/issues/1? Just got this problem, really don't want to rename the provider

matt.fellows
2020-11-20 11:39
It?s a proposal in the v4 spec, I?m not sure if Java supports it yet


matt.fellows
2020-11-20 11:40
There definitely isn?t broad support for it yet though

marc.ferland
2020-11-20 14:43
has joined #pact-jvm

sebastien.crapoulet
2020-11-20 15:24
has joined #pact-jvm

adutrillaux
2020-11-20 15:28
has joined #pact-jvm

he
2020-11-20 15:59
has joined #pact-jvm

ivgeni.slabkovski
2020-11-20 21:52
has joined #pact-jvm

serhatburakyildirim
2020-11-21 21:57
has joined #pact-jvm

alnasl
2020-11-22 18:46
has joined #pact-jvm

ashutosh23802
2020-11-23 06:20
has joined #pact-jvm

leonty
2020-11-23 10:33
has joined #pact-jvm

dariusz.piwko
2020-11-23 11:34
has joined #pact-jvm

uladzislau_danilchyk
2020-11-23 15:08
Hi everyone! I have a question regarding provider verification using junit5. I have a provider verification test as per docs. And I want to verify provider against specific pacts version (consumer version) which are stored in Pact Broker? How to do that? I want to pass consumer version before/during running of provider verification test. But no docs were found related to that. Could anyone help me?

phil.endsley
2020-11-23 15:14
I think typically, you would tag your consumer pact when you publish them to broker. Then, when you run your provider verification, you would specify that tag using `@PactBroker with @ConsumerVersionSelector`

antonello
2020-11-23 15:33
I?ve answered in #general

antonello
2020-11-23 15:33
I?ve assumed the use case is legitimate

antonello
2020-11-23 15:53
but you?re right, @phil.endsley, obviously :slightly_smiling_face:

antonello
2020-11-23 15:54
we use `pact.filter.pacturl=http://$BROKER_HOSTNAME:$BROKER_PORT/pacts/provider/$PROVIDER_NAME/consumer/$CONSUMER_NAME/version/$CONSUMER_VERSION` when we want to run some provider verification tests in CI against a specific consumer version

antonello
2020-11-23 15:55
Sometimes it?s happened that can-i-deploy on a consumer failed because of missing verifications

antonello
2020-11-23 15:55
so we?ve built a special job that verifies a specific consumer version

praneeth.kumar
2020-11-23 16:18
has joined #pact-jvm

mark.white
2020-11-24 09:03
has joined #pact-jvm

ufuk.ozcelik
2020-11-24 14:58
has joined #pact-jvm

stefanos.varsanis
2020-11-24 16:48
has joined #pact-jvm

lalexander2810
2020-11-24 16:53
has joined #pact-jvm

lalexander2810
2020-11-24 20:39
Hey everyone I wanted to know if there were any examples of fuzzy matching in pact. I am using the `eachLike` method to set the data type but my tests is still checking absolute value vs data type. Any ideas on how to implement this correctly?

sivaprasad9
2020-11-24 20:46
has joined #pact-jvm

phil.endsley
2020-11-24 20:50
You should be able to use the `...Type` methods for matching on data type stringType, numberType, etc... https://docs.pact.io/implementation_guides/jvm/consumer/#dsl-matching-methods

lalexander2810
2020-11-24 21:00
It seems like the `...Type` methods check for the data value as well it appears. I'm trying to limit the validation to strictly data types vs data type + value

phil.endsley
2020-11-24 21:02
For the consumer, they will check the value. The provider verification will be more lenient and only verify types. On the consumer side, you can use the example parameter to make the value used in the test deterministic. If you omit the example, pact chooses a random value for each test.

phil.endsley
2020-11-24 21:03
The assumption is since you're writing unit tests on the consumer, you should have full control over which values get returned, so making mocks return values matching the examples shouldn't be an issue

yann.courtel
2020-11-25 10:26
Hi guys, I wanted to know if it was at all possible to have a PACT between one consumer and one provider with interactions (http like) and messages at the same time? I know that responsibility wise, it's not correct but I'd like to know if it is possible in the PACT spectifications 3.0. Thanks a lot

matt.fellows
2020-11-25 11:02
You have to currently name them differently. In spec v4.0 it will be supported to allow both types in the same contract file

yann.courtel
2020-11-25 12:35
Thank you for the quick answer Matt :)

uladzislau_danilchyk
2020-11-25 14:48
Hi everyone! I have a Spring Boot app which is consumer and provider at the same time. I have following dependencies in gradle.build: ```testImplementation 'au.com.dius.pact.consumer:groovy:4.1.11' testImplementation 'au.com.dius.pact.provider:junit5:4.1.11'``` But after running VerificationTest it fails with: ```Could not find org.codehaus.groovy:groovy:4.1.11. Searched in the following locations: - https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy/4.1.11/groovy-4.1.11.pom If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration. Required by: project :modules:shop > Could not find org.codehaus.groovy:groovy-ant:4.1.11. Searched in the following locations: - https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy-ant/4.1.11/groovy-ant-4.1.11.pom If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration. Required by: project :modules:shop > Could not find org.codehaus.groovy:groovy-templates:4.1.11. Searched in the following locations: - https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy-templates/4.1.11/groovy-templates-4.1.11.pom If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration. Required by: project :modules:shop``` Could anyone help me with that?

scyr
2020-11-25 14:56
has joined #pact-jvm

pavel.azarau
2020-11-25 18:32
Hello folks. Didn?t know what channel to use. I?m using Gradle plugin ?http://au.com.dius.pact? version ?4.1.9". I?ve configured it to access pactflow acc. And when I run `pactVerify` task I?m getting ```Failed to fetch the root HAL document au.com.dius.pact.core.pactbroker.RequestFailedException: Request to path '/' failed with response 'HTTP/1.1 400 Bad Request' at au.com.dius.pact.core.pactbroker.HalClient.handleHalResponse(HalClient.kt:301) at au.com.dius.pact.core.pactbroker.HalClient.access$handleHalResponse(HalClient.kt:140) at au.com.dius.pact.core.pactbroker.HalClient$getJson$1.invoke(HalClient.kt:284)``` However in Postman I can successfully perform a GET request using the same url and token I used to configure plugin

matt.fellows
2020-11-25 21:03
I've responded in your other post

pavel.azarau
2020-11-25 21:07
if anybody is interested the issue is solved with ugrade to 4.1.11

timotheus.ruprecht
2020-11-25 22:12
has joined #pact-jvm

uladzislau_danilchyk
2020-11-26 09:05
Hi! Currently I have error when running verification test: ```Could not resolve all files for configuration ':modules:shop:detachedConfiguration243'. 2020-11-26T12:01:44.861+0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not find org.codehaus.groovy:groovy:4.1.0. 2020-11-26T12:01:44.861+0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Searched in the following locations: 2020-11-26T12:01:44.861+0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] - https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy/4.1.0/groovy-4.1.0.pom 2020-11-26T12:01:44.861+0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration. 2020-11-26T12:01:44.862+0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Required by: 2020-11-26T12:01:44.862+0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] project :modules:shop 2020-11-26T12:01:44.862+0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not find org.codehaus.groovy:groovy-ant:4.1.0.```

uladzislau_danilchyk
2020-11-26 11:01
Could anyone help me with that? I don't understand why gradle tries to load groovy 4.1.0 as for consumer package...

abubics
2020-11-26 11:06
You could try inspecting the dependency tree, to work out which dependency is pulling it in . . . seems like the place to start is `:modules:shop`, if that means something to you?

uladzislau_danilchyk
2020-11-26 11:39
@abubics if you look at maven repo you will see that no such version of groovy dependencies

uladzislau_danilchyk
2020-11-26 11:40
@abubics but in logs 4.1.0 version is passed because of I have `testImplementation 'au.com.dius.pact.consumer:groovy:4.1.0'`

manali.mogre
2020-11-26 11:44
has joined #pact-jvm

uladzislau_danilchyk
2020-11-26 11:48
It's is reproducing on fresh project with junit and consumer groovy libs only

erik.terpstra
2020-11-26 12:08
has joined #pact-jvm

uladzislau_danilchyk
2020-11-26 13:22
How to enable debug for provider test? Because of kotlin files are used by Pact

kjayachandra2000
2020-11-26 20:40
has joined #pact-jvm

kjayachandra2000
2020-11-26 20:43
hey lads, how to run the pact provide tests from gradle and commandline

uglyog
2020-11-26 22:10
This has happened to me, and after a but of debugging I think it is a bug with the Gradle dependency resolution

uglyog
2020-11-26 22:11
Can't remember what I did to resolve it, but you can try cleaning out the Gradle cache (it is stored in `.gradle` in your home directory)

uglyog
2020-11-26 22:12
Depends on how you are running the provider tests


sushil.kumar
2020-11-27 01:45
has joined #pact-jvm

sushil.kumar
2020-11-27 01:47
Hi there! looking for info how to define self referencing object in PactDslJsonBody

uglyog
2020-11-27 01:52
What do you mean by a self referencing object?

uglyog
2020-11-27 01:52
Maybe an example JSON payload would help

sushil.kumar
2020-11-27 02:02
{ "product": { "id": "product-1", "name": "Lorem Ipsum product name", "subProducts": [ { "id": "nested-product-2", "name": "Lorem Ipsum product name", "subProducts": [] }, { "id": "nest-product3", "name": "Lorem Ipsum product name", "subProducts": [] } ] } }

uglyog
2020-11-27 02:03
Oh, you mean repeated

sushil.kumar
2020-11-27 02:03
in this json example, root body has an object "product" that in turn has an array "subProducts" referencing to "product" object

uglyog
2020-11-27 02:04
You might be able to do it with a recursive function

uglyog
2020-11-27 02:05
Also, the Java 8 lambda extension might also help

sushil.kumar
2020-11-27 02:06
```.minArrayLike("subProducts",0,1)```

sushil.kumar
2020-11-27 02:08
how to define/associate this recursive object relationship, are there any examples to docs

uglyog
2020-11-27 02:10
None that I know of

sushil.kumar
2020-11-27 02:11
ok, thank you for looking in to it, happy thanksgiving

zhujian
2020-11-27 07:54
has joined #pact-jvm

kjayachandra2000
2020-11-27 08:55
Hi All, when I try to refresh gradle[./gradlew clean] on a provider repo/project i am getting an error attached both the pact information and the error

uladzislau_danilchyk
2020-11-27 09:48
@uglyog, with gradle

matt.fellows
2020-11-27 09:51
is there a pact broker running on port `8113`?

matt.fellows
2020-11-27 09:51
(I?m assuming not!)

kjayachandra2000
2020-11-27 10:06
no

matt.fellows
2020-11-27 10:15
so there?s your answer

kjayachandra2000
2020-11-27 10:29
so if i want to use `./gradlew clean` i need pact broker to be running ?

matt.fellows
2020-11-27 10:36
If you want to do a provider test with Pact, you have to either a) point to a running pact broker to fetch the contracts or b) have them locally

matt.fellows
2020-11-27 10:36
99.99% of the time it should be a broker

matt.fellows
2020-11-27 10:37
and 99.99% of the time, the broker shouldn?t be running on your machine

matt.fellows
2020-11-27 10:37
it is a shared piece of infrastructure that all of your team/company uses

kjayachandra2000
2020-11-27 10:38
thanks matt, is my configuration correct for provider?

kjayachandra2000
2020-11-27 10:38
which i have shared in the screenshot

h.octavian
2020-11-27 14:08
has joined #pact-jvm

h.octavian
2020-11-27 14:11
Hi all, do you have a Java code example on how to use pact-jvm for consumer and provider tests of a message queue (I use RabbitMQ) ?

nathan.deamer
2020-11-27 16:35
End of Day Friday in the UK and struggling with the DSL to match this: ```{ "references": { "Key1": [ "123456789" ], "Key2": [ "three-random-words" ] } }``` In Java: `Map<String, List<String>> references;` Can anyone help please :slightly_smiling_face:

matt.fellows
2020-11-27 22:02
pactflowexamples


matt.fellows
2020-11-27 22:03
There's at least one Java Kafka example there. The principle is the same for all message queues

noel
2020-11-28 23:12
has joined #pact-jvm

uglyog
2020-11-29 00:14
You need to wrap the pact broker section in a if statement so it is not executed all the time. See the section in https://github.com/pact-foundation/pact-jvm/tree/master/provider/gradle#for-pact-jvm-versions-before-410

uglyog
2020-11-29 00:17
Are they JUnit tests?

uglyog
2020-11-29 00:19
If so, you can add a SLF4J library to the classpath (like logback). If you're using Spring (or Springboot), you need to configure it as per the Spring instructions.

noel
2020-11-29 01:24
I'm in a situation where each service is built once and deployed into multiple environments where some endpoints are only enabled in specific environments. Each dev/test environment will have its own broker. I'd like to conditionally enable/disable certain consumer pact tests and attempted to use the junit `EnabledIfEnvironmentVariable` annotation but pact-jvm doesn't like skipped tests without being completely `Disabled` : https://github.com/pact-foundation/pact-jvm/blob/1bb705c13e140e621d482e3240a89f7121fbdd63/consumer/junit5/src/main/kotlin/au/com/dius/pact/consumer/junit5/PactConsumerTestExt.kt#L423 Is there another approach to conditionally enable tests so pacts could differ on a per-environment basis? Thanks!

uglyog
2020-11-29 01:44
Pact is designed to verify what is running matches what is in your production environment. There is no support for any type of optional validation apart from what the test frameworks give you.

matt.fellows
2020-11-29 03:42
> Each dev/test environment will have its own broker. that is really not how Pact is supposed to work. Why do you do this?

matt.fellows
2020-11-29 03:42
> Is there another approach to conditionally enable tests so pacts could differ on a per-environment basis? Thanks! tags. tags are how you differentiate the content/use of pacts e.g. `dev` or `test` or `prod`?

noel
2020-11-29 04:40
Hey guys, thanks for the feedback. To clarify, I have multiple production environments. Each production environment has its own test environment where CI takes place independently. Some service endpoints are disabled in certain prod/test environments. So a pact between two services in one environment might have a subset of the interactions of the pact between the same two services in another environment. Also, some services don't exist at all in certain prod/test environments. So that's why I've been considering one broker per test environment, to track each independently.

noel
2020-11-29 04:48
I did discover that I can annotate pact builder methods with Disabled and pact stops complaining about them not being executed if the corresponding `PactTestFor` is conditionally disabled: ```@Disabled @Pact(consumer = "A", provider = "B") public RequestResponsePact pactABxxx(PactDslWithProvider builder) { ... @EnabledIfEnvironmentVariable(named = "PARTNER_ENVIRONMENT", matches = "XXXX") @Test @PactTestFor(pactMethod = "pactABxxx") void myTestForXXXX() { ...``` And the pacts generated only include the "activated" interactions

noel
2020-11-29 05:00
Thanks for mentioning tags. :eyes: Maybe I'm way out in left field here and need to consider a different approach :joy:

matt.fellows
2020-11-29 21:12
> I have multiple production environments How many production environments?

matt.fellows
2020-11-29 21:13
Either way, your tests need to know about the environment - whether using a different broker or otherwise - so I?d suggest parameterising the builds and using tags to differentiate environments

matt.fellows
2020-11-29 21:13
multiple prod environments feels the same to me

matt.fellows
2020-11-29 21:13
Having multiple brokers mean tools like `can-i-deploy` will be hard to use effectively

matt.fellows
2020-11-29 21:14
it?s really working against the way the broker was intended to be used, so you?re up for more surprises in the future

muraalee
2020-11-30 01:56
has joined #pact-jvm

pooja.sharma
2020-11-30 08:52
has joined #pact-jvm

pooja.sharma
2020-11-30 09:06
hi All, i am new to pact testing and hoping for a little guidance, I am trying to create pactdsl body for a Json like this (screenshot), the objects under root -> customer[] are all the same kind but with different values, so i am looking to just verify the pattern for each and NOT the actual values. if any one have an example of such an implementation, that would be really helpful. thanks in advance

mo
2020-11-30 09:24
has joined #pact-jvm

matt.fellows
2020-11-30 09:33
Look for the like matchers in the docs

matt.fellows
2020-11-30 09:33
I think it's called `arraylike` or similar

uladzislau_danilchyk
2020-11-30 09:58
Hi all! Is there any way to do not fire error when state on a provider side is not defined? There are cases when Consumer defines state, e.g. "products exist" but Provider shouldn't do something special inside provider state method. But if method with `@State` is not defined it fails. How to do not fail without having `@State` ?

pooja.sharma
2020-11-30 10:06
Thanks for a quick reply Matt, will look it up

uglyog
2020-11-30 10:33
There is nothing to support that. Please raise an issue on the Github repo


uladzislau_danilchyk
2020-11-30 14:01
@uglyog, I have tried this but unfortunately...

noel
2020-11-30 15:23
Thanks Matt. Agreed. I do like the idea of instead parameterising the builds and using tags and one global broker. This way we could also fail builds for an environment if the pact tests failed for that environment.

kjayachandra2000
2020-11-30 18:33
Hey all, what's the difference between `pact-jvm-consumer-java8_2.12` and `pact-jvm-consumer-java8` most of the online examples are using java8_2.12 :thinking_face:

phil.endsley
2020-11-30 18:34
`pact-jvm-consumer-java8_2.12` is an old version. The artifacts were renamed a while ago to support java 9 modules

kjayachandra2000
2020-11-30 18:38
so I can use the latest modules if my code base is on java 8 ?

phil.endsley
2020-11-30 18:52
We do. We might be using java 11+ to run tests? It's been a while since that was setup

eric.jones
2020-11-30 21:38
has joined #pact-jvm

david.greene
2020-11-30 21:47
has joined #pact-jvm

pavel.azarau
2020-12-01 00:50
Hi folks. I?m using Gradle plugin ?http://au.com.dius.pact? version ?4.1.11" on provider side to run pacts verification. I?ve configured a web hook in Pactflow which passes 2 parameters (as Gradle plugin docs suggests https://docs.pact.io/implementation_guides/jvm/provider/gradle/#allowing-just-the-changed-pact-specified-in-a-webhook-to-be-verified-406). Those parameters are successfully picked up by CI and passed to Gradle build as: ? -Ppact.filter.consumers=<consumer_name> ? -Ppact.filter.pacturl=https://ourcompanydomain.pactflow.io/pacts/provider/provider-name/consumer/consumer-name/pact-version/pact-version/metadata/somemetadata. pactVerify task results in `WARNING: There are no consumers to verify for provider ?external-authentication-service?. ` However when I run get request with pact.filter.pacturl value I get the pact. I was testing the build locally and noticed that when I run `./gradlew pactVerify` it fetches a correct pact and verifies it. But when I run `./gradlew pactVerify -Ppact.filter.consumers=<consumer-name>` (with consumer name which was passed from Pactflow) the task results in `WARNING: There are no consumers to verify for provider ?external-authentication-service?. ` And this even without passing -Ppact.filter.pacturl. Any ideas why consumer name filtering parameter breaks filtering?

uglyog
2020-12-01 00:54
`pact.filter.pacturl` is pointing to a single pact file, so there is no need to filter by consumer name. It has only one consumer

uglyog
2020-12-01 00:55
Those two properties were never designed to be used together

pavel.azarau
2020-12-01 00:59
thanks! I?ll try using just url to filter. FYI there are 2 places in docs where it says to use those 2 filtering parameters together though (or maybe I misunderstood it) ? https://docs.pact.io/implementation_guides/jvm/provider/gradle/#project-properties , ```pact.filter.pacturl This filter allows just the just the changed pact specified in a webhook to be run. It should be used in conjunction with pact.filter.consumers``` ? https://docs.pact.io/implementation_guides/jvm/provider/gradle/#allowing-just-the-changed-pact-specified-in-a-webhook-to-be-verified-406 , see example

uglyog
2020-12-01 01:02
:thinking_face: I wonder why that is, doesn't make sense

pavel.azarau
2020-12-01 01:03
now I?ve just tried `./gradlew pactVerify -Ppact.filter.pacturl=<URL passed from Pactflow>` and got the same WARNING: There are no consumers to verify for provider ?provider name?

uglyog
2020-12-01 01:04
You will have to provide some debug logs to see what is going on

bas
2020-12-01 09:00
has joined #pact-jvm

wainstead
2020-12-01 14:57
has joined #pact-jvm

kjayachandra2000
2020-12-01 18:01
Hi All, can we run pact provider tests without running actual api service ?

pavel.azarau
2020-12-01 18:01
my Gradle plugin config contains the following ```fromPactBroker { selectors = latestTags(project.hasProperty("consumerTag") ? consumerTag : 'master') }``` I need it to be able to run verification for a build pipeline. So it?s a bit odd but I?ve made it work when I?ve replaced pact.filter.consumers to a proper consumerTag (so web hook passes a tag). I was assuming that pacturl would override `selectors` from plugin too

pavel.azarau
2020-12-01 18:05
to explain a bit more. I don?t have pacts with `master` tag in Pactfow atm. And it looks like Gradle was trying to fetch `master` pact anyway even though later (if this fetch is successful) it actually uses pact.filter.pacturl value to actually verify correct pact

pavel.azarau
2020-12-01 18:06
would like to know it too :slightly_smiling_face: I was able to do it for messages (unit test style). But I wonder if it?s possible for API

uglyog
2020-12-01 20:02
If you use unit tests

kjayachandra2000
2020-12-01 20:10
is there any example i can check on?

jerobinson
2020-12-01 20:32
has joined #pact-jvm

uglyog
2020-12-01 22:41
The spring boot examples can verify just the controllers, not the full service. If you're using Springboot, look at https://github.com/pact-foundation/pact-jvm/tree/master/provider/spring

sumedhagamage
2020-12-02 03:33
has joined #pact-jvm

sumedhagamage
2020-12-02 04:16
qq on test scope It says recommend to use Consumer ClientApi class unit test. What is the rational behind not to use Pact in consumer behavior test. For example if we use SpringBootTest to run consumer IT test that touch consumer MVC + Service and persistence (with H2) and use Pact for external API calls.

sumedhagamage
2020-12-02 04:21
I get that we should not use to test Provider behavior. But some cases we need to test consumer behavior based on different response from provider. I think exact like Provider states. So if we want to use Pact as part of Consumer behavior test. What would be the solution.

sumedhagamage
2020-12-02 04:23
Like if @State -> Student count > 1 consumer have different business logic and if @State Student count =0 consumer have different business logic

abubics
2020-12-02 04:25
The scope you're describing is much wider than the contract at the network boundary. Blending those concerns doesn't give you specificity or isolation, and having more moving parts in the same test makes them slower and probably flakier :slightly_smiling_face:

abubics
2020-12-02 04:25
Just beat you to it, @phil.endsley :sweat_smile: I was looking forward to your input :pray:

phil.endsley
2020-12-02 04:26
Those scenarios should still be tested, but the business logic isn't part of the contract between the consumer and provider, so like @abubics said, out of the intended scope for pact

sumedhagamage
2020-12-02 04:27
Then only way to test the consumer business logic to use mock for external API calls. And have isolated unit test to ClientAPI class with Pact

abubics
2020-12-02 04:28
we must have some diagrams for this . . . I don't know how to find them

phil.endsley
2020-12-02 04:28
The scope of tests was talked about in the recent meetup, which was recorded. There were some diagrams in it

sumedhagamage
2020-12-02 04:28
but isn't that can break the contract when we mock this external calls when doing behavior testing. Because we can have false mock in place for those behavior test

sumedhagamage
2020-12-02 04:29
do you have the link for the recorded session

sumedhagamage
2020-12-02 04:29
@phil.endsley do you have the link for the recorded session


abubics
2020-12-02 04:32
As with the testing pyramid, you always need a balance of different kinds of tests, to make sure things don't work only in isolation (for example). Depending on the language and architecture, there may be different strategies to make sure that test data doesn't get out of sync. It's not a major concern of Pact, but the community often has interesting ideas about it :)

abubics
2020-12-02 04:34
e.g. if you have statically typed models, then Pact can make sure they (un)marshall properly. If you specify fixtures that are parsed into those models, then their values should be valid for all places they're used in.

abubics
2020-12-02 04:35
e.g. pact-js has a feature to extract json without Pact matchers in it, for use in non-Pact tests.

abubics
2020-12-02 04:35
it really depends on the platforms & usage patterns

phil.endsley
2020-12-02 04:36
Your business logic isn't really dependent on the contract though right? It's dependent on the response from the external api. And when you're writing tests on the consumer, you're always in control of that data. I guess your concern is that you have to remember to use the same kind of data in both pact tests and other unit tests

phil.endsley
2020-12-02 04:37
In that case, you could write test models that are shared/reused if you wanted to. There's probably a lot of different ways to solve it, each with their own pros and cons

phil.endsley
2020-12-02 04:38
I.e. what @abubics said :laughing:

sumedhagamage
2020-12-02 04:41
Yeah I think this is the concern. Yeah business logic does not depends on the contract but on the data that consumer test has the control.

sumedhagamage
2020-12-02 04:42
I think as you described share the test data models. with pact and behavior test

sumedhagamage
2020-12-02 04:50
Yeah that make sense now. Share the data models with Pact and other test, One more q. Can I pass a json or data model(lets says shared data model) to PactDsl and get type matcher other than constructing matcher through Dsl builder? Sometime the request/response can be lengthy

abubics
2020-12-02 04:56
I haven't seen this feature in any of the implementations. It's usually easier to go the other way, i.e. start with matchers, and strip them out

sumedhagamage
2020-12-02 04:57
Does pact-jvm has this feature as pact-js that you have mentioned

abubics
2020-12-02 04:58
not that I've seen, but I haven't used pact-jvm-consumer in over a year :thinking_face:

abubics
2020-12-02 04:58
Other people may know better. I haven't seen it on a roadmap, though.

sumedhagamage
2020-12-02 04:59
:thumbsup:

sumedhagamage
2020-12-02 05:01
does pact-jvm have this feature?

bethskurrie
2020-12-02 05:29
If it doesn't, please add a feature request at http://pact.canny.io

alnasl
2020-12-02 11:06
hey, I have a problem with a pact test with one put request and one get. I'm getting a strange exception when running them together. it occurs when I execute the put request. `Software caused connection abort: recv failed executing PUT http://localhost:3003/banks/54fbe6cb-6163-4a3d-bc3c-036feb16808e` feign.RetryableException: Software caused connection abort: recv failed executing PUT http://localhost:3003/banks/54fbe6cb-6163-4a3d-bc3c-036feb16808e at feign.FeignException.errorExecuting(FeignException.java:249) at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:129) at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89) at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100) at com.sun.proxy.$Proxy65.updateBankConnectionByIdForUser(Unknown Source) ... Caused by: http://java.net.SocketException: Software caused connection abort: recv failed at java.base/java.net.SocketInputStream.socketRead0(Native Method) at java.base/java.net.SocketInputStream.socketRead(SocketInputStream.java:115) at java.base/java.net.SocketInputStream.read(SocketInputStream.java:168) at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140) at java.base/java.io.BufferedInputStream.fill(BufferedInputStream.java:252) at java.base/java.io.BufferedInputStream.read1(BufferedInputStream.java:292) at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:351) at java.base/sun.net.http://www.http.HttpClient.parseHTTPHeader(HttpClient.java:746) at java.base/sun.net.http://www.http.HttpClient.parseHTTP(HttpClient.java:689) at java.base/sun.net.http://www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1615) at java.base/sun.net.http://www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520) at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:527) at feign.Client$Default.convertResponse(Client.java:108) at feign.Client$Default.execute(Client.java:104) at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:119) ... 92 more It appears that the provider is aboring the connection because of timeout or something. do you have any ideas, what might be the problem? when run separately the tests are green. so this only happen when they are run together. thanks.

alnasl
2020-12-02 11:22
the get is green when the they are run together. only the put fails.

fealaer
2020-12-02 11:40
has joined #pact-jvm

fealaer
2020-12-02 11:57
@fealaer has left the channel

alnasl
2020-12-02 12:50
is it possible that the mock server closes the connection and feign is trying to reuse already stale connection?


alnasl
2020-12-02 13:18
and `@BeforeAll` public static void setup() { System.setProperty("http.keepAlive", "false"); }

alnasl
2020-12-02 13:18
is working for me as a quick fix.

alnasl
2020-12-02 13:48
ok, this works only locally, not when we run the tests on a server. is there any way to prevent the mock server from closing the connection? My Feign uses BasicHttpClientConnectionManager so, the fix for closing idle connections is not working for me.

patrick.hendron
2020-12-02 14:44
has joined #pact-jvm

h.octavian
2020-12-02 15:55
Thank you.

lpratt
2020-12-02 18:19
has joined #pact-jvm

uglyog
2020-12-02 21:48
Try setting `http.keepAlive` in the build instead in a before in the test

sandragnzalez
2020-12-03 11:04
has joined #pact-jvm

mbieganski.infomatt
2020-12-03 13:11
Hey can consumerVersionSelectors be also used as java system properties or use pactbroker.tags?

phil.endsley
2020-12-03 14:24
Yeah, but it looks like it didn't make it into the docs :disappointed: ```VersionSelector[] consumerVersionSelectors() default @VersionSelector( tag = "${pactbroker.consumerversionselectors.tags:}", latest = "${pactbroker.consumerversionselectors.latest:}");``` So these are two separate properties that are comma delimited. The lengths must match, and the indexes are matched by position. So pactbroker.consumerversionselectors.tags={"tag1","tag3","tag2"} pactbroker.consumerversionselectors.latest={"true","true","false"} would translate to ```[ @VersionSelector(tag = "tag1", latest = "true"), @VersionSelector(tag = "tag3", latest = "true"), @VersionSelector(tag = "tag2", latest = "false") ]```

kristian
2020-12-03 14:34
has joined #pact-jvm

me1466
2020-12-03 23:42
has joined #pact-jvm

mbieganski.infomatt
2020-12-04 09:52
thanks. that's what I thought.. updating from 4.1.4 to 4.11.1 :smile: looks like below did the trick ```systemProperties.put("pactbroker.consumerversionselectors.tags", "dev,master"); systemProperties.put("pactbroker.consumerversionselectors.latest", "true,true");```

mbieganski.infomatt
2020-12-04 11:13
@uglyog is there a way to to include fallback or it will work as using tags. if no tag found basically ignore?

wenfeng.li
2020-12-04 11:42
has joined #pact-jvm

lalexander2810
2020-12-04 14:53
Hey everyone. I am want to have a verification on the provider side where the validation checks type matching. As it stands currently my test also checks for data values (in Java). I've seen documentation for type matching in Ruby and wanted to implement that for Java but having some difficulty doing so. In the thread I will provide a sample json request and response.

lalexander2810
2020-12-04 15:03
Request ```{ "highlight": true, "Id": 1, "items": [ "chair" ], "offset": 0, "stats": true, "count": 5, "countEnabled": true }``` Response: ``` { "offset": 0, "total": 100, "itemStats": { "stats": { "1": 66, "2": 47, "3": 26, "4": 65, "5": 29 } } }``` So the goal is have an expected response to verify the keys and not include the values as values will change day to day.


lalexander2810
2020-12-04 15:23
@antonello I have but unfortunately when I implement, when I don't specify a value i.e. numberType value it defaults to 100 thus causing the the test to fail due to the changing in `itemStats` and `total`

antonello
2020-12-04 15:24
can you share your implementation please?

kjayachandra2000
2020-12-04 15:47
Hi All, at the provide side in gradle what should be status url ```BaseProviderTest > Pact between BusServiceNewClient (1.0-SNAPSHOT) and BusService FAILED java.lang.AssertionError at PactJUnit5VerificationProvider.kt:323 Caused by: au.com.dius.pact.provider.junitsupport.MissingStateChangeMethod at PactJUnit5VerificationProvider.kt:381 2020-12-04 16:46:10.934 INFO 18253 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'```

cdambo
2020-12-05 11:59
has joined #pact-jvm

kjayachandra2000
2020-12-07 09:34
Hi lads, this is my provider side gradle config ```pact{ broker { pactBrokerUrl = 'http://localhost:80' } serviceProviders { BusService { fromPactBroker { selectors = latestTags('test') } } } reports { defaultReports() // adds the standard console output markdown // report in markdown format json // report in json format } }``` When I try to run the tests `./gradlew pactVerify` I am running to an error as below ```Failures: 1) Verifying a pact between Pact between BusServiceNewClient (1.0-SNAPSHOT) and BusService 1.1) Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused) 1.2) Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)``` I am using springboot test to run the provider tests ```@Provider("BusService") @PactBroker(host = "localhost", port = "80") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class BaseProviderTest {```

matt.fellows
2020-12-07 11:19
I think (I could be wrong) that because you?re running the `pactVerify` via gradle, the spring boot annotations don?t take effect

matt.fellows
2020-12-07 11:19
so either a) use the standard test phase or b) find another way to start the provider before your gradle verification task



ranjanayush03
2020-12-07 12:36
Hi all we are facing an issue when trying to validate the last login date of the user onto the app , we need to validate only the format of the time and not the actual value and we tried doing that but facing issue like '''[{mismatch=Expected '2020-12-07T11:08:54.800+00:00' to match a timestamp of 'yyyy-MM-dd'T'HH:mm:ssXx': Unable to parse the date 2020-12-07T11:08:54.800+00:00, diff=}]

ranjanayush03
2020-12-07 12:39
Can someone please help me with this..

rodrigo.costa20
2020-12-07 17:42
.

rodrigo.costa20
2020-12-07 17:43
Hello I'm creating some tests with Pact, and I'm getting this exception PactMismatchesException: The following requests were not received: This is my method to create the pact ```@Override protected RequestResponsePact createPact(PactDslWithProvider builder) { PactDslJsonBody body = new PactDslJsonBody() .stringType("firstName") .stringType("lastName") .numberType("age") .object("ids", new PactDslJsonBody() .integerType("id") .uuid("uuid") ); return builder.uponReceiving("can get user data from user data provider") .path("/user") .method("GET") .willRespondWith() .status(200) .body(body) .toPact(); }``` Does anyone know what I can be doing wrong?

phil.endsley
2020-12-07 17:54
Do you have a unit test that makes a call to the endpoint you're creating the pact for? In order to generate the contract, your consumer must prove that it's making the call you define in your contract

rodrigo.costa20
2020-12-07 18:18
Hi @phil.endsley! Yes, I do. I've created a dummy test just to see if it works, but I keep getting the error this is the test: ```@Override protected void runTest(MockServer mockServer) { assertTrue(1 == 1); }```

phil.endsley
2020-12-07 18:22
In the test, you need to make a GET call to /user with the body you defined The exception you're getting means you defined an interaction between the consumer and provider, but your consumer didn't call the endpoint in your test. Pact won't generate the contract unless your consumer makes the calls you say it will

rodrigo.costa20
2020-12-07 18:31
thanks @phil.endsley! I will try

phil.endsley
2020-12-07 18:32
:thumbsup: `mockServer` should have methods to get the base url

rodrigo.costa20
2020-12-07 18:33
I've just tried in a very basic way

rodrigo.costa20
2020-12-07 18:33
but I dont think it was enough

rodrigo.costa20
2020-12-07 18:34
I've made the call

rodrigo.costa20
2020-12-07 18:34
```System.out.println(mockServer.getUrl() + "/user");```

phil.endsley
2020-12-07 18:38
That will just print it out. You need to use some kind of http client. Ideally, you will just call the method from your code base that makes this call. Pseudo-code: Don't copy/paste :slightly_smiling_face: ```public class UserService { public UserService(url) { this.url = url; } public User getUser() { http.get(url); // http here would be an http client from whatever library you want OkHttp, RestTemplate, etc... } }``` Then in your test, you would do something like ```@Test public void testName() { User user = new UserService(mockServer.getUrl()).getUser(); // Then assert on User to make sure it's being unmarshalled correctly }```

rodrigo.costa20
2020-12-07 18:42
Thanks!

rodrigo.costa20
2020-12-07 18:42
thank you very much!

rodrigo.costa20
2020-12-07 23:28
Hey guys, In a consumer test, which is the best way to validate if the response body of the request is correct?

antonello
2020-12-07 23:47
I don?t think you will want to validate it. If the client can deserialise the response, that would be enough.

antonello
2020-12-07 23:49
In some of our consumer tests we do something simple like ```DogOutput response = client.getDog(1); assertThat(response.getName()).isEqualTo("snoopy");```

antonello
2020-12-07 23:49
in others we simply assert ```assertThat(response).isNotNull();```

rodrigo.costa20
2020-12-08 00:02
great

rodrigo.costa20
2020-12-08 00:03
I was thinking in something like matches if the response body has the correct contract

rodrigo.costa20
2020-12-08 00:03
does that makes sense?

rodrigo.costa20
2020-12-08 00:04
I mean... assert if the pattern is correct

abubics
2020-12-08 00:04
Yeah, usually the matchers in the Pact part of the test would do most (if not all) of the validation you need

abubics
2020-12-08 00:04
and then if you need more specific matching, your test framework can finish it off (with asserts or whatever)

rodrigo.costa20
2020-12-08 00:06
thanks @abubics do you have any examples of how can I do this kind of assertion?

abubics
2020-12-08 00:06
what (unit) test framework are you using?

rodrigo.costa20
2020-12-08 00:06
JUnit


abubics
2020-12-08 00:07
howtoask

2020-12-08 00:07
Please see this page for some tips on how to ask for help to get the best response from the community https://docs.pact.io/help/how_to_ask_for_help

abubics
2020-12-08 00:08
You might mean something more specific, but I can't quite tell . . . this is a Pact support channel, not a general testing support place :slightly_smiling_face:

abubics
2020-12-08 00:08
If you're having trouble with your http client, that's a separate issue, and maybe someone can help, but we'd need more context

rodrigo.costa20
2020-12-08 00:09
great! Actually my question is more about if this kind of validation is the proper one... because most of the examples that I saw on internet, they usually did not verify if the response that was get on the consumer test was matching the contract

rodrigo.costa20
2020-12-08 00:09
So I don't know if its correct to validate it, or if it is not necessary

antonello
2020-12-08 00:10
You don?t need to verify it when you?re using a strongly typed language

rodrigo.costa20
2020-12-08 00:11
e.g. In my test what I did was to actually check if the response that I got was exactly equal the response that I want... ```assertEquals(response.getBody(), responseBody);``` However, by checking on this way, I was validating the values and not only the contract itself

antonello
2020-12-08 00:12
it is not a responsibility of a consumer test to validate the contract

antonello
2020-12-08 00:13
the purpose of the `@Test` part of a consumer test is to make sure that you?ve set up your pact expectations correctly

abubics
2020-12-08 00:14
Sounds like the distinction between checking types only vs typed values is unclear maybe? You can use Pact to assert either, and that can preclude further assertions outside of the Pact DSL (if appropriate).

rodrigo.costa20
2020-12-08 00:15
@antonello... so the verification of the contract even in this case, would be in the provider side?

antonello
2020-12-08 00:17
@rodrigo.costa20 Yes. The purpose of the consumer test is to generate a pact by simulating a call to a provider that is like the one that the consumer would make in real life

abubics
2020-12-08 00:18
This example (here https://docs.pact.io/getting_started/matching/#type-matching) has both type and value validation, if that helps: ``` body: { name: "Mary", age: Pact.like(73) }```

abubics
2020-12-08 00:19
but yes, as @antonello is helping to explain, the consumer side is just one part of the overall validation/verification

rodrigo.costa20
2020-12-08 00:19
Thanks guys! @antonello @abubics You both helped a lot!

uglyog
2020-12-08 03:59
Your actual value has milliseconds in it, you need to add that to the format

uglyog
2020-12-08 03:59
`.800` needs to be matched with `.SSS`

ranjanayush03
2020-12-08 04:08
Thank you I tried this earlier but then also it was throwin unable to parse error.

uglyog
2020-12-08 04:15
```> DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").parse('2020-12-07T11:08:54.800+00:00') ===> {OffsetSeconds=0, InstantSeconds=1607339334},ISO resolved to 2020-12-07T11:08:54.800```

uglyog
2020-12-08 04:15
`yyyy-MM-dd'T'HH:mm:ss.SSSXXX` will work

ranjanayush03
2020-12-08 04:17
Thank you will try this..

ranjanayush03
2020-12-08 04:19
Yeah it worked thank you. .

gayatree.eee
2020-12-08 04:50
has joined #pact-jvm

antonello
2020-12-08 07:58
When did the above started to happen? Just want to avoid upgrading to that version :scream:

abhi.nandan
2020-12-08 10:16
@antonello I faced this on 4.1.8

antonello
2020-12-08 10:16
Interested, I haven?t observed it on 4.1.9

rodrigo.costa20
2020-12-08 13:11
Hey guys! Just a question about best pratices... I'm creating my tests and my contracts on consumer side... and I have many situations... A contract with will responde with 200 with an especific body, another that will response 201 and will return another body, another with 404...

rodrigo.costa20
2020-12-08 13:11
I'm creating those contracts in separated classes

rodrigo.costa20
2020-12-08 13:12
which is the best way to create those contracts?

rodrigo.costa20
2020-12-08 13:12
should I do this creation on the same "builder.uponReceiving..." ?

brendan.donegan
2020-12-08 14:29
@uglyog out of curiosity is there a way to do this in pact-js?

lalexander2810
2020-12-08 15:10
@antonello Sorry about the late response my computer died on me Request ``` private static final String requestWithItem = new PactDslJsonBody() .booleanType("highlight", true) .numberType("Id", 1) .array("items") .string("chair).closeArray() .numberType("offset", 0) .booleanType("stats", true) .numberType("count", 5) .booleanType("countEnabled", true) .toString();``` Response ``` private static final String responseWithSkus = new PactDslJsonBody() .numberType("offset", 0) .numberType("total", 100) .object("ItemStats") .object("stats") .numberType("1", 66) .numberType("2", 47) .numberType("3", 26) .numberType("4", 65) .numberType("5", 29) .closeObject() .closeObject().toString();```

lalexander2810
2020-12-08 15:40
The `stats` object is dynamic and will change when the mock server is hit as the values will differ as I am trying to only test for the keys / data type.


jgfarias42
2020-12-08 16:49
_uponReceiving_ is just a name for the interaction, it doesn?t affect anything at runtime.

jgfarias42
2020-12-08 16:54
Depending on your configuration, you will run the risk of overwritting a contract. It?s safer (and more important, easier to understand) if you start with one class for each Client object / Producer you have. You then will have many sections: ? 1 - Create the mockServer ? 2 - Create the Client object ? 3 - Define one expected interaction between the Client object and the mock server ? 4 - Define a test where you call the Client object (which by itself will call the mockServer) and assert over its response; ? 5 - Repeat (3) and (4) for all expected interactions. Then you can refactor your test class to make it cleaner, if necessary.

jgfarias42
2020-12-08 17:04
[Android][JUnit] Short version: Hey folks, I?m having having troubles in figuring out if my Pact Server is receiving the calls. Is there a way to toggle some logging mechanism in the Pact Server? I?m instantiating it like this: (I can also refactor to JUnit 5 if necessary) ```@get: Rule val mockProvider = PactProviderRuleMk2( "MyProducer", "localhost", 9003, this )``` Long version: So far, on the the Android app I?m working, we were using Pact successfully via RestAssured. However, now we want to refactor it so that our tests will use the Client object that the Android app uses, thus coupling the tests to the Client objects. These Client objects use a in-house subscription mechanism to make async HTTP calls. Debugging out, I see that everything behaves as expected: The arguments for the Client object function are correct transformed in a message that the async HTTP call mechanism understands, targeting the correct URL in localhost, the message is notified to the subscribers, etc. However, neither the success or error callback functions are called after notification - the execution just keeps stuck in a limbo. I decreased the timeouts, but still stuck. If I run a cURL against _localhost_ on the expected URL, I get the response the Pact Server was configured to reply, Is there a way to turn on logs on the Pact Server, so I can investigate if the messages are arriving in the Pact Server?

sumedhagamage
2020-12-08 20:53
We had this issue. But it is related to fail-safe plugin. Not sure you are using this. Technically mvn verify should execute this Springboot test. no need pact:verify

sumedhagamage
2020-12-08 20:54
mvn verify -dpact.verify.publishResults=true

sumedhagamage
2020-12-08 20:54
pushed the verification

sumedhagamage
2020-12-08 20:54
but I think if you want to run verification against running provider you can use pact:verify

sumedhagamage
2020-12-08 20:55
in Springboot test this test will execute in verify goal and -dpact.verify.publishResults=true flag will publish the result to broker

uglyog
2020-12-08 22:09
Only with the V3 beta, it supports those matching functions

uglyog
2020-12-08 22:13
Pact-JVM uses standard SLF4J loggers, so if you have those configured and set to debug, you will get the logs.

abubics
2020-12-09 00:53
There's also usually a separate log file just for the pact mock server, it ends up in `output/pact/server.log`, or something :thinking_face:

uglyog
2020-12-09 00:54
That's the Ruby one, because it is a separate process

uglyog
2020-12-09 00:55
But with SLF4J, you can configure certain packages to log to a separate file


c.pavan1986
2020-12-09 04:18
has joined #pact-jvm

matt.fellows
2020-12-09 09:35
You may not have seen it because for most practical purposes it won't matter. The issue is just that the passing of the verification results for a failing contract doesn't report the passing interactions, just the failing ones.

matt.fellows
2020-12-09 09:36
So contract status, can-i-deploy etc will still work the same way

antonello
2020-12-09 09:36
I am a bit confused - I thought we were reporting cumulatively to the broker, not per interaction.

antonello
2020-12-09 09:50
Ok - I looked again at the issue and I can see that it is about what?s reported in the POST to the broker with the results.

antonello
2020-12-09 09:52
Aside from the incorrect behaviour, when would this ever matter? If you - for whatever reason - want to go and see the verification results in the broker to understand why a verification failed?

matt.fellows
2020-12-09 10:59
I can?t think of a reason it matters significantly, apart from maybe being a bit misleading

william.pritchard
2020-12-09 15:28
has joined #pact-jvm

parveshchaudhary111
2020-12-09 17:54
has joined #pact-jvm

w.sobasik
2020-12-10 10:39
has joined #pact-jvm

rodrigo.costa20
2020-12-10 14:08
Hey guys! I'm working on a test on provider side, that I need to dealing with authentication headers... which is the best way to work on situations like this? Do you guys have any example that you could recommend?

antonello
2020-12-10 14:31
First of all, have you read this? https://docs.pact.io/provider/handling_auth/

rodrigo.costa20
2020-12-10 14:33
Yes!

rodrigo.costa20
2020-12-10 14:33
I was looking now for some pratical examples

komeershettyvinod
2020-12-10 19:00
Hi Guys

komeershettyvinod
2020-12-10 19:01
I was able to generate a contract pact json file

komeershettyvinod
2020-12-10 19:01
But I was unable to make a success at producer side

komeershettyvinod
2020-12-10 19:01
If I see the json file and assertions all are failing at matchers and generators

komeershettyvinod
2020-12-10 19:02
So can any 1 throw some light on whats the difference between matchers and generators

komeershettyvinod
2020-12-10 19:02
?


matt.fellows
2020-12-11 05:16
there is an example of how to deal with authorization there


matt.fellows
2020-12-11 05:17
Extrapolating to Java with Request Filters is all you should need to do

kjayachandra2000
2020-12-11 08:15
Hey All, while writing consumer test which of these have to be used. ```LambdaDsl.newJsonBody((object) -> { object.stringType("station", "Hammersmith") .stringType("nr", "613"); })``` or ```new PactDslJsonArray() .array() .stringValue("a1") .stringValue("a2") .closeArray();``` my config is Java8 with consumer 4.1.11 ?

uglyog
2020-12-12 00:20
Can you please elaborate what you mean by this? Can you provide the error and logs?

uglyog
2020-12-12 00:20
You can use either. It depends on your preferences.

kjayachandra2000
2020-12-12 10:36
thanks, which one of this advised to use

thanuxxxx
2020-12-12 22:41
has joined #pact-jvm

uglyog
2020-12-13 02:40
There is no one advised over the other. It is a matter of style. Do you prefer the older Java only code, or the newer one using lambdas?

ian.hamilton
2020-12-13 06:53
has joined #pact-jvm

colm.j.murphy91
2020-12-13 07:02
has joined #pact-jvm

victoria.kruczek
2020-12-13 14:13
has joined #pact-jvm

komeershettyvinod
2020-12-13 18:18
java.lang.AssertionError: 0 - BodyComparisonResult(mismatches={$.marketingPlanObjective.launchDate=[BodyMismatch(expected="2000-01-31T18:30:00Z", actual="2022-11-12T18:30:00Z", mismatch=Expected "2022-11-12T18:30:00Z" to match a timestamp of 'yyyy-MM-dd'T'HH:mm:sss': Unable to parse the date: 2022-11-12T18:30:00Z

komeershettyvinod
2020-12-13 18:18
Getting Above error even though it has matching date format

komeershettyvinod
2020-12-13 18:19
In Client side code declared as:

komeershettyvinod
2020-12-13 18:19
```launchDate(timestamp)```

wuddarwin
2020-12-14 05:23
has joined #pact-jvm

uglyog
2020-12-14 09:27
The format is wrong, it should end with `:ss`

connor.aird
2020-12-14 15:52
has joined #pact-jvm

arman.najafian
2020-12-14 15:52
has joined #pact-jvm

praveen.lakkaraju
2020-12-14 16:12
has joined #pact-jvm

alejandro.germain
2020-12-14 16:26
has joined #pact-jvm

komeershettyvinod
2020-12-14 16:35
Hi In my pact.json file I want the request pattern something like below ``` "description": "marketingplan details", "request": { "method": "GET", "generators": { "path": { "type": "ProviderState", "expression": "api/v1/marketingPlanDetails/${uuid}", "dataType": "STRING" } } },``` But it always generates as below - ```"description": "marketingplan details", "request": { "method": "GET", "path": "/api/v1/marketingPlanDetails/5f591924089d2c4fdc64e0bd" },``` Any reason why I could not generate the generators and path object (with type, expression and datatype)attributes, My groovy client code is below: ```given('test Get call marketing plan details') uponReceiving('marketingplan details') // upon_receiving starts a new interaction withAttributes( method: 'get', path: fromProviderState('/api/v1/marketingPlanDetails/${uuid}','/api/v1/marketingPlanDetails/5f591924089d2c4fdc64e0bd') ) willRespondWith( // define the response we want returned status: 200, headers: ['Content-Type': 'application/json'])```

komeershettyvinod
2020-12-14 16:39
can any 1 please help me out

phil.endsley
2020-12-14 17:50
If you're not overriding the `${uuid}` parameter in the state changed method, it will use the default path you provided. It looks like that's what's happening. https://docs.pact.io/implementation_guides/jvm/provider/gradle#returning-values-that-can-be-injected Your state change method needs to return a map/dictionary where `uuid` is the key, and the path value you want to substitute is the value

komeershettyvinod
2020-12-14 18:17
@phil.endsley This is nothing to do with at provider side, If I manually update the .json file to the one which I showed above its working fine at provider side, But I am not sure what changes to do in consumer code to make it generated automatically

phil.endsley
2020-12-14 18:21
Oh, sorry for the misunderstanding. Not sure then, what you have matches the examples in the docs...I'm not a groovy user, so I don't have direct experience. What version of pact are you using? If it's 3.6.11+, I'm not sure...

komeershettyvinod
2020-12-14 18:23
@phil.endsley ``` I am using below versions, testCompile 'au.com.dius:pact-jvm-consumer-groovy_2.12:3.6.11' testCompile 'au.com.dius:pact-jvm-consumer-junit_2.12:3.6.11'```

komeershettyvinod
2020-12-14 18:25
I do not see in the documentation though


phil.endsley
2020-12-14 18:30
The first suggestion you'll probably get will be to update versions and see if that fixes it. Could be a bug in an older version. The package structure changed since the version you're using https://mvnrepository.com/artifact/au.com.dius.pact.consumer/groovy https://mvnrepository.com/artifact/au.com.dius.pact.consumer/junit

komeershettyvinod
2020-12-14 19:07
I am not sure changing the version will work, anyways will try it, but changing the version will break my existing scripts :disappointed:

komeershettyvinod
2020-12-14 19:07
?

komeershettyvinod
2020-12-14 19:23
Also do we have any documentation for the latest pact versions?

rodrigo.costa20
2020-12-14 19:45
Hey guys! Does anyone here have already done any kind of integration using pact and jersey tests? I'm having some issues with it

phil.endsley
2020-12-14 19:49
Not sure if it will break existing scripts. The API is the same with newer versions, but the package names changed. I believe everything in http://docs.pact.io should be for the latest version, unless otherwise specified

phil.endsley
2020-12-14 19:50
I've done this. What issues are you having?

rodrigo.costa20
2020-12-14 20:18
I need to set the application target using Jest, and I'm on pact provider side, so I also need to set the pact target... so when I try to set the jersey target I get a nullpointerexception

rodrigo.costa20
2020-12-14 20:18
how can I set the application target for both of them?

rodrigo.costa20
2020-12-14 20:46
jersey uses a WebTarget

rodrigo.costa20
2020-12-14 20:46
pact use HttpTestTarget

phil.endsley
2020-12-14 20:53
I'm a little lost. `HttpTestTarget` is what pact uses to make the request defined in the contract against a running instance of the provider. So it needs to be configured with the host/port that your service is accessible from in your test. Jersey's `WebTarget` is used to make outbound requests, right? Are you doing that in your provider tests? We do not do that. We do configure them for our consumer tests though

rodrigo.costa20
2020-12-14 20:56
In the project that I'm working we are using jersey to perform requests... and as jersey has a testcontainer, jersey also starts my application properly with it. In pact, I need to start my application using jersey context, and also jersey will start the container... however, I'm a little lost on how can I use the jersey context and start my application and how can pact understand that I'm using jersey

phil.endsley
2020-12-14 21:07
Pact's HttpTestTarget doesn't have an impact on starting your application. This is just telling Pact where your application is during the test. > as jersey has a testcontainer, jersey also starts my application properly with it. If you're using testcontainers, and you have a way to start your application with it, that certainly seems like a valid way to do your test. You would just need to start your application's container during the setup of your test. > how can pact understand that I'm using jersey Why does it need to know? Pact, and any other system making calls into your application, shouldn't care what framework or tech stack you're using. That's essentially an implementation detail that shouldn't impact how your services are invoked.

phil.endsley
2020-12-14 21:07
If you're running a container for your provider tests, Pact's `HttpTestTarget` would just need to be configured with that container's host and port

rodrigo.costa20
2020-12-14 21:11
Yes, the problem is that I need to mock some integration... and when I start my container manually, I'm not able to change the integration, so I cannot use the mock

rodrigo.costa20
2020-12-14 21:12
If I start my application with jersey, I would be able to change the behaviour of my app when starting, and I could use my mock properly

rodrigo.costa20
2020-12-14 21:14
actually I was trying to find a solution to mock a integration that I have... but I did not find a solution yet, since, the way that we start the application we start it already pointing to the real integration, so we were not able to mock this integration in runtime

phil.endsley
2020-12-14 21:20
Sure. Not sure if I can help there. We use Grizzly with Guice to start a webserver in the test context and bind mocks with Guice instead of our real integration points. Not sure if that helps or not

rodrigo.costa20
2020-12-14 21:22
great! thanks a lot

rodrigo.costa20
2020-12-14 21:23
do you have any code example of jersey and pact being used together that you can show? I did not find any example

kjayachandra2000
2020-12-14 21:39
Hey all, any help on this, i am getting an error while running the consumer test

phil.endsley
2020-12-14 21:54
Sure. I'm still a little confused, because like I said, Pact doesn't care about what framework you use. It sounds like it's how you're standing up your jersey services within your tests ``` @BeforeAll public static void setUpClass() throws Exception { // Setup server GrizzlyWebServer webServer = new GrizzlyWebServer(PORT); ServletAdapter adapter = new ServletAdapter(); adapter.addServletListener(ContextListener.class.getName()); adapter.addFilter(new GuiceFilter(), "guiceFilter", null); webServer.addGrizzlyAdapter(adapter, null); webServer.start(); } @BeforeEach public void setUp(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", PORT, "/")); // Other setup, mocks, etc... } // .. // .. public static final class ContextListener extends GuiceServletContextListener { @Override protected Injector getInjector() { return Guice.createInjector( new JerseyConfigModule(), // This has something like serve("/*").with(GuiceContainer.class, params); in it // Other Guice modules.. }```

phil.endsley
2020-12-14 21:55
Don't focus on getting Pact working with Jersey, try to find out how to get your application stood up in your test context. Once you do that, Pact just needs the host and port it's running on


matt.fellows
2020-12-14 23:17
:point_up:

matt.fellows
2020-12-14 23:18
@phil.endsley thanks for all of your question answering. It really is much appreciated. I woke up one morning last week only to see the most thorough explanation of the pending / WIP pacts workflow I?d seen - I think only Beth knows more than you. :taco: :taco: :taco:

rodrigo.costa20
2020-12-15 01:16
Thank you very much @phil.endsley You helped me a lot

josh.ellinger
2020-12-15 01:22
has joined #pact-jvm


nikitsenka
2020-12-15 09:35
has joined #pact-jvm

nikitsenka
2020-12-15 09:39
Created Java 15 + Webflux pact consumer-provider example using latest versions. Just for testing and upgrade https://github.com/nikitsenka/pact-contracts

hibahawes
2020-12-15 09:53
has joined #pact-jvm

sarvar
2020-12-15 14:24
has joined #pact-jvm

komeershettyvinod
2020-12-15 16:09
With the latest upgrade issue has been Fixed But I came across couple of issues

komeershettyvinod
2020-12-15 16:10
1. kotlin error which got resolved by adding an extra dependency "compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: '1.4.20'"

komeershettyvinod
2020-12-15 16:10
But could not resolve the second issue

komeershettyvinod
2020-12-15 16:11
consumer code is failing at line ```assert result == PactVerificationResult.OK.INSTANCE // This means it is all good``` with below message groovy.lang.MissingPropertyException: No such property: OK for class: http://au.com.dius.pact.consumer.PactVerificationResult

komeershettyvinod
2020-12-15 16:11
can any 1 help this?

suruchipatidar14
2020-12-16 05:35
has joined #pact-jvm

smatheson
2020-12-16 06:33
has joined #pact-jvm

olayemifolakemi
2020-12-16 15:23
has joined #pact-jvm

ania.kovalchuk
2020-12-17 00:09
has joined #pact-jvm

writetojoshma
2020-12-17 05:52
has joined #pact-jvm

yann.courtel
2020-12-17 09:43
Hey guys, we have a problem when using MockMvcTarget to mock our API with the pact version 3.6.xx I had to downgrade to 3.5.24 to be able to mock my external APIs. Anyone had this issue before? Is there a different mechanism to mock the APIs after the 3.6.xx version? Thanks a lot.

rejeesh.g
2020-12-17 11:07
has joined #pact-jvm

gayatree.eee
2020-12-17 11:19
~Can you please help us how to enable log for pending pact console output for pact JVM~

lukas.kempec
2020-12-17 12:45
has joined #pact-jvm

vikas543
2020-12-17 16:28
has joined #pact-jvm

bpugh
2020-12-17 17:05
has joined #pact-jvm

rodrigo.costa20
2020-12-17 19:12
Hi All, I know this is probably not a pact issue, but I'm getting an UnfinishedStubbingException when I mock method to be able to run my pact test properly... This is the code: ``` Invoker invoker = mock(Invoker.class); HttpServletRequest httpServletRequest = mock(HttpServletRequest.class); Abcd abcd = mock(Abcd.class); MyRepository myRepository = mock(MyRepository.class); @BeforeEach void before(PactVerificationContext context) { doAnswer((invocation) -> { XptoClassOutputBoundary test = invocation.getArgumentAt(1, XptoClassOutputBoundary.class); test.getResponse().setValue(new BigDecimal("500")); return null; } ).when(myRepository).execute(any(), any());``` Does anyone of you have already had this problem or know what can be wrong in this code? If so, could you help me with it? Thanks!

jeff.burmood
2020-12-19 17:45
has joined #pact-jvm

kyle.florence
2020-12-19 19:21
has joined #pact-jvm

ankurmalik22
2020-12-19 21:14
has joined #pact-jvm

vsukumaran
2020-12-20 01:56
has joined #pact-jvm

omer.morad
2020-12-20 08:10
has joined #pact-jvm

ringo
2020-12-20 10:51
has joined #pact-jvm

rodrigo.costa20
2020-12-20 14:31
Hello all, I'm working on some provider tests, and the tests are all working properly, except for the case that the value that I set on provider states aparently are not being read... when I need to change the value of some state I'm having to do it directly on the Testtemplate... so my code now is like this: ```@TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(Pact pact, Interaction interaction, HttpRequest request, PactVerificationContext context) { http://LOGGER.info("testTemplate called: " + pact.getProvider().getName() + ", " + interaction.getDescription()); if(interaction.toString().contains("mySate01")){ // SET MOCK CHANGES``` And for some reason, if I put the same mock changes on the state method, it does not work... Do you guys know what I can be doing wrong? This is an example of a state method ```@State("myState01") public void validInteraction() { http://LOGGER.info("Now service in myState01"); }```

omer.moradd
2020-12-20 18:01
has joined #pact-jvm

uglyog
2020-12-20 22:13
You need to find out what UnfinishedStubbingException means. A quick google turned up this https://medium.com/@adamspeakman/mockito-unfinishedstubbingexception-in-tests-3d622532d491


uglyog
2020-12-20 22:24
Those tests the state annotated methods get called

mamtha.3687
2020-12-21 06:38
Hello, We're trying to explore opportunities in automating provider and consumer tests generation based on a given yaml file. We understand that it may not be possible to get to the granular level of assertions/rules that the consumer might be interested in, but the idea is to get them started with a skeletal structure so they can focus on only what is more important to them. Any thoughts or links to resources of something similar?

yann.courtel
2020-12-21 08:22
I'd say unless your assets are automatically generated, I would not recommend that. Even if you were to have contracts close to what you want, the cost of maintenance will be higher. You will most likely not know what the PACTs are containing. Although just having a structure to indicate which interactions to write might not be a bad idea.

mamtha.3687
2020-12-21 09:21
@yann.courtel agree with you on the fact that we'll not know what the PACTs contain. In spring cloud contract, we're able to generate the tests automatically using groovy files for each interaction. More than anything, it simplifies the process of specifying what you want to test and not having to know the code intricacies. Ultimate need for us is to look at automating maximum part of it to help teams onboard easily and handle most of the initial setup so it is faster too.

yann.courtel
2020-12-21 09:44
Good to know. I specialized in the .NET implementation of it but it's good to know you have that tool in hand!

mamtha.3687
2020-12-21 09:52
Oh! No it doesn't solve our problem :grin:. My bad. I assumed you had java background and spoke about Spring. Are you saying that you have implemented the interactions structure in the .net framework? Can you please share a link to your github page if it's publicly available?

yann.courtel
2020-12-21 09:56
No I meant I didn't know Java offered that. I am familiar with PACT in Spring. And no, in .NET so far there is no such thing I know of. We are at the moment trying to get in sync with the 3.0 specifications so having a tool doing to testing structure for the interactions will come later. I'll keep in mind what you are doing as it is similar to another subject we have which is to know interactions between all the consumers and providers to have an "endpoint coverage". Similar to what you want but solved differently!

souravsen1
2020-12-21 11:28
has joined #pact-jvm

kjayachandra2000
2020-12-21 13:35
Hi All, while trying to run pact provider test. I have gradle config as below ```task contractTest(type: Test) { System.setProperty 'pactbroker.host', 'localhost' System.setProperty 'pactbroker.port', '80' filter { includeTestsMatching "*ContractTest" } useJUnitPlatform() }``` but still the test fails due to `Invalid pact broker host specified ('${pactbroker.host:}'). Please provide a valid host or specify the system property 'pactbroker.host'.` my test looking something like below ```@AutoConfigureWireMock(port = 8090) @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD) @ActiveProfiles(Profiles.TEST) @PactBroker @Provider("FeatureToggle") public class SampleContractTest{ ...... }```

andoni.arroyo
2020-12-21 17:51
has joined #pact-jvm

mikahchapman
2020-12-21 18:53
How are you supposed to specify a x-www-form-urlencoded body where the order is not fixed? For example, we're trying to write a request that has a body like `userId=1234&value=1&value=2&value=3`, but the order of the value params is not guaranteed by the client making the request. We tried a `PactDslRootValue.stringMatcher()` with a RegEx, but that didn't quite work.


uglyog
2020-12-21 21:53
Also, if you are using static host, you can also set it on the annotation `@PactBroker(host=...`

uglyog
2020-12-21 21:54
Can you raise an issue for that, it has never been implemented

kjayachandra2000
2020-12-21 22:08
Thanks uglyog, systemProperty worked for me :party_parrot:


matt.fellows
2020-12-22 05:39
Probably about time I gave @uglyog a :taco:

theovanessen
2020-12-22 10:47
has joined #pact-jvm

stuart3166
2020-12-22 12:35
has joined #pact-jvm

kjayachandra2000
2020-12-22 14:31
Hi All, i am running the *pact provider tests* in *gradle - junit 5*, while executing the tests testcasename is displayed as `pactVerificationTestTemplate`. This might be junit5 issue but if any of you know on the fix please share I saw a something in related to this on github, but the fix was more on surefire plugin. This creating confusion on the test readability

thanuxxxx
2020-12-22 18:39
Hi all, I am trying follow this example. I have this maven dependency ``` <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>spring</artifactId> <version>4.1.12</version> </dependency>``` And my base class start with following ```@TestPropertySource(locations = "classpath:application-pact-test.properties") @RunWith(SpringRestPactRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @Provider("Service") @PactBroker(scheme = "https", host = "${pactbroker.host}") public abstract class PactTestContext {....}``` All I have configure my host name in application-pact-test.properties but when I run this, I am getting `java.lang.IllegalArgumentException: Invalid pact broker host specified ('${pactbroker.host}'). Please provide a valid host or specify the system property 'pactbroker.host'.` I can create system property variables and assign values but I want to put all of my values into `application-pact-test.properties` file. Am I missing anything?

uglyog
2020-12-22 22:14
Not much we can do about that, it is not a Pact issue. Your test runner is using the classname and not the test description.

uglyog
2020-12-22 22:15
Try upgrading either JUnit5 ot Gradle, my test project generates the report with the description

uglyog
2020-12-22 22:49
Where have you created the application-pact-test.properties file? It needs to be in the test resources for Springboot to pick it up.

winfante
2020-12-22 22:51
has joined #pact-jvm

thanuxxxx
2020-12-22 22:53
Springboot is actually picking up the file because, I am using some hardcoded values for testing

uglyog
2020-12-22 23:04
And if you add them to the application.properties file above that one?

thanuxxxx
2020-12-22 23:07
I didn't try to add them to the application.properties because I explicitly says to get `application-pact-test.properties`

thanuxxxx
2020-12-22 23:07
```@TestPropertySource(locations = "classpath:application-pact-test.properties") @RunWith(SpringRestPactRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @Provider("Service") @PactBroker(scheme = "https", host = "${pactbroker.host}") public abstract class PactTestContext {....}```

uglyog
2020-12-22 23:08
I'm trying to work out where your issue is. If you put the values in application.properties and it works, the issue is with the `@TestPropertySource` annotation. If it still does not work, then it is something else.


thanuxxxx
2020-12-22 23:13
I moved those variables to application.properties file and commented out @TestProperySource annotation but I see the same error. Don't you guys have an example with application.properties instead application.yml.

uglyog
2020-12-22 23:15
application.properties is functionally the same as application.yml, you can use them interchangeably

uglyog
2020-12-22 23:16
Are you using JUnit5?

uglyog
2020-12-22 23:16
No, you are using the JUnit4 runner

thanuxxxx
2020-12-22 23:17
I wanted to use JUnit5 but `@ExtendWith(SprintRestPactRunner.class)` gives syntax error

uglyog
2020-12-22 23:18
Maybe it's the abstract base class that is cauding the issue. Could you try putting the annotations on an actual test class?

thanuxxxx
2020-12-22 23:24
I did that, but now I see a different error ```java.lang.Exception: Exactly one pact source should be set, found 2: @au.com.dius.pact.provider.junitsupport.loader.PactSource(au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.class), @au.com.dius.pact.provider.junitsupport.loader.PactSource(au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.class) at org.junit.runners.model.InitializationError.<init>(InitializationError.java:38) at au.com.dius.pact.provider.junit.PactRunner.getPactSource(PactRunner.kt:164) at au.com.dius.pact.provider.spring.SpringRestPactRunner.getPactSource(SpringRestPactRunner.kt:60) at au.com.dius.pact.provider.junit.PactRunner.initialize(PactRunner.kt:94) at au.com.dius.pact.provider.junit.PactRunner.getChildren(PactRunner.kt:151) at org.junit.runners.ParentRunner.getFilteredChildren(ParentRunner.java:534) at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:400) at org.junit.runners.model.RunnerBuilder.configureRunner(RunnerBuilder.java:81) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:72) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70) at org.junit.internal.requests.ClassRequest.createRunner(ClassRequest.java:28) at org.junit.internal.requests.MemoizingRequest.getRunner(MemoizingRequest.java:19) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:50) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)```

uglyog
2020-12-22 23:27
Just comment out the one on the base class for now

thanuxxxx
2020-12-22 23:30
No luck. Same error `Invalid pact broker host specified ('${pactbroker.host}'). Please provide a valid host or specify the system property 'pactbroker.host'.`

thanuxxxx
2020-12-22 23:31
Let me convert my .properties file to .yml and try again

uglyog
2020-12-22 23:31
That probably won't change anything

uglyog
2020-12-22 23:32
Just to double check, the property in the property file is `pactbroker.host`?

thanuxxxx
2020-12-22 23:33
I copied from here

uglyog
2020-12-22 23:35
I mean, not what the property is, but that the property in the property file is the same as the one used on the annotation?

thanuxxxx
2020-12-22 23:41
I doubled checked they are same. Only different between the one example you shared with me and mine is extension of application. file

uglyog
2020-12-22 23:42
What version of Springboot are you using?

thanuxxxx
2020-12-22 23:43
``` Running Spring Boot (v2.3.3.RELEASE)```

souravsen1
2020-12-23 06:02
Hi I'm new to Contract tests and I'm doing a POC using Pact JVM for a client. So I'm having some difficulties setting up the pact folder. I tried declaring it under @Test @PactVerification block of the consumer side and setting the system properties for pact.rootDir location, it didn't work. Then I used maven surefire plugin and declared the pact directory from the pom file. Still it didn't work. I'm using the example from here https://m.youtube.com/watch?v=F-IUh0M-pu8&t=915s and this is his repo https://github.com/mattiasmgn/Pact-JVM-Example though his code is outdated and with some changes I'm able to run the Junit test under consumer side and it passes but dont generate any pact file. Any help on this would be highly appreciated.


souravsen1
2020-12-23 06:28
Thanks @uglyog. Will give it a check.

lars.bonnes
2020-12-23 13:05
has joined #pact-jvm

lars.bonnes
2020-12-23 13:07
Hi, I am playing around with pact over XMas and was trying out the example junit5 code provided https://docs.pact.io/implementation_guides/jvm/provider/junit5. So having a super simple example ```@ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @Provider("GreetingsProvider") @PactFolder("pacts") public class GreetingsProviderPactTest { @TestTemplate @ExtendWith(PactVerificationSpringProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } }``` That yields ```At least one pact source must be present on the test class java.lang.UnsupportedOperationException: At least one pact source must be present on the test class``` when executing the test. Is there something super obvious I am missing?

kjayachandra2000
2020-12-23 13:19
```@Provider("BusService") @PactBroker(host = "pact_broker_app", port = "80") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class BaseProviderTest { @LocalServerPort private int port; @BeforeAll static void enablePublishingPact() { System.setProperty("pact.verifier.publishResults", "true"); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", port)); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @State("With missing node in the response body") public void toDefaultNNState() { } }``` This is my provide side test and in your test you are missing the `state`

lars.bonnes
2020-12-23 13:21
What has the state to do with the pact source?


lars.bonnes
2020-12-23 13:59
True, but how is that related to the error message I am seeing? https://docs.pact.io/implementation_guides/jvm/provider/junit5spring also does not state the need to specify a state

lars.bonnes
2020-12-23 13:59
So what are you aiming at?

phil.endsley
2020-12-23 13:59
@lars.bonnes make sure you're importing the right `@PactFolder` annotation. ```import au.com.dius.pact.provider.junitsupport.loader.PactFolder;``` This has bitten people before. Unfortunate naming conflict

lars.bonnes
2020-12-23 14:04
@phil.endsley awesome. That was it. You know how they say: There are only two hard things in Computer Science: cache invalidation and naming things.

thanuxxxx
2020-12-23 16:50
Is that any other way to assign `pactbroker.host` and `token` inside my test class instead of `@PactBroker(scheme = "https", host = "${pactbroker.host}", authentication = @PactBrokerAuth(token = "${pactbroker.auth.token}"))`

thanuxxxx
2020-12-23 16:51
Even I tried something like this but it did not work ``` @BeforeClass public static void loadPactProperties() { System.setProperty("pactbroker.host","myhost"); System.setProperty("pactbroker.auth.token","mytoken"); System.setProperty("pact.verifier.publishResults", "true"); }```

uglyog
2020-12-23 22:54
These properties work for a lot of people, so you need to work out what is different with your setup. Can you clone that example repo and try running the test there?

thanuxxxx
2020-12-24 00:30
It seems like I am unable to do `@ExtendWith(SpringRestPactRunner.class)`. Can I use JUnit 5 with SpringRestPactRunner?


thanuxxxx
2020-12-24 00:36
Okay, but If I want to do this `@PactBroker(scheme = "https", host = "${pactbroker.host}", authentication = @PactBrokerAuth(token = "${pactbroker.auth.token}"))` along with Junit5 then, which maven I should use? ``` <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.1.12</version> <scope>runtime</scope> </dependency>``` Can I use above dependency?

uglyog
2020-12-24 00:37
No, read the docs at the link I posted above

thanuxxxx
2020-12-24 00:37
Okay. Let me let me read it. Thanks

thanuxxxx
2020-12-24 01:06
Okay, I redid everything with Junit5 + SpringBoot, but I am getting a similar error j`ava.lang.RuntimeException: Could not resolve property "pactbroker.host" in the system properties or environment variables and no default value is supplied`

uglyog
2020-12-24 01:07
How are you running the test?

uglyog
2020-12-24 01:08
Have you tried cloning the example project and running that?

thanuxxxx
2020-12-24 02:32
I cloned `https://github.com/pact-foundation/pact-jvm` project and did the same thing as I did for my project. I get the same error

uglyog
2020-12-24 02:50
Change that test with `PactVerificationSpringProvider` instead of `PactVerificationInvocationContextProvider` ``` @TestTemplate @ExtendWith(PactVerificationSpringProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { }``` and the values resolve for me

thanuxxxx
2020-12-24 02:51
Okay. That makes sense

thanuxxxx
2020-12-24 02:52
I think that would solve my problem as well

thanuxxxx
2020-12-24 02:52
Thank you so much

eungjun.yi
2020-12-25 14:25
has joined #pact-jvm

abhi.nandan
2020-12-27 09:50
hey, I am trying to ignore no pacts to verify by annotating the test class as `@IgnoreNoPactsToVerify(ignoreIoErrors = "${pact.verification.ignoreIoErrors:true}")` , when running the test, it is failing with the error -

abhi.nandan
2020-12-27 09:50
```au.com.dius.pact.core.pactbroker.NotFoundHalResponse: No HAL document found at path '<domain>/pacts/provider/<service-name>/for-verification' at au.com.dius.pact.core.pactbroker.HalClient.handleHalResponse(HalClient.kt:298) at au.com.dius.pact.core.pactbroker.HalClient.access$handleHalResponse(HalClient.kt:140) at au.com.dius.pact.core.pactbroker.HalClient$postJson$3.invoke(HalClient.kt:473) at au.com.dius.pact.core.pactbroker.HalClient$postJson$3.invoke(HalClient.kt:140) at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:38) at au.com.dius.pact.core.pactbroker.HalClient.postJson(HalClient.kt:471) at au.com.dius.pact.core.pactbroker.PactBrokerClient$fetchPactsUsingNewEndpoint$1.invoke(PactBrokerClient.kt:248) at au.com.dius.pact.core.pactbroker.PactBrokerClient$fetchPactsUsingNewEndpoint$1.invoke(PactBrokerClient.kt:138) at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:38) at au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchPactsUsingNewEndpoint(PactBrokerClient.kt:247) at au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchConsumersWithSelectors(PactBrokerClient.kt:214) at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:209) at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:111) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$$inlined$flatMap$lambda$1.invoke(PactJUnit5VerificationProvider.kt:77) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$$inlined$flatMap$lambda$1.invoke(PactJUnit5VerificationProvider.kt:34) at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:38) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.resolvePactSources(PactJUnit5VerificationProvider.kt:77) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:38) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:103) at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:271) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:107) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:42) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)```

abhi.nandan
2020-12-27 09:50
My provider test class looks as below - ```@Provider("skeleton-service") @PactBroker( host = "<host_name>", port = "443", scheme = "https", authentication = @PactBrokerAuth(token = "<pact_broker_token>"), providerTags = { "dev" } ) @IgnoreNoPactsToVerify(ignoreIoErrors = "${pact.verification.ignoreIoErrors:true}") public class MyServiceProviderContractTest { @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", 7771, "/")); System.setProperty("pact.verifier.publishResults", "true"); System.setProperty("pact.provider.version", "v1"); } }```

ebanster
2020-12-27 13:18
has joined #pact-jvm

onur.baskirt
2020-12-28 10:48
has joined #pact-jvm

abhi.nandan
2020-12-28 12:04
Is there a way to convert a spring-cloud-contract to pact dsl?

uglyog
2020-12-28 22:52
If you asking about an automatic one, I haven't heard of any


massimo.daros
2020-12-29 13:18
has joined #pact-jvm

chris.fullinwider
2020-12-29 18:15
has joined #pact-jvm

piotr.soltysiak
2020-12-30 16:55
has joined #pact-jvm

piotr.soltysiak
2020-12-30 17:07
Hi all! I'm very happy to start working with pact-broker and pact-jvm, but I have little trouble with properly setting it up correctly. I have the broker up and running on non-root path (`https://api.gw.url/path/to/broker`) which causes an error while trying to test the provider: ```java.lang.IllegalArgumentException: Invalid pact broker host specified ('api.gw.url/path/to/broker'). Please provide a valid host or specify the system property 'pactbroker.host'.``` Is there a way to provide the path to broker? Or should I host the broker on subdomain? (`https://pact-broker.api.gw.url` ) Cheers!

uglyog
2020-12-30 23:06
Could you raise an issue for that?

piotr.soltysiak
2020-12-31 08:03
https://github.com/pact-foundation/pact-jvm/issues/1282 raised with more detailed description

adrian.przybyla
2021-01-04 13:41
has joined #pact-jvm

dcorrales
2021-01-04 22:06
has joined #pact-jvm

jokubas.lekevicius
2021-01-04 22:10
has joined #pact-jvm

matt195
2021-01-05 16:35
has joined #pact-jvm

rafael.manzoni
2021-01-05 17:56
has joined #pact-jvm

animesh2712
2021-01-05 19:29
has joined #pact-jvm

info
2021-01-06 01:55
has joined #pact-jvm

pascal.libenzi
2021-01-06 10:57
has joined #pact-jvm

pascal.libenzi
2021-01-06 11:03
Hello all, and happy new year! I would like to use junit5spring plugin (version 4.1.9) for testing my provider with a pact broker which is behind an ingress controller with a path (https://example.com/pact-broker). It seems that it does not work when using @PactBroker annotation since we don't have pactBrokerUrl anymore, but host, port and scheme only (path param is missing...). Do you know if a workaround exists? I didn't find any trick in the documentation of the plugin for such configuration Thank you very much

brett
2021-01-06 18:55
has joined #pact-jvm

josh.rosenfeld
2021-01-06 19:39
has joined #pact-jvm

josh.rosenfeld
2021-01-06 19:56
Hi there! Wasn't able to find any documented support so I figured I'd ask here. I'm writing a contract test for an endpoint that prepends their json payload with four characters. (So think `{"name": "Joe"}` becomes `{}__{"name": "Joe"}`). This makes it hard to both write the contract and verify it. The verification fails because it is unable to parse the response as JSON and there is a similar issue writing the contract in the first place unless we, of course, omit those first four characters. Is there any way we can equip Pact with some way of filtering out these characters before trying to match the response? Or is there perhaps some way we can test for this unconventional response body?


uglyog
2021-01-06 23:02
Unfortunately, the payload is expected to be a valid JSON document. There is no mechanism to modify the response, so you might have to look at using something like Nginx to act as a proxy.

josh.rosenfeld
2021-01-06 23:03
Alright, good to know I didn't miss anything. Thanks for the response.

pascal.libenzi
2021-01-07 08:48
Yes I saw it after, but I can?t delete my post on slack :disappointed:

pascal.libenzi
2021-01-07 08:48
thank you for the notice by the way

carlo
2021-01-07 13:24
has joined #pact-jvm

danny.porrello
2021-01-07 16:48
has joined #pact-jvm

dawood.abbas
2021-01-08 07:00
has joined #pact-jvm

souravsen1
2021-01-10 12:55
Can anyone link me to a simple Pact-jvm example project using maven for simple consumer and provider services? I'm new to Pact and contract tests, so could really use some help on this. Thanks in advance.

souravsen1
2021-01-10 13:15
Any simple maven springboot example project using pact-jvm would work.

victoria.kruczek
2021-01-10 16:35
@victoria.kruczek has left the channel

cksharma122
2021-01-10 17:19
has joined #pact-jvm

cksharma122
2021-01-10 17:20
Hi I recently created a project to learn pact testing e2e flow. In my existing project we used to have build.gradle file in which config was simple to me ```pact { publish { pactBrokerUrl = 'http://localhost:80/' } }``` In my new project I'm having build.gradle.kts file and in which if I define the same thing I gets errors. I want to know, how can I define same thing in my build.gradle.kts file?

matt.fellows
2021-01-10 20:05
Seems more like a gradle question to me.

matt.fellows
2021-01-10 20:05
Or a Kotlin one

matt.fellows
2021-01-10 20:05
What specifically stops working?

caiquedpfc
2021-01-11 04:05
has joined #pact-jvm

henrik.rudstrom
2021-01-11 18:30
has joined #pact-jvm

eric
2021-01-12 10:23
has joined #pact-jvm

eric
2021-01-12 10:37
hi - can you please advise how to inject a request body using pact-jvm ? in the consumer: `body(PactDslRootValue.valueFromProviderState("key", "example value")` in the producer: `@State...` `public Map<String,Object> mymethod() {` `map.put("key","some test value")` `returm map;` `}` I would expect the "key" string to be replaced by "some test value" when running the test but this is not happening.. any idea what goes wrong or how to debug this ?

fnguyen
2021-01-13 00:39
has joined #pact-jvm

pollet_22
2021-01-13 16:04
has joined #pact-jvm

dshattuck
2021-01-13 20:49
has joined #pact-jvm

thomas.rosati
2021-01-13 21:58
has joined #pact-jvm

ranjanayush03
2021-01-14 07:43
Hi all I am facing an issue that upon matching on an API which accepts some query parameters, while writing consumer test then the interactions with query parameters embedded directly in the url are considered non-matching whereas when I seperate out the query as "match query" then it is working fine so is there any way so that I can specify the parameters inside the path itself..

uglyog
2021-01-14 07:47
If "match query" is working, why would you want to include it in the path?

ranjanayush03
2021-01-14 07:52
Actually we have a requirement where we are autogenerating the consumer side test cases and finding it difficult to includeit in the parameters inside match query so we thought of doing it in the path itself but it was failing there..

ranjanayush03
2021-01-14 07:53
So is there a way to include it in path itself .

uglyog
2021-01-14 07:53
If you put it in the path, it needs to match exactly

ranjanayush03
2021-01-14 07:54
Okay if I provide the exact path in the interaction builder then it will pass

ranjanayush03
2021-01-14 07:55
I tried matching it exactly but it failed when i tried running the test cases.

rahulsmalpani
2021-01-14 07:56
has joined #pact-jvm

uglyog
2021-01-14 07:59
It is intended to use the query parameter attributes, not the path. That is not supported, and matches won't work

ranjanayush03
2021-01-14 08:02
Okay so if i have an end point like "api/users?id=2" then I need to provide the "id" inside query param or will .path("api/users?id=2") work.?

uglyog
2021-01-14 08:04
`.path("api/users").query("id=2")`

ranjanayush03
2021-01-14 08:07
Thank you will try this...

sacha.camfferman768
2021-01-14 09:42
has joined #pact-jvm

brandonbeard86
2021-01-14 22:10
has joined #pact-jvm

geetishnayak
2021-01-15 01:02
has joined #pact-jvm

shettyg
2021-01-15 14:18
has joined #pact-jvm

shettyg
2021-01-15 14:22
Hi All.I am facing an error while implementing pact provider using Junit

shettyg
2021-01-15 14:22
Receiver class http://au.com.dius.pact.provider.spring.junit5.MockMvcTestTarget does not define or inherit an implementation of the resolved method 'abstract java.util.Map executeInteraction(java.lang.Object, java.lang.Object)' of interface http://au.com.dius.pact.provider.junit5.TestTarget. java.lang.AbstractMethodError: Receiver class http://au.com.dius.pact.provider.spring.junit5.MockMvcTestTarget does not define or inherit an implementation of the resolved method 'abstract java.util.Map executeInteraction(java.lang.Object, java.lang.Object)' of interface http://au.com.dius.pact.provider.junit5.TestTarget. Has anyone faced this error before

shettyg
2021-01-15 14:23
Has anyone faced this error before

phil.endsley
2021-01-15 14:29
What version are you using? Do you paste an example (redacted if necessary) of your current setup? Did you see the docs that have an example? https://docs.pact.io/implementation_guides/jvm/provider/junit5spring#usage at the very bottom

shettyg
2021-01-15 14:32
Yes I referred to the document and implemented the provider

shettyg
2021-01-15 14:32
```public class ContractVerificationTest { @Autowired private MockMvc mockMvc; @MockBean private MongoTemplate mongoTemplate; @MockBean private RestTemplateBuilder restTemplateBuilder; @MockBean private FeatureTogglesClient featureTogglesClient; @MockBean private RestTemplate restTemplate; @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new MockMvcTestTarget(mockMvc)); } @State("treatments exist") public void txMetadataExists() { // nothing to do, real service is used } }```

shettyg
2021-01-15 14:33
Its giving me response back

shettyg
2021-01-15 14:33
but in context.verifyInteraction(); its failing

shettyg
2021-01-15 14:34
```testCompile('au.com.dius:pact-jvm-provider-junit5:4.0.10') testCompile('au.com.dius.pact.provider:junit5spring:4.1.7')```

shettyg
2021-01-15 14:34
these are the versions I am using

phil.endsley
2021-01-15 14:50
I'm pretty sure this is because you have conflicting versions. I'm not sure if you need both of those dependencies or not. You could try commenting out the pact-jvm-provider-junit5 one. If you do need both, make them both the same version. The api was changed between those two versions 4.0.10: ```fun executeInteraction(client: Any?, request: Any?): Map<String, Any>``` 4.1.7 ```fun executeInteraction(client: Any?, request: Any?): ProviderResponse```

shettyg
2021-01-15 15:15
```testCompile('au.com.dius:pact-jvm-provider-junit5:4.0.10')``` Then these annotations are not working MockMvcTestTarget and State

phil.endsley
2021-01-15 15:16
Keep both if you need them, but you should use the same version across all the pact libraries. So they should both be 4.0.10 or 4.1.7

shettyg
2021-01-15 15:24
Do we have a 4.1.7 version for the below one

shettyg
2021-01-15 15:24
```testCompile('au.com.dius:pact-jvm-provider-junit5:4.0.10')```

phil.endsley
2021-01-15 15:26
> Then these annotations are not working MockMvcTestTarget and State They don't work, or you can't import them?

shettyg
2021-01-15 15:28
Can Import them but trying to compile it doesnt work

shettyg
2021-01-15 15:28
compile

natarajang1
2021-01-15 15:29
has joined #pact-jvm

shettyg
2021-01-15 15:30
If we use testCompile or TestImplementation the jars are not pulled properly

phil.endsley
2021-01-15 15:32
Hmm...well, I know there was a change a while ago where the packages were reorganized and new jars were produced. I think that was 4.0 -> 4.1, but I'm not 100% sure... I know `@State` was changed. At least, the package is different. In 4.1.7, it should be ```import au.com.dius.pact.provider.junitsupport.State;``` We don't use mockmvc, but `testCompile('au.com.dius.pact.provider:junit5spring:4.1.7')` works fine for us and everything we use.

shettyg
2021-01-15 15:40
Even if I keep the testCompile('au.com.dius.pact.provider:junit5spring:4.1.7') on build the gradle file it gives following error

shettyg
2021-01-15 15:40
error: package http://au.com.dius.pact.provider.junit5 does not exist import http://au.com.dius.pact.provider.junit5.PactVerificationContext; ^

phil.endsley
2021-01-15 15:47
It gets pulled in for us...idk The line above is the only pact dependency that's explicitly included, and it pulls in everything else we need.

natarajang1
2021-01-16 00:36
@phil.endsley i'm getting the below error even though host, port and protocol values are configured in application.yaml file. Invalid pact broker host specified ('${pactbroker.host:}'). Please provide a valid host or specify the system property 'pactbroker.host'.

bheemreddy181
2021-01-17 03:57
has joined #pact-jvm

bheemreddy181
2021-01-17 04:00
Team , I am using workshop implementation to run some quick tests using java , seeing below exceptions on step 1 ```2021-01-16T21:59:30.771-0600 [DEBUG] [org.gradle.internal.work.DefaultWorkerLeaseService] Worker lease root.1 completed (0 worker(s) in use) 2021-01-16T21:59:30.771-0600 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Daemon worker Thread 7: released lock on root.1 2021-01-16T21:59:30.771-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 2021-01-16T21:59:30.771-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception. 2021-01-16T21:59:30.771-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 2021-01-16T21:59:30.771-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Where: 2021-01-16T21:59:30.771-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Build file '/Users/user/eclipse-workspace/pact-workshop-jvm/providers/springboot-provider/build.gradle' line: 51 2021-01-16T21:59:30.771-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 2021-01-16T21:59:30.771-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong: 2021-01-16T21:59:30.771-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] A problem occurred evaluating project ':providers:springboot-provider'. 2021-01-16T21:59:30.772-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Call to fetch pacts from Pact Broker failed with an exception 2021-01-16T21:59:30.772-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 2021-01-16T21:59:30.772-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try: 2021-01-16T21:59:30.772-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. Run with --scan to get full insights. 2021-01-16T21:59:30.772-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 2021-01-16T21:59:30.772-0600 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org 2021-01-16T21:59:30.772-0600 [WARN] [org.gradle.internal.featurelifecycle.LoggingDeprecatedFeatureHandler] Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.6.1/userguide/command_line_interface.html#sec:command_line_warnings 2021-01-16T21:59:30.772-0600 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 2021-01-16T21:59:30.772-0600 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 813ms 2021-01-16T21:59:30.772-0600 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Run build'``` I have my pact broker running locally

matt.fellows
2021-01-17 08:10
Step1 doesn't interact with the pact broker. Have you checked out the step1 branch?

matt.fellows
2021-01-17 08:12
My guess is that you've run it from `master` which is the same as being in step13, so it's trying to download non-existent pacts from the broker

matt.fellows
2021-01-17 08:13
Might need to increase logging to see actual problem tho

bheemreddy181
2021-01-17 16:53
`./gradlew consumer:run` also fails with the same error - same normal gradle build too

uglyog
2021-01-17 22:46
Please provide details on the error that occurred. See https://docs.gradle.org/current/userguide/command_line_interface.html#command_line_interface for details on running Gradle tasks. The `-s` option prints out the error stack trace.

michel.neufeglise
2021-01-18 08:55
has joined #pact-jvm

bart.boersma
2021-01-18 10:48
has joined #pact-jvm

bheemreddy181
2021-01-18 16:01
here is what i see when i run `gradle build -s` on master

uglyog
2021-01-18 22:15
We need the full stack trace. Also, you should run the Gradle tasks as specified in the readme.

matt.fellows
2021-01-19 00:00
Anyone know how to split pact JUnit tests over multiple files? I'm sure it's possible but a search of the JVM docs doesn't help https://pact-foundation.slack.com/archives/C5F4KFKR8/p1610986004015100?thread_ts=1610721992.009100&cid=C5F4KFKR8 @michaelkochub

michaelkochub
2021-01-19 00:00
has joined #pact-jvm

uglyog
2021-01-19 00:06
The tests are annotation driven. They don't have to exist in the same test class.

matt.fellows
2021-01-19 00:07
Cool, and Pact JVM will simply merge the interactions into the pact right? (assuming you don?t clear the pact file in between)

uglyog
2021-01-19 00:08
Yes, using the values from the annotations

matt.fellows
2021-01-19 00:09
too easy!

monica.wu
2021-01-19 06:25
has joined #pact-jvm

makobernal
2021-01-19 08:23
has joined #pact-jvm

makobernal
2021-01-19 08:46
Hello! I was wondering if there under Pact Provider + Junit5 it is possible to "name" the single tests being run per consumer pact being verified. For instance in my block ```@TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); }``` I end up generating test tasks with the name `pactVerificationTestTemplate(PactVerificationContext)[1]`. As oposed to `Pact between consumer-xyz(version) and provider - (pact description here)`

makobernal
2021-01-19 08:47
IntelliJ test run example.

makobernal
2021-01-19 08:50
I have other provider verification tests using JUnit4 and `@TestTarget` where this was done automatically.

jibrail.idris
2021-01-19 10:11
has joined #pact-jvm

jibrail.idris
2021-01-19 10:27
Hi, I am getting this error message. What does it mean? `No ParameterResolver registered for parameter [http://au.com.dius.pact.provider.junit5.PactVerificationContext context] in method [void ccc.xxx.SomeTest.beforeTestCase(http://au.com.dius.pact.provider.junit5.PactVerificationContext)].`

jmvb.registros
2021-01-19 11:01
has joined #pact-jvm

yann.courtel
2021-01-19 11:06
Hi everyone, we are creating a new provider class in java but the consumer is using pact-net therefore the matchers version seem to be the problem. Anyone know if there is a specific SpringBoot annotation to make this work ? Here is the error after running it locally : Diff:       {     -  "json_class": "Pact::SomethingLike",     -  "contents": {     -    "httpStatus": 400,     -    "errorMessage": "You must fill in either the customerCaseId field or the scopusId.",     -    "date": "2021-01-12T14:41:17.178878"     -  }     +  "httpStatus": 400,     +  "errorMessage": "You must fill in either the customerCaseId field or the scopusId.",     +  "date": "2021-01-19T11:46:03.691868600"     } Thanks a lot

matt.fellows
2021-01-19 11:12
hmmm that .NET contract looks broken, it shouldn?t have the `json_class` bits in it

matt.fellows
2021-01-19 11:12
it?s either a _really_ old version, or something went wrong. Could you please share the contract?

yann.courtel
2021-01-19 12:57
It's an old version. The consumer version appears to be a 1.0.0 pact spec version.

matt.fellows
2021-01-19 13:06
Any chance that can be upgraded?

matt.fellows
2021-01-19 13:33
I'm no Java expert but I'm guessing it's the wrong annotation or a missing import/dependency. Could you please share your code?

matt.fellows
2021-01-19 13:33
Howtoexamples


matt.fellows
2021-01-19 13:34
There's a couple of Java examples there for reference

yann.courtel
2021-01-19 13:58
```{ "consumer": { "name": "CancellationApi" }, "provider": { "name": "cc.action" }, "interactions": [ { "description": "A request to create an action", "request": { "method": "post", "path": "/actions", "headers": { "Content-Type": "application/json; charset=utf-8" }, "body": { "customerCaseId": 2920754, "scopusId": "azerty", "customerId": "0000000NPY85", "idAction": 1, "description": "Ouverture", "userId": 4259, "txt": "txt", "message": "comment" } }, "response": { "status": 200, "headers": { "Content-Type": "application/json; charset=utf-8" }, "body": { "json_class": "Pact::SomethingLike", "contents": { "evolId": 2 } } } } ], "metadata": { "pactSpecification": { "version": "1.0.0" } }, "createdAt": "2021-01-15T15:25:42+00:00" }```

yann.courtel
2021-01-19 13:58
for my contract... yeah ideally it would need to be upgraded I know

yann.courtel
2021-01-19 14:15
so there is no way to validate this old version of PACT with a java provider ?

uglyog
2021-01-19 22:07
Are you using Maven?

uglyog
2021-01-19 22:09
Pact-JVM supports 1.0 Pact files, but that Pact file is not correct: ```"body": { "json_class": "Pact::SomethingLike", "contents": { "evolId": 2 } }```

tpham
2021-01-19 22:36
has joined #pact-jvm

natarajang1
2021-01-20 01:07
can some please help me on this issue?

jibrail.idris
2021-01-20 01:45
@matt.fellows The issue was that the @Test and @State methods cannot co-exist in the test class if it is executed in IntelliJ (ant task). `mvn test` runs fine.


matt.fellows
2021-01-20 01:56
Makes sense. The state handler is not a test

jibrail.idris
2021-01-20 01:59
Would be awesome if this can be included in the docs. Will definitely save engineers troubleshooting time because the error is too vague.

matt.fellows
2021-01-20 02:29
Is it in the docs to say that annotation _should_ be there? The `@Test` annotation is for actual tests, right?

matt.fellows
2021-01-20 02:34
I?m not sure guarding against the use of non-Pact annotations is something Pact should be doing. In this case, it?s clearly a JUnit issue

jibrail.idris
2021-01-20 02:39
@matt.fellows In principle, yes I agree with you. Practically, at times, engineers tend to mix the two because on the surface they appear to be the same and hence the confusion, as shown in the Github issue page, which is one of some that I found on Google. In my test scenario, the pact contract testing on the provider side becomes part of the integration tests because we are using that to validate the response state. Our @State annotated methods are filled with assert() after persistence implying that @State methods also become integration tests. In theory, we can extract the two; a clean integration tests away from contract testing. However, that would mean duplicate codes across both tests and hence combining the two makes sense from the maintainability point of view.

vishal.grover
2021-01-20 03:12
has joined #pact-jvm

phil.endsley
2021-01-20 03:21
@natarajang1 you asked a new question in a thread about something else. You'd get quicker help by asking with a new post. Can you post the code you have that's running into issues too. Specifically, the annotations on the class

matt.fellows
2021-01-20 05:21
I see what you mean. Perhaps there are others who?ve tried similar things

matt.fellows
2021-01-20 05:22
I believe you could still run assertions in those state methods, just not under a separate test context - am I right in thinking that?

jibrail.idris
2021-01-20 05:43
Yes. That's correct

priya.saraf
2021-01-20 08:43
has joined #pact-jvm

fahad.aj.khan
2021-01-20 08:58
has joined #pact-jvm

fahad.aj.khan
2021-01-20 09:05
Hello... I can't get pact-jvm to write the pact files. I've debugged into PactWriter.kt (vesion 4.1.14) and can see that it is writing the file on line 99. But that file does not ever appear on my machine.

fahad.aj.khan
2021-01-20 09:31
Please ignore my message above... Our build tools is removing the file after the test run.

nicole.jaenchen
2021-01-20 09:38
has joined #pact-jvm

vuttithatkrongyot
2021-01-20 10:10
Hi Andra, how was it going on, is it work or not? I wanna use pact with cucumber too.

dinakaran.ulaganathan
2021-01-20 13:59
has joined #pact-jvm

makobernal
2021-01-20 14:29
No, gradle

antonello
2021-01-20 15:57
Same issue here

yann.courtel
2021-01-20 16:07
Hey Matt, apparently, it does work with the 2.0.0 specifications. Thanks

natarajang1
2021-01-20 17:47
sure i'll start a new post, thanks and sorry about that

alan.nichols
2021-01-20 17:57
Hi everyone. I?m working with a team that?s creating pacts from android that are using the 3.0 specification, but the provider is using .net core which only supports up to 2.0 specification at the moment. As a result there are many warnings such as > WARN: Ignoring unsupported combine AND for path $[?something?] which I think means that it?s ignoring some of the contract and we aren?t getting the full coverage that we need. If this is correct then I?ve been asked about downgrading the android contracts to 2.0 specification but from reading up on this it seems like I?d have to install a very old version that doesn?t support kotlin, and then rewrite everything. Could anyone give me (or point me to) some more info about this please?

ptsiakos77
2021-01-20 21:55
has joined #pact-jvm

abubics
2021-01-20 23:10
I feel like there's a way to limit the features to a particular version, but I don't know what it is, or where the docs are

jibrail.idris
2021-01-21 00:51
Is it possible to use @TargetRequestFilter with @SpringBootTest?

jibrail.idris
2021-01-21 00:54
Currently, I am hardcoding my Authorization: Bearer token in the pact contract file and I want to remove that and put it in the provider request header

jibrail.idris
2021-01-21 01:03
Is @TargetRequestFilter even working at all?

uglyog
2021-01-21 01:09
Yes, if you're using JUnit 4

mhdtouban
2021-01-21 01:58
has joined #pact-jvm

mhdtouban
2021-01-21 02:43
Hello guys, am starting writing pact tests for our android project and I was wondering why wouldn't the pact file be generated, am I missing something here? those pact files would be uploaded to our broker, so no need to deal with the provider locally. ```class PactTests { @Pact(provider = "public_api", consumer = "Andromeda") fun createPact(builder: PactDslWithProvider): RequestResponsePact? { return builder .given("account exists") .uponReceiving("A request for account") .path("/auth/api/v1/users/me") .method("GET") .willRespondWith() .status(200) .body("[\n" + " {\n" + " \"response\":[\n" + " {\n" + " \"id\":2920615,\n" + " \"first_name\":\"John\"\n" + " }\n" + " ]\n" + " }\n" + "]") .toPact() } @Test @PactVerification("public_api") @Throws(IOException::class) fun test() { assertThat(true, `is`(true)) } }```

uglyog
2021-01-21 02:52
Are you using Gradle or Maven? If you enable debug logs, you will see logs indicating where the file is being written to

mhdtouban
2021-01-21 02:54
am using Gradle, i don't think it's getting generated i searched for it all the place.

matt.fellows
2021-01-21 02:55
> those pact files would be uploaded to our broker, so no need to deal with the provider locally. what do you mean by that one, sorry?

mhdtouban
2021-01-21 02:56
i mean i don't need to deal with the verification part.. all what i care about is generating the pact file and then i'll upload them to our pact broker.

matt.fellows
2021-01-21 02:57
If you could share the debug logs, we migth be able to help

jibrail.idris
2021-01-21 03:11
@mhdtouban Your JSON pact files should be in the pacts/ directory.

veeraprathap.n
2021-01-21 04:10
has joined #pact-jvm

mhdtouban
2021-01-21 05:04
ok so i made the class `extends ConsumerPactTest` and now am getting the following error ```java.lang.NoClassDefFoundError: org/apache/http/conn/ssl/TrustSelfSignedStrategy```

mhdtouban
2021-01-21 05:06
i didn't build a client yet, so am wondering why am getting that

uglyog
2021-01-21 05:07
That's the Apache HTTP library, which is used by the Pact framework

uglyog
2021-01-21 05:09
You need to have `org.apache.httpcomponents:httpclient:4.5.13` on your classpath

mhdtouban
2021-01-21 05:16
alright i added the library but am still getting the error, is there something else needed to bypass that ?

uglyog
2021-01-21 05:16
Did you add it to the correct classpath? It needs to be on the test one.

mhdtouban
2021-01-21 05:26
I added to project root build.gradle inside the dependencies

uglyog
2021-01-21 05:28
Can you show us?

mhdtouban
2021-01-21 05:31
``` dependencies { classpath 'org.apache.httpcomponents:httpclient:4.5.13' }```

uglyog
2021-01-21 05:33
It needs to be `testCompile` not `classpath`

mhdtouban
2021-01-21 05:37
unfortunately still getting the error

uglyog
2021-01-21 05:41
Where is the pact-jvm dependency defined?

uglyog
2021-01-21 05:43
Android provides it's own versions of the Apache HTTP libraries, so you can't run the tests as Android tests.

uglyog
2021-01-21 05:45
What version of Pact-JVM are you using?


mhdtouban
2021-01-21 05:46
they are defined same place. ```testImplementation 'au.com.dius.pact.consumer:junit:4.1.0'``` i was using 4.1.7 but after using 4.1.0 am getting different error now ```java.lang.NoClassDefFoundError: org/apache/http/entity/ContentType```

uglyog
2021-01-21 05:49
Are you running Android instrumented tests?

mhdtouban
2021-01-21 05:51
no it's a local unit test

matt.fellows
2021-01-21 06:07
Perhaps you could share a reproducable setup that we can look at, including the commands you?re running.

matt.fellows
2021-01-21 06:07
see howtoask for more

2021-01-21 06:07
Please see this page for some tips on how to ask for help to get the best response from the community https://docs.pact.io/help/how_to_ask_for_help

gayatree.eee
2021-01-21 07:19
Tried using -Dpact.filter.consumers=conumer1 to pick only consumer1 contract while verifying Provider build. But still it picks all the contracts from all the consumer. Please help!!

uglyog
2021-01-21 07:30
How are you verifying the provider?

gayatree.eee
2021-01-21 09:23
from local using maven verify

tsiakos
2021-01-21 09:24
has joined #pact-jvm

phillip.goff
2021-01-21 09:50
has joined #pact-jvm


gayatree.eee
2021-01-21 10:17
mvn verify -Pcontract-tests -Dpact.filter.consumers=consumer1

alan.nichols
2021-01-21 10:35
Found an actual section on it in the junit docs - https://docs.pact.io/implementation_guides/jvm/consumer/junit#generating-v2-spec-pact-files This seems to fix my problem.

alan.nichols
2021-01-21 11:29
That said we?re now struggling with getting the junit pact to generate a contract with numbers having ?type? matchers rather than the v3 only int, decimal etc

alan.nichols
2021-01-21 11:39
Posting here in case it?s lost in a thread. We are trying to make v2 contracts using a new enough version of pact to support kotlin, and can choose to make the contracts in specification 2.0, however we can?t work out how to select a type match for a number. the numberType methods seem to still be generating the contract with things like decimal matcher which aren?t supported in v2. Any suggestions of how we should be writing our pact to get a matcher of just type?

matt.fellows
2021-01-21 12:33
There is an annotation/parameter from memory that lets you specify the spec version that gets spit out

matt.fellows
2021-01-21 12:34
There you go. It?s in the `@PactTestFor` annotation

kjayachandra2000
2021-01-21 12:44
```pact { publish { pactDirectory = "$buildDir/pacts" pactBrokerUrl = 'https://pact.com/' pactBrokerUsername = 'username' pactBrokerPassword = 'password' } }``` hey lads, just want to check. is there a way to publish the contract's to pact broker without adding this to `build.gradle` file? :thinking_face: something like a java method

oleg
2021-01-21 13:05
has joined #pact-jvm

alan.nichols
2021-01-21 13:41
Thanks yeah that?s what we found. But then when we run our test a contract is created with things like ```"match": "integer"``` that isn?t supported by a v2 contract and so can?t be verified. I?m wondering is we need to build up our test with a different method in the dsl but I can?t find a likely candidate

alan.nichols
2021-01-21 15:54
I?ll circle back to this when I?ve confirmed but this may have been a caching issue

uglyog
2021-01-21 22:06
No, that's the only way

mhdtouban
2021-01-22 01:30
back to this issue https://pact-foundation.slack.com/archives/C9UN99H24/p1611207961008900?thread_ts=1611196998.004300&cid=C9UN99H24 which am getting now as well, I had apache jar added as a library since Apache HTTP client is deprecateded in android and the one downloaded through gradle doesn't have ContentType class. What would be a solution here to bypass that error?

geetishnayak
2021-01-22 07:36
Hello Everyone. I have a `build.gradle` file which has the pact properties present, where I have specified the bearer token and url etc for authentication purposes. When you run `gradle build` the bearer token gets verified against the URL and if the bearer token is invalid/present there is a 401 thrown which is obvious. But the problem is I do not want this authentication check to happen during the build phase. Is there any way to disable this? Also whats the recommended way to use the bearer token without checking it in to the source-code(build.gradle) which is accessible to everyone? Can it be passed as a property during the build phase? Thanks

kjayachandra2000
2021-01-22 08:31
i think this will help you, give a try ```pact { if ('pactVerify' in gradle.startParameter.taskNames) { serviceProviders { BusService { protocol = 'http' host = 'localhost' port = 8083 hasPactsFromPactBroker("http://localhost:80") } } } }```

geetishnayak
2021-01-22 08:50
Super. That worked. Thanks

matt.fellows
2021-01-22 08:52
:taco: for @kjayachandra2000, thanks!

gayatree.eee
2021-01-22 09:47
mvn pact:verify is throwing 404 for the contract tests added for spring boot based provider. The tests are being verified successfully when ran as a junit from the test class. Please advice

thomas.powell
2021-01-22 10:18
has joined #pact-jvm

wesleythomaswilliams
2021-01-22 10:33
Not sure if this is useful for your case, but we also test spring boot providers and we don't use pact:verify. Our jenkins pipeline executes the provider tests as part of our unit tests `mvn test` and we pass in `-Dpact.verifier.publishResults=true` to publish the results.

gayatree.eee
2021-01-22 10:35
Thanks for the quick reply. We are using pact:verify as we need to pass pact.filter.consumers as a plugin paramter

jibrail.idris
2021-01-22 11:51
@uglyog thanks

shettyg
2021-01-22 16:16
Hi All, I am trying to implement PACT Consumer in java using junit5. I am referring to the pact documentation using junit and junit5. Under juint we have ConsumerCLient and we have a separate Pact Consumer provided. So if I want to implement consumer using junit5 then what are the steps to follow. If I could get the step by step process would be better. Thanks

wesleythomaswilliams
2021-01-22 16:40
Are you using Maven to import dependencies etc?

shettyg
2021-01-22 16:42
yeah I am using maven

shettyg
2021-01-22 16:44
```@ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "treatments-metadata-api") public class ExampleJavaConsumerPactTest { @Pact(provider="treatments-metadata-api", consumer="hemocare-portal-api") public RequestResponsePact createPact(PactDslWithProvider builder) { return builder .given("test state") .uponReceiving("ExampleJavaConsumerPactTest test interaction") .path("/articles.json") .method("GET") .willRespondWith() .status(200) .body("{\"responsetest\": true}") .toPact(); } protected void runTest(MockServer mockServer, PactTestExecutionContext context) throws IOException { Assert.assertEquals(new ConsumerClient(mockServer.getUrl()).options("/second"), 200); Map expectedResponse = new HashMap(); expectedResponse.put("responsetest", true); expectedResponse.put("name", "harry"); assertEquals(new ConsumerClient(mockServer.getUrl()).getAsMap("/", ""), expectedResponse); assertEquals(new ConsumerClient(mockServer.getUrl()).options("/second"), 200); } @Test void test(MockServer mockServer) throws IOException { HttpResponse httpResponse = Request.Get(mockServer.getUrl() + "/articles.json").execute().returnResponse(); assertThat(httpResponse.getStatusLine().getStatusCode(), is(equalTo(200))); }```

shettyg
2021-01-22 16:45
This is what I have using juint and junit5 as per the pact document...not sure how to implement ConsumerClient

wesleythomaswilliams
2021-01-22 16:49
Have you looked at this example: https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit5/src/test/java/au/com/dius/pact/consumer/junit5/ArticlesTest.java I'm not sure about the need for the runTest method you have there.

shettyg
2021-01-22 16:56
It was present in the pact documentation using juint...but will not include it..Thanks

stefan.selent
2021-01-23 01:54
has joined #pact-jvm

natarajang1
2021-01-24 04:06
i'm trying to set tag and version of consumerVersionSelectors on provider thru system properties variable "pactbroker.consumerversionselectors.tags" instead of adding that in @PactBroker annotation. I want this to be dynamic based on the git branch for which the CI/CD build runs. I'm doing it in the code via. prop.put("pactbroker.consumerversionselectors.tags", patcTag); on @BeforeEach method but its seems to be not working.

uglyog
2021-01-24 04:09
It would be better to pass those values in from your CI build instead of doing it in code

natarajang1
2021-01-24 04:15
but how to set those values thru the build? sorry i'm not clear yet. Pact provider test cases will run as junit5 on spring MockMvcTarget

uglyog
2021-01-24 04:23
In the CI, it will probably have a build script that starts the Java test process.

natarajang1
2021-01-24 04:27
but do i need to use "pactbroker.consumerversionselectors.tags" to set the tag value?>

uglyog
2021-01-24 04:33
Yes, they can be set as an environment variable or as a system property for the test process (which is different to set depending on using Gradle or Maven)

natarajang1
2021-01-24 04:42
i tried passing it as -Dpactbroker.consumerversionselectors.tags=dev but its not getting set.

uglyog
2021-01-24 04:44
Because it needs to be set on the test process, not the Maven process. The build starts Maven, which starts a new JVM process to run the tests. They need to be set on *that* process.


natarajang1
2021-01-24 04:46
i'm currently running the test on Intellij (junit) and passing the above value in VM options

uglyog
2021-01-24 04:48
In that case, you need to use the JUnit test runner, not the Maven one

uglyog
2021-01-24 04:51
You can also set it as an environment variable

natarajang1
2021-01-24 04:52
let me try

natarajang1
2021-01-24 05:17
sorry my bad , i was running as gradle test not junit. so what i did is added VM options -Dpactbroker.consumerversionselectors.tags=local and in build.gradle > test i added ```systemProperty 'pactbroker.consumerversionselectors.tags', System.getProperty("pactbroker.consumerversionselectors.tags")``` now i can see this value populated in system.properties inside provider test class ```@BeforeEach void before(PactVerificationContext context) { Properties prop = System.getProperties(); }```

natarajang1
2021-01-24 05:18
but still it's not pulling the correct tag that i'm passing


natarajang1
2021-01-24 05:22
[from Pact Broker http://host:9092/pacts/provider/<consumer-name>/consumer/<provider-name>version/e66b9ef (Tag local)] ---- i see this in the console, so its pulling the correct tag i believe but when it publishes the results to broker i see other tags getting updated as well, any idea why this is happening?

uglyog
2021-01-24 05:29
Because all those tags refer to the same version of the Pact

mhdtouban
2021-01-24 05:32
hey @uglyog any workaround for the issue above?

natarajang1
2021-01-24 05:36
versions (gitsha) are different and here is the screenshot from broker UI. Since i'm running the test in local i'm expecting only "local" tag to get updated but not "feature". i cropped the consumer name and provider name for security reasons

uglyog
2021-01-24 05:38
Check the Pact that those tags point to, If it has the same contents, it has the same version

uglyog
2021-01-24 05:38
Has the Pact changed between local and feature?

natarajang1
2021-01-24 05:39
nope, its the same

uglyog
2021-01-24 05:44
Sorry, I'm not an Android developer, so I haven't heard of a fix for this issue.

uglyog
2021-01-24 05:44
One way would be to run the tests as normal java tests, and not include any Android libs

uglyog
2021-01-24 05:45
Or exclude the Apache HTTP client from the Android libs

mhdtouban
2021-01-24 06:14
that's the thing, am running those as a unit tests without android interference.

uglyog
2021-01-24 06:20
But your build has the wrong version of the Apache HTTP client on the classpath, you need to work out why.

uglyog
2021-01-24 06:22
Try running `./gradlew dependencies` on your project and have a look at all the test dependencies

uglyog
2021-01-24 06:23
Also look at all the plugins you are using. Some plugins (like Spring) can alter the dependencies

mhdtouban
2021-01-24 06:34
right, seems we weren't getting the correct version of the Apache HTTP. the issue is solved now. thanks

uglyog
2021-01-24 06:44
Can you add a comment to the issue on how you resolved the issue?

kjayachandra2000
2021-01-25 07:04
I am using something like this, you can replace the tags with environment variables. You can give a try with the below code ```pact { publish { pactDirectory = "$buildDir/pacts" pactBrokerUrl = 'http://pact_broker_app:80' tags = ["test","prod"] } }```

c.pavan1986
2021-01-25 11:22
On using the pactbroker.consumers in @PactBroker annotation, its giving runtime error

c.pavan1986
2021-01-25 11:22
org.junit.runners.model.InitializationError

c.pavan1986
2021-01-25 11:27
On using the pactbroker.consumers in @PactBroker annotation, its giving runtime error org.junit.runners.model.InitializationError


paulo
2021-01-25 11:37
has joined #pact-jvm

c.pavan1986
2021-01-25 12:03
Looks like pactbroker.consumers is deprecated, but how do we configure it from system properties if we have to use consumerVersionSelectors, https://github.com/pact-foundation/pact-jvm/commit/677cc2d2575ad25a4ed5a9036bca9c2c6e999c3c


natarajang1
2021-01-25 13:35
sure thanks

natarajang1
2021-01-25 14:07
I tried setting it as system property pact.provider.tag to local but still seeing the same issue. Here is the screen shot

kmckeever
2021-01-25 14:38
has joined #pact-jvm

mhdtouban
2021-01-25 15:27
sure, ill

mhdtouban
2021-01-25 16:18
done

robert.land
2021-01-25 19:25
has joined #pact-jvm

aparnachaudhari
2021-01-25 21:34
has joined #pact-jvm

uglyog
2021-01-25 22:39
Please provide the runtime error and stack trace so we can try help you

uglyog
2021-01-25 22:41
That is not deprecated. Where did you get the idea that that was so?

uglyog
2021-01-25 22:45
It is because it is the same Pact file, so all the tags and verification results are applied to it. If in your branch, if you published a Pact with changed contents, you will see the tag and results only apply to the new one.

gwhill7
2021-01-25 23:23
has joined #pact-jvm

ruben.cagnie
2021-01-26 00:16
I'm trying to write a test class where I want to setup my contracts in the function that is annotated with `@Pact` , but has multiple `@Test` for each endpoint. The problem I am running into that every test fails because not all contracts are exercised in that test - `The following requests were not received` . Is there a way or will I have to (a) make 1 Test class per endpoint or (2) combine all my tests into 1 `@Test`?

uglyog
2021-01-26 00:19
Define separate `@Pact` methods for each test that only have the expectations for that test.


ruben.cagnie
2021-01-26 00:40
Thanks for the quick reply @uglyog. That seems to do exactly what I was looking for, thanks!

ruben.cagnie
2021-01-26 00:40
I do have some weird behavior, that if I test 1 contract, it works fine, but if I have the same test with other contract tests, it starts failing

uglyog
2021-01-26 00:43
Can you provide the error?

ruben.cagnie
2021-01-26 00:47
Looking into the logs, it looks like the wrong method is called

ruben.cagnie
2021-01-26 00:47
So the outline of my functions: ``` @Pact(consumer="xxx") fun setupTransactionPacts(builder: PactDslWithProvider): RequestResponsePact { @Pact(consumer="xxx") fun setupCreateAccountPacts(builder: PactDslWithProvider): RequestResponsePact { @Test @PactVerification(fragment = "setupCreateAccountPacts") fun testCreateAccount(mockServer: MockServer) { @Test @PactVerification(fragment = "setupTransactionPacts") fun testTransactions(mockServer: MockServer) {```

ruben.cagnie
2021-01-26 00:48
But for the `testTransactions` , I get the following in the logs: ```Invoking method 'setupCreateAccountPacts' to get Pact for the test 'testTransactions'```

ruben.cagnie
2021-01-26 00:57
I found it. I was stepping through the code and apparently the annotation to be used is ```@PactTestFor(pactMethod = "setupTransactionPacts") ```

uglyog
2021-01-26 01:07
Ah, you're using JUnit 5

natarajang1
2021-01-26 01:49
@uglyog Yes, feature and local has the same contract. Let me explain what i'm trying to achieve here. I'd like to publish the pact contract (from consumer) when CircleCI builds from feature and master branch. Now on broker there will be 2 tags (feature and master) for the same contract with same consumer and provider name and contract will be same. When provider test runs and publishes the results i want only contract with "feature" tag to be updated but not the master tag. How can i achieve this?

uglyog
2021-01-26 02:02
You can't. They are the same Pact file, so all tags and results will be applied to it.

uglyog
2021-01-26 02:03
If you want to test that behaviour, make a change so that the Pact file is different on your branch.

natarajang1
2021-01-26 02:05
thanks and appreciate your help!

jmvb.registros
2021-01-26 10:36
Hi all, I started reading about pact not so long ago and I've seen there a few ways to implement the consumer (java8, junit5...) I have a question regarding the assertions of the test. Let's say we have a json object looking like, where we want to check that all the keys (seconds & minutes) are present ```{ seconds: 10 minutes: 20 }``` I've seen a working assertion looking like ```assertFalse(JsonPath.read(httpResponse.getEntity().getContent(), "$.seconds").toString().isEmpty());``` My question is, 1) is there any cleaner way of writing these assertions? 2) how show I implement the consumer to make the assertions more readable and simple?

matt.fellows
2021-01-26 12:10
Pact already makes these assertions as part of what it does. But usually you would be unit testing your API client, and not just issuing HTTP calls to pact in the test code, bypassing your real code. Can you please share your test code so we can help make it clearer?

jmvb.registros
2021-01-26 12:23
```@ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "dateProvider", port = "1234") public class PactAgeConsumerTest { @Pact(consumer = "ageConsumer") public RequestResponsePact validDateFromProvider(PactDslWithProvider builder) { Map<String, String> headers = new HashMap<String, String>(); headers.put("content-type", "application/json"); return builder .given("valid date received from provider") .uponReceiving("valid date from provider") .method("GET") .queryMatchingDate("date", "2001-02-03") .path("/provider/validDate") .willRespondWith() .headers(headers) .status(200) .body(LambdaDsl.newJsonBody((object) -> { object.numberType("year", 2000); object.numberType("month", 8); object.numberType("day", 3); object.numberType("seconds", 3); object.booleanType("isValidDate", true); }).build()) .toPact(); } @Test @PactTestFor(pactMethod = "validDateFromProvider") public void testValidDateFromProvider(MockServer mockServer) throws IOException { HttpResponse httpResponse = Request.Get(mockServer.getUrl() + "/provider/validDate?date=2001-02-03") .execute().returnResponse(); assertThat(httpResponse.getStatusLine().getStatusCode()).isEqualTo(200); assertThat(JsonPath.read(httpResponse.getEntity().getContent(), "$.isValidDate").toString()).isEqualTo("true"); assertFalse(JsonPath.read(httpResponse.getEntity().getContent(), "$.seconds").toString().isEmpty()); } }```

ruben.cagnie
2021-01-26 12:39
Yeah, I should have mentioned that. Thanks for the plug though, it made me look further into annotations!

ruben.cagnie
2021-01-26 13:18
I do run into the issue that both tests write the same contract JSON file, so they are basically overwriting each-other... Any way to specify the name of the JSON file being written?

phil.endsley
2021-01-26 13:19
Somewhere in your code, you should have a method that is making the call to `provider/valiDate.` Instead of making a direct http call to the mock server, you should call that method instead. What you're doing is essentially the same as ```MyClass mockClass = mock(MyClass.class); Mockito.when(mockClass.getNumber()).thenReturn(2); assertThat(mockClass.getNumber()).isEqualTo(2);``` By calling the real method, you couple your test to the actual code that gets invoked in production. This makes sure your actual code and tests don't drift. Another way to think about it, is if you changed your production code to call `/provider/v2/valiDate` , your test above would continue to pass.

bibinc99
2021-01-26 14:37
has joined #pact-jvm

jmvb.registros
2021-01-26 19:43
First of all, thanks for the quick response :clap: I am clearly confused at this point and might be wrong but isn't the point to call a mock provider from the consumer point of view? What I have in mind is 2 separate projects(teams); 1 is the consumer and 1 is the provider. Did you mean to create any sort of DummyConsumer where you just implement these methods? I haven't seen anything like that and but I found in the docs is a similar implementation I'd say https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit5/src/test/java/au/com/dius/pact/consumer/junit5/ArticlesTest.java I appreciate it and I'm happy to have a look at any docs that you might suggest Thanks

phil.endsley
2021-01-26 19:52
> but isn't the point to call a mock provider from the consumer point of view? Yes > What I have in mind is 2 separate projects(teams); 1 is the consumer and 1 is the provider. Yes, exactly. Of course, the number of each of these can expand to whatever number (1 consumer, 3 providers or whatever combination you need) > Did you mean to create any sort of DummyConsumer where you just implement these methods? No I pressed send too soon, so I'll elaborate more in another comment :slightly_smiling_face:

phil.endsley
2021-01-26 20:00
So, like you said, for a single pact, you'll have one consumer (The application that calls, or consumers, the api) and one provider (The application providing the api). The consumer is responsible for defining the contract. It does this by defining the expectations in unit tests, exactly like you did in your original post. Once the contract is defined, it is generated by running tests that validate the consumer is actually using the api how it says it is. i.e. If a consumer wants to generate a contract that expects a `/provider/valiDate` endpoint, it needs to prove that it actually calls that endpoint. To do this, a unit test is used. When running the unit test, the Pact framework will start a mock server, which serves up the expected contracts as defined by the consumer. The best way to do this, is to call the methods in your code base that make those API requests. When you do this, you're verifying that the consumer is calling all the expected/defined services, and handles the responses in an appropriate way. Once this is done, a contract will be generated. On the provider side, that generated contract is then used to make the defined api calls against the provider. The pact framework then makes sure the responses the provider gives match what is defined in the contract.

phil.endsley
2021-01-26 20:01
When you're writing the consumer tests, this means that your application should be able to configure the host you make calls to, so you can change it to make calls to the mock server for the pact tests.

phil.endsley
2021-01-26 20:04
I need to get around to getting the rest of the branches merged into the official repo, but here's a workshop broken down into different steps of the process: https://github.com/pendsley/pact-workshop-jvm-spring-1/tree/master I know there's also other workshops for other languages. The implementation details might be a little different, but the concepts as a whole apply across all languages

phil.endsley
2021-01-26 20:05
Howtoexamples


phil.endsley
2021-01-26 20:05
Howtolearn

2021-01-26 20:05
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

phil.endsley
2021-01-26 20:05
Those are both good resources for further reading/learning

jmvb.registros
2021-01-26 20:29
Thanks so much for breaking it down. I definitely will check all the mentioned resources and will also check the repo :slightly_smiling_face:

jmvb.registros
2021-01-26 20:30
Much appreciated

jokubas.lekevicius
2021-01-26 20:31
Hi Ruben, The contracts should have different names! Contract names are defined in `.uponReceiving()` (filename depends one the consumer - producer name pairs, which are defined in the class level annotation @PactTestFor(providerName =...) and in the pact @Pact(consumer=..., producer=...) AFAIK)

jmvb.registros
2021-01-26 20:32
I think I see now what you meant when you referred to this `The best way to do this, is to call the methods in your code base that make those API requests. When you do this, you're verifying that the consumer is calling all the expected/defined services, and handles the responses in an appropriate way.`

ruben.cagnie
2021-01-26 20:37
So both my tests test the same consumer+producer. This leads to the json files having the same name and being overwritten...

jokubas.lekevicius
2021-01-26 20:38
That's weird, normally it should write to the same file, but the contracts should be appended to it

ruben.cagnie
2021-01-26 20:39
If you add all the contracts in the same `@Pact` method, then yes it is (which I'm doing now)

matt.fellows
2021-01-26 21:30
Awesome response @phil.endsley :taco:

uglyog
2021-01-26 22:19
It will merge the contents into the Pact file. It will not overwrite it.

abubics
2021-01-26 23:56
I concur, :taco: for @phil.endsley!

luisc.barretog
2021-01-27 00:42
has joined #pact-jvm

laxmi.somni508
2021-01-27 10:27
has joined #pact-jvm

ruben.cagnie
2021-01-27 15:44
Seems like the offender was this `systemProperty("pact.writer.overwrite", "true")`

ryanding16
2021-01-27 20:25
has joined #pact-jvm

ryanlevell
2021-01-27 20:58
Hello. Is it possible to pass consumer version selectors at runtime? I want to verify against only the master-branch-tagged contract during a Pull Request, but then follow-up verifying all the other tags in a non-blocking way. The reason is I don?t want my Pull Requests to be blocked by failed tests if one of my higher environment tagged contracts is failing. But I do want to block my Pull Request if the master-tagged contract is failing. I am also open to other suggestions. Thank you!

uglyog
2021-01-27 21:45
Ah! Yeah, that will do it.

ryanlevell
2021-01-27 21:49
Sorry I am using JVM but realized this might not be JVM specific.

uglyog
2021-01-27 21:55
If you're using JUnit, the annotations default to system properties


ryanlevell
2021-01-27 21:58
Excellent, thank you. For multiple tags is it comma separated?


ryanlevell
2021-01-27 21:59
Thank you

athurner
2021-01-28 13:55
has joined #pact-jvm

alex.mcnair
2021-01-28 18:35
has joined #pact-jvm

kflo
2021-01-28 19:35
question about pact-jvm and scala-pact: it seems to me it would be ideal to have a base java implementation and a separate scala implementation which sits on top of it and provides a more scala friendly DSL, and then have specific framework implementations sit separately on top of that. but it appears right now that pact-jvm and scala-pact have completely separate implementations. i?m just curious about why and if there are any plans to consolidate them at some point

kflo
2021-01-28 19:36
thread here

uglyog
2021-01-28 21:45
Scala-Pact was developed independently of Pact-JVM by the folks at ITV. I guess they thought the could create better support for the Scala eco-system if they built it from scratch.

kflo
2021-01-28 21:46
yep, i?m aware

kflo
2021-01-28 21:47
it seems best, in the long term, to consolidate it into a single implementation stack

kflo
2021-01-28 21:47
i have a fairly good idea now of what scala-pact provides, less so for pact-jvm, i should familiarize myself with it more

uglyog
2021-01-28 21:48
I would have thought they could have use some of the Pact-JVM core modules

kflo
2021-01-28 21:49
me too, i was surprised to see they didn?t

kflo
2021-01-28 21:50
it would be nice to have ?official? support for scala under pact-foundation

uglyog
2021-01-28 21:52
We would need someone with scala knowledge to manage that (handle feature requests, documentation, bug fixes, etc.) There is nobody with that atm.

kflo
2021-01-28 21:57
my company is a scala shop, and we have now adopted pact using the itv/scala-pact implementation at the moment. so i?m happy to help strengthen scala support. i guess i?m wondering where my time is best spent. i could continue working on the itv project, but i think it will always be falling behind the pact-jvm project as it is currently structured

uglyog
2021-01-28 21:59
That's awesome.

uglyog
2021-01-28 22:01
Maybe a way to start would be to start using some of the Pact-JVM libraries. For instance, for accessing a Pact Broker to fetch pacts.

kflo
2021-01-28 22:02
seems reasonable, does it make sense to do that work in the ITV project?

kflo
2021-01-28 22:03
will try to get some of the ITV folks in this thread as well

kflo
2021-01-28 22:03
@david.j.smith for example

kflo
2021-01-28 22:03
don?t want to ?hijack? their project :slightly_smiling_face:

uglyog
2021-01-28 22:05
You can also look at the scala support in Pact-JVM. It is nearly non-existant, and hasn't been looked at by anyone for maybe 5 years.

kflo
2021-01-28 22:05
i did take a quick peak at that, it seems to be a bit behind yes.

uglyog
2021-01-28 22:05
There is also an old ticket to get the SBT plugin working again

uglyog
2021-01-28 22:06
But I would prefer scala-pact to be updated as well

kflo
2021-01-28 22:07
seems like long term it might be better to have the scala stuff in it?s own repository

uglyog
2021-01-28 22:09
I'm ok with that. I had a lot of issues with SBT because of the way it names modules.

kflo
2021-01-28 22:11
eventually the scala libraries should just be a thin layer on top of the java libraries, as well as providing support for SBT

kflo
2021-01-28 22:11
(although you can also use SBT with java? so maybe that should also be in pact-jvm)

kflo
2021-01-28 22:12
anyways, i appreciate the early feedback, hopefully this is just a conversation starter and we can see where it goes

matt.fellows
2021-01-28 23:26
Coming in a bit late here, but generally agree with the sentiment.

matt.fellows
2021-01-28 23:26
I look at it a bit this way, albeit it?s not a completely fair comparison

matt.fellows
2021-01-28 23:27
We have Pact JS (it?s written in TypeScript actually). We get users of both TS and JS and it works as expected. There are many testing libraries too - Jest, Mocha, etc. We have separate packages that extend/adapt Pact JS to work in a more integrated way there

matt.fellows
2021-01-28 23:28
The challenge is maintaining a stable interface, for the ecosystem to innovate around, whilst also adding new features so that the ecosystem doesn?t have to re-invent the wheel

kflo
2021-01-28 23:28
agreed. hoping that stable interface can be pact-jvm

matt.fellows
2021-01-28 23:29
It?s worth exploring, for sure

kflo
2021-01-28 23:29
although maybe there was a good reason itv diverged, i?m not sure of the history

matt.fellows
2021-01-28 23:29
I recall there being a thread on Google Grroups, I can pull it up

kflo
2021-01-28 23:29
thanks!

matt.fellows
2021-01-28 23:30
Often times, it?s curiosity and technically interesting. For some history that I do remember - and ironically - Pact JVM was actually first written in Scala :stuck_out_tongue:

mailinglistsspammedme
2021-01-28 23:30
has joined #pact-jvm


kflo
2021-01-28 23:30
i think it is smart to keep the core in java as it is more portable

matt.fellows
2021-01-28 23:30
over time, that caused issues for non-Scala users (strange exceptions with `$` in them and all of the weirdness you might imagine a language like Java trying to explain Scala issues)

matt.fellows
2021-01-28 23:31
so Scala was stripped away, meaning the interface wasn?t very scala friendly.

kflo
2021-01-28 23:31
oh do i know. i have had to support a groovy application that uses scala JARs


matt.fellows
2021-01-28 23:34
no doubt conversations will be elsewhere in that group

andra.moraru
2021-01-29 07:55
Hi @vuttithatkrongyot yes, we managed to configure everything to run the cucumber tests against the pact mock service.

ranjanayush03
2021-01-29 08:43
Hi I have a query regarding the pacts that gets generated , actually I tried to generate the pacts by using both the jvm and pact-js approach for an end point as there were two seperate consumers consuming the api but on different technologies , the pacts that gets generated using the different approaches are different although on the provider side both the pacts are able to pass the test.

ranjanayush03
2021-01-29 08:45
As in jvm I made use of DslPart to construct the mock response while on js side I used the eachLike property that we need to specify in the body itself

ranjanayush03
2021-01-29 08:46
So the pacts generated are different in the matchers section but both the pacts passes the test , so is there anything that I am doing wrong?

uglyog
2021-01-29 09:00
Pact-JVM supports V3 pact files, while Pact-JS only V2. That's why they are different.

ranjanayush03
2021-01-29 09:02
Okay but the functionality are basically the same for both as in both the pacts were passing the test cases on provider side

ranjanayush03
2021-01-29 09:02
Or are there any difference between the two

matt.fellows
2021-01-29 09:03
Just think of them as equivalent

steven.beaver.retail
2021-01-29 15:34
has joined #pact-jvm

jokubas.lekevicius
2021-01-29 21:50
Hi, is the pact port exposed anywhere as a property, on the consumer side? I would love to use the random port and then inject it into other Spring properties. For now we're using a static port and I would love to avoid that

uglyog
2021-01-30 01:08
Are you using JUnit 4 or 5 tests? There is a mechanism to use a random port.

uglyog
2021-01-30 01:09
For JUnit 4, don't specify a port and then you can get the mock server base URL from the PactProviderRule. For JUnit 5, you just inject MockSever into your test method.

jokubas.lekevicius
2021-01-30 13:01
I'll try to explain my usecase, maybe you'll have an idea how to solve this. I'm using Junit5 and @SpringBootTest to override the providers endpoints, for example, when using Wiremock for more complex tests, I write the annotation like this ```@SpringBootTest(properties = { "external.service.url=http://localhost:${wiremock.server.port}" })``` My goal would be to override the external.service.url with something like ${pact.url} or pact.port.

ekberli.elbrus
2021-01-30 16:33
has joined #pact-jvm

ekberli.elbrus
2021-01-30 16:38
Hi everyone! I'm new in using Pact. Almost 2 days I'm trying to use pact but I cant find Pact Gradle config(plugin, dependency etc.). May anyone send me the simple Gradle config?

jokubas.lekevicius
2021-01-30 18:50
You're trying to configure it on consumer side, yes? Preface, I haven't used gradle for some time. I think the only thing that you need to do, is to import the test dependencies as you probably have junit or mockito imported. If you're using junit5 and java 8, you probably have to import these 2 dependencies: `au.com.dius.pact.consumer:java8:4.1.15` and `au.com.dius.pact.consumer:junit5:4.1.15` . Take my answer with a grain of salt though :smile:

ekberli.elbrus
2021-01-30 20:35
@jokubas.lekevicius thank you))

jokubas.lekevicius
2021-01-30 21:37
Please update if you got it working

natarajang1
2021-01-30 22:17
Hi, how to configure @State to take multiple values on provider side? i tried @State("name1", "name2") but getting --> error: annotation values must be of the form 'name=value'. i referred to example code in this link https://docs.pact.io/implementation_guides/jvm/provider/junit#example-of-http-test. i'm using au.com.dius.pact.provider:junit5spring:4.1.15 jar. Appreciate the help, Thanks.

phil.endsley
2021-01-30 22:20
Not at a computer to verify, but maybe try wrapping the arguments in curly braces

natarajang1
2021-01-30 22:21
yeah, i just tried and it worked... thanks

phil.endsley
2021-01-30 22:27
I guess we should follow up and update that example

uglyog
2021-01-31 00:26
You'll need to raise an issue to get spring support like that. You can try setting the spring property in a before method.

uglyog
2021-01-31 00:27
You can also try inject your class that uses `external.service.url` in the before method and set it there

natarajang1
2021-01-31 03:53
@ekberli.elbrus If you have pact broker and would like to publish the contract you would also need to add ```plugin { id 'au.com.dius.pact' version '4.1.15' } pact { publish { pactDirectory = 'build/pacts' pactBrokerUrl = 'http://<host>:<port>/' // using gitHash as version consumerVersion = getGitHash() } }```

ekberli.elbrus
2021-01-31 06:12
@natarajang1 thank you))

ekberli.elbrus
2021-01-31 06:13
@jokubas.lekevicius I used these and now its working ```plugins { id "au.com.dius.pact" version "4.1.7" } dependencies { testCompile 'au.com.dius.pact.consumer:junit:4.1.7' }```

ekberli.elbrus
2021-01-31 06:16
Hi again! Can anyone explain the difference between pact and postman(I mean on the testing side)? What we can do with Pact which cant do with postman tests?

brendan.donegan
2021-01-31 10:47
Pact provides a framework to enable the consumers of a services endpoints to define the contract with that service in such a way that the service can be confident about making changes without breaking this contract

brendan.donegan
2021-01-31 10:48
With Postman, if you make a change in the service then you can easily just update the test and it will now pass, even though the contract with the consumer is still broken

jokubas.lekevicius
2021-01-31 13:44
Thanks for the suggestions, before trying the workarounds, just wanted to make sure that I'm not missing anything :smile: Thanks for the answer

ekberli.elbrus
2021-01-31 14:34
@brendan.donegan thank you:slightly_smiling_face:


phil.endsley
2021-01-31 14:47
@jokubas.lekevicius :taco:

ekberli.elbrus
2021-01-31 15:15
Hi. I used both configs but I dont know why pact file doesn't create. Do you have any idea? 1st one: ```pact { publish { pactDirectory = 'target/pacts' pactBrokerUrl = 'http://localhost:8000' } }``` 2nd one: ```pact { serviceProviders { provider1 { // All the provider properties are optional, and have sensible defaults (shown below) protocol = 'http' host = 'localhost' port = 8080 path = '/' hasPactWith('consumer1') { pactSource = file('path/to/provider1-consumer1-pact.json') } } } }```

jokubas.lekevicius
2021-01-31 15:23
Are you trying to connect to a pact broker, or just generate a local pact file?

ekberli.elbrus
2021-01-31 16:27
@jokubas.lekevicius yeah just for local

jokubas.lekevicius
2021-01-31 19:47
What happens if you use neither of the configs and run your pact tests. Does the directory `build/pacts` generate for you?


uglyog
2021-01-31 21:52
These configurations are for verifying a provider against a Pact file. Pact files are created by running unit tests on the consumer side.

ekberli.elbrus
2021-02-01 05:48
@jokubas.lekevicius yeah pact file is created on the `build/pacts` but I want to change the directory

ekberli.elbrus
2021-02-01 05:49
@uglyog got it) thank you

jokubas.lekevicius
2021-02-01 07:04
Were you able to change the output directory? If not, I would think that this should work, maybe the problem earlier was that you had both the directory and pactBrokerUrl ```pact { publish { pactDirectory = 'target/pacts' } }```

daniel.tattan.birch
2021-02-01 09:38
has joined #pact-jvm

ekberli.elbrus
2021-02-01 10:38
Solved thank you))

ekberli.elbrus
2021-02-01 10:41
Is there any example for pact provider for localhost? I implemented the consumer and now I want to test it on the provider side.

jokubas.lekevicius
2021-02-01 10:43
Is this how you solved it?

ekberli.elbrus
2021-02-01 10:43
No I just keep my pact file on the build/pacts directory

jokubas.lekevicius
2021-02-01 10:48
https://docs.pact.io/implementation_guides/jvm/provider/gradle Here's a guide on what you need to do with your gradle config And then for the verification test itself, you can use https://docs.pact.io/implementation_guides/jvm/provider/junit5 as for an example project, I'm not sure, maybe others can help

ekberli.elbrus
2021-02-01 10:58
@jokubas.lekevicius I'm getting this error

ekberli.elbrus
2021-02-01 10:59
and my pact file is here

jokubas.lekevicius
2021-02-01 11:03
Can you show the contents of PactProviderTest?

ekberli.elbrus
2021-02-01 11:04
@jokubas.lekevicius

ekberli.elbrus
2021-02-01 11:05
I also tried this one `pact-contract-testing/build/pacts`

jokubas.lekevicius
2021-02-01 11:05
Your pact folder annotation tells Pact to search for pacts in the provider projects scope. What you need to do is to copy the pacts folder to your pact-provider/resources folder

jokubas.lekevicius
2021-02-01 11:06
and you can set your PactFolder to be like `@PactFolder("src/test/resources/pacts")`

ekberli.elbrus
2021-02-01 11:09
@jokubas.lekevicius I did but same situation((

jokubas.lekevicius
2021-02-01 11:11
Make sure the provider names are the same in the consumer and the provider. I'm seeing that the you named your ~consumer~ provider `MyAwesomeService` but the pact file has `test_provider` as the providers name. You might need to edit the name in the consumer and regenerate the pact

matt.fellows
2021-02-01 11:13
also double check the import. I think it should be: ```import au.com.dius.pact.provider.junitsupport.loader.PactFolder;```

matt.fellows
2021-02-01 11:14
I?m sure you?re just testing things out, but the overwhelming use case is to use a Pact Broker

matt.fellows
2021-02-01 11:14
if you?re lazy and just want to go quickly, you can spin up a free http://pactflow.io account for testing and demos.

matt.fellows
2021-02-01 11:15
If you?re going to demo to the team, the broker experience is going to add a lot more weight to the POC

matt.fellows
2021-02-01 11:15
You may also be interested in the Java tutorial (can be done in a browser): https://docs.pactflow.io/docs/tutorials

ekberli.elbrus
2021-02-01 11:21
@matt.fellows Yeah I have to do demo for team. After we'll decide to use pact or postman. What do you think which one we have to use? P.S. i'm working at the bank and we'll implement the BFF(Backend For Frontend)

matt.fellows
2021-02-01 12:03
Pact and postman are really different tools.

matt.fellows
2021-02-01 12:04
With different purposes etx

matt.fellows
2021-02-01 12:04
If you'd like a demo you can book one and we can take you through how pact works and demo to your team if that helps?

ekberli.elbrus
2021-02-01 12:06
@matt.fellows How can I book?

uladzislau_danilchyk
2021-02-01 12:09
Hi there! Maybe @uglyog can look into https://github.com/pact-foundation/pact-jvm/issues/1300 ? :slightly_smiling_face:


jokubas.lekevicius
2021-02-01 16:07
Is there a way to describe an array for a request where the order of the items would not matter? As I understood from the docs, request matching should be as strict as possible, so we need to describe all the expected values in them. With this approach I've encountered a problem. I can't ensure the order of items, because the request model has those in a HashSet, and the order is not guaranteed with it. I wouldn't like to use different kind of Set implementation just to please the testing framework. Let's say I have `.array("list_of_numbers", array -> array.numberValue(1).numberValue(2).numberValue(3))`. It will not always verify that a Set.of(1,2,3) is valid. Maybe I'm doing something wrong here.

jokubas.lekevicius
2021-02-01 20:14
While I'm at it, I'm trying to create test for a possible bug, but I can't get the pact-jvm project to compile on windows, using IntelliJ IDEA and Java 11. Anywhere here's the test code ```@ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "ApiProvider", port = "1234") public class NumberInObjectIssueTest { @BeforeEach public void setUp(MockServer mockServer) { assertNotNull(mockServer); } @Pact(provider = "config-service", consumer = "test-integration") public RequestResponsePact pactForTestWithNumber(PactDslWithProvider builder) { return builder .uponReceiving("Valid number") .path("/url") .method("PUT") .headers(Collections.singletonMap("Content-Type", ContentType.JSON.toString())) .body(LambdaDsl.newJsonBody(body -> body.numberValue("valid_number", 1.0)).build()) .willRespondWith() .status(200) .body("{\"data\":\"\", \"status\":\"success\"}") .toPact(); } @Test @PactTestFor(pactMethod = "pactForTestWithNumber") public void runTest(MockServer mockServer) { RequestLoggingFilter requestLoggingFilter = new RequestLoggingFilter(); ResponseLoggingFilter responseLoggingFilter = new ResponseLoggingFilter(); RequestSpecification requestSpec = new RequestSpecBuilder() .setContentType(ContentType.JSON) .setPort(mockServer.getPort()) .setBasePath("/url") .addFilter(requestLoggingFilter) .addFilter(responseLoggingFilter) .setBody(new RequestModel(1.0)) .build(); Response response = given().spec(requestSpec).put(); assertEquals("success", response.body().jsonPath().get("status")); } private static class RequestModel { private final Double validNumber; private RequestModel(Double validNumber) { this.validNumber = validNumber; } public Double getValidNumber() { return validNumber; } } }``` The problem is that I thought that a number is also an integer, but pact is telling me it's not.

george.south
2021-02-01 21:12
has joined #pact-jvm

abubics
2021-02-02 00:58
By default, I think there are no unordered set matchers. You could add a custom matcher, I guess? There is a general concern, though, about returning non-deterministic responses (which interferes with caching, and probably other things).

uglyog
2021-02-02 01:12
Ignoring array order has been added to 4.2.0.


abubics
2021-02-02 01:20
v4, so aspirational :heart:

ekberli.elbrus
2021-02-02 06:50
Hi everyone! Is it possible to write provider and consumer test in one package. Like below:

jokubas.lekevicius
2021-02-02 07:11
I think there's no stopping you from using both in one package, but that doesn't really make sense even in a demo scenario

matt.fellows
2021-02-02 07:44
Can you please elaborate on why? No technical reason you couldn't tho but it's certainly not the normal practice

ekberli.elbrus
2021-02-02 09:00
@matt.fellows Because I think in both case on provider side we just forward provider to the real provider link. That's why I think there is no need to additional module on the project

matt.fellows
2021-02-02 10:43
when you say ?forward to the provider?, do you mean that you point the verification at the running provider environment (e.g. staging/test)? That is also not best practice

ekberli.elbrus
2021-02-02 10:57
@matt.fellows Yeah as you see on below. First I run the UserApp and I point the UserApp on the provider

ekberli.elbrus
2021-02-02 10:58
What is the best practice for that? What should I do?

matt.fellows
2021-02-02 10:58
I?m sorry, screenshots of your IDE aren?t really helping with this conversation!

matt.fellows
2021-02-02 10:59
Your provider tests aren?t owned by the consumer - whoever owns the provider code base should be responsible for doinsg this. Related to this, the tests should run _with the provider tests_ not with the consumer test

matt.fellows
2021-02-02 10:59
there are a myriad of workflow issues that aren?t worth discussing right now, but if you don?t do it the way described above, you?ll be severely limited in your outcomes



ekberli.elbrus
2021-02-02 11:01
Okay. thank you very much @matt.fellows :slightly_smiling_face:

matt.fellows
2021-02-02 11:02
this is the full guide for CI/CD (which links to a really good workshop): https://docs.pact.io/pact_nirvana

matt.fellows
2021-02-02 11:02
If I recall, you were possibly wanting a demo with the team? If so, I (or somebody else in the team) can take you through a version of all of this in that session

mhdtouban
2021-02-03 00:15
Hi, am trying to publish the pact using `./gradlew pactPublish` but getting this error ```java.io.FileNotFoundException: /StudioProjects/andromeda/build/pacts``` i don't see pact generated in build folder but it's available in /target/pacts

uglyog
2021-02-03 00:23
If the pact files are in `targets/pacts` then you need to specify that directory

mhdtouban
2021-02-03 00:36
i added this to the the build.gradle ```apply plugin: 'java' // adds 'test' task test { systemProperties['pact.rootDir'] = "$rootDir/Andromeda/target/pacts" }``` but doesn't seems to be changing the directory

uglyog
2021-02-03 00:41
That changes the directory the pacts are written to when the tests run, not the directory the pacts are published from

twierzchowski
2021-02-03 07:05
has joined #pact-jvm

yassin.hajaj
2021-02-03 10:35
has joined #pact-jvm

yassin.hajaj
2021-02-03 10:36
:man-raising-hand:

kjayachandra2000
2021-02-03 11:35
```pact { publish { pactDirectory = '/target/pacts' pactBrokerUrl = 'url' pactBrokerUsername = 'username' pactBrokerPassword = 'password' } }``` just adding this incase it can be of any help :slightly_smiling_face: . document https://docs.pact.io/implementation_guides/jvm/provider/gradle#publishing-pact-files-to-a-pact-broker

dany.marques90
2021-02-03 12:48
has joined #pact-jvm

marcelo
2021-02-03 13:11
has joined #pact-jvm

sandeeparthur
2021-02-03 19:46
has joined #pact-jvm

uladzislau_danilchyk
2021-02-04 09:17
@uglyog, did you have a chance to have a look at this?

octoberclub
2021-02-04 16:27
has joined #pact-jvm

slavick
2021-02-04 17:21
has joined #pact-jvm

imran.settuba
2021-02-04 18:57
has joined #pact-jvm

christopher.roberts
2021-02-05 01:02
has joined #pact-jvm

christopher.roberts
2021-02-05 01:05
I just tried initializing my consumer / provider pacticipant names from an environment variable and it didn't work. Is this supported?

matt.fellows
2021-02-05 01:11
I just did some googling (read: fumbling). I?m assuming there needs to be some parameter resolver that is aware of this.

matt.fellows
2021-02-05 01:12
I can see the provider side has these imports: ```import au.com.dius.pact.core.support.expressions.SystemPropertyResolver; import au.com.dius.pact.core.support.expressions.ValueResolver;```

matt.fellows
2021-02-05 01:12
The provider (Junit5) has: ```import org.junit.jupiter.api.extension.ParameterResolver```

christopher.roberts
2021-02-05 01:16
I'm writing my consumer contract test at the moment, and I tried the following: `@PactTestFor(providerName = "${CI_PROJECT_NAME}", port = "1234")`

uglyog
2021-02-05 01:17
If they're set with annotations, they can not be overridden

matt.fellows
2021-02-05 01:18
Yeah, looking at the annotation definitions for things like `PactTestFor` and `Provider` there is no parameter resolver, unlike the `PactBroker` annotation

matt.fellows
2021-02-05 01:20
Is there a system property that can be used instead of the annotation? Searching through the docs I can?t see

christopher.roberts
2021-02-05 01:24
Another thing I tried which didn't work was: `System.setProperty("pact.provider.name", System.getenv("CI_PROJECT_NAME"));`

christopher.roberts
2021-02-05 01:24
In this case I'm trying to write a generic test which will test a common endpoint of all services in an inheritable project (for context)

matt.fellows
2021-02-05 01:30
yep I also tried this. Then I looked at the source and realised it wouldn?t work that way

matt.fellows
2021-02-05 01:30
or at least, I think it makes sense looking at it

r.darcel
2021-02-05 09:15
has joined #pact-jvm

christopher.roberts
2021-02-05 23:46
I was able to hack it to work by overriding `PactTestFor` and `PactConsumerTestExt` btw. On the provider side, I could actually use `pact.provider.name` . Still, it would be nice if it worked out of the box :)

uglyog
2021-02-06 00:50
If you could create a PR with your changes, that would be awesome.

ashish.joshi
2021-02-06 01:07
has joined #pact-jvm

christopher.roberts
2021-02-06 02:17
Is all the code in https://github.com/pact-foundation/pact-jvm ? I couldn't find the .kt file for `PactTestFor` in there


christopher.roberts
2021-02-06 02:27
ah ok, was looking at version 4.1.8

christopher.roberts
2021-02-06 02:50
remote: Permission to pact-foundation/pact-jvm.git denied to *****

uglyog
2021-02-06 02:55
Just clone it to your account, make the changes and then create the PR


przemek.sech296
2021-02-08 23:18
has joined #pact-jvm

vplows
2021-02-09 06:00
has joined #pact-jvm

wesleythomaswilliams
2021-02-09 13:02
.

rodney.stromlund
2021-02-09 16:18
has joined #pact-jvm

nada
2021-02-09 19:00
has joined #pact-jvm

siddhardhan
2021-02-09 20:21
has joined #pact-jvm

josh.rosenfeld
2021-02-09 20:30
Encountered an issue that I was hoping to get some clarity on. We have set up a provider for our monolithic service that builds through Bazel. Today, we added a second provider test class that tests a different endpoint in our service. When we run both classes, it errors with: `MissingStateChangeMethod: Did not find a test class method annotated with @State("Our first endpoint test") for Interaction ("our first endpoint") and Consumer SomeService`. Basically, our second provider test class fails because it is unable to verify the interaction that is verified in the first provider test class. Is it by design that all provider tests for a service should be consolidated to a single class or is this rather an issue possibly with Bazel not carrying Pact context over to the next test class it runs?

pbobba
2021-02-09 22:58
Hello pact-enthusiasts, I?m having trouble with fuzzy matching in pact-jvm. I?m trying to write a junit5 test which looks kinda like the attached _*dummyPact.java*_ file. When using pact-verify, I don?t really care for the value of field *?nums?* but I care about whether it?s an integer or not. The above test is generating _*generated.json*_ whereas the other _*tampered.json*_ is the one edited (matchingRules section) by hand to pass pact verification. You can refer to https://www.diffchecker.com/X9MZgA1c link to see the difference between generated vs tampered json files. I?ve referred to examples https://github.com/pact-foundation/pact-jvm/blob/00f3fe69955aa8e1eb988b7afbdfc1e5807cb851/consumer/junit/src/test/java/au/com/dius/pact/consumer/junit/Defect266Test.java and https://github.com/pact-foundation/pact-jvm/blob/00f3fe69955aa8e1eb988b7afbdfc1e5807cb851/consumer/junit/src/test/java/au/com/dius/pact/consumer/junit/WildcardKeysTest.java before posting here. Any help is appreciated! Thank you. @lbraymusso for visibility

uglyog
2021-02-10 00:55
You can share the state annotations between the tests by using interfaces or a base class. See https://github.com/pact-foundation/pact-jvm/blob/master/provider/junit/src/test/java/au/com/dius/pact/provider/junit/StateAnnotationsOnInterfaceTest.java for an example

josh.rosenfeld
2021-02-10 01:00
ah, interesting. So is it by design that you are either using one provider test class or several connected through interfaces or inheritance?

uglyog
2021-02-10 01:02
`eachKeyLike` is for matching all the attributes in an object. Do you expect to have more than one attribute like `nums`?

uglyog
2021-02-10 01:04
Yes, normally there would be one test. But there are mechanisms to filter based on consumer names or provider states.

lbraymusso
2021-02-10 01:47
Shouldn't be for this use case - an example response object for this scenario might look like the following: ```{ "nums": 0, "aggregations": {}, "rates: {}, }``` I believe `eachKeyLike` was something we simply tried after exhausting the original approaches with `numberType` (eg. `.numberType("nums", 782782)`) and `integerType` which we were unable to get working.

lbraymusso
2021-02-10 01:47
Essentially, we only care to match the data _types_ for each of the response body's keys (`nums` should be int, `aggregations` and `rates` should be obj) but in practice, the verification always fails on `nums` because it's expecting a literal value to be matched. The only way we've gotten around it is to manually add the `matchingRules` for `$.nums` to the contract (as shown in `tampered.json`) :sweat_smile:

uglyog
2021-02-10 02:11
That is exactly what `integerType` will do, what version of Pact-JVM are you using?

lbraymusso
2021-02-10 02:15
checking...

lbraymusso
2021-02-10 02:21
looks like the project's pact dependencies are ``` testImplementation 'au.com.dius.pact.consumer:junit5:4.1.0' testImplementation 'au.com.dius:pact-jvm-model:3.5.1'```

lbraymusso
2021-02-10 02:22
also of note: we're using a docker image (`pactfoundation/pact-cli:0.6.0.2`) to verify the resulting contract artifact against the provider endpoint, in case that's relevant here. of course, running the initial consumer contract test via junit works just fine, but the crux of the issue is that the generated contract (ie. `generated.json`) never furnishes the appropriate matching rules (as seen in `tampered.json`) we need to get past verification later on.

uglyog
2021-02-10 02:24
Don't mix the major versions of the Pact-JVM libs: 4.1.0 and 3.5.1. That is what is probably what is causing the issues.

lbraymusso
2021-02-10 02:28
ah, I thought that looked odd when i checked. caveat here is that I wasn't directly involved in setting up the project, so there might be a backstory to how we landed on those dependencies which i'm not privy to. hopefully Prathyusha can chime in later on, in case there was a reason for that deviation :smile: in the interim, is there a recommended combination that would be preferable (4.x versus 3.x) - and would that simply be a matter of bringing the dependencies in lockstep? eg: ``` testImplementation 'au.com.dius.pact.consumer:junit5:4.1.0' testImplementation 'au.com.dius:pact-jvm-model:4.1.0'```

uglyog
2021-02-10 02:35
``` testImplementation 'au.com.dius.pact.consumer:junit5:4.1.16' testImplementation 'au.com.dius.pact.core:model:4.1.16'```

uglyog
2021-02-10 02:35
Might as well use the latest version

lbraymusso
2021-02-10 02:36
indeed! will give it a go

lbraymusso
2021-02-10 02:43
looks like it's close - consumer test actually seems to be failing on something silly now, like it's enforcing a strict sequence for the response body keys: ```Expected :{\"nums\":0,\"aggregations\":{\"rates\":{}}} Actual :{\"aggregations\":{\"rates\":{}},\"nums\":0}``` i vaguely recall reading about some option to ignore the order - not sure if that would apply here?

lbraymusso
2021-02-10 02:49
this is how the relevant bit of code looks at the moment: ``` private static final String responseForFalseSku = new PactDslJsonBody() .integerType("nums", 0) .object("aggregations") .object("rates") .closeObject() .closeObject().toString();```

uglyog
2021-02-10 02:51
Don't call `toString()`, because you will loose all the matching rules. Pass the result directly to the `body` method

lbraymusso
2021-02-10 03:00
Ahh, good call

lbraymusso
2021-02-10 05:06
all right, just had a chance to tweak this so it's no longer sending the pact Dsl to a string: ``` private static final DslPart responseForFalseSku = new PactDslJsonBody() .integerType("nums", 0) .object("aggregations") .object("rates") .closeObject() .closeObject();``` it's still failing for the same sequencing reason as pasted above (albeit, slightly different now that it's a JsonObject rather than String being compared): ```Expected: is <{"numFound":0,"bucketAggregations":{"PrvRating":{}}}> but: was "{\"bucketAggregations\":{\"PrvRating\":{}},\"numFound\":0}"``` here's the relevant test method, which i modified to pass in the `DslPart` rather than `String` for `requestFalseSku` and `responseForFalseSku` : ``` @Pact (consumer="sf-reviews-provider") public RequestResponsePact skusNotFound(PactDslWithProvider builder) { return builder .given("A sku which is not found") .uponReceiving("test interaction") .path("/reviews/skus") .method("POST") .headers(headers) .body(requestFalseSku) .willRespondWith() .status(HttpStatus.OK.value()) .body(responseForFalseSku) .toPact(); } @Test @PactTestFor(pactMethod = "skusNotFound") void testSkusNotFound(MockServer mockServer) throws IOException { HttpResponse httpResponse = post(mockServer, requestFalseSku.toString()); assertThat(httpResponse.getStatusLine().getStatusCode(), is(equalTo(HttpStatus.OK.value()))); assertThat(CharStreams.toString(new InputStreamReader(httpResponse.getEntity().getContent(), Charsets.UTF_8)), is(equalTo(responseForFalseSku))); }```

lbraymusso
2021-02-10 05:07
(_that said:_ when i comment out that final problematic `assertThat` line and just let it run, the generated contract is looking much better :smile: `matchingRules` and all :thumbsup: )

uglyog
2021-02-10 05:07
Yeah, I was about to say that is not relating to the Pact libraries, but the assert

lbraymusso
2021-02-10 05:15
right. i'm just stuck on why it's trying to enforce the order of the keys so strictly - is that the expected behavior? on a whim, i tried adjusting `responseForFalseSku` to match the _literal_ order of the response body, but got an IDE error (`Cannot resolve method 'integerType' in 'DslPact'`) so i'm assuming there's restrictions on the order in which `PactDslJsonBody` can be built: ``` private static final DslPart responseForFalseSku = new PactDslJsonBody() .object("aggregations") .object("rates") .closeObject() .closeObject() .integerType("nums", 0); // throws 'Cannot resolve method' error``` either way, having to reorder the lines like that feels icky, even if that _did_ work, so the better question is probably - is there an advisable way we should rework that final assert statement so it's less strict about matching the order of the keys?

uglyog
2021-02-10 05:17
The issue is you are asserting that the response as a string is exactly equal to the generated JSON as a string. Try instead to parse the response to a JSON or a model object and assert on that.

lbraymusso
2021-02-10 05:21
cool, that's the approach i was leaning towards - just wanted to make sure i wasn't missing something obvious before proceeding. thanks! i'll give that a shot tomorrow and let you know how it goes - thanks for all your help so far, massively useful :raised_hands:

lars.hisken916
2021-02-10 08:08
has joined #pact-jvm

pauligoe10
2021-02-10 08:19
has joined #pact-jvm

tusharvarm
2021-02-10 09:38
has joined #pact-jvm

tusharvarm
2021-02-10 09:40
Hello..I have a json file which contains 25-30 fields in it and it is very difficult for me to create a pact body using LambdaDslJsonBody class. is there any way that I can parse the json file to LambdaDslBody object and use it to create pact file?

laxmi.somni508
2021-02-10 10:33
Hello Helpful folks, What is a best plugin/library for using PACT-Java in a project written in Scala code-base? If you've any sample example on Git/Stackoverflow of this kind then kindly let me know. Thanks STAY HOME-STAY SAFE:pray:

igorsharf
2021-02-10 10:39
has joined #pact-jvm

matt.fellows
2021-02-10 11:55
Might also be worth asknig in #pact-scala-itv

matt.fellows
2021-02-10 11:55
I?m not sure there _is_ a plugin/lib to do that. You either use Pact JVM or the scala variant. Keen for other perspectives

matt.fellows
2021-02-10 11:55
e.g. @kflo

laxmi.somni508
2021-02-10 11:56
We've the project code-base in Scala, but would like to try Pact JVM (Java variant) on top of it for Pact testing (Provider-side)

matt.fellows
2021-02-10 12:00
So are you looking for something else (you mentioned a plugin)

pbobba
2021-02-10 14:57
Went through the discussion. I din't think about checking for version clash. That's a nice catch. We set up this project 3.5 months ago so I don't recall the reason why those exact versions were chosen. Thank you both for spending time on this.

pbobba
2021-02-10 16:28
I've changed the versions as suggested ``` testImplementation 'au.com.dius.pact.consumer:junit5:4.1.16' testImplementation 'au.com.dius.pact.core:model:4.1.16'``` and am using ```pactfoundation/pact-cli:0.31.0.0` for verification.``` Matching rules are looking much better now but with `numberType` or `integerType` match shows up as ```"matchers": [ { "match": "integer" } ],``` This is still causing a failure in verification when expected value is not the same.

josh.rosenfeld
2021-02-10 17:12
i see. Thanks for clearing that up! That's very helpful

kieran
2021-02-10 17:13
has joined #pact-jvm

kflo
2021-02-10 17:33
@laxmi.somni508 unfortunately the pact-jvm library doesn?t have great scala support right now, both for SBT or for scala test frameworks (like scalatest). it is easiest to integrate with scala-pact https://github.com/ITV/scala-pact

kflo
2021-02-10 17:35
also of note, scala-pact does not implement pact-jvm, they are two divergent implementations at the moment

poward
2021-02-10 18:17
has joined #pact-jvm

ckhadilkar
2021-02-10 21:16
has joined #pact-jvm

matt.fellows
2021-02-11 01:56
is there any reason, apart from the fact that the DSL itself is not scala native, that Pact JVM couldn?t be used from within a Scala project?

lbraymusso
2021-02-11 02:20
I was able to reproduce the behavior Prathyusha describes FWIW -- here is an expanded snippet of the relevant portion of the newly-generated contract: ``` "response": { "status": 200, "headers": { "Content-Type": "application/json; charset=UTF-8" }, "body": { "numFound": 10, "bucketAggregations": { "PrvRating": { } } }, "matchingRules": { "body": { "$.numFound": { "matchers": [ { "match": "integer" } ], "combine": "AND" } }, "header": { "Content-Type": { "matchers": [ { "match": "regex", "regex": "application/json(;\\s?charset=[\\w\\-]+)?" } ], "combine": "AND" } } } },```

uglyog
2021-02-11 02:23
@pbobba `pactfoundation/pact-cli` does not support any of the V3 features (like the number type matcher). You need to use a normal type matcher.

lbraymusso
2021-02-11 02:24
Ah, I didn't realize that feature was part of the V3 spec. Are there any future plans to support V3 in the CLI image?

lbraymusso
2021-02-11 02:28
Alternatively - what did you mean by normal type matcher? is there a way we could still run verification through docker?

uglyog
2021-02-11 02:31
Hmm, that's a good point, there is no general `like` method on PactDslJsonBody. I'll add one.

uglyog
2021-02-11 02:32
I don't have any plans to upgrade pactfoundation/pact-cli to V3, and I haven't heard of anyone else mentioning that. But it needs to be done at some point.

lbraymusso
2021-02-11 02:33
Ah yeah, i think that's what was throwing me - we were able to achieve fuzzy matching with the `pact-python` client (which i'm fairly sure uses V2 spec for the most part) with the regular `Like` keyword, which i couldn't find an equivalent for in `pact-jvm` & thought i was missing something obvious :sweat_smile: that would be great!

lbraymusso
2021-02-11 02:33
Looks like there's an open issue about V3 support in the CLI repo already - https://github.com/pact-foundation/pact-provider-verifier/issues/61

lbraymusso
2021-02-11 02:35
FWIW, the use case for us preferring the `pact-cli` image is primarily the language agnosticism + ability for us to more easily support Pact in CI via Docker - we have to support engineers across ~4-5 major languages, so it's difficult to standardize on pact implementation without a common wrapper like that

uglyog
2021-02-11 02:35
The `pactfoundation/pact-ref-verifier` supports V3 spec, you could try use that instead

lbraymusso
2021-02-11 02:36
oh neat, i'll check that out. as a quick sanity check, does this also mean that things like Message Pact will not work with `pact-cli` ?

uglyog
2021-02-11 02:37
I don't know about Message Pact support with `pact-cli`, @matt.fellows might be able to answer that

lbraymusso
2021-02-11 02:38
ah wait, I just realized the 'V3 not supported' PR I linked to is _from_ the `pact-provider-verifier` repo :facepalm:

lbraymusso
2021-02-11 02:39
I'll give it a shot either way though since now i'm curious, hadn't seen the verifier before now

lbraymusso
2021-02-11 02:42
one final Q that came up in the course of debugging the fuzzy matching stuff above - after making the recommended changes, I noticed that the newly-generated contract was adding `charset=UTF-8` to the expected response and matchingRules, even though we've not defined this anywhere in our code (just `application/json`): ``` Failure/Error: expect(header_value).to match_header(name, expected_header_value) Expected header "Content-Type" to equal "application/json; charset=UTF-8", but was "application/json"``` Any idea how / why this would be happening in the contract? ``` "response": { "status": 200, "headers": { "Content-Type": "application/json; charset=UTF-8" },``` ``` "header": { "Content-Type": { "matchers": [ { "match": "regex", "regex": "application/json(;\\s?charset=[\\w\\-]+)?" }```

uglyog
2021-02-11 02:54
It adds that if the content type header is not set. If you set the header first, it will not add that.

lbraymusso
2021-02-11 02:56
hmm. do you mean setting it somewhere other than here? ``` @Pact (consumer="sf-reviews-provider") public RequestResponsePact skusNotFound(PactDslWithProvider builder) { return builder .given("A sku which is not found") .uponReceiving("test interaction") .path("/reviews/skus") .method("POST") .headers(headers) .body(requestFalseSku) .willRespondWith() .status(HttpStatus.OK.value()) .body(responseForFalseSku) .toPact();``` where `headers` is defined as `private Map<String, String> headers = Map.of("Content-Type", "application/json");`

matt.fellows
2021-02-11 02:58
you haven?t set a _response_ header, just a request one

lbraymusso
2021-02-11 02:58
oooof, right you are!

lbraymusso
2021-02-11 02:59
good catch

lbraymusso
2021-02-11 02:59
while you're here, @matt.fellows - not sure if you happened to catch the question above about whether `Message Pact` would be supported by `pactfoundation/pact-cli` ?

matt.fellows
2021-02-11 03:03
It kind of does, but not in a way that?s straightforward

matt.fellows
2021-02-11 03:03
I think the new rust based one would be a better path forward (e.g. https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier_cli-v0.8.4)

matt.fellows
2021-02-11 03:03
I haven?t tried message pact that way though. At a minimum, you?d need to start an HTTP server so that the CLI could ?invoke? your message providers

matt.fellows
2021-02-11 03:03
this for provider verification or consumer?


lbraymusso
2021-02-11 03:04
this would be for both, eventually - we're evaluating a way to broadly implement support for message pacts in a way that could be leveraged in CI

lbraymusso
2021-02-11 03:06
(we've intentionally restricted use cases to HTTP services for now since Message Pact support isn't evenly applied across all the client languages we'd need to potentially accommodate)

matt.fellows
2021-02-11 03:06
What were the languages you needed again? I think Java, Python were already discussed - what else?

lbraymusso
2021-02-11 03:08
Python was the biggest one because a ton of our python microservices are starting to use Kafka - at last check, Consumer support was _just_ added to pact-python https://github.com/pact-foundation/pact-python/pull/194, and the Provider support is https://github.com/pact-foundation/pact-python/pull/200, so we're chomping at the bit to evaluate that once it's merged in :smile:

lbraymusso
2021-02-11 03:09
other languages we'll eventually need to support are PHP, Javascript, and .NET -- I _think_ Message Pact is supported with PHP and JS, not sure about dotnet though

matt.fellows
2021-02-11 03:09
Yep, we had a few folks over here do the initial implementation. You can see how they did it if you were interested in porting that to .NET.

matt.fellows
2021-02-11 03:09
It?s not a huge amount of work to be honest, but we don?t have the .NET skills here to do it

matt.fellows
2021-02-11 03:10
There is no CLI tool for the consumer side I?m afraid

lbraymusso
2021-02-11 03:10
Gotcha. so meaning that there'd be no way to use the CLI to verify/publish consumer contracts that use Message Pact? or am i misunderstanding

matt.fellows
2021-02-11 03:11
that?s right. The way consumers work just doesn?t lend itself to a CLI tool this way. The provider side is a bit easier

matt.fellows
2021-02-11 03:12
Python (beta), Java, PHP, JS and Golang all have message support. It?s just .NET you?re losing out on

matt.fellows
2021-02-11 03:12
so you?re probably better off investing any effort to ?standardise? into the .NET DSL, rather than trying to build a generic consumer side message pact CLI

lbraymusso
2021-02-11 03:13
That's probably fine for now TBH (the language support for messages) - the biggest users of Kafka are Python & Java devs , we dont have many .NET users

matt.fellows
2021-02-11 03:13
or at least, I?m all ears on how you?d do it - because it would be handy to have a CLI approach

lbraymusso
2021-02-11 03:13
As for the CLI support for consumers, it's probably just because i haven't gotten my hands dirty with the consumer side of message pact that i didn't know there were added complexities there

lbraymusso
2021-02-11 03:14
But the ability for us to provide a generic consumer-side verification/publish capability for multiple languages (in CI) has been a huge plus for adoption just on HTTP services alone, so it's definitely something i'd want to look into once i have a chance to evaluate the Pact Python message support

matt.fellows
2021-02-11 03:15
Can you please elaborate on that? What have you done to standardise it?

matt.fellows
2021-02-11 03:15
that sounds interesting

lbraymusso
2021-02-11 03:15
Not sure how familiar you folks are with Buildkite (Melbourne based as well I believe?) but we've been building out a BK plugin for Pact - hence the need for it to be as 'one size fits all' as possible - within reason :stuck_out_tongue:

lbraymusso
2021-02-11 03:15
Planning to open source it eventually if others would find it useful

matt.fellows
2021-02-11 03:20
very familiar with BK! :stuck_out_tongue:

matt.fellows
2021-02-11 03:20
(we use it here as well FWIW)

matt.fellows
2021-02-11 03:20
and yes, would love to see that

lbraymusso
2021-02-11 03:20
oh, awesome! that would explain this - https://github.com/pact-foundation/pact-specification/issues/42 :stuck_out_tongue: (which can be closed, btw, there's a pact emoji on BK now!)

matt.fellows
2021-02-11 03:20
what does the BK plugin actually _do_ though

matt.fellows
2021-02-11 03:21
is there! Cool!

lbraymusso
2021-02-11 03:21
Yeah, i was planning to add one but someone beat me to it back in May lol


matt.fellows
2021-02-11 03:22
nice

lbraymusso
2021-02-11 03:25
So, at the moment, the plugin basically just wraps the `pactfoundation/pact-cli` and exposes the CLI args as plugin parameters so that any of our devs can use it regardless of language (and regardless of whether they are a consumer or provider service, since the CLI supports both) - so there's basically two main flows, the 'consumer' flow which validates the contract and then publishes it to the broker, and the 'provider' flow which pulls the contract down from the broker and runs verifications before deploy. it also supports the ability to spin up a dockerized instance of the service under test (part of the reason we prefer using docker for the CI solution - so pact and the provider service can be orchestrated together using docker compose)

matt.fellows
2021-02-11 03:26
how are the tests actually run though - in the context of the standard unit test framework? or only via the CLI itself?

matt.fellows
2021-02-11 03:27
I?m assuming on the consumer side, it?s just doing the `pact-broker publish` command and `pact-broker can-i-deploy` command right?

lbraymusso
2021-02-11 03:27
Yep, the tests still have to be run in a required preceding step - the plugin only handles everything from the "contract has been generated" state on

matt.fellows
2021-02-11 03:27
got it

lbraymusso
2021-02-11 03:27
that's where we drew the line on language agnostic support :smile:

matt.fellows
2021-02-11 03:27
got it

matt.fellows
2021-02-11 03:27
what you?re doing is exactly what we would recommend people do.

matt.fellows
2021-02-11 03:27
that?s why we docker it

lbraymusso
2021-02-11 03:27
glad to hear it!

matt.fellows
2021-02-11 03:27
on the provider side, I?m gathering you run the `pact-provider-verifier` command then and _not_ the provider side contract test in the native language?

lbraymusso
2021-02-11 03:32
i think it's just the generic `verify` command provided by `pact-cli` but yeah, def not using the native language for provider-side verification

matt.fellows
2021-02-11 03:32
oh yeah, that dispatches to the same command basically

lbraymusso
2021-02-11 03:33
yup

lbraymusso
2021-02-11 03:34
it's funny, we were literally just talking about plans to open source the plugin today - would love to connect with you guys once we have a beta version released to see if we're on the right path!

tusharvarm
2021-02-11 04:43
Can anyone please suggest me solution on this?

laxmi.somni508
2021-02-11 10:34
@matt.fellows - Thanks for your response. Yes. I meant a bridging plugin / library / example of implementation of Pact-JVM using Java, in a project having Scala /Play framework based code base

neild
2021-02-11 18:53
has joined #pact-jvm

kflo
2021-02-11 21:00
@matt.fellows you could certainly use pact-jvm within a scala project, but you?d have to write some integration code yourself in order to use it effectively with build tools like SBT and test frameworks. it?s do-able though. i started a thread awhile back about trying to reconcile the two projects so that the scala version of pact is built on top of the java version so they can better stay in sync? when i have a little more free time i?d like to explore what that would look like. hoping it wouldn?t be too big of a lift

mhdtouban
2021-02-11 22:14
hey, just a quick question cause I didn't find this in documentation. is there a way to pass a parameter through Gradle to publish task ? something like `./gradlew pactPublish -PpactBrokerToken=""`

painenigowthami
2021-02-11 22:32
has joined #pact-jvm

stephenkilbourn
2021-02-11 23:02
has joined #pact-jvm

tcarlson
2021-02-11 23:05
has joined #pact-jvm

uglyog
2021-02-12 00:04
If you configure it like so: ```pact { broker { pactBrokerUrl = 'https://your-broker-url/' pactBrokerToken = project.pactBrokerToken } }``` then the parameter will set the project property

mhdtouban
2021-02-12 01:02
hmm this token would be stored in a secured place (env. variables) in our CI and then passed by when calling the publish job.. so storing it in the project wouldn't be a feasible option

uglyog
2021-02-12 01:13
It's not stored in the project. All Gradle properties (including any created using `-P` ) are accessible on the Gradle `project` object

mhdtouban
2021-02-12 01:17
hmm trying out `./gradlew pactPublish -PpactBrokerToken="my token"` doesn't seem to be passing the token. also i had to add pactBrokerToken inside my `gradle.properties` file otherwise it will complain about ```Could not get unknown property 'pactBrokerToken' for root project of type org.gradle.api.Project.```

uglyog
2021-02-12 01:18
Ah, but the value comes from the command line?

mhdtouban
2021-02-12 01:21
yes i can see the value when printing it but the publish failed for some reason

mhdtouban
2021-02-12 01:21
401

uglyog
2021-02-12 01:21
That means the token was not correct

mhdtouban
2021-02-12 01:24
yeah i guess token was revoked because multiple failed tries. it's working out now with new token. Thanks

tusharvarm
2021-02-12 05:06
Hello Folks..I have a json file which contains 25-30 fields in it and it is very difficult for me to create a pact body using LambdaDslJsonBody class. is there any way that I can parse the json file to LambdaDslBody object and use it to create pact file?

abubics
2021-02-12 05:11
There are a couple of concerns to go with this . . . ? Are all of those fields significant for every interaction? ? JSON on its own doesn't represent the flexible matchers without building a new DSL, so the answer will probably stay "no"

abubics
2021-02-12 05:11
(When you say "I have a json file", I assume you mean that's the response from an API saved as a file . . . correct that if I'm wrong, please)

abubics
2021-02-12 05:13
If you want some kind of reuse, I'm sure there are ways to build that with helper functions, but that may be missing the point of writing unit tests that describe the interactions.

matt.fellows
2021-02-12 05:34
I do think there is merit in being able to do something like this `like({?representative json blob})` sort of thing, like what you can do in Pact JS for example

matt.fellows
2021-02-12 05:34
that would make it a simple way to get started

matt.fellows
2021-02-12 05:35
but as soon as you need to have specific matching rules on any property or nested value, you?re going to create a wrapper that?s eventually going to be as powerful as the one you?re trying to abstract away from :wink:

abubics
2021-02-12 05:51
yarr . . . it doesn't chop much off the start of the learning curve, but maybe still helpful

tusharvarm
2021-02-12 06:57
@abubics All the fields in the json file are required files. Also it is the request of the API endpoint which is created in form of json file

tusharvarm
2021-02-12 06:58
@abubics Do we have some kind of third party library which can be used to parse Json file to LambdaDslJsonBody object?

abubics
2021-02-12 06:59
I haven't seen anything like that, sorry. Very few parties outside pact-foundation provide standalone libs that integrate with Pact.

abubics
2021-02-12 07:00
Seems like you might want a helper function, or default structure where you can override specific fields (maybe a builder pattern?) to help reduce your copypasta

r.strauch
2021-02-12 10:15
has joined #pact-jvm

tusharvarm
2021-02-12 11:46
yeah that's true

tusharvarm
2021-02-12 11:47
Common question is how to create a LambdaDSLJSONBody object for the large request?

tusharvarm
2021-02-12 11:47
and all the fields are mandatory

ztlboy05
2021-02-12 14:57
has joined #pact-jvm

smith260194
2021-02-12 15:22
has joined #pact-jvm

smith260194
2021-02-12 15:29
Hi everyone :wave:, I am having trouble in setting default request headers for every pact using junit 5, is this possible?

smith260194
2021-02-12 16:06
This is for the consumer side, I see a way in the docs provider side but not for consumer side. But I do see a way to do it for junit4 :thinking_face:

dabfleming
2021-02-12 20:34
has joined #pact-jvm

prasanthp
2021-02-13 00:45
has joined #pact-jvm

uglyog
2021-02-13 00:48
It has only been implemented for JUnit 4

smith260194
2021-02-13 05:13
Thank you!

uglyog
2021-02-13 05:53
Raise an issue at the Github project to get it implemented for JUnit 5

jokubas.lekevicius
2021-02-13 17:45
There's this line in the https://docs.pact.io/faq/#can-i-generate-my-pact-file-from-something-like-swagger > Something that could be useful, however, is to generate skeleton Pact test code from a Swagger document. If you're interested in working on this, have a chat to the maintainers on the Pact Slack. Not sure if someone made any progress on this, but it sounds exactly like what you'd want

tjones
2021-02-14 15:00
I don?t have the code, but @abubics and I have written groovy tests for Scala code using pact-jvm. It?s definitely possible.

abubics
2021-02-14 22:20
@tusharvarm What language are you using? With Kotlin, I could structure the Java 8 DSL a lot better to make it readable. Still, the 25-30 field have to be specified somewhere...

bhardwajdiwakar
2021-02-14 22:38
has joined #pact-jvm

jun.li
2021-02-15 01:23
```Request to provider method failed with an exception: Failed to invoke provider method 'aConditionUserMitigatedEvent' (java.lang.RuntimeException)``` Hi, when I have a test has an null pointer exception I get message like this only showing me java.lang.RuntimeException, are there any way to show me full error trace like junit?

uglyog
2021-02-15 01:41
Set the JVM system property `pact.showStacktrace` to `true`

jun.li
2021-02-15 01:41
thanks

abubics
2021-02-15 03:01
Oh something I also missed, the question of whether the fields are relevant is different to whether they're mandatory. > Are all of those fields significant for every interaction? Like, you might have an item count, or status, or something, that's pertinent to some interactions and not especially relevant in others.

hiteshpatadia
2021-02-15 06:29
has joined #pact-jvm

laxmi.somni508
2021-02-15 10:28
Thanks, if you have any sample on Github/stackoverflow/medium etc.. then kindly share the link. It will be a big help . Thanks :+1:

vikrant.sarkaniya
2021-02-15 13:31
has joined #pact-jvm

lemitrou
2021-02-15 14:20
has joined #pact-jvm

bhardwajdiwakar
2021-02-15 14:30
Hi guys, I am still learning pact and wanted to go through it slowly. I?ve already gone through tutorials but all of them directly jumps to using pact-broker. Our endgoal is to use pact-broker and pactflow but, in order to convince our organization's larger team, we are planning to use it internally between 2 of our services. For starters we are planning to share pact json manually. I am not able to find a relevant tutorial for using a pact file in provider side and failing tests/build without using pact-broker or aws s3. Kindly provide relevant links/tutorials for this. P.S. I am able to use pact-broker but want to use physical json file. Kindly provide relevant links

phil.endsley
2021-02-15 14:45
On the provider, instead of using the `@PactBroker` annotation, you can use `@PactFolder`. Everything else is the same. There are a few other methods you can use too (ex: supplying a url), but the folder is probably easiest for a poc. https://docs.pact.io/implementation_guides/jvm/provider/junit/#pact-folder

bhardwajdiwakar
2021-02-15 16:24
Thanks @phil.endsley, Can this be achieved as a maven/gradle verification stage as well?

laxmi.somni508
2021-02-15 16:54
Thanks @tjones, if you have any sample on Github/stackoverflow/medium etc.. then kindly share the link. It will be a big help . Cheers..

abubics
2021-02-15 22:54
There are definitely options (https://docs.pact.io/implementation_guides/jvm/provider/gradle/#2-define-the-pacts-between-your-consumers-and-providers) for the gradle provider plugin, not sure about maven


tjones
2021-02-16 04:35
Sorry, I don?t have the code. Have a look for resources on calling scala from groovy (or whatever JVM language you prefer to write your tests in).

abubics
2021-02-16 05:03
I feel like we might've only done a Groovy test consumer, and then the Scala bits were using the itv plugin :thinking_face: it was, like, 4 years ago, though.

tjones
2021-02-16 06:46
I thought we didn?t use the itv plugin

tjones
2021-02-16 06:47
I remember it was spiked, but we needed something it didn?t support, so we did the consumer tests in groovy calling down to the client

abubics
2021-02-16 07:17
hm . . . I guess I could check . . . :upside_down_face:

helloraj
2021-02-16 08:09
has joined #pact-jvm

uladzislau_danilchyk
2021-02-16 09:42
Hi everyone! I have experienced with the following behavior when some of the tests failed but in reports/logs I can't see details (body diff, etc) what actually wrong. But some time ago it was working fine. But additionally I would like to add that I need to run debug panel with variables to see what was actually wrong. Could you investigate it?

wesleythomaswilliams
2021-02-16 11:12
25-30 fields seems pretty manageable, I've recently finished working on a contract that was about 600 fields (this was a MessagePact) and it wasn't built with LambdaDSLJSONBody, we're using PactDslJsonBody.

wesleythomaswilliams
2021-02-16 11:13
And yes, I'd have given my right arm for a tool that would have auto-generated that, but thankfully there was some repetition in the contract that allowed some level of copy/paste.

jamesmlucas
2021-02-16 19:29
has joined #pact-jvm

jamesmlucas
2021-02-16 19:57
Hi folks, I am trying to get a Pact consumer test running for first time and running into issue where the test fails with the following (details posted in thread reply)

jamesmlucas
2021-02-16 19:59
: ```org.apache.http.NoHttpResponseException: 127.0.0.1:1234 failed to respond``` I have this dependency in my build.gradle: ``` testImplementation "au.com.dius:pact-jvm-consumer-junit5:4.0.10"``` The test is modeled after the examples and is as follows (some code removed for brevity): ```@ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "si-service-platformconfiguration", port = "1234") public class AlternateIDServicePact { private Map<String, String> headers = MapUtils.putAll(new HashMap<>(), new String[] { "Content-Type", "application/json" }); @BeforeEach public void setUp(MockServer mockServer) { assertThat(mockServer, is(notNullValue())); } @Pact(consumer = "consumer") public RequestResponsePact sequence(PactDslWithProvider builder) { return builder .given("sequence request") .uponReceiving("a request for a sequence with orgs, type of PMConfig and desired quantity") .path("/hello") .method("GET") .willRespondWith() .headers(headers) .status(200) .body(new PactDslJsonBody() .stringType("prefix") .integerType("start") .integerType("end") ) .toPact(); } @Test @PactTestFor(pactMethod = "sequence") void test(MockServer mockServer) throws IOException { HttpResponse httpResponse = Request.Get(mockServer.getUrl() + "/hello") .execute() .returnResponse(); Assertions.assertEquals(httpResponse.getStatusLine().getStatusCode(), 200); } }``` Debug logging shows that request is being received and matching is being executed, but the http client seems to close prematurely: ```2021-02-16T13:51:02,284 DEBUG [HTTP-Dispatcher] a.c.d.p.c.BaseJdkMockServer: Received request: method: GET path: /hello query: {} headers: {Accept-encoding=[gzip,deflate], Accept=[application/json; charset=UTF-8], Connection=[Keep-Alive], Host=[127.0.0.1:1234], User-agent=[Apache-HttpClient/4.5.13 (Java/11.0.10)]} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: EMPTY 2021-02-16T13:51:02,284 DEBUG [HTTP-Dispatcher] a.c.d.p.c.m.RequestMatching$Companion: comparing to expected request: method: GET path: /hello query: {} headers: {} matchers: MatchingRules(rules={path=Category(name=path, matchingRules={})}) generators: Generators(categories={}) body: MISSING 2021-02-16T13:51:02,285 DEBUG [HTTP-Dispatcher] a.c.d.p.c.m.Matching: Found a matcher for text/plain -> au.com.dius.pact.core.matchers.PlainTextBodyMatcher@4756c6de 2021-02-16T13:51:02,285 DEBUG [HTTP-Dispatcher] a.c.d.p.c.m.RequestMatching$Companion: Request mismatch: [] 2021-02-16T13:51:02,286 DEBUG [Test worker] o.a.h.i.c.Wire: http-outgoing-2 << "end of stream" 2021-02-16T13:51:02,287 DEBUG [Test worker] o.a.h.i.c.LoggingManagedHttpClientConnection: http-outgoing-2: Close connection 2021-02-16T13:51:02,287 DEBUG [Test worker] o.a.h.i.c.LoggingManagedHttpClientConnection: http-outgoing-2: Shutdown connection 2021-02-16T13:51:02,287 DEBUG [Test worker] o.a.h.i.e.ConnectionHolder: Connection discarded 2021-02-16T13:51:02,288 DEBUG [Test worker] o.a.h.i.c.PoolingHttpClientConnectionManager: Connection released: [id: 1][route: {}->http://127.0.0.1:1234][total available: 0; route allocated: 0 of 100; total allocated: 0 of 200] 2021-02-16T13:51:02,288 INFO [Test worker] o.a.h.i.e.RetryExec: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http://127.0.0.1:1234: The target server failed to respond```

jamesmlucas
2021-02-16 20:01
I'm not able to debug the issue. It seems like the mock server is working correctly but possibly closing the connection prematurely?

gabe707
2021-02-16 20:31
has joined #pact-jvm

wangpei9679
2021-02-16 21:29
has joined #pact-jvm

matt.fellows
2021-02-16 22:59
hmmm strange

matt.fellows
2021-02-16 22:59
This does ring a bell, have you searched the Pact JVM issues?

geir
2021-02-16 23:03
has joined #pact-jvm

jamesmlucas
2021-02-16 23:12
Thanks for the response. Yes, have looked pretty thoroughly at existing issues. I got called onto something else, but I notice if I comment out the body in the mock, the test will pass, so I think it's something w/ the way I'm building the response body....

matt.fellows
2021-02-16 23:13
To my eyes, it looks completely sensible!

uglyog
2021-02-17 00:09
Can you try with the latest 4.1 version?

jamesmlucas
2021-02-17 04:11
Hi -- I haven't tried to use latest version -- I don't currently see anything later than 4.0.10 in maven. For the time being, it looks like casting the body to string is fixing issue: ``` .body(new PactDslJsonBody() .stringType("prefix") .integerType("start") .integerType("end") .toString() )```

uglyog
2021-02-17 04:22
But you loose the matchers that way ```implementation 'au.com.dius.pact.consumer:junit5:4.1.17'```

jamesmlucas
2021-02-17 05:24
:facepalm: Thank you. In the process of upgrading, I believe I found the core issue. Upgrading commons-lang3 to 3.11 (from 3.0) in my project appears to have fixed the issue in 4.0.10 as well. Thanks again for the assistance!

uglyog
2021-02-17 05:36
Ok, there is an issue for this. Could you add a comment on how it fixed it for you? https://github.com/pact-foundation/pact-jvm/issues/1054 and https://github.com/pact-foundation/pact-jvm/issues/1176

soruma.net
2021-02-17 05:58
has joined #pact-jvm

jamesmlucas
2021-02-17 07:06
Sure thing, done. Let me know if I can add any additional info.

uladzislau_danilchyk
2021-02-17 10:59
Hi everyone! How to tag provider after publishing verification results (junit5)? I thought about `pactbroker.providerTags` but maybe it is not..

uladzislau_danilchyk
2021-02-17 11:24
Found `pact.provider.tag`

uladzislau_danilchyk
2021-02-17 11:45
Does pact-jvm have possibility to publish only positive results to pact broker? In our project we want to store in Pact broker only positive results due to having many pushes to pact broker.

matt.fellows
2021-02-17 11:58
> In our project we want to store in Pact broker only positive results due to having many pushes to pact broker. why is too many pushes a problem?

matt.fellows
2021-02-17 11:58
Not publishing verification results is like not reporting failed unit test runs

matt.fellows
2021-02-17 11:58
(in Pact land)

therimpact
2021-02-17 12:30
has joined #pact-jvm

amaljayaraj07
2021-02-17 17:51
has joined #pact-jvm

jokubas.lekevicius
2021-02-17 20:31
600!!!!! How many layers did this message have? Wow

andrzej.igielski
2021-02-17 21:41
has joined #pact-jvm

uglyog
2021-02-17 21:53
No, it stores all the results it gets

uglyog
2021-02-17 21:54
Thank you!

wesleythomaswilliams
2021-02-17 22:00
It wasn't as deep as it was broad, but it did require @uglyog putting in a change to Pact to handle it. :smile:

mikewagner21
2021-02-18 03:15
has joined #pact-jvm

wilkinsweiqiangliang
2021-02-18 04:42
Hey @matt.fellows @uglyog im getting `http://au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify` with my ci/cd pipeline now, anything changed on pact end?

wilkinsweiqiangliang
2021-02-18 04:43
``` [TestEventLogger] com.lendi.decisions.actions.condition.pact.ConditionWorkerPactTest > com.lendi.decisions.actions.condition.pact.ConditionWorkerPactTest > initializationError FAILED 2021-02-18T15:36:16.689+1100 [DEBUG] [TestEventLogger] au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify 2021-02-18T15:36:16.689+1100 [DEBUG] [TestEventLogger] Provider: xxx 2021-02-18T15:36:16.689+1100 [DEBUG] [TestEventLogger] Source: xxx https://xxx.pactflow.io: consumerVersionSelectors=[ConsumerVersionSelector(tag=test123, latest=true, consumer=, fallbackTag=master), ConsumerVersionSelector(tag=development, latest=true, consumer=, fallbackTag=), ConsumerVersionSelector(tag=staging, latest=true, consumer=, fallbackTag=), ConsumerVersionSelector(tag=production, latest=true, consumer=, fallbackTag=)] 2021-02-18T15:36:16.689+1100 [DEBUG] [TestEventLogger] at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:43) 2021-02-18T15:36:16.689+1100 [DEBUG] [TestEventLogger] at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:102) 2021-02-18T15:36:16.689+1100 [DEBUG] [TestEventLogger] at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:271) 2021-02-18T15:36:16.689+1100 [DEBUG] [TestEventLogger] at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)```

uglyog
2021-02-18 04:52
Not that I know of

wilkinsweiqiangliang
2021-02-18 04:53
any suggestion? the contract is on pactflow, running successfully for a few days

uglyog
2021-02-18 05:02
I need to ask @bethskurrie

wilkinsweiqiangliang
2021-02-18 05:02
cool thanks

uglyog
2021-02-18 05:25
Just checking, what version of Pact-JVM are you using?

wilkinsweiqiangliang
2021-02-18 05:26
`pactVersion = '4.1.11'`

uglyog
2021-02-18 05:27
Can you try 4.1.17?

wilkinsweiqiangliang
2021-02-18 05:27
sure

uglyog
2021-02-18 05:27
Actually, you mentioned it was working before

uglyog
2021-02-18 05:28
Must be something in the Pactflow backend

wilkinsweiqiangliang
2021-02-18 05:28
yea it working like today before lunch time

wilkinsweiqiangliang
2021-02-18 05:28
still the contract is in pactflow

bethskurrie
2021-02-18 05:38
I'm looking into it @wilkinsweiqiangliang

wilkinsweiqiangliang
2021-02-18 05:38
Thank you

wilkinsweiqiangliang
2021-02-18 05:54
seems upgrade to `4.2` fix the issue

wilkinsweiqiangliang
2021-02-18 05:54
still checking

bethskurrie
2021-02-18 05:57
I haven't been able to reproduce it yet @wilkinsweiqiangliang

bethskurrie
2021-02-18 05:57
keep me updated as you find out more.

wilkinsweiqiangliang
2021-02-18 05:57
cool

bethskurrie
2021-02-18 06:17
@wilkinsweiqiangliang I'm still working on identifying the cause. It's something to do with the fallback tag.

wilkinsweiqiangliang
2021-02-18 06:17
yea

bethskurrie
2021-02-18 06:17
Can you add a separate selector for the master pacts?

wilkinsweiqiangliang
2021-02-18 06:17
okay

bethskurrie
2021-02-18 06:18
Just a plain one, no fallback. That should get you going for now, until I can identify the fix required.

wilkinsweiqiangliang
2021-02-18 06:18
thanks

wilkinsweiqiangliang
2021-02-18 06:18
i believe this is causing the issue

bethskurrie
2021-02-18 07:20
@wilkinsweiqiangliang We've resolved the issue.

bethskurrie
2021-02-18 07:20
Please try running your verifications again.

wilkinsweiqiangliang
2021-02-18 07:33
any suggestion on changes? do i need an version upgrade?

wilkinsweiqiangliang
2021-02-18 07:33
i found a stackoverflow like this issue


matt.fellows
2021-02-18 07:33
nothing to do on your end - you should be able to continue as is

uglyog
2021-02-18 07:34
But the fallback tag was fixed in a later version, so upgrade to 4.1.17 at least

wilkinsweiqiangliang
2021-02-18 07:34
sure

matt.fellows
2021-02-18 07:35
So there were two separate issues I think. One was the fallback tag itself not actually working in your version of Pact JVM

matt.fellows
2021-02-18 07:35
the second was that no pacts were being returned at all (we?ve fixed that at the Pactflow end)

wilkinsweiqiangliang
2021-02-18 07:35
:+1:

khandelwalbhushan
2021-02-18 08:10
has joined #pact-jvm

aniket.agarwal
2021-02-18 09:21
has joined #pact-jvm

arpit.modani
2021-02-18 09:43
has joined #pact-jvm

byronth
2021-02-18 11:45
has joined #pact-jvm

isa.levine
2021-02-18 23:37
has joined #pact-jvm

isa.levine
2021-02-19 00:02
Hi folks! :wave::slightly_smiling_face: I have a question about defining provider state names inside the `builder.given()` method. I have a situation where my provider state is the same (?default state?), and I have two interactions with that state I want to test (both are GET requests, and the only difference is the value of an integer query param). However, using `.given("default state")` for both interactions? state leads to an error where one of the two requests is not received. I can solve this by simply changing the ?default state? string, but then I may not know if I?m actually testing the same provider state in each interaction. The docs on provider states (https://docs.pact.io/getting_started/provider_states/) seem to suggest I should be able to create multiple interactions under the same state. But I did notice that all the examples show different strings in that `.given()` method. So, I wanted to clarify: ? does the string in ALL `.given()` calls need to be unique to avoid this error? ? is there a way to register multiple interactions under the same state?

uglyog
2021-02-19 00:10
The interaction description + provider states must be unique. You can re-use the provider state, but you need to provide a different interaction description.

uglyog
2021-02-19 00:11
Also, if you are defining both interactions in the same test, then the mock server is going to expect to receive both. Use separate tests for each one.

isa.levine
2021-02-19 00:14
The interaction description is what's inside `uponReceiving`, right? Here's a gist of the code I have, where I'm using the same string in `given` but different ones in `uponReceiving`: https://gist.github.com/isalevine/87ffb2e331ce48f7cc7a232c2c457de1

uglyog
2021-02-19 00:15
You're defining both at the same time, so the test has to make both requests

uglyog
2021-02-19 00:15
Use separate tests for each one

isa.levine
2021-02-19 00:17
Sounds good, thank you! I'll refactor them to be in separate tests. Strange though, I thought I _was_ making both requests by firing them off in the same `@Test` method. Maybe something to do with this CloseableHttpResponse class then? (I'm coming from Ruby, so all this Java HTTP stuff is brand-new to me)

uglyog
2021-02-19 00:20
I'm not sure why one of the requests was not received. You may need to debug your test to see what is happening

uglyog
2021-02-19 00:20
You can also re-use the same httpClient in your test, you don't need a separate one

isa.levine
2021-02-19 00:21
Good to know, I appreciate that!

uglyog
2021-02-19 00:22
Actually, now that I look at your example, the regex in the second request will match the first one, so it is probably matching both requests

isa.levine
2021-02-19 00:22
OHHHH that's a great point, thanks for catching that! I'll play around with that first

isa.levine
2021-02-19 00:49
Yep, better regex fixed the problem. Thank you so much for catching that (and for generally doing a sanity check for me)! :slightly_smiling_face:

brian.pfretzschner
2021-02-19 10:15
has joined #pact-jvm

philipchardwick
2021-02-19 16:21
I'm looking at creating a test in the junit provider for the issue I created above, I need to have a pact source produce a pending pact for my test. What's the best way to go about this? It'd be nice to do a more wholistic test for pending pacts in the junit library - like some of the other tests written in java. One idea would be to create a custom pact source like a `MockPactBrokerSource` which `implements PactLoader` and which returns a `BrokerUrlSource` from `getPactSource()`

uglyog
2021-02-20 01:34
The mock source would work

chitra.adikesavan
2021-02-20 15:50
has joined #pact-jvm

tausif2909
2021-02-22 06:10
HI, I have 3 consumer services `consumer-1`, `consumer-2` & `consumer-3` and 1 provider verification service `provider-1` I have written the code for all 3 consumer services and those are published to pact server. and also written provider verification for `consumer-1`, verification for consumer 2 & 3 is pending. Provider verification for `consumer-1` is working fine. But it also starts verification for `consumer-2` & `consumer-3` in jenkinks pipeline even though I have not written any code of it and ending up with build failure of provider service How do I skip the verification for `consumer-2` and `consumer-3` till the time I write verification code for it?

uglyog
2021-02-22 06:12
The verification is run for all published pacts. You only need one test for it, not one for each consumer

tausif2909
2021-02-22 06:17
But all 3 consumers are from different services. is there any way we can temporarily skip or disable verification for specific in interaction or all calls in a consumer?

ankita.soni
2021-02-22 07:26
has joined #pact-jvm

jacek.helper
2021-02-22 08:03
has joined #pact-jvm

matt.fellows
2021-02-22 09:12
a few options

matt.fellows
2021-02-22 09:13
1. Use pending pacts (this won?t fail your build, because they are new expectations) 2. Use tags to manage workflows. If a Pact has been merged into, say, `master` but the provider can?t verify it, now the consumer can?t deploy

matt.fellows
2021-02-22 09:14
see the CI/CD workshop in howtolearn for more on these workflows

2021-02-22 09:14
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

tausif2909
2021-02-22 09:29
Thanks @matt.fellows

seanw122
2021-02-22 15:36
has joined #pact-jvm

akennedy
2021-02-22 15:54
has joined #pact-jvm

esimpson
2021-02-22 16:42
has joined #pact-jvm

dagrawal
2021-02-22 17:24
has joined #pact-jvm

venkata.pro
2021-02-22 21:47
has joined #pact-jvm

siddharth.gupta
2021-02-23 12:23
has joined #pact-jvm

siddharth.gupta
2021-02-23 12:24
can someone point me to any example code to run provider PactVerification tests using junit5


wesleythomaswilliams
2021-02-23 12:36
Feel free to fire questions at me, I might be able to answer, we use Junit5/Maven/Spring. Also see Matt's link in the post below yours

siddharth.gupta
2021-02-23 12:37
Thanks

laxmi.somni508
2021-02-23 14:51
Hello Helpful Guys, We're trying to implement PACT framework in our organisation. I've had a interesting query from a Android developer - " If from Android Consumer side, we're creating few PACT files & ultimately would be sending it over towards BE Provider, once set-up is complete. So, if we have HTTP header in response coming from Backend API. So tomorrow, in the header file if Backend starts to send few more fields, then should PACT test-framework (mainly consumer-side) catch it?" Do we need to go in such level of details in PACT testing? Kindly provide some light. Thanks

brendan.donegan
2021-02-23 14:56
@laxmi.somni508 it shouldn?t be possible for *extra* response headers to break anything, AFAIK

phil.endsley
2021-02-23 14:58
Pact would "catch" it by receiving all headers the provider sends, but as long as the provider response still contains everything the consumer defines, verification should still pass.

laxmi.somni508
2021-02-23 14:58
Noted.:+1: Thanks a lot for quickly clarifying @brandonbeard86 @phil.endsley

jordan.levin
2021-02-23 19:13
has joined #pact-jvm

francesco.latorre
2021-02-24 05:59
has joined #pact-jvm

francislainy.campos
2021-02-24 08:34
These two articles I?ve written with some samples may help you.



aniket.g2185
2021-02-24 09:13
has joined #pact-jvm

sundaresank360
2021-02-24 12:12
has joined #pact-jvm

uladzislau_danilchyk
2021-02-24 13:13
@uglyog, do you plan to implement such functionality to define which type of results need to be stored: all, positive, negative? I think it would be useful. Especially for our project at least.

francislainy.campos
2021-02-24 13:39
Hi, is it possible not to have a port appended to the provider url like this https://api.br.internal:8443/v1/states that comes from ```@BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpsTestTarget("api.br.internal")); }```

ryanlevell
2021-02-24 13:56
I am using -Dpactbroker.consumerversionselectors.tags to run the provider side tests against specific tags. I also want to include the latest contract regardless of the tag. Is there a way to get the latest contract that has no tag yet via the system property?

ryanlevell
2021-02-24 14:37
I believe an empty comma separated value is working e.g. ?,prod? will grab 2 contracts; latest any tag, and latest prod tag

jhawthor
2021-02-24 15:18
has joined #pact-jvm

ryanlevell
2021-02-24 15:52
Never mind, that did not work. The /for-provider endpoint supports no tag, but not sure if it is possible via this system property.

chris.r.thomas
2021-02-24 16:54
has joined #pact-jvm

peter.cook
2021-02-24 17:05
has joined #pact-jvm

jayeshguru81
2021-02-24 18:34
has joined #pact-jvm

ben.kirberger
2021-02-24 19:16
has joined #pact-jvm

uglyog
2021-02-24 22:11
No, there is no plan for that. Previously, it only pushed up the failed results, but was fixed recently to store all results because that was causing problems.

bethskurrie
2021-02-24 22:24
@uladzislau_danilchyk what problems are you noticing with the number of pushes?

bethskurrie
2021-02-24 22:39
You can set the consumer name in the consumer version selectors.


abubics
2021-02-25 00:27
Omitting the port would just imply the default port for that protocol (i.e. 443 for `https`, 80 for `http`, etc) . . . is that your intent?


rejeesh.g
2021-02-25 04:31
Is there any solution to the this issue https://github.com/pact-foundation/pact-jvm/issues/319

rejeesh.g
2021-02-25 04:32
Say my request is as per this sample request "Certification": { "Java": { "Version": "1.5", "Year": "2015" }, "Scala": { "Version": "1.6", "Year": "2016" }, "C#": { "Version": "1.7", "Year": "2017" }, "C": { "Version": "1.8", "Year": "2018" } }

rejeesh.g
2021-02-25 04:33
and i want to test the interaction as per the below request "Certification": { "Java": { "Version": "1.5", "Year": "2015" }, "Scala": null, "C#": null, "C": null, }

rejeesh.g
2021-02-25 04:36
How do we specify the body = new PactDslJsonBody() to expect a nullvalue json object or have value

phil.endsley
2021-02-25 04:39
I don't think Pact currently supports optional values in contracts. https://docs.pact.io/faq/#why-is-there-no-support-for-specifying-optional-attributes The most common advice is to define multiple interactions where the optional field is the expected value, and one where it is null

rejeesh.g
2021-02-25 04:41
ok Thanks

m.stephkan
2021-02-25 05:30
has joined #pact-jvm

matt.fellows
2021-02-25 07:49
It doesn't support optionals

matt.fellows
2021-02-25 07:49
Correct

matt.fellows
2021-02-25 07:50
We are trialling a provider driven approach in Pactflow where a consumer uploads a pact with their examples, and provider verifies their OAS and we check compatability

matt.fellows
2021-02-25 07:50
This would allow optionals as the OAS schema allows it

matt.fellows
2021-02-25 07:50
DM me if keen to hear more

francislainy.campos
2021-02-25 08:21
Hi, not really. I don?t want the port to appear at all on the url.

stephen.tjasink
2021-02-25 08:23
has joined #pact-jvm

uladzislau_danilchyk
2021-02-25 10:04
@bethskurrie, i'm working on a huge project with large team > 150 members. And we have too much pushes into pact broker. We don't know restrictions of pact broker storage and it would be good to have a possibility to choose what types of verification results it can store

beatrizwaclawek
2021-02-25 20:27
has joined #pact-jvm

zhoutianli1234
2021-02-25 21:09
has joined #pact-jvm

abubics
2021-02-26 00:16
Sorry, I'm not suggesting that you replace it with an explicit `:80` or `:443`, but that would be the effective outcome.

travis.day
2021-02-26 04:06
has joined #pact-jvm

andrew.cunningham
2021-02-26 11:13
has joined #pact-jvm

andrew.cunningham
2021-02-26 11:18
Hey :wave: Has anyone seen `No signature of method: http://au.com.dius.pact.core.pactbroker.PactBrokerClient.uploadPactFile()` while using `au.com.dius:pact-jvm-consumer-junit_2.12:3.6.15`?

uglyog
2021-02-27 00:49
Make sure you are not mixing major versions of the Pact JVM libraries. That version is pretty old.

brianmasschaele
2021-02-27 13:27
has joined #pact-jvm

pedroefajardo_pactio
2021-02-27 17:18
has joined #pact-jvm

bethskurrie
2021-02-28 22:54
@uladzislau_danilchyk that number of pushes should be fine. but what you want to do is configure the clean up task https://github.com/pact-foundation/pact_broker/issues/360#issuecomment-735216009

bethskurrie
2021-02-28 22:54
And make sure you've provisioned it well enough!

bethskurrie
2021-02-28 22:55
> And we have too much pushes into pact broker. Again, what problems are you noticing? Are the responses slow? Is anything timing out?

r.strauch
2021-02-28 23:59
Hey, In order to test a HTTP 500 response from my Spring Boot application, I've setup the following state with Mockito using `@SpyBean` on the `mailService`. When debugging, I can see that the service is proxied by Mockito but the exception is not thrown. Am I missing something? The `mailService` is actually a service which is injected in another service. Maybe that causes the problem? ```@State("SERVER_ERROR") public void serverError() { doThrow(new IOException()) .when(mailService) .sendMessage(any(User.class), anyBoolean(), any(MailType.class), anyMap(), anyMap()); }```

dominic_herrmann
2021-03-01 06:54
has joined #pact-jvm

uladzislau_danilchyk
2021-03-01 09:47
@bethskurrie, Responses growing up

laxmi.somni508
2021-03-01 15:19
Hi @abubics, Hope you're doing great. Just wanted to check if you managed to find more info about this? Thanks [P.S::round_pushpin: If I send you a message outside your usual working hours, please do not feel that you need to respond immediately.]

andrew.cunningham
2021-03-01 15:55
Does Pact work with Kotlin DSL in Gradle?

thanuxxxx
2021-03-01 16:23
Hey guys, I have a `Springboot` microservice where I run my pact provider tests along with other integration tests by executing `mvn verify` command. I am planning to have separate Jenkins pipeline for pact since regular build takes a bit longer to complete. My question is how can I just run pact tests only via maven commands. mvn verify also executes all of other time consuming integration tests, I don't want to execute other tests. Do we have a way to do that?

andrew.cunningham
2021-03-01 16:55
Turns out it does not play nice...

wesleythomaswilliams
2021-03-01 17:14
Hi Shan, we also have springboot microservices. Our pact tests run as part of our unit test stage in our pipeline using `mvn test`, but I've created maven profiles so I can execute test types separately. So I could run `mvn test -Pcontract-tests` if I wanted and that would only run tests that fit a naming convention (e.g. *ContractTest)

thanuxxxx
2021-03-01 17:35
Okay

wesleythomaswilliams
2021-03-01 18:26
Was that helpful? Happy to try and provide more details.

thanuxxxx
2021-03-01 21:57
Yes, that was helpful. I'll be keep posting if I encounter any road blocks

abubics
2021-03-02 00:04
yarr, I found a lot of things didn't play too nice with the Kotlin DSL last time I tried (about 15 months ago) . . .

abubics
2021-03-02 02:10
Just had a quick look through backups, we created a test consumer using itv.scalapact, and JVM gradle provider, with the older-style "provide a state-change endpoint" setup.

ryanlevell
2021-03-02 02:47
@uglyog do the `pactbroker.consumerversionselectors.*` properties support no tag e.g. just the latest contract, in addition to other tags? Something like: `-Dpactbroker.consumerversionselectors.tags=<no tag>,prod` It appears that the API can support no tag: `localhost:9292/pacts/provider/{provider}/for-verification` ```{ "consumerVersionSelectors": [ { "latest": true } ] }```

andrew.cunningham
2021-03-02 09:04
It would be a nice addition to the product - most new projects I work on use the Gradle Kotlin DSL

matthew.long
2021-03-02 14:08
has joined #pact-jvm

gayatree.eee
2021-03-02 14:31
Hi, Can you please point me to the system property which can be used for --tag in create-version-tag

ryanlevell
2021-03-02 15:46
For consumer tag(s): -Dpact.consumer.tags For provider tag: -Dpact.provider.tag Sorry on mobile or would link the source.

gayatree.eee
2021-03-02 15:48
-Dpact-provider-tag works for tagging publishing contract verification result. It is not working for create-version-tag, which is used to tag in postdeploy stage.

ryanlevell
2021-03-02 15:50
You mean via the Pact Broker CLI or by maven plugin?

tmoncm
2021-03-02 17:17
has joined #pact-jvm

phoenixcampos01
2021-03-02 21:25
has joined #pact-jvm

gayatree.eee
2021-03-03 03:27
Pact Broker CLI

uglyog
2021-03-03 04:13
It wasn't designed that way, if it does, it is a side-effect

uglyog
2021-03-03 04:13
Pact Broker CLI is not built with Java, so does not use system properties


ryanlevell
2021-03-03 04:23
Any suggestions to allow for it? I have it working in a branch with an empty comma and without breaking the other logic. But it looks kind of funny and could cause issues for anyone currently expecting ?empty == do not include?: `-Dpactbroker.consumerversionselectors.tags=,prod`

uglyog
2021-03-03 04:28
Can you raise a Githuib issue for this so I can look at what you're trying to do when I have a chance

abubics
2021-03-03 04:31
tangential, but I haven't tried the Kotlin DSL for gradle many times . . . I love Kotlin, but the groovy DSL still works better for me

gayatree.eee
2021-03-03 06:19
ok.. is there any other way to achieve the same without using Pact Broker CLI..

andrew.cunningham
2021-03-03 09:26
I was wondering if anyone has tried to tie the creation of their pacts to UI/automation testing? I have an Android project where SETs have created tests for all requests/responses - I want to utilise this pre-existing set up to generate my Pacts. Any thoughts?


matt.fellows
2021-03-03 09:42
Can be done. The precondition that must hold for it to work with current Pact 1. Pacts must be reliably generated i.e. the consumer side must actually do what the test data does. If it drifts you have no confidence 2. Need to be careful with data. This is likely to cause pain for the provider team This being said, we're exploring a way to do that better at Pactflow.

francislainy.campos
2021-03-03 09:53
Yes, the port comes up when I don?t add it there, so I was looking for a way not to have this appended to the url. But it?s not a biggie, I can workaround it if there?s no such a way. Thanks.

hugh.paul.mcgowan
2021-03-03 17:52
has joined #pact-jvm

uglyog
2021-03-03 21:36
What's wrong with using the Pact Broker CLI? Why does it have to be a system property?

normanrs
2021-03-04 11:18
has joined #pact-jvm

jayson.bailey
2021-03-04 19:18
has joined #pact-jvm

matias.waterloo
2021-03-05 13:34
Hi, is it possible to mix HttpTestTarget and MessageTestTarget in a single test class (junit5)? What is the approach to have both http and async provider tests (but single serivce/provider) fetched from the broker?

josue.boix
2021-03-05 13:43
QQ. So I have a pact with Upon receiving: ```{ "method": "GET", "path": "/api/v1/url/csv" }``` And the response that look as follows: ```{ "status": 200, "body": "NAME,EMAIL\nSome name, \nOther name, \n" }``` Which is actually a *csv* response. I create a provider verification test, everything works as expected but fails with the following message: ```BodyTypeMismatch: Expected a response type of 'application/json' but the actual type was 'text/plain'``` Why is it expecting a `application/json` body?

ryanlevell
2021-03-05 15:27
~Your confusing your ?body? field with the real ?response body?. Your response body IS json. Your json has 2 fields, status and body. Your ?body? is not the same as the ?response body?. The ?response body? is JSON. The ?body? field is in CSV format, but that is within the overall JSON payload. When you created the pact, you probably used a `PactDslJsonBody` object. Pact uses this to determine the content-type (I think). The only time the content-type should be ?text/*? is when the whole payload is literally plain text. I haven?t done it, but I imagine you can override the response content-type in the pact. Although ?application/json? is not required, is the correct content-type for this response.~

ryanlevell
2021-03-05 15:29
Your confusing your ?body? field with the real ?response body?. Your response body IS json. Your json has 2 fields, status and body. Your ?body? is not the same as the ?response body?. The ?response body? is JSON. The ?body? field is in CSV format, but that is within the overall JSON payload. When you created the pact, you probably used a `PactDslJsonBody` object. Pact uses this to determine the content-type (I think). The only time the content-type should be ?text/*? is when the whole payload is literally plain text. I haven?t done it, but I imagine you can override the response content-type in the pact. Although ?application/json? is not required, is the correct content-type for this response.

ryanlevell
2021-03-05 17:14
I have a similar question from consumer side. Can the same consumer/provider pair be used in a contract that requires both sync/async interactions? Or does that require 2 separate contracts with slightly different names? Consumer -> SameProviderApi Consumer -> SameProviderQueue

josue.boix
2021-03-05 17:30
Thanks for the reply. The pact was actually created from the FE using JS, with the following: ```describe('Description', () => { beforeAll(async () => { await provider.setup() await provider.addInteraction({ uponReceiving: 'Some request', state: 'Some state', withRequest: { method: 'GET', headers: { Accept: 'text/csv', }, path: url, }, willRespondWith: { status: 200, body: EXPECTED_CSV_RESPONSE, }, }) }, SETUP_TIMEOUT)```

olarrmide
2021-03-05 19:29
has joined #pact-jvm

matt.fellows
2021-03-05 22:03
You haven't specified the content type on the response

matt.fellows
2021-03-05 22:03
I think without it, it will default to looking for JSON

uglyog
2021-03-06 00:21
The new V4 Pact format supports both message and http interactions in the same file, but it is largely untested. I'll try setup an example test that does that.

josue.boix
2021-03-08 09:28
If I do as follows: Upon receiving: ```{ "method": "GET", "path": "/api/v1/url/csv" "headers": { "Accept": "text/csv" }``` And the response that look as follows: ```{ "status": 200, "headers": { "Content-Type": "text/csv" } "body": "NAME,EMAIL\nSome name, \nOther name, \n" }``` I get the following error instead: ```java.lang.AssertionError: Failures: 1) Get headquarter drafts list 1.1) com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 5 path $ at au.com.dius.pact.provider.spring.target.MockMvcTarget.testInteraction(MockMvcTarget.kt:86) at au.com.dius.pact.provider.junit.InteractionRunner$interactionBlock$statement$1.evaluate(InteractionRunner.kt:226) at au.com.dius.pact.provider.junit.RunStateChanges.evaluate(RunStateChanges.kt:30) at au.com.dius.pact.provider.junit.InteractionRunner.run(InteractionRunner.kt:162) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:150) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:56) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)```

matt.fellows
2021-03-08 09:38
hmmm could you please share the generated pact file and the provider test?

josue.boix
2021-03-08 09:58
The problem is see here is that the controller is not sending any response header, and that causes problems with pact

josue.boix
2021-03-08 09:58
```MockHttpServletResponse: Status = 200 Error message = null Headers = [Content-Disposition:"attachment; filename=file-2-2021-03-08T10:57:22.256.csv"] Content type = null Body = DMT,NAME...```

josue.boix
2021-03-08 09:58
And then the error ```java.lang.AssertionError: Failures: 1) Get headquarter drafts list 1.1) com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 5 path $ at au.com.dius.pact.provider.spring.target.MockMvcTarget.testInteraction(MockMvcTarget.kt:86) at au.com.dius.pact.provider.junit.InteractionRunner$interactionBlock$statement$1.evaluate(InteractionRunner.kt:226) at au.com.dius.pact.provider.junit.RunStateChanges.evaluate(RunStateChanges.kt:30) at au.com.dius.pact.provider.junit.InteractionRunner.run(InteractionRunner.kt:162) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:150) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:56) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)```

laxmi.somni508
2021-03-08 12:35
Hello Helpful Pact-JVM community-members, Brining your attention to below Question on Stackoverflow. We're looking for a simple barebone sample boilerplate of Pact-JVM usage on Scala codebase. If you're aware of any sample on public Github / blog etc.. then kindly share the link in answer. _This could you useful to not only to myself but other newbies in the future_:pray: [p.s. - There's a 50 Stackoverflow points bounty for a successful answer..:tada:] Thanks a lot https://stackoverflow.com/q/66426214/2451016

philipchardwick
2021-03-08 15:25
Hey, does v4.2.x support both V3 and V4 of the pact specification? Are there any considerations to take when upgrading?

uglyog
2021-03-08 22:05
The V4 work is still in progress and not not complete. But it does support all specification formats.

uglyog
2021-03-08 22:05
There has been some refactoring and removal of some deprecated methods, but nobody has reported any issues when upgrading as yet

mjsmcp
2021-03-08 23:46
has joined #pact-jvm

philipchardwick
2021-03-09 08:42
Thanks!

uglyog
2021-03-09 21:36
It also has JDK 11 as minimum

javier.garcia_cotado
2021-03-09 21:52
has joined #pact-jvm

javier.garcia_cotado
2021-03-09 21:55
hi all

javier.garcia_cotado
2021-03-09 21:55
I would like to know how can I match the following expectation

javier.garcia_cotado
2021-03-09 21:56
from this Pact spec:

javier.garcia_cotado
2021-03-09 21:57
and this kind of test_

javier.garcia_cotado
2021-03-09 21:57
where jsonEventsFile() is

javier.garcia_cotado
2021-03-09 21:59
PS: Commenting .body(...) spec fixes the issue _but_ I won't verify anything from the body (maybe is correct?)

javier.garcia_cotado
2021-03-09 22:00
PS2: Production code tries to upload a zip file to S3


uglyog
2021-03-09 22:02
This does a check for the content type of the binary data

javier.garcia_cotado
2021-03-09 22:04
thanks! I will try!


javier.garcia_cotado
2021-03-09 22:25
How can I inject PactDslRequestWithPath?

javier.garcia_cotado
2021-03-09 22:29
BTW, the example you shared uses multipart/form-data ... which is not allowed by the provider

uglyog
2021-03-09 22:37
Ah, right. This is probably more to what you need, but unfortunately it is only implemented for response bodies


javier.garcia_cotado
2021-03-09 22:46
where is pact-consumer-junit v4.1.0?




javier.garcia_cotado
2021-03-09 22:49
got it

matt.fellows
2021-03-10 02:47
hmmm, interesting.

matt.fellows
2021-03-10 02:47
so, it should send a response content-type header

matt.fellows
2021-03-10 02:49
Thought I?d share this here. Ron has created a new JVM workshop (this time, with Maven/Junit5/Springboot): https://github.com/pact-foundation/pact-workshop-Maven-Springboot-JUnit5

wesleythomaswilliams
2021-03-10 09:30
I should check this out just to find out what I've done wrong :smile:

akos.csurai
2021-03-10 13:39
has joined #pact-jvm

testme2020testme
2021-03-10 14:12
has joined #pact-jvm

testme2020testme
2021-03-10 14:18
Hi, I am new to Pact, How to solve below error java.lang.AssertionError: Pact Test function failed with an exception: Empty body

josue.boix
2021-03-10 15:19
I ended up fixing the issue by changing the response header in the controller. Thanks for your help!

brendan.donegan
2021-03-10 15:28
I have the feeling the answer to this question is no but I have an interaction that needs to provide a date in the body, but I want to move the generation of this date into the provider state because it causes problems with triggering the verification too much. My question is really, can I modify the body of the request on the provider side and add those fields.

ryanlevell
2021-03-10 16:42
Hard code the date in the contract to avoid Pact thinking the contract keeps changing. And to make it easier on your Provider, use regex to match the date so they don?t have to match your date exactly. https://docs.pact.io/getting_started/matching/#random-data---avoid-it

tommy.mirchandani
2021-03-10 17:13
has joined #pact-jvm

phil.endsley
2021-03-10 19:28
Pact supports it, but you have to define it from the consumer, so it depends on the consumer library you're using (and I'm not familiar with other languages, so can't help you there). https://docs.pact.io/implementation_guides/jvm/consumer/#having-values-injected-from-provider-state-callbacks

varinderjitkaur13
2021-03-11 01:46
has joined #pact-jvm

krcl.dev
2021-03-11 05:11
has joined #pact-jvm

akos.csurai
2021-03-11 07:54
Hello, Could someone give me a hint to find the right Gradle dependency settings for https://github.com/pact-foundation/pact-jvm/blob/4_0_10/consumer/pact-jvm-consumer-junit/src/test/java/au/com/dius/pact/consumer/exampleclients/ConsumerClient.java ? I tried with Pact version 4.0.10 and 4.1.17 with the help of these pages: https://github.com/pact-foundation/pact-jvm/tree/4_0_10/consumer/pact-jvm-consumer-junit https://github.com/pact-foundation/pact-jvm/tree/v4.1.x/consumer/junit Last time exactly here: https://github.com/pact-foundation/pact-jvm/tree/v4.1.x/consumer/junit#using-the-base-consumerpacttest additional: I tried ```import au.com.dius.pact.consumer.exampleclients.ConsumerClient;``` from au.com.dius.pact.consumer:junit:4.1.0 but that lib doesn`t contain the test folder (of course) Thanks, Akos

uglyog
2021-03-11 08:10
That is an example class used by the tests and is not included in any published module

akos.csurai
2021-03-11 08:15
Ah, Thanks! Can i just reproduce (kind of copy paste ) in my package ?


mahdi.ali
2021-03-11 09:46
has joined #pact-jvm

brendan.donegan
2021-03-11 09:50
yeah. we?re desperately in need of upgrading to v3 but unfortunately ours is a JS project. I know it?s technically available but I would like to wait until the interface is stable before doing so

brendan.donegan
2021-03-11 09:50
(the provider is JVM which is why I asked in here)

krishnaraoveera1294
2021-03-11 17:53
has joined #pact-jvm

raghavendra.kalakonda
2021-03-11 23:08
has joined #pact-jvm

raghavendra.kalakonda
2021-03-11 23:18
Hello Everyone,

raghavendra.kalakonda
2021-03-11 23:18
Has anyone used Pact with Azure event hub please?

matt.fellows
2021-03-11 23:36
what?s specific to Azure event hub that you can?t do with regular message pact?

andries.spies
2021-03-12 07:25
has joined #pact-jvm

kamil.klima
2021-03-12 11:38
has joined #pact-jvm

marcelo
2021-03-12 12:56
@marcelo has left the channel

kflo
2021-03-12 22:25
i?ve created a library for using https://www.openapi4j.org/ in conjunction with https://www.scalatest.org/ (it provides a DSL for verifying an OpenAPI spec against an API implementation). wondering if others would find that useful. as it was developed on company time i?d need to get sign off to open source it but it seems valuable

kflo
2021-03-12 22:26
where pact focuses more on internal contracts, this is for public contracts (the public OpenAPI spec)

matt.fellows
2021-03-13 00:30
Cool!

matt.fellows
2021-03-13 00:31
Did you end up looking at optic btw?

kflo
2021-03-13 00:31
i did, unfortunately it?s not yet mature enough for us to use, otherwise that would have been my choice

kflo
2021-03-13 00:31
(it doesn?t support query params or header values yet)

kflo
2021-03-13 00:31
the tool i ended up making is kind of similar to optic in that it?s a proxy

kflo
2021-03-13 00:32
it does the validation in the proxy layer, in between the client and the real service

matt.fellows
2021-03-13 00:36
Cool, yeah I've seen a few of those

matt.fellows
2021-03-13 00:37
It seems a popular approach

kflo
2021-03-13 00:37
works really well because it makes the client and server agnostic of each other

matt.fellows
2021-03-13 00:56
By the way we should talk about how you might like to combine that with our new bi directional contracts feature at Pactflow

matt.fellows
2021-03-13 00:57
(just out for brekky with family but will pop a reminder to follow up next week)


kflo
2021-03-13 02:46
if we can eventually use pact for everything that would be nice

matt.fellows
2021-03-13 03:20
It's the plan, but we're not there yet. So it's good to have options!

lswanborough
2021-03-15 00:50
has joined #pact-jvm

aniket.g2185
2021-03-15 06:06
Hi, I am trying to upload pact files to broker via Gradle Plugin. Irrespective of giving invalid URL or invalid Pact Dir I do not see it failing, am I missing something ?

uglyog
2021-03-15 06:11
It doesn't fail if it finds no files

aniket.g2185
2021-03-15 06:12
So if I understand correctly , Publish task won't complain even if PactDir config is invalid dir ? And how about the Broker URL, it doesn't complain even if URL is invalid

uglyog
2021-03-15 06:14
If there are files to publish, it will get an error with an incorrect broker URL

don.tobias
2021-03-15 19:35
has joined #pact-jvm

aniket.g2185
2021-03-16 07:51
any pointers around how can I stop someone from using `pactPublish` gradle task if a particular env var is not set ?

aniket.g2185
2021-03-16 07:51
this is to make sure it runs only via CI

art.ptushkin
2021-03-16 08:21
I use specific tags for pipeline and verbally forbid using these, for local run only specific tags also. Don't think that can be something more suitable

matt.fellows
2021-03-16 08:24
Don't let people have access to publish, so if they try it will fail

matt.fellows
2021-03-16 08:25
What's the reason for it, prevent local publish or something else?

uglyog
2021-03-16 08:27
Set the broker details with ENV VARS. Without the vars, it should fail

aniket.g2185
2021-03-16 08:33
@matt.fellows, yes from preventing them to run `pactPublish` task locally

aniket.g2185
2021-03-16 08:34
so I get the branch name from `CI_COMMIT_BRANCH` and set it as tag during publishing of pacts

aniket.g2185
2021-03-16 08:35
but when this env is empty `tags[]` empty tags array is sent

uglyog
2021-03-16 08:36
Set the broker host/port

aniket.g2185
2021-03-16 08:37
using env vars?

aniket.g2185
2021-03-16 08:38
That kind of brings me to another question, with so many microservices using Pact Broker URL, which is the good place to configure it, considering it may change in future

uglyog
2021-03-16 08:45
You can use a Gradle properties file that only exists on CI

aniket.g2185
2021-03-16 08:46
Not sure how do u do that, having file only in CI ?

aniket.g2185
2021-03-16 08:46
Also for me, only 1 Android App consumer is rest all backend services are golang

uglyog
2021-03-16 08:52
Gradle will load properties from a file in `$HOME/.gradle/gradle.properties`

uglyog
2021-03-16 08:52
Have that file to exist on your CI server with the host/port of the pact broker

aniket.g2185
2021-03-16 08:53
hmmm this is tricky, cos our CI runners are shared docker containers, we do not maintain any kind of state on runners

matt.fellows
2021-03-16 09:17
We use things like AWS SSM to get dynamic parameters for CI

matias.waterloo
2021-03-16 17:30
Hi! is there a best practice to follow regarding enums? I?d like to catch when new values are added braking compatibility with consumers

wesleythomaswilliams
2021-03-16 18:31
I'm curious why a provider expanding the enum options would break a consumer?

ben.kirberger
2021-03-16 20:46
Hey fam! I?m trying to work through the kafka examples (js consumer, jvm producer) and I?ve hit a bit of a snag trying to turn on ?enablePendingPacts?... Documentation https://docs.pact.io/pact_broker/advanced_topics/pending_pacts states: > You need to be use at least the following version of your Pact library: > JVM: 4.1.7 I?m not sure I can find this version of Pact jvm / Pact jvm-junit-provider / pact jvm-junit5-provider, and thus I am running into problems trying to add an `enablePendingPacts` property to this annotation: ```@PactBroker(scheme = "https", host = "${PACT_BROKER_HOST}", tags = { "master", "prod", "latest" }, authentication = @PactBrokerAuth(token = "${PACT_BROKER_TOKEN}"))``` I?ve confirmed in VS code that the project is only currently pulling in ~4.0.1 versions. :disappointed: Any help would be much appreciated!

uglyog
2021-03-16 21:55
The module names have changed and it is now `au.com.dius.pact.provider:junit5:4.1.18`

abubics
2021-03-16 23:41
If the consumer expects its own enum definition to be exhaustive (can be expressed with tests), then it might barf on an unexpected value. It's a bit different to responding with extra (unknown) fields.

abubics
2021-03-16 23:42
You can regex all the values for an enum, or cover it with unmarshalling in the post-pact bit of your unit tests, if you need to. These options have different reasoning and maintenance implications.

abubics
2021-03-16 23:43
But to cover it completely, you'd need to explicitly cover all possible values in your provider states intersected with your consumer test case states. That's hard to guarantee, usually.

sagar.kathuria
2021-03-17 04:25
has joined #pact-jvm

shao.sum
2021-03-17 08:35
has joined #pact-jvm

matias.waterloo
2021-03-17 12:11
thanks!

riddhichopra
2021-03-18 01:28
has joined #pact-jvm

anu.de
2021-03-18 02:28
has joined #pact-jvm

sreyaslj
2021-03-18 04:25
has joined #pact-jvm

sreyaslj
2021-03-18 04:30
Hi Team, How we will change the pact spec version for messagepactproviderrule

matt.fellows
2021-03-18 04:48
why do you want to do that?

sreyaslj
2021-03-18 04:53
I need to change the version from 3.0 to 2.0 . So i have checked and found able to change the version in pactproviderrule ```@rule public PactProviderRule m= new PactProviderRule("test", PactSpecVersion.V2,this);``` but it is not applicable for MessagePactProviderRule

uglyog
2021-03-18 04:57
Message Pact is only for V3

sreyaslj
2021-03-18 05:05
@uglyog Thanks for the response. so we cannot make the version to V2 rgt for this case?

uglyog
2021-03-18 05:06
No, Message Pacts were introduced as part of the V3 spec

sreyaslj
2021-03-18 05:07
Thanks much

matt.fellows
2021-03-18 06:33
Are you asking because you are trying to verify with a language that doesn?t support v3?

sreyaslj
2021-03-18 07:44
Yes @matt.fellows, We are using java in the consumer test (generating pact with V3) but the provider test is using in python (its using V2)

matt.fellows
2021-03-18 08:17
gotcha

matt.fellows
2021-03-18 08:17
you?ll want to follow https://github.com/pact-foundation/pact-python/pull/200 (if you?ve not seen it already)

sreyaslj
2021-03-18 08:33
Let me check.. Thanks alot

arvind1017
2021-03-18 22:48
has joined #pact-jvm

sushilvc84
2021-03-19 00:30
has joined #pact-jvm

tejakoshti7
2021-03-19 06:26
has joined #pact-jvm

yannick.adler
2021-03-19 12:44
has joined #pact-jvm

aelse
2021-03-19 23:54
has joined #pact-jvm

eric2323223
2021-03-20 01:35
has joined #pact-jvm

jordan.r.stewart
2021-03-20 16:07
has joined #pact-jvm

tmorrison
2021-03-21 21:45
has joined #pact-jvm

a.chandrasekaran
2021-03-22 00:50
has joined #pact-jvm

maksym.motornyi
2021-03-22 11:50
has joined #pact-jvm

maksym.motornyi
2021-03-22 12:02
Hello folks! I've upgraded `http://au.com.dius.pact` from 4.1.10 to 4.1.18 and gradle task for verification the pact fails with an error:

gareth.somerville
2021-03-22 12:10
has joined #pact-jvm

anja.gruss
2021-03-22 15:10
has joined #pact-jvm

laxmi.somni508
2021-03-22 15:55
Hi Folks, We would like to know how to configure the consumer version when the pact files are published using Gradle. When using the CLI tool it is done by ```pact-broker publish --consumer-app-version="3.0.0" ``` According to the documentation https://docs.pact.io/implementation_guides/jvm/provider/gradle/#publishing-pact-files-to-a-pact-broker,  the `pactPublish` task will use the version of the gradle project by default. You can override this with the `consumerVersion` property. Make sure you have set one otherwise the broker will reject the pact files. However when I try ```pact { publish { consumerVersion = "3.0.0" ... }``` I get `MissingPropertyException: Could not set unknown property 'consumerVersion'` Any idea of how this should be done in Gradle? Thanks

maksym.motornyi
2021-03-22 15:58
which version of the gradle plugin do you use?

laxmi.somni508
2021-03-22 15:59
4.1.0

maksym.motornyi
2021-03-22 16:01
Indeed. There are no consumerVersion property in that version. Try to upgrade if you can

maksym.motornyi
2021-03-22 16:03
Or if I remember correctly there was property providerVersion which used for the same purpose as consumerVersion before some version of a gradle plugin. But I can be wrong so it's still better just to upgrade lets say to 4.1.10 or even further up to 4.1.18

phil.endsley
2021-03-22 16:04
I think for a little bit, it was incorrectly named as providerVersion

a.chandrasekaran
2021-03-22 19:34
I am trying to verify a contract that has request cookie. I am using pact junit5 spring and mockmvc. *Contract Snippet:* ```"request": { "headers": { "Accept": "application/json, text/plain, */*", "Cookie": "ffm_access_token=value" },``` However, the controller is not getting invoked as the cookie is not getting passed. `12:24:58.272 [Test worker] DEBUG org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod - Could not resolve parameter [3] in public org.springframework.http.ResponseEntity<java.lang.Object> .VehicleTripController.getVehicleTrips(java.util.UUID,java.time.OffsetDateTime,java.time.OffsetDateTime,java.lang.String): Missing cookie 'ffm_access_token' for method parameter of type String` I verified during runtime the context had the required cookies in the header. Struggling with it for some time. Any help is greatly appreciated. ```@TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun pactVerificationTestTemplate(context: PactVerificationContext) { context.verifyInteraction() }```

joseph.method
2021-03-22 19:55
has joined #pact-jvm

dennyg666
2021-03-22 20:54
has joined #pact-jvm

me1295
2021-03-23 00:15
has joined #pact-jvm

a.chandrasekaran
2021-03-23 05:35
Update: Tried with Spring-junit5 and spring-junit as mentioned in the Doc. My controller class look like below. Both MockMvcTestTarget and MockMvcTestTarget were not able to populate CookieValue. If i change my controller param from `@cookievalue(token)` to `@RequestHeader("Cookie") cookie: String`. I am able to read the value. Look like a bug. Should I open an issue? *Controller Snippet:* `@GetMapping("/trips")` `fun getTrips(` `@PathVariable vehicleUuid: UUID,` `@CookieValue(token) token: String` `): ResponseEntity<Any> {` `return ResponseEntity.ok(` `mapper.toTripDtos(tripService.getVehicleTrips(vehicleUuid, token))` `)` `}`

anchit.99
2021-03-23 09:04
has joined #pact-jvm

joseph.method
2021-03-23 14:30
@joseph.method has left the channel

laxmi.somni508
2021-03-23 15:46
Thanks a lot guys.

wola.adedeji
2021-03-23 16:25
has joined #pact-jvm

kenny.shobowale
2021-03-23 16:38
has joined #pact-jvm

uglyog
2021-03-23 22:07
Please raise an issue for it

uglyog
2021-03-23 22:09
How have you specified the pact source?

ragarwal
2021-03-24 02:10
has joined #pact-jvm

a.chandrasekaran
2021-03-24 04:45
Thanks for the response. Will do after I rule out any error from my end.

anchit.99
2021-03-24 06:35
I'm new to Pact and I'm going through the pact-workshop. It says on Step 4 that in order to verify the pact against provider, we can use the gradle plugin. The benefit of this approach is that we don't need to write pact tests for the provider. But it mentions that the gradle plugin cannot be installed on windows. Does anyone know whether there exists an alternate way to verify pacts against the provider when on windows?

matt.fellows
2021-03-24 06:42
The gradle plugin works on Windows (I think), just not the specific way it?s been done in that step. I believe it uses a plugin to start the actual provider before the Pact verification tests run, and stop it after they have finished. That plugin only works on Windows

matt.fellows
2021-03-24 06:42
so TL;DR - you need to replace those with your own way to start/stop the server

anchit.99
2021-03-24 06:55
Okay great. Thank you for answering! :slightly_smiling_face:

maksym.motornyi
2021-03-24 07:21
Alternate way is to install Ubuntu

abubics
2021-03-24 07:38
The gradle Pact plugin works in Windows, just the thread spawning plugin doesn't. If you can find an alternative way to start the provider in the right profile (even if manually), it'll work just fine.

maksym.motornyi
2021-03-24 07:44
Well, I assume if @anchit.99 work on windows then he is able to run his server locally. If that is true then he can use local server to verify pact.

anchit.99
2021-03-24 08:52
I'm trying out step 13 now where we've added the pact broker. I startd the docker image using the command provided and I'm able to access the pact broker at http://localhost:9292 Up until step13 I have had pact files created locally and being transferred via gradle task (or manually). Now step 13 introduces the pact broker feature. However, when I try to build the gradle project in Intellij (or run any gradle task from earlier) I get the an exception which tells me that during the build process it's trying to fetch the URL: http://localhost:9292/pacts/provider/Our%20Provider/for-verification which doesn't exist because we just booted the docker image / broker service. So there is no existing pact in the broker. If I try to publish the existing pact file by using the following command: ```./gradlew consumer:pactPublish``` It fails. Here is the full exception trace. Could someone please help me out? How can I load a pact into the broker before building the gradle project? Running the gradle command directly from a powershell also leads to the same exception.

maksym.motornyi
2021-03-24 09:24
Would you like to publish pact on broker or verify it against local server?

anchit.99
2021-03-24 10:40
I would like to publish it against the local pact broker (the one which I brought up with the docker image) and then verify it with a local server (Dropwizard, if possible, that was supplied as part of the demo code)

anchit.99
2021-03-24 10:45
Here's a screenshot of the local server

maksym.motornyi
2021-03-24 10:46
Are you sure you need to publish it to local broker? Maybe you can just take the pact and verify it against any server without publishing.

anchit.99
2021-03-24 11:22
Sure, I've already completed that step of verifying it against the Dropwizard server. I want to try publishing/retrieving it with the local broker. It would be great if someone could help me with this exception (I've attached the full trace in the first message).

maksym.motornyi
2021-03-24 11:27
According to screenshots you use wrong provider name

anchit.99
2021-03-24 11:46
I think this has been reported. Just found this issue logged with a code fix: https://github.com/pact-foundation/pact-jvm/issues/356

anchit.99
2021-03-24 11:52
Sorry I'm new at this. What I understand here is that there's a catch 22 situation where the default step13 code with a fresh broker expects the broker to contain some pacts. Please correct me if I'm wrong.

anbu.pandian
2021-03-24 11:54
has joined #pact-jvm

anchit.99
2021-03-24 12:05
Thanks for responding to me and looking into this issue! But I think I've solved this issue on my own. The problem was that pact fails the build when using a local broker for the first time. This was being caused by the build.gradle for springboot. The solution was to comment out the last 3 lines where a check is made to the broker to find out whether there are any existing pacts. Adding the code here in case it helps anyone else stuck with the same problem on step#13. ```// if (project.hasProperty('pactBrokerUser') && pactBrokerUser != '<YOUR USER>') { // hasPactsFromPactBroker(pactBrokerUrl, authentication: ['Basic', pactBrokerUser, pactBrokerPassword]) // }```

scott.riley111
2021-03-24 15:07
has joined #pact-jvm

rachel.barton
2021-03-24 19:12
has joined #pact-jvm

uglyog
2021-03-24 21:48
@matt.fellows :point_up:

james522
2021-03-24 22:06
has joined #pact-jvm

matt.fellows
2021-03-24 23:11
Ah, makes sense!

matt.fellows
2021-03-24 23:12
I actually recall doing something similar locally once, but obviously I never pushed that up!

matt.fellows
2021-03-24 23:12
If you could please submit a PR, that will no doubt be helpful for others

maksym.motornyi
2021-03-25 06:55
@uglyog

anne.schuth320
2021-03-25 07:49
has joined #pact-jvm

anchit.99
2021-03-25 09:07
@matt.fellows I've logged the following issue for this: https://github.com/pact-foundation/pact-jvm/issues/1331 Thanks for responding back!

james.shirtcliffe
2021-03-25 12:04
has joined #pact-jvm

serhii.makarenko
2021-03-25 12:55
has joined #pact-jvm

mashabudryte
2021-03-25 14:35
has joined #pact-jvm

matthew.simon.barnes_
2021-03-25 16:08
has joined #pact-jvm

jose.manzano
2021-03-26 14:27
has joined #pact-jvm

chris.faulkner
2021-03-26 16:13
has joined #pact-jvm

chris.faulkner
2021-03-26 16:23
Hi - I am using PACT and completing provider tests with the Junit 5 provider. ```pact-jvm-provider-junit5_2.12-3.5.20.jar``` My implementations use Spring boot with the reactive WebClient, lots of asynchronous calls. I started by using a simple `HttpTestTarget`. I read on the docs (https://docs.pact.io/implementation_guides/jvm/provider/spring/) that I should use `WebFluxTarget` which is fine but it looks like this is only a Junit 4 and there?s not much concrete on that page to help me. Any pointers to docs or to let me know if it could work would be great. Thanks

bryanw
2021-03-26 18:46
has joined #pact-jvm

uglyog
2021-03-27 01:11
That's an old version. If you need to use WebFluxTarget you will have to upgrade to the latest

uglyog
2021-03-27 01:14
`au.com.dius.pact.provider:junit5:4.2.2`

uglyog
2021-03-27 01:15
Also, can you raise an issue to get the webflux target added to the JUnit 5 library

a.chandrasekaran
2021-03-27 03:40
Created an issue for this. https://github.com/pact-foundation/pact-jvm/issues/1333 Also, found one for adding header into mockmvctarget. https://github.com/pact-foundation/pact-jvm/issues/1334

chris.faulkner
2021-03-29 08:01
OK thanks for the feedback. I?m a bit confused - you seem to say that I just need to upgrade my dependency but then that it?s not available with Junit 5 (?) I have upgraded to latest version but don?t see WebFluxTarget

kerem.durak
2021-03-29 08:34
has joined #pact-jvm

dave.clissold
2021-03-29 12:40
has joined #pact-jvm

sidhant.bhayana.15
2021-03-29 18:34
has joined #pact-jvm

jarmy
2021-03-30 16:55
Is there anything available that reads a snippet of JSON and turns it into `PactDslJsonBody`?

crhawkins85
2021-03-30 21:02
has joined #pact-jvm

wesleythomaswilliams
2021-03-30 21:43
I believe this has been asked before and the answer is none that we know of currently, but I'll be very happy if someone corrects me on that.

abubics
2021-03-30 23:18
yeah, nah, we've seen stuff that goes the other way, though

pranav.gore
2021-03-31 01:58
has joined #pact-jvm

matt.fellows
2021-03-31 02:09
I?ve actually seen an example of this (previous client project) but don?t have the code for it sorry

matt.fellows
2021-03-31 02:09
It?s not terribly difficult, I think it was a half day?s work for another dev who knew Java

matt.fellows
2021-03-31 02:09
but even then, you still will want to look at the matchers etc.

harsha6988
2021-03-31 12:19
has joined #pact-jvm

leixu
2021-03-31 14:42
has joined #pact-jvm

wesleythomaswilliams
2021-03-31 14:49
I might see if I can beg one of our devs to do it and get it published externally. If we ever get some downtime that is.

matthew.brown
2021-03-31 15:15
has joined #pact-jvm

oleksandr.tryshchenko
2021-03-31 19:54
has joined #pact-jvm

jarmy
2021-03-31 22:25
Please beg nicely. This is beyond my capabilities but would be a huge help. I've written 3 different contract tests for different consumer/provider combinations and getting the `PactDslJsonBody` to match the body of the response is something I struggle with.

phelantomas
2021-04-01 13:13
has joined #pact-jvm

ktogias
2021-04-01 20:04
has joined #pact-jvm

ktogias
2021-04-01 21:36
@ktogias has left the channel

balaji.sivakumar
2021-04-02 05:41
has joined #pact-jvm

piotr.soltysiak
2021-04-02 06:33
Hi guys, I'm writing my provider tests with pact + spring slice tests (`@WebMvcTest`) + junit test templates. This combination allows me to "turn off" business logic and mock the interactions, so my tests are very fast and strictly focused on contracts. I'm quite happy wit it, but there is one thing I cannot solve - the test class becoming bigger and bigger (by injected MockBeans, declaring state change handlers etc) :slightly_smiling_face: *Is there any way to split such configuration so i would have single spring-slice-test class per provider controller?* I was thinking about using `@PactFilter`, but there are two problems with it (or I am not aware of solution): ? you have to be careful, because all interactions have to be verified in order to publish the results to broker (and there is no way to automatically check in in the build time) ? you have to declare the filtered provider states in the annotation (it would be a great feature if you could simply filter out the state change handlers declared in test class)

robert.strehli
2021-04-02 11:02
Hey guys, I'm currently working on a project to use pact with kafka. As a first step I wanted to try out the consumer example project from https://github.com/pactflow/example-consumer-java-kafka. I cloned it and tried to start it, but there were essential files missing like the `kafka-cluster.yml` and now a start script is missing. I'm currently trying to get it running by comparing it with the `example-consumer-js-kafka`. I just wanted to ask if there is a extra tutorial or an essential step I overlooked?

matt.fellows
2021-04-02 12:19
Hmm my apologies, I'll have to look next week for you (long weekend here in Australia)

matt.fellows
2021-04-02 12:20
But hopefully the tests should run without needing docker, I can't recall (sorry not near a computer right now)

matt.fellows
2021-04-02 12:20
I've set a reminder for Tuesday

uryadov212
2021-04-05 20:52
has joined #pact-jvm

soumya.aithal966
2021-04-05 22:45
has joined #pact-jvm

sheyan.rizfee
2021-04-06 00:55
has joined #pact-jvm

piotr
2021-04-06 09:24
has joined #pact-jvm

dmitry.korolev
2021-04-06 11:47
has joined #pact-jvm

matt.fellows
2021-04-06 12:02
looking/fixing now?

matt.fellows
2021-04-06 12:39
OK, I?ve re-added the cluster and added a small producer (via the `make test-events)`

matt.fellows
2021-04-06 12:39
hopefully that helps

matt.fellows
2021-04-06 12:39
albeit, the tests should still of course have worked without!

robert.strehli
2021-04-06 12:46
great thanks for the help!! It works now also for me!

sravyavadrevu988
2021-04-06 20:40
has joined #pact-jvm

johnnycareer
2021-04-06 21:34
has joined #pact-jvm

johnnycareer
2021-04-06 21:41
@johnnycareer has left the channel

matt.fellows
2021-04-07 00:59
Awesome, thanks for confirming Robert

danil.nurgaliev
2021-04-07 12:26
has joined #pact-jvm

gtsifrikas
2021-04-08 08:53
has joined #pact-jvm

kanapuramamarnath
2021-04-08 09:18
has joined #pact-jvm

chris.faulkner
2021-04-08 13:02
Hello. I have added a provider verification class. When I try to run I see this ```Cannot inherit from final class java.lang.VerifyError: Cannot inherit from final class at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) at au.com.dius.pact.provider.spring.junit5.PactVerificationSpringProvider$provideTestTemplateInvocationContexts$1.apply(PactVerificationSpringProvider.kt:26) at au.com.dius.pact.provider.spring.junit5.PactVerificationSpringProvider$provideTestTemplateInvocationContexts$1.apply(PactVerificationSpringProvider.kt:12) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)``` Is this something anyone else has seen ? My gradle config adds this as a version `testImplementation("au.com.dius.pact.provider:junit5spring:4.2.3")`

chris.faulkner
2021-04-08 13:41
When I change 4.2.3 to 4.2.2 it?s OK

rodrigo.costa20
2021-04-08 21:01
Hey guys! I'm using pact-jvm and I'm on a test where my provider when he performs the request, it has to get data from a 3rd party api... so a way that I found to mock this 3rd party api on provider-side was using wiremock... but I'd like to know... is using wiremock on pact to cases like this a bad practice?

uglyog
2021-04-08 22:52
This is the downside of using Kotlin. Please raise an issue for that

uglyog
2021-04-08 22:53
If it works, use it

rodrigo.costa20
2021-04-09 01:20
thanks!


arnaud.dutrillaux
2021-04-09 10:59
has joined #pact-jvm

gsinghania
2021-04-09 15:40
has joined #pact-jvm

gsinghania
2021-04-09 15:42
Is there an example of How we create Mocks in @states at the Provider Side ? My Consumer is Making a GET call and I want to first perform POST with the Mocks any idea ?

souravmohanty35
2021-04-09 16:34
has joined #pact-jvm

itzdavey
2021-04-09 17:23
has joined #pact-jvm

uglyog
2021-04-10 02:42
Depends on what test and mocking libraries you are using

phil.endsley
2021-04-11 23:15
Are there any labels or anything used in the github issues for help wanted? If not, any suggestions for something I can look into? Otherwise, I'll just browse the open issues I guess. Took a brief break and want to try to contribute a little more regularly

uglyog
2021-04-11 23:25
Let me have a run through the list as well as well.

uglyog
2021-04-11 23:27
Actually, there is an interesting suggestion to allow loose matching of status codes (i.e success or error, or maybe allowing a subset of status codes)


phil.endsley
2021-04-11 23:39
Yeah, sounds good. I'll read through the issue and the linked spec/proposal later tonight

tmorrison
2021-04-12 00:19
@tmorrison has left the channel

phil.endsley
2021-04-12 03:27
6 months later...opened PRs for the rest of the steps of https://github.com/pact-foundation/pact-workshop-jvm-spring/pulls This is a spring boot workshop that mirrors the reworked js one. Better late than never, right? :sweat_smile:

uglyog
2021-04-12 03:35
I've merged them

uglyog
2021-04-12 03:37
I'll run through it when I have a spare moment

matt.fellows
2021-04-12 06:36
Awesome - thanks @phil.endsley :taco: :taco: :taco:

bheemreddy181
2021-04-13 02:37
How do we generate auth regex in pact jvm ?

bheemreddy181
2021-04-13 02:39
a regex like this is adding special characters in the pact file ``` .matchHeader("Authorization", "APIAuth us:.*")```

bheemreddy181
2021-04-13 02:41
turns into this ```"Authorization": "APIAuth us:?",```

bheemreddy181
2021-04-13 02:41
from pact jvm 3.0 specification

phil.endsley
2021-04-13 02:44
If you don't supply an example value, Pact will generate one for you. The generated value chooses any character that fulfills the pattern. To prevent this, you can do ```.matchHeader("Authorization", "APIAuth us:.*", "APIAuth us:yourValueHere")```

phil.endsley
2021-04-13 02:50
Another option would be to be more restrictive in your regex pattern. Ex: Specifying alphanumeric ranges instead of allowing any character

bheemreddy181
2021-04-13 03:46
Makes sense thanks

laura.edington
2021-04-13 17:45
has joined #pact-jvm

liam.mcdermott
2021-04-13 22:38
has joined #pact-jvm

anchit.99
2021-04-14 09:50
I have a very basic question regarding the *Client* class. I'm trying to understand the code present in *pact-workshop-jvm* . Let's say we have microservice A (consumer) that talks to microservice B (provider). Let's say that normally A would send a "`request1`" and receive a "`response1`" from B. So we're first going to write `@Pact` method that mocks B. This `@Pact` method would define `request1` and `response1` based on expected values. So far so good. Next we're going to write `@PactVerification` method that interacts with the mock and generates the actual pact. Inside this method we are instantiating a `Client` class. In a real microservice, *what would this "Client" class represent?* Does this mean we're opening the *source code* of *microservice A -->* finding the class/component that makes a request to B, and then importing that same class into our test and instantiating it in order to make a request? In other words, in order to write contract tests I would need access to the source code of microservice A. Or, does this mean that we're creating a *generic client* on our own (AKA *Client* = *any code that has the capability to make a request to B*) and then instantiating our custom-made client to send/receive whatever responses we want?

maksym.motornyi
2021-04-14 10:03
You are creating the code that generates pact. Pact is a json file that contain verification rules. You can use this pact to: 1. Generate mocked response that will fit the rules in the pact. 2. Verify any server that needs to has the contract described in the pact. You don't actually need access to source code of a server.

anchit.99
2021-04-14 10:45
I'm sorry, this doesn't answer the question exactly. Let me ask in a different way. Who would typically write the code for the "Client" module? Would it be the tester writing the Pact tests or would it be the developers of either microservice team?

matt.fellows
2021-04-14 11:15
The answer is yes, you need to use the source code to generate the Pact

matt.fellows
2021-04-14 11:15
Otherwise, you can't be sure your code actually makes the call and therefore might out something into a contract that isn't valid

matt.fellows
2021-04-14 11:16
Answering the second question, it's usually a developer. But if you have access to the source code then the role is irrelevant.

matt.fellows
2021-04-14 11:16
But think of it as a unit test

matt.fellows
2021-04-14 11:17
For an approach that's more relevant to testers, see https://pactflow.io/blog/bi-directional-contracts/

anchit.99
2021-04-14 11:44
@matt.fellows Thank you so much for clarifying this! This ties several concepts. :slightly_smiling_face: :+1:

matt.fellows
2021-04-14 11:51
You're welcome

francislainy.campos
2021-04-14 12:45
Hi all, good afternoon. I have a general query about the need to set the content type for pact as I?ve been getting an error on my tests that read ```java.lang.AssertionError: 0 - Index 1 out of bounds for length 1``` whenever I only have application/json there for the header within the contract and I need to add charset=utl-8 to bypass that. So, this: ```"response": { "status": 200, "headers": { "Content-Type": "application/json; charset=utf-8" },``` vs this: ```"response": { "status": 200, "headers": { "Content-Type": "application/json;" },``` I don?t have charset-8 coming back from the server response so if I add this to contract the out of bounds error is fixed but the assertion on the header fails and as a workaround for the moment I?m removing the verification on the header altogether.

francislainy.campos
2021-04-14 13:06
Thank you.

wedlaaa
2021-04-14 13:33
has joined #pact-jvm

wedlaaa
2021-04-14 13:36
hello all! i opened this issue on github, but someone replied that it was more a help request than a pact issue, so I joined you here :slightly_smiling_face: can someone help me?

maksym.motornyi
2021-04-14 13:48
In case of necessity to add new parameters into to the endpoint would be better to introduce new one so avoid any problems )

maksym.motornyi
2021-04-14 13:49
This is just my thoughts

maksym.motornyi
2021-04-14 13:49
How does that feature flag concept works on their side?

maksym.motornyi
2021-04-14 13:50
It would be nice if you could provide example of what are you talking about to be able to understand the problem

wedlaaa
2021-04-14 13:51
hi! thank you for your answer! :slightly_smiling_face: they check in an if else kind of way, so if the feature is on, they apply the validations otherwise all remains the same

wedlaaa
2021-04-14 13:55
ok, Maksym, let me give the example: it was asked to add new fields and validations to the endpoints that already exist. in order to not break the contract already made, the development team used the concept of feature flag. when is on, they validate the fields, for example, they inserted a new field which is an enum. if the feature in on, i pass an inexistent value to the field and i have to receive a client error from the server, but if the feature is off, nothing happens

wedlaaa
2021-04-14 13:56
so i have to run two tests, one when the feature is on and another when the feature if off

wedlaaa
2021-04-14 13:57
i wanted to skip the test based on a system property, and for that i used the assumeTrue from JUnit, but @PactVerification doesn't allow that

wedlaaa
2021-04-14 13:57
the test fails

maksym.motornyi
2021-04-14 13:58
yeah, that's pretty expected

maksym.motornyi
2021-04-14 13:59
From what I know generated pact do not allow such kind of conditional checks

maksym.motornyi
2021-04-14 13:59
and it makes sense

maksym.motornyi
2021-04-14 13:59
because API endpoint it's an interface

maksym.motornyi
2021-04-14 14:00
and in case of such kind of workaround like your server has it breakes 4th SOLID principle

maksym.motornyi
2021-04-14 14:02
You actually can continue to use workaround and generate special pact for the case when parameters are required and for the case when they are not. But you'll end up with a mess of huge amount of pacts in this case

maksym.motornyi
2021-04-14 14:03
In other words your endpoint has more than one contract and that's bad

maksym.motornyi
2021-04-14 14:04
Maybe I'm wrong but it really sounds like you're in trouble :smiley:

wedlaaa
2021-04-14 14:04
i super agree with you, my dear friend!

wedlaaa
2021-04-14 14:04
i'm in deep trouble

wedlaaa
2021-04-14 14:06
but what do you suggest in this case? how can i skip the pact verification?

maksym.motornyi
2021-04-14 14:12
remove this verification at all :smiley:

maksym.motornyi
2021-04-14 14:15
or post endpoint details and json example maybe somebody will offer some workaround

maksym.motornyi
2021-04-14 14:15
you can let's say obfuscate the details if you want to keep the information under NDA

maksym.motornyi
2021-04-14 14:17
How do you verify the header?

francislainy.campos
2021-04-14 14:21
Hi, sorry, not sure if I?m answering this as you?d expect, but it?s verified together with the contract, just so see if the content type is a match. This is how it?s set on the contract. ```const interaction = { state: 'i have a list of teachers', uponReceiving: 'a request for a list of teachers', withRequest: { method: 'GET', path: '/ids/v1/schools/54d2a3eb-0010-4988-9d41-ec68ea869399/teachers', headers: { Accept: '*/*', }, }, willRespondWith: { status: 200, headers: { 'Content-Type': 'application/json;', }, body: GET_EXPECTED_BODY, }, };```

maksym.motornyi
2021-04-14 14:22
Is it java script?)

francislainy.campos
2021-04-14 14:22
``` @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactTestTemplate(PactVerificationContext context, HttpRequest request) { context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpsTestTarget("myapi", 443, "/")); } @State("i have a list of states") void sampleState() { }```

francislainy.campos
2021-04-14 14:22
This is the provider done in java.

francislainy.campos
2021-04-14 14:23
The contract is done by the consumer in javascript.

maksym.motornyi
2021-04-14 14:25
Looks like you need proper matcher that will allow both variants of headers. Try to ask in #pact-js channel

wedlaaa
2021-04-14 14:54
that's ok, but the problem is not with the pact itself, the problem is that i have two contracts that only run when a condition is met

wedlaaa
2021-04-14 14:55
i can't remove the validation because when the feature flag is on, i need to verify if they really implemented it


wedlaaa
2021-04-14 15:47
i'm using pact consumer junit version 4.1.18 and it's not there anymore


maksym.motornyi
2021-04-14 16:42
@wedlaaa is using pact consumer junit version 4.1.18 and it's not there anymore

aliaksandr.valadzko
2021-04-14 16:47
Hey guys! Getting strange issue in one of my projects (no such issue in other projects, all versions are the same across all the projects) ```@Category(PactProvider.class) @Provider("my_provider") @PactBroker( host = "http://my.host.net", scheme = "http", authentication = @PactBrokerAuth(scheme = "bearer", username = "mytoken", password = "")) or this @Category(PactProvider.class) @Provider("my_provider") @PactBroker(host="http://my.host.net", port = "80") public class MyConsumerPactTest { ...```

aliaksandr.valadzko
2021-04-14 16:47
```java.lang.NoSuchMethodError: au.com.dius.pact.core.model.BrokerUrlSource.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V at au.com.dius.pact.provider.ConsumerInfo$Companion.from(ProviderClient.kt:170) at au.com.dius.pact.provider.junit.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:140) at au.com.dius.pact.provider.junit.loader.PactBrokerLoader.load(PactBrokerLoader.kt:92) at au.com.dius.pact.provider.junit.PactRunner.initialize(PactRunner.kt:85) at au.com.dius.pact.provider.junit.PactRunner.getChildren(PactRunner.kt:140) at org.junit.runners.ParentRunner.getFilteredChildren(ParentRunner.java:426) at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:351) at org.junit.runners.Suite.describeChild(Suite.java:123) at org.junit.runners.Suite.describeChild(Suite.java:27) at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:352) at org.junit.runners.ParentRunner.run(ParentRunner.java:359) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:748)```

aliaksandr.valadzko
2021-04-14 16:48
Any thoughts?:pray:

phil.endsley
2021-04-14 18:08
Not sure what your setup looks like, but... Could you add another contract and use the state methods to control whether the feature flag is on/off? If the expected response is different based on that, maybe that would work? Unless the endpoint is the same for both (i.e. no path or query params)

wedlaaa
2021-04-14 18:10
unfortunately, the endpoint is the same :disappointed:

phil.endsley
2021-04-14 18:10
> 82ccb26 - deprecating the expectMismatch value on @PactVerification because it causes too much confusion #245 (Ronald Holshausen, Wed Apr 27 14:58:15 2016 +1000) https://docs.pact.io/implementation_guides/jvm/changelog/#327---bugfix-release Looks like it was deprecated a while ago, and was finally removed

phil.endsley
2021-04-14 18:16
Bummer... So, I know it doesn't help you, but I want to lay out my thought process here. Really, ~~~the provider team made a breaking change to the API, and these are the things that Pact is supposed to prevent~~~. edit: I don't think this is quite right You have a consumer and provider. The feature flag is a dynamic switch on the provider (I'm assuming). This means for the release it was added, it can be turned on and off at will without changing the provider's code base (i.e. it's the same version). Because the consumer expects both to be supported (it can call either one), the provider must support both. You can't run the provider tests for only one or the other, because the other scenario would be unverified. Your provider must be capable of supporting both. Because of this, I don't think the right approach would be to ignore verification for certain conditions. Obviously, this is all in an ideal world.

phil.endsley
2021-04-14 18:18
Have you tried adding another contract for the same endpoint, but different state (That would control the feature flag)? I don't have a setup available to test it out, and I don't remember if Pact allows it. If not, perhaps this is what it needs to do? I'm sure there are a few different approaches that would work, but this could be one way?

phil.endsley
2021-04-14 18:31
Kind of looks like a version mismatch. Do you have multiple versions of pact libraries on the same class path?

wedlaaa
2021-04-14 18:31
Phil, thank you so much for your attention and kind answer. I did understand your approach, but the problem is that if i do it, i need to tell the provider which scenarios have to be run, and i don't think we have this is Pact right now, but it would be great if they develop it

wedlaaa
2021-04-14 18:34
as I use maven, i cloned my test classes in which ones will run the "deprecated" tests (flag off), and i put these classes in a package

wedlaaa
2021-04-14 18:34
and now i'm running this way: mvn test -Dtest=com.deprecated.*.*Test

phil.endsley
2021-04-14 18:35
What I'm saying is the provider should always run every scenario. Otherwise, you can't guarantee it supports all cases the consumer needs You need a way to say (from the consumer): ? i expect response x when feature flag is off ? I expect response y when feature flag is on And the provider needs a way to run both in the same test suite

phil.endsley
2021-04-14 18:35
But in your case, the only thing changing in the request is the state. That's what I'm not sure if pact supports or not

wedlaaa
2021-04-14 18:36
that's right, Phil, but I have to turn the flag on and off on the server (i'm testing locally), so half the tests will always fail, do you understand?

aliaksandr.valadzko
2021-04-14 18:36
Thanks for responding @phil.endsley ```pactConsumerJunit : "au.com.dius.pact.consumer:junit:4.1.7" pactProviderJunit : "au.com.dius:pact-jvm-provider-junit:4.0.10" pactProviderSpring: "au.com.dius:pact-jvm-provider-spring:4.0.10"```

aliaksandr.valadzko
2021-04-14 18:39
But I had no any issues with this ^ set up before in other projects

phil.endsley
2021-04-14 18:39
Yes. I guess that was why I had the disclaimer about not knowing your setup, how you're starting/running your server for the tests). I've been primarily in spring boot land for a long time now, and, in my experience, the feature flag would be pretty straight forward to configure per test But run configs also vary wildly between organizations, and even within orgs

aliaksandr.valadzko
2021-04-14 18:40
I don't understand what possibly can be wrong here

phil.endsley
2021-04-14 18:41
You should be using the same version across all pact libs. I would bet that method exists in either 4.1.7 or 4.0.10, but not the other


aliaksandr.valadzko
2021-04-14 18:42
But there is no version matching, correct?


aliaksandr.valadzko
2021-04-14 18:43
I mean there is no `4.1.7` for `au.com.dius:pact-jvm-provider-junit` and `"au.com.dius:pact-jvm-provider-spring` And no `4.0.10` for `au.com.dius.pact.consumer:junit`

aliaksandr.valadzko
2021-04-14 18:51
However you was right

aliaksandr.valadzko
2021-04-14 18:52
Excluding `au.com.dius.pact.consumer:junit` from this project fixed problem

aliaksandr.valadzko
2021-04-14 18:52
Thank you so much, @phil.endsley!

phil.endsley
2021-04-14 18:53
Np. The recommendation would be to update the provider libs to the new package and use the latest versions. Either way, I'm glad we got it worked out!

wderksen
2021-04-14 22:26
has joined #pact-jvm

uglyog
2021-04-15 00:50
> In a real microservice, *what would this "Client" class represent?* The client class is the class that is responsible for making the requests to the other service. If your service talks to many other services, it makes sense to have a client for each separate service.

uglyog
2021-04-15 00:51
It is part of the service code, and is written by the developer who is writing the service. That way it can be easily re-used in the tests.

matt.fellows
2021-04-15 01:06
Thanks so much - :taco: for @phil.endsley!

abubics
2021-04-15 01:56
> The development team had to add more fields to existing endpoints of an API, but [...] this breaks the contract between consumers and provider If you're saying that the API has new required fields in the *request*, then Pact is absolutely doing its job, letting them know that it's not safe to deploy until all consumers can satisfy the new requirement. If you want the provider build not to break, and also wait for consumers to catch up, I think pending Pacts might be designed for this use case?

mail_4brad
2021-04-15 02:34
has joined #pact-jvm

anchit.99
2021-04-15 04:37
@uglyog Thank you Ron for clarifying this!

github
2021-04-15 05:02
:warning: *Action required - upgrade app for Pact Foundation* :warning:

matt.fellows
2021-04-15 05:19
I just did this upgrade

anja.gruss
2021-04-15 09:33
is there a way to suppress request header matching? or matching only one 1 specific key?

matt.fellows
2021-04-15 10:30
What problem are you having? To suppress matching you essentially don't include it in the consumer test

anja.gruss
2021-04-15 10:44
I get an ?unexpected response? , and basically I would only be interested in making sure the Content-Type header is set correctly, the other headers for the request are of no interest to me

anja.gruss
2021-04-15 11:00
even leaving out the header in the pact builder, I stil get an unexpected response

matt.fellows
2021-04-15 11:12
this the consumer side or provider side?

anja.gruss
2021-04-15 11:14
consumer side

matt.fellows
2021-04-15 11:19
could you please paste the error?

matt.fellows
2021-04-15 11:19
and/or code

anja.gruss
2021-04-15 11:20
error: `{"error":"Unexpected request : \tmethod: POST\n\tpath: /machines-service/v1/machines/\n\tquery: {}\n\theaders: {Accept-encoding=[gzip, x-gzip, deflate], Accept=[application/json], Connection=[keep-alive], Host=[localhost:49686], User-agent=[Apache-HttpClient/5.0.3 (Java/14.0.2)], Content-type=[application/json], Content-length=[38]}\n\tmatchers: MatchingRules(rules={})\n\tgenerators: Generators(categories={})\n\tbody: PRESENT({\"name\":\"Neue Maschine\",\"active\":true})"}`

anja.gruss
2021-04-15 11:21
pact builder: ```MachineCreation createMachine = new MachineCreation(); createMachine.setActive(true); createMachine.setName("Neue Maschine"); ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper(); Map<String, String> headers = Map.of("Content-Type", "application/json"); final DslPart responseBody = newJsonBody( (body) -> { body.stringType("id"); body.stringType("name"); body.booleanType("active"); }) .build(); return builder .given("a new machine can be created") .uponReceiving("a request to create a new machine with minimal data") .path("/machines-service/v1/machines") .method("POST") // .headers(headers) .body(new JSONObject(mapper.writeValueAsString(createMachine))) .willRespondWith() .status(201) .headers(headers) .body(responseBody) .toPact();```

matt.fellows
2021-04-15 11:22
ah, great. It should actually ignore headers (it?s the one exception to the rule: https://docs.pact.io/getting_started/matching/gotchas/#but-pact-breaks-postels-law-for-request-headers)

matt.fellows
2021-04-15 11:22
I could be wrong here, but it might be the extra trailing `/` on the path

matt.fellows
2021-04-15 11:23
see how the unexpected request has `/machines-service/v1/machines/` but you have `/machines-service/v1/machines` in your test

matt.fellows
2021-04-15 11:23
subtle, but different

anja.gruss
2021-04-15 11:23
oh jesus christ

matt.fellows
2021-04-15 11:24
was that it? :grimacing:

anja.gruss
2021-04-15 11:24
gimme a sec

anja.gruss
2021-04-15 11:28
yeah, it was the slash ? damnit, I was so sure I messed something up in the body or somewhere ? thanks a lot Matt!

matt.fellows
2021-04-15 11:29
all good - I?m thinking about if that mismatch could be better displayed

matt.fellows
2021-04-15 11:30
With others, it shows the expected mismatch and the actual request. Was there no other log file or output?

anja.gruss
2021-04-15 11:30
unfortunately not, probably one of the reasons why I got so confused

matt.fellows
2021-04-15 11:31
hmm

anja.gruss
2021-04-15 11:31
they host the broker themselved, and I am not sure which version it is

matt.fellows
2021-04-15 11:32
(just checknig a code example I have to see how it behaves)

matt.fellows
2021-04-15 11:34
Are you using the JUnit clietn?

matt.fellows
2021-04-15 11:34
I get this: ```21:33:10.271 [HTTP-Dispatcher] DEBUG au.com.dius.pact.consumer.BaseJdkMockServer - Received request: method: GET path: /product/110 query: {} headers: {Accept-encoding=[gzip,deflate], Accept=[application/json], Connection=[Keep-Alive], Host=[localhost:52174], User-agent=[Apache-HttpClient/4.5.10 (Java/15.0.2)]} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: EMPTY 21:33:10.271 [HTTP-Dispatcher] DEBUG au.com.dius.pact.core.matchers.RequestMatching - comparing to expected request: method: GET path: /product/10 query: {} headers: {} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING 21:33:10.470 [HTTP-Dispatcher] DEBUG au.com.dius.pact.core.matchers.Matching - Found a matcher for text/plain -> au.com.dius.pact.core.matchers.PlainTextBodyMatcher@37f54f53 21:33:10.470 [HTTP-Dispatcher] DEBUG au.com.dius.pact.core.matchers.RequestMatching - Request mismatch: [PathMismatch(expected=/product/10, actual=/product/110, mismatch=null)]```

matt.fellows
2021-04-15 11:34
FRom that, I can see that the path was incorrect (the final line shows the specific expected/actual failure)

anja.gruss
2021-04-15 11:35
ah, yes, that would have been a lot more informative

matt.fellows
2021-04-15 11:35
I have to run, sorry, but this is the project: https://github.com/pactflow/example-consumer-java-junit

anja.gruss
2021-04-15 11:35
thanks, have a nice, err..evening?

matt.fellows
2021-04-15 11:35
I?ll follow back up this thread tomorrow

matt.fellows
2021-04-15 11:35
yes, nigth time - I get to go and wash some dishes now. How exciting! :stuck_out_tongue:

matt.fellows
2021-04-15 11:35
:wave:

goncalosamuel
2021-04-15 15:08
has joined #pact-jvm

matthew.hall
2021-04-15 17:36
has joined #pact-jvm

raony
2021-04-15 19:21
has joined #pact-jvm

gupta.ratnesh9
2021-04-16 04:48
has joined #pact-jvm

greg595au
2021-04-16 10:00
has joined #pact-jvm

wedlaaa
2021-04-16 12:53
hi, Boris, yes! i was studying pending pacts, but unfortunately, I'm the only veteran tester in the team, so I have no one to help me build it :disappointed: that's why i was looking for another approach

manel_ben_yahia
2021-04-16 13:59
has joined #pact-jvm

manel_ben_yahia
2021-04-16 14:02
Hi i am trying to generate a Pact between two Micro services, i have an error when i create Pact with junit5, creating RequestResponsePact

manel_ben_yahia
2021-04-16 14:03
~when i put .query() to put a query param i have an error assertion~

manel_ben_yahia
2021-04-16 14:03
~it is supposed to render 200 and i get 500~

manel_ben_yahia
2021-04-16 14:03
~when i remove the .query() all works~

manel_ben_yahia
2021-04-16 14:04
~i am spending some time and don't find a solution can you please help me on this ?~

maxence
2021-04-17 11:07
has joined #pact-jvm

kranti.deep
2021-04-17 14:17
has joined #pact-jvm

aaronw153
2021-04-17 21:42
has joined #pact-jvm

abubics
2021-04-18 06:10
I haven't had a chance to use it yet (I expect I will in the next few months :pray:) . . . at the very least, you can check https://docs.pact.io/pact_broker/advanced_topics/pending_pacts/#to-start-using-the-pending-pacts-feature. If not, you'll almost certainly need more dev help. But if you can narrow down which bits you need help with, it might help you make your case :innocent:

abubics
2021-04-18 06:13
The only other way I can think to avoid breaking the provider build is to manually implement your own version of pending pacts, which is probably even more work. To do that, you could (dangerously?) allow/block specific feature branch names in the provider verify.

abubics
2021-04-18 06:14
If you want to integrate it with your feature flags, you could maybe change the branch selection based on your flags configuration. But it still sounds like more work than using the pending pacts feature :thinking_face:

github
2021-04-19 00:57
GitHub app is successfully upgraded in your workspace :tada: To receive notifications in your private channels, you need to invite the GitHub app `/invite @GitHub`

matt.fellows
2021-04-19 04:27
@uglyog @phil.endsley we now have two JVM workshops: https://github.com/pact-foundation/pact-workshop-jvm-spring and https://github.com/DiUS/pact-workshop-jvm. Do we still need both? I ask, because if they are similar, I?m inclined to make one the ?main? one and make a note / archive the old one. Thoughts?

uglyog
2021-04-19 04:30
Archive the Dius one then, it's the older one

matt.fellows
2021-04-19 04:30
thanks

matt.fellows
2021-04-19 04:31
I ask (in part) because of this issue: https://github.com/DiUS/pact-workshop-jvm/issues/23

matt.fellows
2021-04-19 04:31
I just replicated: ```java -jar /Users/matthewfellows/development/public/pact-workshop-jvm/providers/springboot-provider/build/libs/springboot-provider.jar is ready. > Task :providers:springboot-provider:pactVerify_Our_Provider FAILED Expected a PactSource, but got /Users/matthewfellows/development/public/pact-workshop-jvm/providers/springboot-provider/build/pacts/Our Little Consumer-Our Provider.json Failed to load pact file java.lang.NullPointerException at au.com.dius.pact.provider.ProviderVerifier.loadPactFileForConsumer(ProviderVerifier.kt:744) at au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer(ProviderVerifier.kt:671) at au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer$default(ProviderVerifier.kt:669) at au.com.dius.pact.provider.ProviderVerifier.verifyProvider(ProviderVerifier.kt:649) at au.com.dius.pact.provider.gradle.PactVerificationBaseTask.runVerification(PactVerificationBaseTask.kt:11) at au.com.dius.pact.provider.gradle.PactVerificationTask.verifyPact(PactVerificationTask.groovy:49) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)```

matt.fellows
2021-04-19 04:31
And then remembered there was a new workshop

github2
2021-04-19 05:48
[pact-foundation/pact-jvm] Issue opened by uglyog

kranti.deep
2021-04-19 06:59
@kranti.deep has left the channel

maksym.motornyi
2021-04-19 08:39
Is it true that pact v4 will allow to verify arrays that may contain different types of objects?

matt.fellows
2021-04-19 09:53
Yes, I believe it's already in the JVM but I'd need to check

github2
2021-04-19 10:10
[pact-foundation/pact-jvm] Issue opened by tlinkowski

dwmahieddine
2021-04-19 12:44
has joined #pact-jvm

maksym.motornyi
2021-04-19 14:53
Is it possible to measure test coverage using pact?

caiquedpfc
2021-04-19 16:43
Hi guys how are you? I'm writing my first contract test and I'm having trouble importing Pact annotations from my Java provider, apparently the project doesn't recognize the gradle plugin, because I can't import things like @Provider @PactFolder @TestTarget among others, can someone help me please? I'm importing pact with: ```plugins { id "au.com.dius.pact" version "4.1.0" id "org.sonarqube" version "2.7.1" id 'io.franzbecker.gradle-lombok' version '2.1' id 'org.springframework.boot' version '2.1.7.RELEASE' id 'java' }``` And my gradleVersion id 5.5.1 This is my code: ```package br.com.quintoandar.fastforward.api.longtermanticipation; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; @RunWith(SpringRestPactRunner.class) @Provider("fast-forward") @PactFolder("pacts") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class LongTermAnticipationProviderTest { @TestTarget public final Target target = new SpringBootHttpTarget(); @State("Check LRA status") public void checkLRAStatus() { // nothing to do, real service is used } }```

garrettmichael
2021-04-19 18:34
has joined #pact-jvm

matt.fellows
2021-04-19 22:43
The plugin is just for gradle, you still need to import the main pact test libraries

uglyog
2021-04-19 22:50
Yes, search for array contains matcher

caiquedpfc
2021-04-20 01:08
Hi @matt.fellows, thank you very much for your help :heart: my project has only build.gradle. How can I import the main pact test libraries?


daniel.kalleward
2021-04-20 08:16
has joined #pact-jvm

github2
2021-04-20 11:52
[pact-foundation/pact-jvm] Issue opened by pawelryznar

mattias.persson
2021-04-20 12:45
has joined #pact-jvm

martin.eklund
2021-04-20 12:47
has joined #pact-jvm

enda.brody
2021-04-20 17:37
has joined #pact-jvm

cristian.moisa
2021-04-20 18:25
has joined #pact-jvm

abubics
2021-04-21 01:08
Maybe a longshot, but anyone had issues with pact-provider + kotest in Maven? I don't usually use Maven, it seems like a subpackage conflict (at runtime).

james.elsey
2021-04-21 01:14
Hi team, I?ve updated my junit pact dependency from `4.0.3` -> `4.1.20` and it?s broken my pact tests. No other changes, just a lib update due to some CVEs. It?s complaining about `.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.4.21/kotlin-stdlib-1.4.21.jar; zip file is empty`, any ideas?

uglyog
2021-04-21 01:15
Try delete that file from your local Maven repo and try running your build again

darccide
2021-04-21 01:35
has joined #pact-jvm

james.elsey
2021-04-21 02:14
Thanks, that resolved it :thumbsup:

abubics
2021-04-21 04:47
Any pro-tips for enabling debug logging, so I can see what requests the mock service received? > Just enable debug level logging for `http://au.com.dius.pact.consumer.UnfilteredMockProvider`. This line in the docs gives me the hint, but the rest of the docs don't mention any specifics, and the slf4j docs are impenetrable. I'm using gradle, and I don't have any logging configured in this demo codebase.

uglyog
2021-04-21 04:48
Just add logback to your classpath. I think it defaults to DEBUG if there is no logging config


github2
2021-04-21 04:53
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-04-21 04:55
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-04-21 04:55
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-04-21 04:56
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-04-21 04:56
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-04-21 04:57
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-04-21 04:59
[pact-foundation/pact-jvm] Issue closed by uglyog

abubics
2021-04-21 05:06
Perfect thanks, now I have a real error :sweat_smile::tada:

github2
2021-04-21 05:07
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-04-21 05:07
[pact-foundation/pact-jvm] Issue closed by uglyog

uglyog
2021-04-21 05:10
I'm so sorry! :smile:

abubics
2021-04-21 05:12
Ok, real error now: ```ERROR au.com.dius.pact.consumer.BaseJdkMockServer - Failed to generate response au.com.dius.pact.core.model.InvalidPathExpression: Expected a "." or "[" instead of "$" in path expression "$.amendments[*]$.amendmentID" at index 15``` Not too sure what to make of this, it seems like the mock server can't generate the JSON response, but it cites the matchers on the request :thinking_face:

abubics
2021-04-21 05:13
Not sure what would end up in the pact file, it's not generating that interaction (because of the error, I suppose)

abubics
2021-04-21 05:14
Not doing anything too crazy, afaict: ```.body( PactDslJsonBody().eachLike( "amendments", newJsonBody { it.uuid("amendmentID") }.build() ) )```

uglyog
2021-04-21 05:14
That expression is wrong, it looks like it has two expressions concatenated (i.e. there shouldn't be a dollar in the middle)

abubics
2021-04-21 05:15
ok, cool, I'll play around with the DSL until it works :ok_hand:

uglyog
2021-04-21 05:15
Or raise an issue on Github and some person will look into it

abubics
2021-04-21 05:37
all g, it should've been ```.body( newJsonBody { body -> body.eachLike("amendments") { with(it) { uuid("amendmentID") } } }.build() )``` somehow I built something that would compile, but wouldn't actually work :sweat_smile:

uglyog
2021-04-21 05:53
Ah, the `newJsonBody` was creating a new JSON body

abubics
2021-04-21 06:17
Something like that :upside_down_face:

abubics
2021-04-21 06:17
I like that there's one place to look for reference (http://docs.pact.io) but there's not a lot of good examples in there. Especially with the new DSL being highlighted, and then having almost no samples.

uglyog
2021-04-21 06:18
You up to correcting that :stuck_out_tongue:

abubics
2021-04-21 06:19
hey, I'd love to :yay: just gotta get some of that billable time in . . .

github2
2021-04-21 12:42
[pact-foundation/pact-jvm] Issue closed by sdobrovolschi

github2
2021-04-21 13:20
[pact-foundation/pact-jvm] Issue closed by artemptushkin

github2
2021-04-21 19:38
[pact-foundation/pact-jvm] Issue closed by keeping-it-up

tjones
2021-04-22 01:32
Yes, you can run any coverage tools you normally would.

tjones
2021-04-22 01:33
Pact doesn't have anything built in to do this, because it runs using your usual test framework

stain.witness
2021-04-22 02:43
has joined #pact-jvm

maksym.motornyi
2021-04-22 05:57
Ok, thanks. I'll try to use jacoco then

oleksandra.pishcheiko
2021-04-22 08:31
has joined #pact-jvm

abubics
2021-04-22 09:05
I'm finding some brittleness where I wasn't expecting: `eachLike` and `minArrayLike` are claiming mismatches when I omit a field from matching that's present in the request. Is this something that's changed, or was it always like that? It feels like it would get in the way of expand/contract refactoring :thinking_face:

akos.csurai.4github
2021-04-22 10:01
has joined #pact-jvm

christosbouloumpasis
2021-04-22 10:38
has joined #pact-jvm

steve.cook
2021-04-22 12:34
@steve.cook has left the channel

uglyog
2021-04-22 13:11
That's not behaviour I would expect

chris.faulkner
2021-04-22 13:27
Hi - I have a project which implements both provider verification tests and consumer tests. I added `testImplementation("au.com.dius.pact.consumer:junit5:4.2.2")` for consumer tests. All OK. When I run the consumer test, I get this ```V4 java.lang.NoSuchFieldError: V4 at au.com.dius.pact.consumer.junit.JUnitTestSupport.conformsToSignature(JUnitTestSupport.kt:20)``` I understand this, there is no V4 in `http://au.com.dius.pact.core.model.PactSpecVersion`. When I look at the source of that, there is only V1, 1_1, V2 and V3. That class is in `pact-jvm-core-model-4.0.10.jar`. So which dependency will satisfy the V4 ? When I look for most recent version here https://mvnrepository.com/artifact/au.com.dius/pact-jvm-core-model, 4.0.10 is it

chris.faulkner
2021-04-22 13:48
OK - so I added `au.com.dius.pact.core:model` as shown below which solves the V4 issue as above but now I get a different error. ``` testImplementation("au.com.dius.pact.provider:junit5spring:$pactVersion") testImplementation("au.com.dius:pact-jvm-provider-junit5:4.0.10") testImplementation("au.com.dius.pact.core:model:$pactVersion") testImplementation("au.com.dius.pact.consumer:junit5:$pactVersion")``` The error is ```'java.lang.String au.com.dius.pact.core.support.Json.escape(java.lang.String)' java.lang.NoSuchMethodError: 'java.lang.String au.com.dius.pact.core.support.Json.escape(java.lang.String)' at au.com.dius.pact.core.support.json.JsonValue.serialise(JsonValue.kt:130) at au.com.dius.pact.core.support.json.JsonValue$serialise$3.invoke(JsonValue.kt:134) at au.com.dius.pact.core.support.json.JsonValue$serialise$3.invoke(JsonValue.kt:5)``` pactVersion is 4.2.2 - there is a fatal error about final classes with 4.2.4 which is already logged. Would it be possible to simply have a bom for PACT - when I look around maven repository there is a fairly bewildering list of possible libraries

piotr.soltysiak
2021-04-22 14:21
Sorry for bumping, but I still have no idea how to approach this issue

chris.faulkner
2021-04-22 15:12
OK - I sorted this but only for consumer tests. ``` testImplementation("au.com.dius.pact.provider:junit5spring:$pactVersion") testImplementation("au.com.dius:pact-jvm-provider-junit5:4.0.10") { exclude group: 'au.com.dius', module: 'pact-jvm-core-support' } testImplementation("au.com.dius.pact.core:model:$pactVersion") testImplementation("au.com.dius.pact:consumer:$pactVersion") testImplementation("au.com.dius.pact.consumer:junit5:$pactVersion")``` There are conflicts between the pact-jvm-core-support (v 4.0.10) brought in by the pact-jvm-provider-junit5 dependency. The consumer tests now run. When I run provider tests they now fail. So it looks like an issue with the pact-jvm-provider-junit5 library at 4.0.10. Please -could someone tell me what is needed to simultaneously use these ? consumer and provider tests in same project ? Junit 5 ? Spring boot provider tests

temanibeck
2021-04-22 16:04
has joined #pact-jvm

chris.faulkner
2021-04-22 19:58
Hi again - quick one. How can I add a request header with the Spring Junit5 provider (PactVerificationSpringProvider) to authenticate a request ? I have read this https://docs.pact.io/implementation_guides/jvm/provider/junit5#modifying-the-requests-before-they-are-sent But the example has ExtendWith PactVerificationInvocationContextProvider ``` @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(PactVerificationContext context, HttpRequest request) { // This will add a header to the request request.addHeader("X-Auth-Token", "1234"); context.verifyInteraction(); }``` I am using Junit 5 and Spring so I have ``` @TestTemplate @ExtendWith(PactVerificationSpringProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); }```

phil.endsley
2021-04-22 20:01
I'm pretty sure there's a way to do this, but I don't have it in front of me right now. I'll try and find the docs/example tonight (4-5 hours from time of posting)

phil.endsley
2021-04-22 20:03
This is what I was thinking of. I remember it not clicking until I looked at the unit tests as examples in the pact repo though. https://docs.pact.io/implementation_guides/jvm/provider/junit/#using-multiple-classes-for-the-state-change-methods

michael_swiss
2021-04-22 21:04
has joined #pact-jvm

uglyog
2021-04-22 22:45
Just remove that dependency, the junit5 one will bring in the correct one

uglyog
2021-04-22 22:47
You can't use version 4.0.x libs with version 4.2.x, you need to use the same base version

chris.faulkner
2021-04-23 07:57
Thanks - so I?ll just drop back. Will keep my eye out for when that lib gets updated. Cheers


dawoud.sheraz
2021-04-23 09:34
has joined #pact-jvm

adriano.tanoue
2021-04-23 12:01
has joined #pact-jvm

piotr.soltysiak
2021-04-24 13:05
@phil.endsley thanks for response! I?ve seen it, but it?s not exactly solving my problem. This solution allows me to move the state change handler methods to separate classes, but I still have one entry point for tests, looking like this: ```@Provider("MyProviderApi") @PactBroker @WebMvcTest( controllers = { SomeController.class, SomeOtherController.class, ... // what if there would be 100s of them? } ) public class MyProviderApiPactVerificationSpec { @Autowired private MockMvc mockMvc; @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new MockMvcTestTarget(mockMvc)); context.addStateChangeHandlers( new SomeStateChangeHandler(), new SomeOtherStateChangeHandler(), ... // what if there would be 100s of them? ); } } ``` It?s allright, but with every controller tested there are some depenedencies to mock, some state change handler methods to add, etc. Every new controller adds more mess :slightly_smiling_face: That?s why I wonder if I can create such test class for each controller separately. `@PactFilter` annotation allows me to filter out only expected tests, but I have no idea how to guarantee that all pacts which should be verified has been verified (otherwise, the verification results won?t be uploaded to the broker)

saurabh.goel
2021-04-24 20:10
has joined #pact-jvm

cemal.onder
2021-04-25 12:22
has joined #pact-jvm

github2
2021-04-25 22:08
[pact-foundation/pact-jvm] Issue opened by leonleo997

richard.forjoe
2021-04-26 00:52
has joined #pact-jvm

ron.aharoni
2021-04-26 11:03
has joined #pact-jvm

andrewmorton
2021-04-26 13:33
has joined #pact-jvm

aram
2021-04-26 15:24
has joined #pact-jvm

github2
2021-04-26 16:47
[pact-foundation/pact-jvm] Issue opened by dckallos

github2
2021-04-26 20:47
[pact-foundation/pact-jvm] Issue closed by dckallos

marcelo.souzameinberg
2021-04-26 21:32
has joined #pact-jvm

songqing.gu
2021-04-27 01:25
has joined #pact-jvm

songqing.gu
2021-04-27 01:55
Hi team

songqing.gu
2021-04-27 02:05
Anyone can provide a sample for SpringMessagePactRunner in provide side? I have tried for a couple of days but no luck so far, with "Did not find any pact files for provider " issue.

matt.fellows
2021-04-27 02:12
Can you please share your code/setup? It sounds like an issue unrelated to spring message, and more about config

songqing.gu
2021-04-27 02:14
@matt.fellows Many thanks for your quick response. Her is my code snippet: @RunWith(SpringMessagePactRunner.class) @Consumer("tinybank_messaging_consumer") @Provider("tinybank_messaging_provider") @PactBroker(host = "${pactbroker.hostname:localhost}", port = "${pactbroker.port:80}") @VerificationReports({"console", "markdown"}) public class MessagingProducerPactVerification { /** * The pact will pretend to be a message queue and * get the producer to publish the appropriate message. */ @TestTarget public final Target target = new SpringAwareAmqpTarget();

uglyog
2021-04-27 02:15
Are there pacts in your broker for `tinybank_messaging_consumer`?

songqing.gu
2021-04-27 02:16
yes, in my local broker

uglyog
2021-04-27 02:18
You need to run your test with debug logging enabled, because "Did not find any pact files for provider" means it didn't find any pact files in your broker.

uglyog
2021-04-27 02:18
With debug logs you will see what requests and responses happened

uglyog
2021-04-27 02:19
Also check the consumer and provider names to make sure they are correct

songqing.gu
2021-04-27 02:21
I did use PactRunner, it works fine. but to align with my existing SpringRestPactRunner test cases I change to use SpringMessagePactRunner it stops working. If I can have a sample of SpringMessagePactRunner to setup my testing, that will be really great.

uglyog
2021-04-27 02:25
Ok, check that `pactbroker.hostname` and `pactbroker.port` is not being set in your test application context, because that will be the difference between PactRunner and SpringMessagePactRunner

songqing.gu
2021-04-27 02:30
Many thanks for your guidance! This is exactly what I am after. anywhere I can find right setting?

songqing.gu
2021-04-27 02:34
I mean, rather @PactBroker(host = "${pactbroker.hostname:localhost}", port = "${pactbroker.port:80}") in my code, what will be the right setting for broker server?


songqing.gu
2021-04-27 02:38
:thumbsup: Many thank! let me try and see how it goes.

songqing.gu
2021-04-27 02:45
I still got the same issue. Looks it is more about wrong library I have used.

songqing.gu
2021-04-27 02:48
<dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-spring_${scala-compiler.version}</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-junit</artifactId> <version>4.0.10</version> <scope>test</scope> </dependency> <dependency> <groupId>http://au.com.dius.pact</groupId> <artifactId>provider</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.8.6</version> </dependency>

songqing.gu
2021-04-27 02:48
Not sure what my problems are with my jars?

uglyog
2021-04-27 02:50
You're mixing old and newer ones. Change `pact-jvm-provider-spring_...` to

uglyog
2021-04-27 02:50
```<dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-spring</artifactId> <version>4.0.10</version> </dependency>```

uglyog
2021-04-27 02:50
Note also all the artifacts have changed with versions 4.1+


songqing.gu
2021-04-27 03:13
Thanks, @uglyog let me try ...

matt.fellows
2021-04-27 05:07
How?d you go?

songqing.gu
2021-04-27 05:39
Thanks for asking @matt.fellows! with my existing jar setting it works fine with SpringRestPactRunner. but failed to run with SPringMessagingPactRunner. As suggested by @uglyog to use version 4.1.0 I find it takes time to load this new version into company's maven repository. I am little bit surprised that I can not find any sample code with SPringMessagingPactRunner. May I ask again there is any sample code with SPringMessagingPactRunner?

matt.fellows
2021-04-27 06:11
Ah, yes the old maven repository proxy goodness

matt.fellows
2021-04-27 06:13
I can?t comment on the `SpringMessagingPactRunner` - there are so many different variations of Pact APIs for different framework specific things (like Spring) across languages that maintaining an example for each one can be very time consuming. So if one doesn?t exist, that is probably the main reason.

songqing.gu
2021-04-27 06:38
Hi @matt.fellows and @uglyog Finally it works now after changed to use right version jars. OMG, jar version miss matching is a source of nightmare. Thanks your both! I can have a good sleep tonight. :handshake:

matt.fellows
2021-04-27 06:43
awesome!

songqing.gu
2021-04-27 06:51
I own your guys a beer :thumbsup:

fortiss.anita
2021-04-27 09:34
has joined #pact-jvm

matt.fellows
2021-04-27 10:29
haha well if you ever come to Melbourne, I will take you up on that :beers:

aliaksandr.valadzko
2021-04-27 11:14
Hello! I need to pass `id` from provider state to pact And it is obvious for this example: ```JSON { ... "accountNumber": { "id":345 !!! id is needed to be returned from provider state } ... } PACT .`object`("accountNumber") .valueFromProviderState("id", "\${accountNumber}", 100) .closeObject()``` But what about this example: ```{ ... "id": { !!! id is needed to be returned from provider state "name":"something" } ... }``` Could someone help me? Thanks

matt.fellows
2021-04-27 11:22
might need a `keyFromProviderState` option. It may not be supported, but keen to hear

aliaksandr.valadzko
2021-04-27 11:23
Thanks @matt.fellows Any workarounds so far?

matt.fellows
2021-04-27 11:25
If you can, stick with standard provider states

aliaksandr.valadzko
2021-04-27 11:28
However there is no suitable option for my case: ```For JSON bodies, use valueFromProviderState. For headers, use headerFromProviderState. For query parameters, use queryParameterFromProviderState. For paths, use pathFromProviderState.``` And `valueFromProviderState` can't be applied here Correct?

aliaksandr.valadzko
2021-04-27 11:29
I can't use `.object(valueFromProviderState(...))`

aliaksandr.valadzko
2021-04-27 11:30
However assume that this is common use case, and probably I miss something

uglyog
2021-04-27 12:04
You are using accountNumber in the expression, so you're provider state handler needs to return a Map with an accountNumber key

aliaksandr.valadzko
2021-04-27 12:06
Thanks @uglyog Let me rephrase I need to pass value from provider state as json object name

keshav.reddy503
2021-04-27 12:06
has joined #pact-jvm

aliaksandr.valadzko
2021-04-27 12:07
So, I have no issue with returning of provider values I have issue with specifying it in `DslPart`

aliaksandr.valadzko
2021-04-27 12:07
```{ ... "{$valueFromProvider}": "name":"..." } ... }```

aliaksandr.valadzko
2021-04-27 12:07
I need something like this ^

aliaksandr.valadzko
2021-04-27 12:08
`.object(valueFromProviderState(...))` but I can't use this structure

uglyog
2021-04-27 12:09
It needs to be `object('fieldname').valueFromProviderState('fieldname', 'expression', value)`

aliaksandr.valadzko
2021-04-27 12:10
but fieldname should be returned from provider and be dynamic `object('fieldname')` -> `object('{$fieldname}')`


aliaksandr.valadzko
2021-04-27 12:15
Probably we are not in same page:slightly_smiling_face: ```{ "cf14796c-a751-11eb-bcbc-0242ac130002": { "date": "2000-01-31T15:00:00.000Z", "acked": true } }``` `cf14796c-a751-11eb-bcbc-0242ac130002` should be dynamic

aliaksandr.valadzko
2021-04-27 12:17
`cf14796c-a751-11eb-bcbc-0242ac130002` is object name in context of DSL is `.object("cf14796c-a751-11eb-bcbc-0242ac130002)` However should be replaced by provider state value

uglyog
2021-04-27 12:17
Ah, you want to replace the attribute name. That is not supported

uglyog
2021-04-27 12:18
The only option is to ignore the attribute names, and match the values

aliaksandr.valadzko
2021-04-27 12:18
Any workarounds?

uglyog
2021-04-27 12:18
No, `valueFromProviderState` only works with values

aliaksandr.valadzko
2021-04-27 12:19
`.body(pact.toString().replace("hardcode", "{$valueFromProvider}")).toPact();` Should it work?

uglyog
2021-04-27 12:19
If you can use fixtures in your tests, you can use data with known values. That is really the only way

uglyog
2021-04-27 12:20
No, bu using `pact.toString()` that converts it to a JSON string value and you loose all the matching rules

aliaksandr.valadzko
2021-04-27 12:21
Ok From my point of view this should be common case Any plans to support it?

uglyog
2021-04-27 12:25
Can you raise a GitHub issue for it?

github2
2021-04-27 12:31
[pact-foundation/pact-jvm] Issue opened by AliaksandrValadzko


aliaksandr.valadzko
2021-04-27 12:32
Please, ping me if something is needed to be rephrased

matt.fellows
2021-04-27 12:48
so all of those options are pretty advanced cases where you can?t control the data of the provider in the first place.

matt.fellows
2021-04-27 12:49
The simplest approach, is to simply have your consumer test specify a state e.g. `"id 1234 exists"`. When the provider test runs, your `@State` annotation will read this annotation, and can perform any setup before the test is executed, to ensure that the correct values are there

matt.fellows
2021-04-27 12:50
but even more fundamentally, do you actually care that the `id` is an exact value, or just the structure of the data itself?

aliaksandr.valadzko
2021-04-27 12:51
Already discussed in thread https://pact-foundation.slack.com/archives/C9UN99H24/p1619522082188700 with Ronald Yep, I do need to verify exact values that are objectNames in json


matt.fellows
2021-04-27 12:52
I just read that thread.

matt.fellows
2021-04-27 12:52
Those matchers only assume that you can?t control the data in advance (i.e. the ID will always be different each time you run the tests and that will cause issues)

matt.fellows
2021-04-27 12:53
> Yep, I do need to verify exact values that are objectNames in json why?

matt.fellows
2021-04-27 12:53
(I?m not trying to be annoying, I?m trying to ensure you aren?t over complicating things)

aliaksandr.valadzko
2021-04-27 12:55
Eg: From provider side I create 3 business objects and relationship between 2 of them From consumer side I query by some parameter and expect exact 2 ids of business objects

aliaksandr.valadzko
2021-04-27 12:56
For example 1st and 3rd business object ids, not 2nd

matt.fellows
2021-04-27 12:56
Why does the consumer care about exact values for IDs?

aliaksandr.valadzko
2021-04-27 12:56
If I use wildcard or ignore values, I will not cover my case


aliaksandr.valadzko
2021-04-27 12:57
For example consumer search for 2 apples Provider has 2 apples and one peach

aliaksandr.valadzko
2021-04-27 12:57
I don't need one apple and one peach, I need 2 apples

matt.fellows
2021-04-27 13:00
:slightly_smiling_face:

matt.fellows
2021-04-27 13:00
sure

matt.fellows
2021-04-27 13:00
do the `id` s represent an apple and a peach, or the unique identifier of the apple/peach in the db?

matt.fellows
2021-04-27 13:00
this is what I?m trying to understand

matt.fellows
2021-04-27 13:01
if the value is dynamic, then that must imply that that are just object identifiers that have nothing to do with their apple-ness or peach-ness. It?s the data structure below the id that is useful

matt.fellows
2021-04-27 13:02
Or put another way if `id` was `4` instead of `27` does that break the consumer behaviour? Or does it only break the behaviour if the shape of the data structure is not an apple

aliaksandr.valadzko
2021-04-27 13:04
Got your point, Matt Thanks for explanations So, from your perspective, this is not contract test direct responsibility

matt.fellows
2021-04-27 13:05
yes!

matt.fellows
2021-04-27 13:05
Functionally, there may be something in that test, but from a contract perspective it?s not very useful to care about

matt.fellows
2021-04-27 13:06
all you care about is that if consumer asks for 2 peaches, that the provider comes back with two peach shaped objects. If the peach?s `id` is `27` or `4` the consumer is unlikely to behave any differently, and can certainly understand the message (this is what contract testing really cares about).

aliaksandr.valadzko
2021-04-27 13:06
Makes sense, thank you:thumbsup: But I will not close my ticket:joy:

matt.fellows
2021-04-27 13:06
haha no need to, somebody will want it someday

matt.fellows
2021-04-27 13:07
Hopefully I?ve clarified things, i?ll get out of your way now :wink:

aliaksandr.valadzko
2021-04-27 13:08
Definitely:slightly_smiling_face:

jeremykeczan
2021-04-27 14:57
has joined #pact-jvm

yeseniavega411
2021-04-27 15:31
has joined #pact-jvm

almantusk
2021-04-27 16:56
has joined #pact-jvm

daniel.kalleward
2021-04-27 21:58
*Quarkus users:* has anyone found a resolution to the `ConversionException` given a Quarkus stack with the Pact JVM Junit 5 Extension? It seems to have existed for a year, but without a known resolution. Barring options I've yet to discover, this represents a potential showstopper for a Pact integration into my stack. https://github.com/quarkusio/quarkus/issues/9677

alexandra.huamani
2021-04-28 00:12
has joined #pact-jvm

matt.fellows
2021-04-28 01:17
:scream:

tonynguyenit18
2021-04-28 02:12
has joined #pact-jvm

matt.fellows
2021-04-28 03:45
Haven?t used Quarkus, but the pitch is :ok_hand:

agrawalneeraj43
2021-04-28 04:37
has joined #pact-jvm

shixun.liu1023
2021-04-28 04:39
has joined #pact-jvm

narendra.pathai
2021-04-28 06:21
has joined #pact-jvm

anchit.99
2021-04-28 07:37
I am trying to run a ProviderTest that will generate a message contract. But I'm getting an error stating "No tests were found". I have the following code written: ```import au.com.dius.pact.provider.PactVerifyProvider; import au.com.dius.pact.provider.junit.PactRunner; import au.com.dius.pact.provider.junit5.MessageTestTarget; import au.com.dius.pact.provider.junitsupport.Consumer; import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.target.TestTarget; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.organization.SearchObjectMetadata; import org.junit.runner.RunWith; @RunWith(PactRunner.class) @Provider("providerSiteProvisioning") @Consumer("consumerSearchIndexer") public class PactProviderTest { @TestTarget public final MessageTestTarget target = new MessageTestTarget(); //We're basically telling Java > Pact that this class's tests would be sending a message to a message queue normally @PactVerifyProvider("valid message from site provisioning") public String createValidMessageForIncident() { SearchObjectMetadata searchObjectMetadata = SearchObjectMetadata.newBuilder() .setName("parent").setNamespace("namespace").build(); String searchObjectMetadataSerialized=null; try { // This is the class that will create some data which we need to put into the message searchObjectMetadataSerialized = new ObjectMapper().writeValueAsString(searchObjectMetadata); } catch (JsonProcessingException e) { // writeValueAsString throws this exception System.out.println("Json processing exception occurred"); e.printStackTrace(); } System.out.println("\n\nSerialized data = " + searchObjectMetadataSerialized + "\n\n"); return searchObjectMetadataSerialized; } }```

anchit.99
2021-04-28 07:39
Here's the error message. I'm not sure why it's throwing this error. Googling for this doesn't give any results.

wesleythomaswilliams
2021-04-28 08:01
Hi Anchit, not sure if this is the issue or not, but you're missing this: ``` @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); }```


anchit.99
2021-04-28 08:19
@wesleythomaswilliams Thanks for pointing this out! I think the test is getting triggered. But I'm getting a different error now. It says "at least one pact source must be set". Looks like it is searching for a pact file to pick up and execute. I'm creating a message pact that would have normally gone to kafka and been consumed at the other end.

anchit.99
2021-04-28 08:20
I am generating the pact in this class (in case of message that would be the provider).

anchit.99
2021-04-28 08:24
Not positive here but I think that PactVerificationInvocationContextProvider.class is trying to pick up a pact file and verifying it. If that is the case we might need to run the test in some other manner?

wesleythomaswilliams
2021-04-28 08:36
Yes, your provider test will always look for a pact file, either stored on a broker (e.g. Pact Flow), stored locally or at a given URL. That is defined at the top of the class like: ```@Provider("myprovider") @PactBroker( host = "${pact.broker.host}", scheme = "https", port = "443", authentication = @PactBrokerAuth(token = "${pact.broker.token}")) public class ProviderPactTest {``` As you can see, we're using a PactBroker annotation, but I believe there is PactFolder and PactUrl

anchit.99
2021-04-28 08:57
@wesleythomaswilliams I see. Is it that we need to generate the pact from consumer end first (even in case of messages)? And only then we can work with the provider?

saurabh.goel
2021-04-28 09:06
AFAIK pact is only generated by consumer for now. there is a new feature in making where bi-directional pact testing will be possible.

anchit.99
2021-04-28 09:15
@wesleythomaswilliams @saurabh.goel Thanks a lot for confirming about this!

github2
2021-04-28 09:29
[pact-foundation/pact-jvm] Issue opened by tlinkowski

matt.fellows
2021-04-28 10:42
:taco: for @wesleythomaswilliams

matt.fellows
2021-04-28 10:42
:taco: for @saurabh.goel

daniel.kalleward
2021-04-28 11:05
Above my pay grade :confused:

marcin.grzejszczak
2021-04-28 13:53
has joined #pact-jvm

marcin.grzejszczak
2021-04-28 13:53
:wave:

github2
2021-04-28 15:38
[pact-foundation/pact-jvm] Issue opened by miaguicam7

flubniewski
2021-04-28 17:01
has joined #pact-jvm

github2
2021-04-28 17:56
[pact-foundation/pact-jvm] Issue opened by JanGr2

github2
2021-04-28 21:34
[pact-foundation/pact-jvm] Issue opened by leonleo997

github2
2021-04-29 06:32
[pact-foundation/pact-jvm] Issue closed by miaguicam7

knsrividya10
2021-04-29 11:19
has joined #pact-jvm

anchit.99
2021-04-29 11:42
*EDIT: This appears to be working! (Yay)* *Please feel free to ignore this thread.* I tried to write a code using LambdaDsl but it seems that that will require ==> Pact 4.2.x which requires ==> Java 11 (because it's classes seem to be compiled with it). Im using Java 8 and running this code throws an error stating "class version name mismatch". So I switched to trying out the code given over here which is for Java 8 : https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit/src/test/java/au/com/dius/pact/consumer/junit/v3/ExampleMessageConsumerTest.java I'm trying to create a message Pact at the consumer side with the following code: ```package pactContract.searchIndexer; import au.com.dius.pact.consumer.MessagePactBuilder; import au.com.dius.pact.consumer.dsl.PactDslJsonBody; import au.com.dius.pact.consumer.junit.MessagePactProviderRule; import au.com.dius.pact.consumer.junit.PactVerification; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; import au.com.dius.pact.consumer.junit5.ProviderType; import au.com.dius.pact.core.model.annotations.Pact; import au.com.dius.pact.core.model.messaging.MessagePact; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.jupiter.api.extension.ExtendWith; import java.util.HashMap; import java.util.Map; @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "providerSiteProvisioning", providerType = ProviderType.ASYNCH) public class PactConsumerTest { @Rule public MessagePactProviderRule mockProvider = new MessagePactProviderRule(this); private byte[] currentMessage; //This tells Pact's mock server what to consume @Pact(consumer = "consumerSearchIndexer", provider = "providerSiteProvisioning") public MessagePact createPactForCaseReceiveValidKafkaMetadata(MessagePactBuilder builder) { PactDslJsonBody body = new PactDslJsonBody(); body.stringValue("test1", "value1"); body.stringValue("test2", "value2"); Map<String, String> metadataForMessage = new HashMap<>(); metadataForMessage.put("contentType", "application/json"); return builder .expectsToReceive("valid message from site provisioning") .withMetadata(metadataForMessage) .withContent(body) .toPact(); } @Test @PactTestFor(pactMethod = "createPactForCaseReceiveValidKafkaMetadata" ) @PactVerification({"providerSiteProvisioning"}) public void testValidMessageFromSiteProvisioning(){ Assert.assertNotNull(new String(currentMessage)); } public void setMessage(byte[] messageContents) { currentMessage = messageContents; } }``` The strange thing is that running this code passes but no pact file is generated. Does anyone know what could be wrong here?

maksym.motornyi
2021-04-29 11:51
Is it possible verify the array ignore the order using pact v2 specification?

anchit.99
2021-04-29 11:59
Please ignore the previous message. I just noticed the pact file! Yay! :)

github2
2021-04-29 12:09
[pact-foundation/pact-jvm] Issue opened by JohnCannon87

uglyog
2021-04-29 22:46
No, sorry, there is no ignore order support for that version

maksym.motornyi
2021-04-30 07:41
ok, no problem, thanks for the response

roy_collings
2021-04-30 15:15
has joined #pact-jvm

github2
2021-05-01 14:16
[pact-foundation/pact-jvm] Issue closed by tlinkowski

github2
2021-05-02 00:06
[pact-foundation/pact-jvm] Issue closed by leonleo997

prachi_mangesh_edake
2021-05-03 04:43
has joined #pact-jvm

sams.prashanth
2021-05-03 08:04
has joined #pact-jvm

philip.m.wood
2021-05-03 12:46
has joined #pact-jvm

amiller
2021-05-03 15:27
has joined #pact-jvm

jarmy
2021-05-03 22:32
Hello. I'm trying to set up a job to run the `pactVerify` gradle task with the `pact.filter.consumers` and `pact.filter.pacturl` properties: https://docs.pact.io/implementation_guides/jvm/provider/gradle/#allowing-just-the-changed-pact-specified-in-a-webhook-to-be-verified-406 when doing so, I get the following message: ```> Task :catalog:pactVerify_catalog WARNING: There are no consumers to verify for provider 'catalog'``` If I exclude `pact.filter.consumers=graphql`, the pactVerify picks up the sole consumer and the task works. This is how I've defined my pact task (I'm using `au.com.dius.pact.provider:gradle:4.1.20`) ```pact { def gitSha = "git rev-parse --short HEAD".execute().text.trim() def gitBranch = "git rev-parse --abbrev-ref HEAD".execute().text.trim() broker { pactBrokerUrl = 'https://pact-broker.docker.savagebeast.com' } serviceProviders { catalog { terminateProviderTask = killTheApp port = 9100 fromPactBroker { selectors = latestTags('graphql-catalog-consumer-contract', 'main', 'master', 'mobile-test', 'production') // specify the tags we want to verify here providerTags = [gitBranch] providerVersion = { gitSha } if (gitBranch == 'master') { enablePending = true // enable pending pacts support } } } }``` Perhaps the documentation is incorrect and all we need is the `pact.filter.pacturl` ?

uglyog
2021-05-03 22:44
Good point, `pact.filter.pacturl` points to a single pact, which can only ever have one consumer.

agarwal.akash333
2021-05-03 23:14
has joined #pact-jvm

agarwal.akash333
2021-05-03 23:25
Hello. I have a simple pact with request and response headers as such: ```REQUEST_HEADERS_WITH_AUTH = new HashMap<>(); REQUEST_HEADERS_WITH_AUTH.put("Authorization", "blah"); RESPONSE_HEADERS_FOR_VALIDATION = new HashMap<>(); RESPONSE_HEADERS_FOR_VALIDATION.put("Content-Type", CONTENT_TYPE); builder .uponReceiving("a request for json data") .path("/api/experiments/00000000-0000-0000-0000-000000000001") .headers(REQUEST_HEADERS_WITH_AUTH) .method("GET") .willRespondWith() .status(200) .headers(RESPONSE_HEADERS_FOR_VALIDATION) .body(experimentPactDslJsonBody) .toPact();``` And seems like pact is expecting the Authorization header in response: ```java.lang.AssertionError: Pact Test function failed with an exception, possibly due to Mismatches(mismatches=[PartialMismatch(mismatches=[HeaderMismatch(headerKey=Authorization, expected=blah, actual=, mismatch=Expected a header 'Authorization' but was missing)])])``` My assertion fails with 500. I?m using: ```testImplementation au.com.dius:pact-jvm-consumer-junit:4.0.10``` Is this an expected behaviour? Cheers.

uglyog
2021-05-03 23:27
You've added the `Authorization` header meaning it is an expected header. Your test code is not sending that header.

agarwal.akash333
2021-05-03 23:29
Thanks for the prompt response! The return type of the `.headers(REQUEST_HEADERS_WITH_AUTH)` is `PactDslRequestWithPath` , so my understanding is that headers added to `REQUEST_HEADERS_WITH_AUTH` shouldn?t be expected in response.

uglyog
2021-05-03 23:30
It is not the response, it is the request that doesn't have the header

agarwal.akash333
2021-05-03 23:48
Ah perfect, thanks heaps!


anand.ilkal
2021-05-04 08:01
has joined #pact-jvm

jackbwheatley
2021-05-04 10:39
Hi, I?m writing a pact-jvm wrapper for a scala testing framework (I am aware of scala-pact, I?m one of the maintainers :simple_smile:) I?m wondering if you can publish verification results directly from a test suite. I?m using `ProviderInfo#hasPactsFromPactBrokerWithSelectors` to fetch the pacts for verification, and my suite roughly looks like this: ```val providerInfo: ProviderInfo = ??? val verifier = new ProviderVerifier() verifier.initialiseReporters(providerInfo) providerInfo.getConsumers.forEach {consumer => verifier.runVerificationForConsumer(new java.util.HashMap[String, Object](), providerInfo, consumer) }``` Is there some method on `ProviderVerifier` or something in the `ProviderInfo` I can set to publish the results back to the broker?

dennis.minard
2021-05-04 16:23
has joined #pact-jvm

chris.williams
2021-05-04 16:41
has joined #pact-jvm

ssorcnafets
2021-05-04 19:20
has joined #pact-jvm

kowalczuk.jnr
2021-05-04 22:24
has joined #pact-jvm

uglyog
2021-05-04 23:07
You can use `DefaultVerificationReporter` to publish the results


hugo
2021-05-05 00:48
has joined #pact-jvm

jackbwheatley
2021-05-05 09:29
How does the `PACT_VERIFIER_PUBLISH_RESULTS` flag get set to true?

jadelong
2021-05-05 15:51
has joined #pact-jvm

jamesmlucas
2021-05-05 20:43
Issue identified, please disregard.

jamesmlucas
2021-05-05 20:45
I'm passing ```PACTBROKER_URL='https://{myhostname}'``` but tests continually fail with ```au.com.dius.pact.core.pactbroker.RequestFailedException: Request to path 'http://{myhostname}/pacts/provider/{myServiceName}/for-verification' failed with response 'HTTP/1.1 400 Bad Request'```

jamesmlucas
2021-05-05 20:46
I tried to explicitly set PACTBROKER_HOST, PACTBROKER_SCHEME, and PACTBROKER_PORT as well in the pre-4.1.18 style, but it doesn't seem to make any difference

jamesmlucas
2021-05-05 21:02
.... Oh, nevermind, I think I see the issue. Appears to be an issue with the newly provisioned broker. My apologies, please disregard

uglyog
2021-05-05 21:33
It?s a system property or environment variable

alexei.solcanu
2021-05-06 02:01
has joined #pact-jvm

alexei.solcanu
2021-05-06 02:15
Hi here, I've encountered an issue in consumer/junit when using @PactVerifications - these annotations @DefaultRequestValues/@DefaultResponseValues are never processed. It only works well with single @PactVerification. Is this by design or a bug? Here is my fix for it if it's a bug: ```https://github.com/asolcanu/pact-jvm/commit/eb3e1e69db7f7532f8fe8e260ab9d810cb8660e0``` Please advise

abubics
2021-05-06 02:18
Howdy :slightly_smiling_face: Where's the best place to set the base path using `junit5spring`? The https://docs.pact.io/implementation_guides/jvm/provider/junit5#test-target mention some `@Before` stuff, but maybe setting it on the `context` in the `@TestTemplate` method once is better?

abubics
2021-05-06 02:25
Especially since I'm not writing any `@Test` functions, using the Spring annotated shenanigans . . . unless that's not the intended approach? :thinking_face:

uglyog
2021-05-06 02:26
Could you create a PR?

uglyog
2021-05-06 02:28
It just needs to be set before `verifyInteraction()` is called

uglyog
2021-05-06 02:28
Doesn't have to be in a before, unless you want to inject the request into the method

abubics
2021-05-06 02:33
awesome, thanks . . . just need to work out the correct incantation, since I only want to override that one param :party_parrot:

alexei.solcanu
2021-05-06 02:34
created one for 4.2.x, is that good? https://github.com/pact-foundation/pact-jvm/pull/1357

abubics
2021-05-06 02:48
I'm just getting 404s, and I can't see what URL it's trying to hit in the interaction tests . . . even with `--debug` :thinking_face: both the test report (failed tests & stdout) and console logs don't get any URLs printed

abubics
2021-05-06 02:51
(Manually prefixing the basepath into the pact file works, so I think I'm on the right track . . .)

abubics
2021-05-06 02:51
I'm trying like this, not much doco to go on: ``` @TestTemplate @ExtendWith(PactVerificationSpringProvider::class) fun pactVerificationTestTemplate(context: PactVerificationContext) { context.target = HttpTestTarget(path = "/planning/v2/") context.verifyInteraction() }```

uglyog
2021-05-06 02:52
The full URL will be output by the Apache HTTP client, which you need to enable logging for


abubics
2021-05-06 03:11
Bit stuck :cry: Followed the top example "Enable header wire + context logging - «Best for Debugging»" from "Commons Logging Examples" and it definitely added timestamps to my logs, but no extra info from Pact

abubics
2021-05-06 03:12
i.e. ```> ./gradlew \ -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog \ -Dorg.apache.commons.logging.simplelog.showdatetime=true \ -Dorg.apache.commons.logging.simplelog.log.org.apache.http=DEBUG \ -Dorg.apache.commons.logging.simplelog.log.org.apache.http.wire=ERROR \ --debug \ build```

abubics
2021-05-06 03:12
I'm going to get lunch, and see if anything clicks in the background . . .

uglyog
2021-05-06 03:13
Ah, it needs to be configured on the test JVM, not the Gradle one

abubics
2021-05-06 04:02
makes complete sense, and yet :sweat_smile:

abubics
2021-05-06 04:03
From inside the gradle file, I guess . . . should be easy :thumbsup:

agarwal.akash333
2021-05-06 04:38
Disregard

abubics
2021-05-06 04:49
still stuck :sob: I'm setting them in my build.gradle file, like so ```test { useJUnitPlatform() jvmArgs += [ '-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog', '-Dorg.apache.commons.logging.simplelog.showdatetime=true', '-Dorg.apache.commons.logging.simplelog.log.org.apache.http=DEBUG', '-Dorg.apache.commons.logging.simplelog.log.org.apache.http.wire=ERROR', ] }``` and I can print them in the Pact `@TestTemplate` function like this ```listOf(...).forEach { println("$it = ${System.getProperty(it)}") }``` so it prints this every test ```org.apache.commons.logging.Log = org.apache.commons.logging.impl.SimpleLog org.apache.commons.logging.simplelog.showdatetime = true org.apache.commons.logging.simplelog.log.org.apache.http = DEBUG org.apache.commons.logging.simplelog.log.org.apache.http.wire = ERROR```

abubics
2021-05-06 04:49
but I'm not getting any more logs

abubics
2021-05-06 04:50
Should it just be in the stdout in the test report? Or am I looking in the wrong place?

abubics
2021-05-06 04:52
Any more context and/or output I can provide to help troubleshoot?

agarwal.akash333
2021-05-06 05:12
Are these the latest libraries I need at the consumer end for creating and publishing pacts? The discrepancies in the naming in quite confusing: https://mvnrepository.com/artifact/au.com.dius.pact/au.com.dius.pact.gradle.plugin/4.2.4 https://mvnrepository.com/artifact/au.com.dius.pact.consumer/junit/4.2.4

agarwal.akash333
2021-05-06 05:16
I?ve been trying to fix a gson method not found error, came across this https://github.com/pact-foundation/pact-jvm/issues/1077#issuecomment-631288351 and found that there?s an update. I tried the following packages but can?t find either: `classpath 'au.com.dius:pact-jvm-provider-gradle:4.2.3'` `classpath '<au.com.dius.pact:au.com.dius.pact.gradle.plugin:4>.2.3'` `classpath '<au.com.dius.pact:au.com.dius.pact.gradle.plugin:4>.2.4'` `classpath '<au.com.dius.pact:gradle.plugin:4>.2.4'`

uglyog
2021-05-06 05:21
It will be in the standout out. The actual settings are based on what logging framework you are using. I.e the `org.apache.commons.logging` settings will work if you have apache commons logging configured

uglyog
2021-05-06 05:24
Oh, just realised. You're using Spring. Spring takes control of all the logging.

uglyog
2021-05-06 05:25
In fact, Spring takes control of everything

uglyog
2021-05-06 05:25
You need to configure the logging in the Spring context

abubics
2021-05-06 05:25
oh, gross

abubics
2021-05-06 05:25
then I shall work out how to do that :thumbsup:



agarwal.akash333
2021-05-06 05:35
Thanks for the prompt reply! Is this supposed to work only with java 8?

uglyog
2021-05-06 05:38
No, 4.2.x requires Java 11. You need to use the 4.1.x versions for Java 8

agarwal.akash333
2021-05-06 05:38
Thanks, I am using java 11, but I run into this: ```A problem occurred configuring project ':researchplatformsdk'. > Could not resolve all artifacts for configuration ':researchplatformsdk:classpath'. > Could not resolve au.com.dius.pact:provider:4.2.4. Required by: project :researchplatformsdk > gradle.plugin.au.com.dius.pact.provider:gradle:4.2.4 > No matching variant of au.com.dius.pact:provider:4.2.4 was found. The consumer was configured to find a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally but: - Variant 'apiElements' capability au.com.dius.pact:provider:4.2.4 declares a component, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8 - Variant 'runtimeElements' capability au.com.dius.pact:provider:4.2.4 declares a runtime of a component, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8```

uglyog
2021-05-06 05:43
`the consumer needed a component compatible with Java 8` - look like you have to use Java 8

agarwal.akash333
2021-05-06 05:45
Yeah I figured that was the case, that would be impossible unfortunately since it?s a long running team project. Is there a workaround I could use to publish pacts to a broker/pactflow?

uglyog
2021-05-06 05:47
You can use the Pact CLI

abubics
2021-05-06 06:33
I have no idea what's going on . . . I've smashed that into all my application.yml files (in main and test), and the logback xml just in case, and I can't get any request logging

abubics
2021-05-06 06:34
does this look right for logback? ```<logger name="au.com.dius.pact" level="ERROR"/>``` just the logger name I'm not sure of

zonkor
2021-05-06 08:08
has joined #pact-jvm

manel_ben_yahia
2021-05-06 09:07
Hello, i have a similar problem and i am using version 4.1.0 for consumer and provider

manel_ben_yahia
2021-05-06 09:07
Here is my pom.xml dependencies

manel_ben_yahia
2021-05-06 09:08
```<dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>4.1.0</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-java8</artifactId> <version>4.0.10</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.1.0</version> <scope>test</scope> </dependency>```

manel_ben_yahia
2021-05-06 09:09
the error i have : NoSuchMethodError java.lang.Object http://au.com.dius.pact.core.support.Json.fromJson(http://au.com.dius.pact.core.support.json.JsonValue)

chris.faulkner
2021-05-06 09:12
I have sorted this in gradle ``` testImplementation("au.com.dius.pact.provider:junit5spring:$pactVersion") testImplementation("au.com.dius.pact.provider:junit5:$pactVersion") testImplementation("au.com.dius.pact:consumer:$pactVersion") testImplementation("au.com.dius.pact.consumer:junit5:$pactVersion")``` pactVersion is 4.2.4 I am no expert - still finding the dependencies a bit baffling - but I don?t think you should have `pact-jvm-consumer-java8` It would help if PACT took a similar approach to Spring

manel_ben_yahia
2021-05-06 09:14
Hello, i am using pact provider and consumer on same project but i get the error `java.lang.NoSuchMethodError: 'java.lang.Object http://au.com.dius.pact.core.support.Json.fromJson(http://au.com.dius.pact.core.support.json.JsonValue)'`

manel_ben_yahia
2021-05-06 09:14
my dependecies on project are :

manel_ben_yahia
2021-05-06 09:15
```<dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>4.1.0</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-java8</artifactId> <version>4.0.10</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.1.0</version> <scope>test</scope> </dependency>```

manel_ben_yahia
2021-05-06 09:15
please tell me what should i do to be able to use pact provider and consumer at the same time in the same project

manel_ben_yahia
2021-05-06 09:16
using : Junit5 - junit5Spring for the provider

manel_ben_yahia
2021-05-06 09:16
is there ay solutions on this please ?

abubics
2021-05-06 09:22
I think you can swap `au.com.dius:pact-jvm-consumer-java8:4.0.10` for `au.com.dius.pact:consumer:4.x.x`. The docs say it was merged into `consumer` already. 4.0.10 is the latest, and is out of date by about a year.

abubics
2021-05-06 09:22
usually you don't want those version numbers to get out of sync

abubics
2021-05-06 09:23
Shouldn't be related to having both consumer and provider at the same time - they'll be namespaced differently, if they even end up in the same JVM.

manel_ben_yahia
2021-05-06 09:25
thank you for your Response, i deleted the `au.com.dius:pact-jvm-consumer-java8:4.0.10`

manel_ben_yahia
2021-05-06 09:26
from pom.xml and did a clean install but as expected i have the cannot find symbol on my class

manel_ben_yahia
2021-05-06 09:26
because am using LambdaDsl

abubics
2021-05-06 09:27
I think you still need `au.com.dius.pact:consumer`, the junit5 lib is just a wrapper for it?

manel_ben_yahia
2021-05-06 09:28
so now i have both

manel_ben_yahia
2021-05-06 09:28
```<dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>4.2.2</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.2.2</version> <scope>test</scope> </dependency>```

manel_ben_yahia
2021-05-06 09:28
i deleted the dependency `au.com.dius:pact-jvm-consumer-java8:4.0.10`

manel_ben_yahia
2021-05-06 09:28
and have the errors for cannot find symbol

manel_ben_yahia
2021-05-06 09:32
the `au.com.dius.pact:consumer` is another dependency that i should include ??

abubics
2021-05-06 09:35
If `au.com.dius.pact.consumer:junit5` pulls `au.com.dius.pact:consumer` in for you automatically, then I don't know what the problem is :thinking_face:

abubics
2021-05-06 09:35
where is `fromJson` being called from?

manel_ben_yahia
2021-05-06 09:39
when i deleted the dependency `au.com.dius:pact-jvm-consumer-java8:4.0.10` i no longer have the error `java.lang.NoSuchMethodError: 'java.lang.Object http://au.com.dius.pact.core.support.Json.fromJson(http://au.com.dius.pact.core.support.json.JsonValue)'` But, deleting the java8 dependency leads to cannot find symbol on my ConsumerTest class (because i am using labmdaDSL in it)

manel_ben_yahia
2021-05-06 09:39
how can i resolve it ?

abubics
2021-05-06 09:39
cannot find which symbol?

manel_ben_yahia
2021-05-06 09:42
[3,45] package io.pactfoundation.consumer.dsl does not exist

manel_ben_yahia
2021-05-06 09:42
cannot find symbol [ERROR] symbol: class LambdaDslJsonArray

manel_ben_yahia
2021-05-06 09:43
and a lot of other cannot find symbol

abubics
2021-05-06 09:44
Those are in `au.com.dius.pact:consumer` now, I think you need to add that dependency.

abubics
2021-05-06 09:44
If `junit5` isn't bringing it in already.

abubics
2021-05-06 09:45
Either that, or the symbols changed package when they got merged into `consumer`

manel_ben_yahia
2021-05-06 09:45
ok so `au.com.dius.pact.consumer:junit5` isin't including the java8 dependency ?

manel_ben_yahia
2021-05-06 09:46
ok i will try to include the dependency of `au.com.dius.pact:consumer` (even if it is maybe a duplication ? )

abubics
2021-05-06 09:46
See https://docs.pact.io/implementation_guides/jvm/consumer/java8, that lib is deprecated, and the functionality got merged into `consumer`

abubics
2021-05-06 09:47
From what I can see https://docs.pact.io/implementation_guides/jvm/consumer/junit5, `junit5` only provides lifecycle hook annotations, no DSL.

abubics
2021-05-06 09:48
The other option is to peg all versions back to 4.0.10. That sounds like a bad idea, though.

manel_ben_yahia
2021-05-06 09:48
but `junit5` includes `consumer` wich should include DSL

manel_ben_yahia
2021-05-06 09:48
?

abubics
2021-05-06 09:48
can you find the DSL in your local jars?

abubics
2021-05-06 09:49
If `junit5` includes `consumer` then I can't tell what the problem is, except maybe the symbols moved to a different package.

manel_ben_yahia
2021-05-06 09:50
ok thank you, i will include `consumer` and re build project

manel_ben_yahia
2021-05-06 09:50
i will check

abubics
2021-05-06 09:50
I'm using consumer, and kotest, so I can't exactly debug your setup

abubics
2021-05-06 09:51
but my DSL functions are here ```import au.com.dius.pact.consumer.* import au.com.dius.pact.consumer.dsl.*```

abubics
2021-05-06 09:52
if that package isn't in your local jars, `consumer` is the only place I can guess they'd come from :slightly_smiling_face:

manel_ben_yahia
2021-05-06 09:58
i have changed the version and included the `consumer`

manel_ben_yahia
2021-05-06 09:58
but have the same cannot find symbols errors

manel_ben_yahia
2021-05-06 09:58
i will check the packages as you said

manel_ben_yahia
2021-05-06 09:58
this is the package i have ```import static io.pactfoundation.consumer.dsl.LambdaDsl.newJsonBody;```

manel_ben_yahia
2021-05-06 10:00
it is sure different from your package

manel_ben_yahia
2021-05-06 10:00
i will do mvn idea:idea maybe intelliJ didn't update after the clean install

manel_ben_yahia
2021-05-06 10:07
how can i find the package of the `newJsonBody` ?

manel_ben_yahia
2021-05-06 10:08
from where can i import it ?

manel_ben_yahia
2021-05-06 10:23
i checked the `http://au.com.dius.pact.consumer.*` doesn't contain any of the java 8 methods

abubics
2021-05-06 10:26
`http://au.com.dius.pact.consumer.dsl.LambdaDsl.newJsonBody`

abubics
2021-05-06 10:26
sorry, I was just getting dinner

manel_ben_yahia
2021-05-06 10:27
ok no problem :slightly_smiling_face:

manel_ben_yahia
2021-05-06 10:27
so in my project i checked that `http://au.com.dius.pact.consumer.dsl.LambdaDsl.newJsonBody` but i don't even have the LambdaDsl class

manel_ben_yahia
2021-05-06 10:28
from which. version it was included ?

abubics
2021-05-06 10:28
do you have the `dsl` package?


abubics
2021-05-06 10:29
I'm using `4.2.4` , I don't know what version it was migrated in

abubics
2021-05-06 10:29
but definitely after `4.0.10`

manel_ben_yahia
2021-05-06 10:30
ok i will check that

abubics
2021-05-06 10:31
can you bump all your versions to `4.2.4` and see if it all gets better? :3

abubics
2021-05-06 10:35
btw, if you're using maven, you can extract values in your pom.xml to `<properties/>` so you don't have copypasta that gets out of sync, e.g. ```<properties> <pact.version>4.2.4</pact.version> </properties> ... <version>${pact.version}</version>```

manel_ben_yahia
2021-05-06 10:43
So i checked

manel_ben_yahia
2021-05-06 10:43
it was my inytelliJ didn't update the consumer version

manel_ben_yahia
2021-05-06 10:44
so mvn idea:idea then intelliJ recognizes the new packages so problem solved thank you very much

abubics
2021-05-06 10:44
oh no

abubics
2021-05-06 10:44
Glad it worked out in the end ^_^

manel_ben_yahia
2021-05-06 10:45
yes glad too thank you i spent much time on this

manel_ben_yahia
2021-05-06 10:45
:slightly_smiling_face:

abubics
2021-05-06 10:45
The nice thing with IntelliJ is, you can browse the jars. Makes debugging this kind of stuff much easier.

manel_ben_yahia
2021-05-06 10:56
yes that's what i like also about intelliJ :))

matt.fellows
2021-05-06 12:19
@abubics on fire :taco::taco::taco:

florian.mautendorfer
2021-05-06 14:04
has joined #pact-jvm

john.mcnulty
2021-05-06 16:49
has joined #pact-jvm

john.mcnulty
2021-05-06 16:53
hi folks, thread on issue i'm hitting publishing v3 pacts using sbt ...

john.mcnulty
2021-05-06 16:58
as i understand it from https://docs.pact.io/getting_started/sharing_pacts/ the JVM options for actually publishing pacts generated by a consumer to a pact broker (pactflow in my case) are gradle and maven i'm using message pact support in v3 which appears to be tripping up the scalaPact sbt plugin: ```************************************* ** ScalaPact: Squashing Pact Files ** ************************************* > 1 files found that could be Pact contracts > - consumer-producer.json > 1 pacts found: > - consumer-producer.json > 1 errors ************************************* ** ScalaPact: Publishing Contracts ** ************************************* WARNING: No pact files found.``` looking for any guidance anyone could provide on a path to publishing v3 pacts from a consumer in an sbt project. ideas or suggestions on an approach?

uglyog
2021-05-06 23:03
@manel_ben_yahia remove `pact-jvm-consumer-java8`

uglyog
2021-05-06 23:15
You can use the Pact CLI to publish the pacts. As long as SBT can start an external process, or just run it after SBT

abubics
2021-05-07 01:53
Given up on logging, but I still haven't worked out how to set the base path with `junit5spring` :confused:

abubics
2021-05-07 01:54
My Pact setup looks like ```@ExtendWith(SpringExtension::class) @SpringBootTest(webEnvironment = DEFINED_PORT) @Provider("planning-schemes-api") @PactFolder("build/pacts") class ContractVerificationTest { @TestTemplate @ExtendWith(PactVerificationSpringProvider::class) fun pactVerificationTestTemplate(context: PactVerificationContext) { context.apply { target = HttpTestTarget(path = "/planning/v2/") verifyInteraction() } } ... }```

abubics
2021-05-07 01:54
and whatever I do to the `context.path`, it doesn't seem to change the base path

abubics
2021-05-07 01:55
wondering if it has anything to do with Spring, e.g. `@SpringBootTest(webEnvironment = DEFINED_PORT)`, or whatever

abubics
2021-05-07 01:56
but I haven't seen any examples of overriding `TestTarget` params with `junit5spring`

abubics
2021-05-07 01:56
and if I manually prefix the URLs in the pactfile, I can get them working

abubics
2021-05-07 01:57
I would've expected this to either work magically through Spring already knowing the basepath, or be overridable

abubics
2021-05-07 01:57
(actually, I better check Spring's config . . . might be different basepath in test for like no reason :thinking_face:)

uglyog
2021-05-07 01:58
I'll have a look over the weekend

abubics
2021-05-07 01:59
You know, it's probably Spring config. It always is.

abubics
2021-05-07 02:00
Same for logging, I assume (although it's really hard to debug)

agarwal.akash333
2021-05-07 02:10
Is this the base url of your provider running on a defined port that you?re after?

agarwal.akash333
2021-05-07 02:13
You can add the second param as in here: `fun pactVerificationTestTemplate(context: PactVerificationContext, request: HttpRequest)` and then modify the request. I don?t use kotlin but on the java side it?s apache?s `httprequest` class

abubics
2021-05-07 04:30
The port is fine, the tests are getting 404s correctly from the Spring context running in the test JVM. Just the base url (context-path) isn't being prefixes in the pact test requests.

abubics
2021-05-07 04:31
for example, my pact file has ``` "interactions": [ { "description": "a request without credentials", "request": { "matchingRules": { "path": { "combine": "AND", "matchers": [ { "match": "regex", "regex": "/admin/amendments/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" } ] } }, "method": "GET", "path": "/admin/amendments/beefcafe-babe-face-0123-456789abcdef" }, "response": { "status": 401 } }, ...``` and whatever I've tried so far, I can't get the pact mock consumer to make the URL `/planning/v2/admin/amendments/{id}`

agarwal.akash333
2021-05-07 04:33
> beefcafe-babe-face ? Can you modify the HttpRequest object like I mentioned?

abubics
2021-05-07 04:41
I can only try :slightly_smiling_face: which package is that HttpRequest class from? I have 3 options atm

agarwal.akash333
2021-05-07 04:42
> I don?t use kotlin but on the java side it?s apache?s `httprequest` class


agarwal.akash333
2021-05-07 05:11
Is there an `application.properties` or junit annotation equivalent for `pact.verifier.publishResults=true` ?

abubics
2021-05-07 05:17
so, that's cool, I can at least see the URL that is going to be hit, e.g. `http://localhost:8080/admin/amendments/beefcafe-babe-face-0123-456789abcdef`, which is more logs that I couldn't configure before.

agarwal.akash333
2021-05-07 05:18
Hah yeah, that object is a game changer

abubics
2021-05-07 05:18
The Pact lib says it provides hooks to override things like basepath, so I'd really prefer to use that, rather than hacking this URL string or parsing, modifying, and remarshalling it.

agarwal.akash333
2021-05-07 05:19
Yeah, some parts of the docs are way too hard to understand/seem outdated

abubics
2021-05-07 05:19
Worst case, I can modify the request :slightly_smiling_face: but I do want the advertised features to work. Good chance I'm just using it wrong, but sometimes there are genuine bugs :innocent:

abubics
2021-05-07 05:19
because there are so many repos and so many libs/languages/platforms/etc it's a tough job to make the docs consistent :sob: doesn't mean we stop trying :muscle:

agarwal.akash333
2021-05-07 05:20
I really want to spend some time on the weekend and contribute on cleaning the jvm docs, but they make no sense for me to begin with

abubics
2021-05-07 05:20
but yeah, frustrating when I know what I'm trying to do, but can't find the right bits in the docs

agarwal.akash333
2021-05-07 05:21
BTW, do you have any idea about my query on the channel? :pleading_face:

abubics
2021-05-07 05:21
Nope, sorry . . . I'm using the junit bits for the first time now. Historically I use the gradle plugin.


agarwal.akash333
2021-05-07 05:25
Well actually, it didn?t answer my question :slightly_smiling_face:

mail_4brad
2021-05-07 05:41
Going through the workshop, step10, error while publishing to a broker running in local docker. Have published to it fine using pact-cli. ```def getGitHash = { -> def stdout = new ByteArrayOutputStream() exec { commandLine 'git', 'rev-parse', '--short', 'HEAD' standardOutput = stdout } return stdout.toString().trim() } def getGitBranch = { -> def stdout = new ByteArrayOutputStream() exec { commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD' standardOutput = stdout } return stdout.toString().trim() } static def getOrDefault(env, defaultVal) { def val = System.getenv(env) if (val == null || val.isEmpty()) { val = defaultVal } return val } pact { publish { pactDirectory = 'consumer/build/pacts' pactBrokerUrl = 'http://localhost:9292/' pactBrokerUsername = getOrDefault('PACT_BROKER_USERNAME', 'pact_workshop') pactBrokerPassword = getOrDefault('PACT_BROKER_PASSWORD', 'pact_workshop') tags = [getGitBranch(), 'test', 'prod'] consumerVersion = getGitHash() } }``` ```./gradlew consumer:test --tests *PactTest* pactPublish FAILURE: Build failed with an exception. * Where: Build file 'workspace-pact-test/pact-workshop-jvm-spring/consumer/build.gradle' line: 63 * What went wrong: A problem occurred evaluating project ':consumer'. > Could not find method pact() for arguments [build_ds889q99l11qrlm0ylnt1r6v5$_run_closure7@3ee1a3fd] on project ':consumer' of type org.gradle.api.Project. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.``` I?m new to gradle so that probably doesn?t help.

uglyog
2021-05-07 05:52
What is at this line? `'workspace-pact-test/pact-workshop-jvm-spring/consumer/build.gradle' line: 63`

abubics
2021-05-07 06:14
So, turns out I can't actually modify the path in the request object anyway. Both `request.requestLine` and `request.requestLine.uri` are read-only (`final`).

mail_4brad
2021-05-07 06:15
The relevant bits of that file are my first code block above cheers

uglyog
2021-05-07 06:17
The error is saying that it could not find the method `pact()` at line 63, that was why I was wondering what is at line 63.

mail_4brad
2021-05-07 06:18
Ah yes. That snippet of the file has pact { at line 63

uglyog
2021-05-07 06:18
OK, then I guess you are missing the pact gradle plugin


mail_4brad
2021-05-07 06:21
That makes sense. I don?t think that was in the doco and unlike the other changes, the gradle file wasn?t modified when switching to step10 branch

mail_4brad
2021-05-07 06:21
I?ll give that a go when in the office again on Monday. Thanks

abubics
2021-05-07 07:56
lmao I was so confused about why my auth headers aren't working . . . turns out Spring doesn't run tests in the `test` profile automatically :joy::face_with_symbols_on_mouth: Happy Friday :tada:

abubics
2021-05-07 08:00
might explain some of my logging & context-path issues . . . have to play around with all of those again

anchit.99
2021-05-07 09:00
When the provider `@PactVerifyProvider` method has an exception then Pact doesn't print the exception. Instead it says: ```java.lang.AssertionError: Failures: 1) Test for provider issue 1.1) Failed to invoke provider method 'checkTheProvider' at au.com.dius.pact.provider.junit.target.MessageTarget.testInteraction(MessageTarget.kt:49) at au.com.dius.pact.provider.junit.InteractionRunner$interactionBlock$statement$1.evaluate(InteractionRunner.kt:227) at au.com.dius.pact.provider.junit.InteractionRunner.run(InteractionRunner.kt:162) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:158) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:63)``` When I ran it via JUnit it was a RunTime exception. This issue can be reproduced with the following code: ```if (true) { throw new AvroRuntimeException("Field " + " not set and has no default value"); }``` Any idea whether this is an expected behavior and has a workaround? I would like Pact to throw the real exception instead of "failed to invoke provider method".

github2
2021-05-07 09:22
[pact-foundation/pact-jvm] Issue opened by anchit-h

github2
2021-05-07 09:28
[pact-foundation/pact-jvm] Issue closed by theovanessen

matt.fellows
2021-05-07 11:43
It?s just trying to be helpful, right?

john.mcnulty
2021-05-07 14:35
much appreciated, i'll have a look at that option

john.mcnulty
2021-05-07 14:36
@kflo fyi ^^

john.mcnulty
2021-05-07 14:47
@uglyog the docs indicate that the CLI only supports provider verification but the ruby-based broker CLI does support publication one feature of the scalaPact sbt plugin that appears useful is gathering all of the pacts generated by a set of tests in a suite and combining the `interactions` into a single pact before publication. do you know if the CLI performs a similar operation or just publishes all of the individual pacts generated by the test run?

john.mcnulty
2021-05-07 14:52
actually never mind, looks like that can happen broker-side with the --merge option (by uploading the first pact with --no-merge to overwrite what's there and then upload the remainder with --merge)

github2
2021-05-07 16:17
[pact-foundation/pact-jvm] Issue opened by wedla

uglyog
2021-05-08 03:08
Can you raise an issue. The exception should be wrapped, but it is not printing out the cause

uglyog
2021-05-08 03:32
@agarwal.akash333 I just had the same error as you, because I was running with Java 8. When I switched to Java 11, it worked. Please run `./gradle --version` on your project, you will see the Java version printed there.

uglyog
2021-05-08 03:32
If you have to use Java 8, use the 4.1.x versions

agarwal.akash333
2021-05-08 03:35
@uglyog cheers mate. I had the same epiphany after finishing work yesterday. Will be giving it a shot soon :+1:


uglyog
2021-05-08 03:46
I can see the requests made in the test report `Standard output:`

uglyog
2021-05-08 03:47
```Verifying a pact between Matching Service (24bdbac2fab702d256f37cb25714eff91eb56679) and Animal Profile Service Notices: 1) The pact at https://test.pact.dius.com.au/pacts/provider/Animal%20Profile%20Service/consumer/Matching%20Service/pact-version/3ef744a768c1950d4b9e7e21828d204519cef58d is being verified because the pact content belongs to the consumer version matching the following criterion: * latest version of a consumer that has a pact with Animal Profile Service (24bdbac2fab702d256f37cb25714eff91eb56679) [from Pact Broker https://test.pact.dius.com.au/pacts/provider/Animal%20Profile%20Service/consumer/Matching%20Service/pact-version/3ef744a768c1950d4b9e7e21828d204519cef58d/metadata/c1tdW2xdPXRydWUmc1tdW2N2bl09MjRiZGJhYzJmYWI3MDJkMjU2ZjM3Y2IyNTcxNGVmZjkxZWI1NjY3OQ] Given Has some animals a request for all animals 2021-05-08 13:44:28.216 DEBUG 783268 --- [ Test worker] a.com.dius.pact.provider.ProviderClient : Making request for provider au.com.dius.pact.provider.ProviderInfo@662c6bf6[consumers=[],createClient=<null>,host=localhost,insecure=false,isDependencyForPactVerify=true,name=provider,packagesToScan=[],path=/,port=8080,protocol=http,requestFilter=<null>,startProviderTask=<null>,stateChangeRequestFilter=<null>,stateChangeTeardown=false,stateChangeUrl=<null>,stateChangeUsesBody=true,terminateProviderTask=<null>,trustStore=<null>,trustStorePassword=changeit,verificationType=REQUEST_RESPONSE]: 2021-05-08 13:44:28.216 DEBUG 783268 --- [ Test worker] a.com.dius.pact.provider.ProviderClient : method: GET path: /animals/available query: {} headers: {Authorization=[Bearer token]} matchers: MatchingRules(rules={path=MatchingRuleCategory(name=path, matchingRules={}), header=MatchingRuleCategory(name=header, matchingRules={}), query=MatchingRuleCategory(name=query, matchingRules={})}) generators: Generators(categories={}) body: MISSING 2021-05-08 13:44:28.218 DEBUG 783268 --- [ Test worker] o.a.h.client.protocol.RequestAddCookies : CookieSpec selected: default 2021-05-08 13:44:28.218 DEBUG 783268 --- [ Test worker] o.a.h.client.protocol.RequestAuthCache : Auth cache not set in the context 2021-05-08 13:44:28.218 DEBUG 783268 --- [ Test worker] h.i.c.PoolingHttpClientConnectionManager : Connection request: [route: {}->http://localhost:8080][total available: 0; route allocated: 0 of 5; total allocated: 0 of 10] 2021-05-08 13:44:28.218 DEBUG 783268 --- [ Test worker] h.i.c.PoolingHttpClientConnectionManager : Connection leased: [id: 3][route: {}->http://localhost:8080][total available: 0; route allocated: 1 of 5; total allocated: 1 of 10] 2021-05-08 13:44:28.218 DEBUG 783268 --- [ Test worker] o.a.http.impl.execchain.MainClientExec : Opening connection {}->http://localhost:8080 2021-05-08 13:44:28.218 DEBUG 783268 --- [ Test worker] .i.c.DefaultHttpClientConnectionOperator : Connecting to localhost/127.0.0.1:8080 2021-05-08 13:44:28.218 DEBUG 783268 --- [ Test worker] .i.c.DefaultHttpClientConnectionOperator : Connection established 127.0.0.1:32890<->127.0.0.1:8080 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] o.a.http.impl.execchain.MainClientExec : Executing request GET /animals/available HTTP/1.1 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] o.a.http.impl.execchain.MainClientExec : Proxy auth state: UNCHALLENGED 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 >> GET /animals/available HTTP/1.1 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 >> Authorization: Bearer token 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 >> Host: localhost:8080 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 >> Connection: Keep-Alive 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 >> User-Agent: Apache-HttpClient/4.5.13 (Java/11.0.11) 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 >> Accept-Encoding: gzip,deflate 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 >> "GET /animals/available HTTP/1.1[\r][\n]" 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 >> "Authorization: Bearer token[\r][\n]" 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 >> "Host: localhost:8080[\r][\n]" 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 >> "Connection: Keep-Alive[\r][\n]" 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 >> "User-Agent: Apache-HttpClient/4.5.13 (Java/11.0.11)[\r][\n]" 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 >> "Accept-Encoding: gzip,deflate[\r][\n]" 2021-05-08 13:44:28.219 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 >> "[\r][\n]" 2021-05-08 13:44:28.223 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "HTTP/1.1 404 [\r][\n]" 2021-05-08 13:44:28.223 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "Vary: Origin[\r][\n]" 2021-05-08 13:44:28.223 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "Vary: Access-Control-Request-Method[\r][\n]" 2021-05-08 13:44:28.223 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "Vary: Access-Control-Request-Headers[\r][\n]" 2021-05-08 13:44:28.223 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "Content-Type: application/json[\r][\n]" 2021-05-08 13:44:28.223 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "Transfer-Encoding: chunked[\r][\n]" 2021-05-08 13:44:28.223 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "Date: Sat, 08 May 2021 03:44:28 GMT[\r][\n]" 2021-05-08 13:44:28.223 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "Keep-Alive: timeout=60[\r][\n]" 2021-05-08 13:44:28.223 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "Connection: keep-alive[\r][\n]" 2021-05-08 13:44:28.223 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "[\r][\n]" 2021-05-08 13:44:28.223 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "77[\r][\n]" 2021-05-08 13:44:28.223 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "{"timestamp":"2021-05-08T03:44:28.221+00:00","status":404,"error":"Not Found","message":"","path":"/animals/available"}[\r][\n]" 2021-05-08 13:44:28.224 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 << HTTP/1.1 404 2021-05-08 13:44:28.224 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 << Vary: Origin 2021-05-08 13:44:28.224 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 << Vary: Access-Control-Request-Method 2021-05-08 13:44:28.224 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 << Vary: Access-Control-Request-Headers 2021-05-08 13:44:28.224 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 << Content-Type: application/json 2021-05-08 13:44:28.224 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 << Transfer-Encoding: chunked 2021-05-08 13:44:28.224 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 << Date: Sat, 08 May 2021 03:44:28 GMT 2021-05-08 13:44:28.224 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 << Keep-Alive: timeout=60 2021-05-08 13:44:28.224 DEBUG 783268 --- [ Test worker] org.apache.http.headers : http-outgoing-3 << Connection: keep-alive 2021-05-08 13:44:28.224 DEBUG 783268 --- [ Test worker] o.a.http.impl.execchain.MainClientExec : Connection can be kept alive for 60000 MILLISECONDS 2021-05-08 13:44:28.224 DEBUG 783268 --- [ Test worker] a.com.dius.pact.provider.ProviderClient : Received response: HTTP/1.1 404 2021-05-08 13:44:28.225 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "0[\r][\n]" 2021-05-08 13:44:28.225 DEBUG 783268 --- [ Test worker] org.apache.http.wire : http-outgoing-3 << "[\r][\n]"```

uglyog
2021-05-08 03:49
Then changing `context.setTarget(new HttpTestTarget("localhost", 8080, "/sub-path"));` I can now see in the logs: ```Executing request GET /sub-path/animals/available HTTP/1.1```

enda.brody
2021-05-08 09:22
Hi Guys  very new to Pact. Trying to get the Consumer test's to work AccountsGateway *(The consumer)* and the *provider service* is MortgageService. They are both are java spring boot services . I am following this example https://github.com/EndaDistilled/pact-workshop-Maven-Springboot-JUnit5 in it the test has the productServiceClient to have a setBaseUrl function which I do not. The MortgageServiceClient set's a private final variable that gets the endpoints from a public interface MortgageApi. Not sure what is the best way to handel this when I run the test I get this output Any advice would be helpful thank you soo much (edited)  *EndaDistilled/pact-workshop-Maven-Springboot-JUnit5* Pact Maven + Springboot + JUnit5 workshop - learn Pact in 60 minutes *Last updated* 2 months ago *Forks* 5 Added by https://pact-foundation.slack.com/services/B01VCUKL99N

enda.brody
2021-05-08 09:22
`http://au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received:` method: GET path: /v1/daft-mortgages/buying-budget/1 query: {} headers: {} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING at http://au.com.dius.pact.consumer.junit.JUnitTestSupport.validateMockServerResult(JUnitTestSupport.kt:60) at http://au.com.dius.pact.consumer.junit5.PactConsumerTestExt.afterTestExecution(PactConsumerTestExt.kt:367) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterTestExecutionCallbacks$8(TestMethodTestDescriptor.java:221)

enda.brody
2021-05-08 09:23
```@SpringBootTest @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "MortgageService") public class MortgageServiceClientPactTest { //Could I USE Rule to mock and spin up the mortgageServiceClient // @Rule // MortgageServiceClient provider = new MortgageServiceClient("", null, // 8080, this); @Autowired private MortgageServiceClient mortgageServiceClient; @Pact(consumer = "AccountsGateway") public RequestResponsePact singleBuyingBudget(PactDslWithProvider builder) { return builder .given("buying budget exists") .uponReceiving("get request buying budget") .path("/v1/daft-mortgages/buying-budget/1") .method("GET") .willRespondWith() .status(200) .body( new PactDslJsonBody() .integerType("buyingBudgetId", 708) ) .toPact(); } @Test @PactTestFor(pactMethod = "singleBuyingBudget") void testSingleBuyingBudget() throws IOException { //Howe to setBaseUrl when there is no Base Url Function to add it would // require it to be deployed //void testSingleProduct(MockServer mockServer) { //productServiceClient.setBaseUrl(mockServer.getUrl()); //mock the mortgageServiceClient final BuyingBudgetResponse buyingBudgetResponse = mortgageServiceClient.getBuyingBudget(1); assertThat(buyingBudgetResponse.getBuyingBudgetId(), is(equalTo(708))); } }```

anchit.99
2021-05-08 09:46
@uglyog Sure thing Ron! Thanks for replying. :slightly_smiling_face:

matt.fellows
2021-05-08 09:54
I don't know how to immediately fix your issue, but you absolutely don't want to mock out the service client - that's the target of your unit test, and the thing we need to prove can make the API calls. Mocking it out wouldn't help you have confidence about anything

matt.fellows
2021-05-08 09:55
You need to find a way to dynamically update the private variable. I'm assuming spring has standard DI ways of handling this

github2
2021-05-09 01:04
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-05-09 01:09
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-05-09 02:24
[pact-foundation/pact-jvm] New release _https://github.com/pact-foundation/pact-jvm/releases/tag/4_2_5_ published by uglyog

github2
2021-05-09 09:28
[pact-foundation/pact-jvm] Issue closed by artemptushkin

abubics
2021-05-10 01:41
That is great and helpful, thanks!

abubics
2021-05-10 01:42
Once I worked out that the test application yaml wasn't even being loaded, everything started making sense again :sweat_smile:

mail_4brad
2021-05-10 02:40
Can someone please point me to best practices for testing large json request bodies? Currently in our code a model object is passed to a service that wraps the object and passes to some provider-team-supplied client code that uses Spring resttemplate to POST it. Options: 1) capture a payload once and hardcode it into the pact test 2) contort code to somehow call the resttemplate in the test to generate the json each time 3) hopefully some better answer...?

mail_4brad
2021-05-10 03:04
And maybe I should test the supplied client code only, not my project?s service layer that calls it...

mail_4brad
2021-05-10 05:59
That did it thanks. Raised PR for the tutorial

songqing.gu
2021-05-10 06:13
I am working on PACT testing for Kafka messaging. the event message types happen to be enum type. My challenge is how to define a matching rule to match a enum type. If anyone could provide any help with that?

uglyog
2021-05-10 06:14
How is the enum type serialised?

songqing.gu
2021-05-10 06:18
thanks for your quick response! I think in my matching rule definition, what I need is to check the event type is one of a list of event type defined in enum type.

songqing.gu
2021-05-10 06:19
event type appears a normal string in message in JSON format.

songqing.gu
2021-05-10 06:21
PactDslJsonBody body = new PactDslJsonBody() .stringValue("eventType", "CREATE") .integerType("customerId", 666) .booleanType("active", Boolean.TRUE);

uglyog
2021-05-10 06:22
Use a regular expression

tarunmehrotra3
2021-05-10 06:31
has joined #pact-jvm

songqing.gu
2021-05-10 06:31
It looks to me, matching rule is to check expected string falls into one of the elements of a list. the regular expression is fit for my case ? or we have other solutions?

uglyog
2021-05-10 06:35
`stringMatcher("eventType", "CREATE|DELETE|....")`

songqing.gu
2021-05-10 06:47
simple ! thanks!

github2
2021-05-10 07:44
[pact-foundation/pact-jvm] Issue closed by anchit-h

abubics
2021-05-10 08:01
I also made a helper to wrap the same concern (in Kotlin): ```fun oneOf(vararg values: String): String = values.joinToString("|")``` so the usage looks like ```stringMatcher("amendmentContains", oneOf("OnlyOrdinances", "OnlyMaps", "Both"), "Both")```

songqing.gu
2021-05-10 11:50
:+1: thank you, @abubics

jbecker
2021-05-10 16:31
has joined #pact-jvm

jbecker
2021-05-10 16:40
:wave: hello! Can anyone point me to some resources for how to write Pact provider test for a contract with a database? (Specifically I'm working with Postgresql, but I've been having a hard time finding any examples of Pact provider tests with databases as providers, so any examples would be appreciated)

phil.endsley
2021-05-10 16:46
As in, your consumer is querying the database directly?

jbecker
2021-05-10 18:18
via spring's JDBC

matt.fellows
2021-05-10 21:30
The database is not a boundary between the ?consumer? and a ?provider? in Pact test. It would usually be considered _part_ of the consumer (or provider).

mail_4brad
2021-05-11 00:14
Ok my option 2 is out because I need to specify matching rules. Unless we annotated the model class fields with custom annotations that specify the matching to use so the matching rules could be auto generated. Has the project done anything like this? I?d hate to roll our own

agarwal.akash333
2021-05-11 03:00
You probably need DB schema validation for what you?re after. A DB is just a storage medium.

james.wettenhall
2021-05-11 04:54
has joined #pact-jvm

agarwal.akash333
2021-05-11 07:53
Hello. I?m trying to use the following in my `application.properties`: ```pactbroker.auth.url= pactbroker.auth.token=``` With a Junit test set as: ```@Provider("ExperimentService") @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ContractTest { ... }``` Running it either by running the class directly or `./gradlew test` results in: ```Did not find any PactSource annotations. At least one pact source must be set java.lang.UnsupportedOperationException: Did not find any PactSource annotations. At least one pact source must be set at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.findPactSources(PactJUnit5VerificationProvider.kt:140)``` What am I missing here? :slightly_smiling_face:

agarwal.akash333
2021-05-11 07:55
This is with the assumption that setting broker config in `application.properties` can act as a replacement for `@PactBroker`, which has worked for me on top of that class. Also, I?m using: ```testImplementation "au.com.dius.pact.provider:junit5spring:4.2.4"```

matt.fellows
2021-05-11 07:55
I believe you still need `@PactBroker( authentication = @PactBrokerAuth(username = "${pactbroker.auth.username}", password = "${pactbroker.auth.password}"))` type things


agarwal.akash333
2021-05-11 08:06
:thinking_face: on Junit 5 my class is unable to read those properties from application.properties.. even with a different name specified

agarwal.akash333
2021-05-11 08:12
Anyhow, I did get it working using environment variables in run configuration for intelliJ. Thanks for the link!

eduardo.marques
2021-05-11 09:19
has joined #pact-jvm

eduardo.marques
2021-05-11 09:32
~Hi,~ ~I'm having trouble using the pact gradle plugin to verify my tests, I have Java 11 installed and using gradle 6.8 and this is my configuration~ ~the error that I'm getting is:~

github2
2021-05-11 13:02
[pact-foundation/pact-jvm] Issue closed by keeping-it-up

al8x.romanov
2021-05-11 13:09
has joined #pact-jvm

jbecker
2021-05-11 13:15
It seems to me like the integration point between the service and the database makes for a contract, where the service has expectations of the database for exactly how it sends and retrieves data, so that the service would qualify as a consumer - and the database, a provider. In fact, it seems like this generalization of defining contracts can apply to any usage of third-party tools or libraries. But maybe you're saying that since nothing is traveling over-the-wire, it doesn't make sense to use Pact to test these, and we should instead stick to simple mocks/stubs to unit test our integrations with the database?

matt.fellows
2021-05-11 13:35
In a general sense there is indeed a contract of sorts there, it's just that there are better tools than Pact to test this (and in fact, I can't think of how you'd do it with Pact in its current incarnation. Once the plugin ecosystem is there it could be done). Databases still talk over a wire, but doing Pact with the various protocols is not something it's designed for

rafael.anachoreta
2021-05-11 15:33
@rafael.anachoreta has left the channel

github2
2021-05-11 19:24
[pact-foundation/pact-jvm] Issue opened by janssk1

jr.jenks
2021-05-11 21:46
has joined #pact-jvm

matt.fellows
2021-05-11 23:02
@al8x.romanov :wave: Thanks for putting your hand up to help with some contributions here. Please meet @uglyog, the core maintainer of the project (there are a number of other contributors here also). Alex is keen to help out with small contributions. He?s going to first learn a bit more about how it works by implementing it on a personal project. Alex, would you mind doing a little intro about yourself?

uglyog
2021-05-11 23:18
You still need the `@PactBroker` annotation

agarwal.akash333
2021-05-12 00:26
Right, looks like it needs pactbroker.host specified even though that?s deprecated

uglyog
2021-05-12 00:27
You don't need to supply any values, just have the annotation on the test class

agarwal.akash333
2021-05-12 00:29
That?s what I did. I ran into ?invalid pactbroker.host specified??

uglyog
2021-05-12 00:31
You need to setup the host or URL in the application properties. You seem to only have the auth ones

uglyog
2021-05-12 00:33
`pactbroker.url`

agarwal.akash333
2021-05-12 00:35
Ah I see what I did wrong there! Cheers mate

agarwal.akash333
2021-05-12 00:40
@uglyog I reckon it?s simply an issue with properties not being read from `application.properties`. Not an issue right now (in fact reading from the environment is better for my use-case), but I figured I?d point it out.

sammomichael
2021-05-12 02:27
has joined #pact-jvm

tony.foster
2021-05-12 03:44
has joined #pact-jvm

mail_4brad
2021-05-12 04:22
Any way to define OR with (null || object)? I have defined strings and integers fine with OR eg OR (null || string). I know about defining multiple state variations, but I will already have 6 variations without this - otherwise I?d need 24 to cover all the permutations.

uglyog
2021-05-12 04:27
No, because the OR changes the matching rules that are applied, but adding an object changes the structure.

mail_4brad
2021-05-12 04:31
Hmm. We have data variations that can be in the request: either supply an id, or (in an object) an area and device name. Only ever the id or the object populated. Any suggestions on how to apply that, other than another state/test?

uglyog
2021-05-12 04:34
I don't think there is another way, but there are only two variations.

mail_4brad
2021-05-12 04:35
Unfortunately there is another pair like this. And another more significant variation that I was actually going to vary the test based on. Will start another thread for that one

mail_4brad
2021-05-12 04:38
In our request json is a list. It can contain employees and customers in the same list. There can be 1-2 employees and 0-2 customers (<= employees). Can I specify 2 different compliant shapes within an array (ie employee shape and customer shape)?

uglyog
2021-05-12 04:42
You can use the ``arrayContaining`` matcher, it will match as long as the different shapes are in the list.

uglyog
2021-05-12 04:42
But it can't check the 1-2 and 0-2 values.

uglyog
2021-05-12 04:43
> Matches the items in an array against a number of variants. Matching is successful if each variant occurs once in the array. Variants may be objects containing matching rules

mail_4brad
2021-05-12 04:54
Ok I think I?ll just do these as 5 variations. And push the teams to split them into separate arrays

abubics
2021-05-12 05:32
A more fundamental question I have for you, @mail_4brad - why are you trying to match fields that are optionally `null`? That doesn't give you any safety, because all interactions might always use `null` in testing. See https://docs.pact.io/faq/#why-is-there-no-support-for-specifying-optional-attributes The 24 permutations you describe sound more like something to cover in unit tests, unless all the permutations are significantly different interactions (in which case you would want to cover each one specifically anyway).

al8x.romanov
2021-05-12 06:15
Hi guys. I am Alex. I work as automation engineer / software engineer for more than 9 years. My technologies a mostly tied with Java / Spring Boot and other JVM based languages (currently I am working at Scala -based project). I got involved into contract testing ~3 years ago - but mostly used Spring Cloud Contract on a company wide scale (multiple products and 300+ microservices). I am eager to join and help you with Pact.

jan.businsky
2021-05-12 09:10
has joined #pact-jvm

github2
2021-05-12 12:47
[pact-foundation/pact-jvm] Issue closed by pawelryznar

lreisch
2021-05-12 19:23
has joined #pact-jvm

mail_4brad
2021-05-12 22:32
I welcome fundamental challenges too, thanks! What I want to be able to specify is conditional mandatory fields. As it stands I could just say that the id must be null and the area/device object must be populated. If I did that, the provider needn?t assert that it can handle id for this interface, right? And the effective documentation would infer that this client doesn?t use the id field. That?s a good page you linked, thanks. It looks like I?ve been trying to define a scheme rather than a couple of likely data variations.

kflo
2021-05-12 22:47
has anyone else tried to convert between scala and kotlin? struggling with providing `MutableMap<String, Any>` to the `PactBrokerClient` from within scala

kflo
2021-05-12 23:18
i feel like this should be working? i think maybe I?m having issues with IntelliJ

kflo
2021-05-12 23:47
doesn?t compile either `value mutableMapOf is not a member of object kotlin.collections.MapsKt` :confused:

uglyog
2021-05-12 23:55
As far as I understand, MutableMap should be an alias for the normal Java Map.

uglyog
2021-05-12 23:56
But the constructor functions look like they are not accessible, maybe just pass through a Java Map (not a Scala one)

kflo
2021-05-12 23:57
that would be excellent if that were the case. that was the first thing i tried but it didn?t work? but maybe i have the typing wrong. looks like it wants `Map[String, Object]` ? let me try that

kflo
2021-05-13 00:00
ok, looks like i had two things wrong: the map type and i also have to include the config argument even though it has a default

kflo
2021-05-13 00:01
it compiles now :yay:

kflo
2021-05-13 00:06
in case it helps anyone in the future, it looks like this: ``` val options: Map[String, Object] = Map("authentication" -> List("bearer", configuration.token)) val config = new PactBrokerClientConfig new PactBrokerClient(new PactJvmBrokerClient(configuration.url.toString, options.asJava, config))```

jorge.curima.corp
2021-05-13 01:37
has joined #pact-jvm

agarwal.akash333
2021-05-13 04:08
Hello. I?m using `au.com.dius.pact.provider:junit5spring:4.2.4` and passing the following via IntelliJ environment: ```pactbroker.auth.token=blah;pact.verifier.publishResults=true;pactbroker.url=https://blah.pactflow.io;pact.provider.version=0.0.7``` All but `pact.provider.version` seem to be actually effective. My workaround so far has been to use `System.setProperty("pact.provider.version", System.getenv("VERSION"));` in a `@BeforeAll` block. Do I need an annotation for the version to be picked up in the JUnit test classes?

uglyog
2021-05-13 04:10
Can you raise a GH issue for that?

agarwal.akash333
2021-05-13 04:11
Sure

github2
2021-05-13 05:49
[pact-foundation/pact-jvm] Issue opened by akashagarwal7

anh.evizi.test
2021-05-13 05:56
has joined #pact-jvm

abubics
2021-05-13 08:15
Yeah, the usual advice we give is to make sure each interaction is significant. So if something is optional, there's usually a significant case where the value is present, and another where it's explicitly not present.

yka259
2021-05-13 08:22
has joined #pact-jvm

joshibharat
2021-05-13 11:43
has joined #pact-jvm

joshibharat
2021-05-13 11:45
I need to setup pact for messaging queues, can any one please guide me with the same

matt.fellows
2021-05-13 12:07
what have you looked at so far?

joshibharat
2021-05-13 12:10
I have gone through this implementation https://reflectoring.io/cdc-pact-messages/

joshibharat
2021-05-13 12:11
But the issue now I have is to implement provider test

matt.fellows
2021-05-13 12:12
have you looked at the Pact JVM docs?


matt.fellows
2021-05-13 12:13
you may also find the Kafka java example helpful: https://docs.pactflow.io/docs/examples/

joshibharat
2021-05-13 12:13
Yes , I have gone through AmqpContractTest class in pact jvm

matt.fellows
2021-05-13 12:14
howtoask

2021-05-13 12:14
Please see this page for some tips on how to ask for help to get the best response from the community https://docs.pact.io/help/how_to_ask_for_help

matt.fellows
2021-05-13 12:15
:point_up: we?re going to need a little more specificity in your questions please!

joshibharat
2021-05-13 13:56
Getting exception as : No test found marching method verify in my provider tests

kflo
2021-05-13 16:08
hm, i?m trying to see how to verify a message pact for a consumer. following the chain of methods in https://github.com/pact-foundation/pact-jvm/blob/master/provider/src/main/kotlin/au/com/dius/pact/provider/ProviderVerifier.kt from `runVerificationForConsumer` seems to bifurcate here: https://github.com/pact-foundation/pact-jvm/blob/master/provider/src/main/kotlin/au/com/dius/pact/provider/ProviderVerifier.kt#L512 on `ProviderUtils.verificationType` ? it seems the two possible types there are `REQUEST_RESPONSE` and `ANNOTATED_METHOD` ? why annotated method instead of something like `ASYNCHRONOUS_MESSAGE`? is it possible to verify messages without annotations?

kflo
2021-05-13 16:09
for context, i?m doing this from scala + scalatest

kflo
2021-05-13 16:14
maybe we can get around this by invoking `verifyMessage` directly

smankala
2021-05-13 20:55
has joined #pact-jvm

uglyog
2021-05-13 23:05
That's historical. At that point, it needs to know how to fetch the actual payload. And it can be done either by making a HTTP request or invoking a method.

uglyog
2021-05-13 23:05
You can fetch a message by HTTP (using a proxy server), that is how the message verification works in the other language implementations.

kflo
2021-05-13 23:06
can you link to an example of one of those?

uglyog
2021-05-13 23:06
But if you know it is a message pact it is ok to just call `verifyMessage`

uglyog
2021-05-13 23:07
Hmm, there are some diagrams and docs somewhere



kflo
2021-05-13 23:10
hm interesting. where is the http proxy used in the pact-jvm provider code? i must have missed it

uglyog
2021-05-13 23:11
I haven't implemented it, because it is easy to invoike a method with an annotation on it

kflo
2021-05-13 23:11
yeah i wonder if the annotations will also work in scalatest? but it?s just not natural for that framework

kflo
2021-05-13 23:12
it is more geared towards junit

uglyog
2021-05-13 23:12
Annotations should still work, because they are a JVM construct

kflo
2021-05-13 23:13
@jackbwheatley fyi

agarwal.akash333
2021-05-14 03:15
@uglyog have you had a chance with passing all of the above properties to gradle wrapper via environment? Apparently using spring kebab syntax doesn?t work either. So doing this: ```PACT_VERIFIER_PUBLISH_RESULTS=true PACTBROKER_URL=https://blah.pactflow.io PACTBROKER_AUTH_TOKEN=blah PACT_PROVIDER_VERSION=blah ./gradlew experiment-service:test --no-daemon -Porg.gradle.parallel=true``` or setting the properties in the environment beforehand using the same syntax has no effect. We can?t use the normal syntax because that gets treated as a command

agarwal.akash333
2021-05-14 03:20
I?m not sure how intelliJ manages to pass those properties on, even while using a gradle runner. This is what the XML looks like for a configuration: ```<component name="ProjectRunConfigurationManager"> <configuration default="false" name="ExperimentServicePactVerification with publishResults=true" type="GradleRunConfiguration" factoryName="Gradle"> <ExternalSystemSettings> <option name="env"> <map> <entry key="pact.provider.version" value="0.0.7" /> <entry key="pact.verifier.publishResults" value="true" /> <entry key="pactbroker.auth.token" value="blah" /> <entry key="pactbroker.url" value="https://blah.pactflow.io" /> </map> </option> <option name="executionName" /> <option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalSystemIdString" value="GRADLE" /> <option name="taskDescriptions"> <list /> </option> <option name="taskNames"> <list> <option value=":experiment-service:test" /> </list> </option> <option name="vmOptions" value="" /> </ExternalSystemSettings> <ExternalSystemDebugServerProcess>false</ExternalSystemDebugServerProcess> <ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess> <DebugAllEnabled>false</DebugAllEnabled> <method v="2" /> </configuration> </component>```

uglyog
2021-05-14 03:31
They need to be the same case as the system properties

agarwal.akash333
2021-05-14 03:32
We?ve been using kebab case on our deployments for activating docker profiles or providing credentials for other stuff, pact however doesn?t seem to be picking up the kebab case as I mentioned in the previous message in this thread

uglyog
2021-05-14 03:38
Kebab case is a spring boot thing, Pact-JVM uses the same form as the system parameters

agarwal.akash333
2021-05-14 04:08
Thanks. I?ve tried setting those properties with -P (and -D) as well before posting here, all in vain: ```./gradlew experiment-service:test --no-daemon -Porg.gradle.parallel=true -Ppact.verifier.publishResults=true -Ppactbroker.url=https://blah.pactflow.io -Ppactbroker.auth.token=blah -Ppact.provider.version=blah --tests=ai.a2i2.conductor.experimentservice.ExperimentServicePactVerification``` and the error I receive every time is: ```? initializationError java.lang.RuntimeException: Could not resolve property "pactbroker.url" in the system properties or environment variables and no default value is supplied```

uglyog
2021-05-14 04:10
Using -P (and -D) won't set it on the test JVM process, only on the gradle CLI one

agarwal.akash333
2021-05-14 04:22
Ah thanks, you?re right. I ended up using `systemProperty` ies in my `build.gradle`

abubics
2021-05-14 05:02
If you're using gradle, and you always want this stuff in test, you can use `jvmArgs`, e.g. ```test { useJUnitPlatform() finalizedBy jacocoTestReport jvmArgs '-Dspring.profiles.active=test' }```

agarwal.akash333
2021-05-14 05:04
Thanks for sharing!

martin.pelikan
2021-05-14 06:48
has joined #pact-jvm

joao_glorioso
2021-05-14 08:41
has joined #pact-jvm

ashok.jan31
2021-05-14 12:25
has joined #pact-jvm

dmitry.korolev
2021-05-14 13:10
Hey guys, Is there a specific reason why annotations `@DefaultRequestValues` and `@DefaultResponseValues` are not supported in `junit5` version of pact-jvm? Is their usage discouraged?

maksym.motornyi
2021-05-14 13:54
BTW! Is it worth to migrate from junit to junit5 ?

gusfisha
2021-05-14 19:52
has joined #pact-jvm

keithgutfreund
2021-05-14 20:13
has joined #pact-jvm

sammomichael
2021-05-15 02:50
Any one take a crack at this yet?

k.gutfreund
2021-05-15 03:47
has joined #pact-jvm

uglyog
2021-05-16 02:11
Probably because nobody asked, so they we never implemented

uglyog
2021-05-16 02:12
JUnit 5 is designed to be extensible, JUnit 4 extensions are workarounds.

siegcollado
2021-05-17 05:03
has joined #pact-jvm

maksym.motornyi
2021-05-17 08:35
Ok, for me it sounds like if I'll spent 8 hours to rewrite tests to use junit5 I'll get nothing?)

simon.thomas1978
2021-05-17 08:53
has joined #pact-jvm

anchit.99
2021-05-17 09:08
I have a message pact that is created by the consumer and published to the broker. Now I need to fetch the pact from the broker and place it in the provider's directory. I'm using the following code in my build.gradle to fetch the message pact: ```buildscript { repositories { mavenCentral() } dependencies { classpath 'au.com.dius.pact.provider:gradle:4.1.6' } } apply plugin: 'au.com.dius.pact' pact { broker { pactBrokerUrl = 'http://localhost:9292/' serviceProviders { providerSiteProvisioning { hasPactWith('consumerSearchIndexer') { fromPactBroker { selectors = latestTags('master') } } } } }``` When I try to run the gradle task: gradle pactVerify It throws an exception ```Execution failed for task ':pactVerify_providerSiteProvisioning'. au.com.dius.pact.core.model.messaging.Message cannot be cast to au.com.dius.pact.core.model.RequestResponseInteraction``` Does anyone know how I can fetch the message pact and place it in a particular folder?

anchit.99
2021-05-17 09:46
This is the full exception: ```gradle pactVerify > Task :pactVerify_providerSiteProvisioning FAILED Verifying a pact between Pact between consumerSearchIndexer (1.0.0) and providerSiteProvisioning Notices: 1) The pact at http://localhost:9292/pacts/provider/providerSiteProvisioning/consumer/consumerSearchIndexer/pact-version/7eef4554c0c445c2d5d536964963413858155a95 is being verified because it matches the following configured selection criteri on: latest pact for a consumer version tagged 'master' [from Pact Broker http://localhost:9292/pacts/provider/providerSiteProvisioning/consumer/consumerSearchIndexer/pact-version/7eef4554c0c445c2d5d536964963413858155a95/metadata/c1tdW3RdPW1hc3RlciZzW11bbF09dHJ1ZSZzW11bY3ZuXT0xLjAuMA==] valid message from site provisioning 2 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':pactVerify_providerSiteProvisioning'. > au.com.dius.pact.core.model.messaging.Message cannot be cast to au.com.dius.pact.core.model.RequestResponseInteraction```

keimiokamoto
2021-05-17 10:36
has joined #pact-jvm

anchit.99
2021-05-17 11:17
I'm able to solve this problem via the code using the `@pactBroker` annotation. However, I'm trying to fetch the pact via a gradle task so that I can have a better separation between the contract-fetching code and execution code.

fabian.feary
2021-05-17 11:52
has joined #pact-jvm

josh.brangwyn
2021-05-17 12:19
has joined #pact-jvm

matt.fellows
2021-05-17 13:10
Why do you want to download it and then save it?

matt.fellows
2021-05-17 13:11
The Pact CLI tools I think have a command to do this

xiao.liang
2021-05-17 16:41
has joined #pact-jvm

uglyog
2021-05-17 23:04
If you just want to fetch it, you can do that directly using either curl or wget.

uglyog
2021-05-17 23:05
You can do things in JUnit 5 easier than in JUnit 4, but if you don't need to do those things, then :man-shrugging:

matt.fellows
2021-05-18 03:08
The problem is you might have multiple contracts, in which case you?d need to use the pacts-for-verification endpoint


anchit.99
2021-05-18 05:37
Great! Thanks Ron/Matt! :slightly_smiling_face: Great! Thanks

github2
2021-05-18 07:03
[pact-foundation/pact-jvm] Issue closed by rahuldeshmukh81

github2
2021-05-18 07:03
[pact-foundation/pact-jvm] Issue closed by rahuldeshmukh81

github2
2021-05-18 13:04
[pact-foundation/pact-jvm] Issue opened by keeping-it-up

bhattacharyyasom
2021-05-18 14:05
has joined #pact-jvm

github2
2021-05-18 14:50
[pact-foundation/pact-jvm] Issue opened by gtudan

bhattacharyyasom
2021-05-18 15:29
Hello , I have been going through the documentation to put together a webflux provider side test case and am unable to execute it. I am trying to write a provider side contract test using PACT for a Spring web flux application. I am not using the Route functions to functionally create the API. I am using the @RestController annotations in code. Also I do not have any spring webmvc dependency in my application. ``` @RunWith(SpringRestPactRunner.class) @Provider("sampleService") @PactFolder("contracts") @SpringBootTest( properties = {"server.port = 9311"}, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = {TestApplication.class}) public class CreatesampleTest { @TestTarget @SuppressWarnings(value = "VisibilityModifier") public final Target target = new HttpTarget(9311); @State("Testing successful sample") public void successRequstForSampleApp() {} }``` This above method throws an error "Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean." which i feel is due to the absence of spring web mvc library. Is there a handy example somewhere to write a pack provider side test for webflux using controllers ?

bhattacharyyasom
2021-05-18 17:42
i was able to address this by including spring boot starter web in the dependencies and changing the target to SpringBootTarget. However , I am unable to do the same for the webflux target

lalit210784
2021-05-18 17:55
has joined #pact-jvm

zaxosdimi
2021-05-18 22:14
has joined #pact-jvm

uglyog
2021-05-18 23:17
You probably need the `spring-webflux` lib

dmitry.korolev
2021-05-19 12:10
Hey guys, I am trying to follow the instructions of _Modifying the requests before they are sent_: https://docs.pact.io/implementation_guides/jvm/provider/junit5/#modifying-the-requests-before-they-are-sent It says `NOTE: JUnit 5 tests do not use @TargetRequestFilter` What is it used then in junit5 for this purpose? The example on the page says to inject `HttpRequest` like `void testTemplate(PactVerificationContext context, HttpRequest request)` , however I cannot find `HttpRequest` in junit5 provider library...

dmitry.korolev
2021-05-19 12:19
It is coming from apache.. My bad, should have read it completely :slightly_smiling_face:

viktor.trako
2021-05-19 15:45
has joined #pact-jvm

abdel.akkoub
2021-05-19 17:27
has joined #pact-jvm

akrala
2021-05-19 21:22
has joined #pact-jvm

mazi.fayazfar
2021-05-19 22:23
has joined #pact-jvm

jorge.curima.corp
2021-05-20 00:11
Hello there! Im trying to implement Pact testing between 2 Java + Springboot artifacts, and I've managed to make the Consumer test work, and publish to a remote pact broker. But the problem I'm facing is to make the Provider test to work. I've used Wiremock to mock the Provider services dependencies to make the :pactVerify, it worked but I've used a Standalone version (script run it before the pactVerify task). I want to make it work programatically, I mean inside the Provider pact test to start wiremock and run the tests (like in an Integration Test) but I haven't acomplished that yet :disappointed: . Is there some Documentation or example in some Github repo where I can look for something like that? Thanks in advance!

matt.fellows
2021-05-20 00:21
I think you?re just asking if it?s possible to programmatically start wiremock during a Pact test. A Pact test is really just a test that runs in your standard unit testing tool/framework, so you might be best researching that

matt.fellows
2021-05-20 00:22
i.e. how to start wiremock with JUnit 5

jorge.curima.corp
2021-05-20 01:41
Ahhhh got it! Thanks for the answer Matt :muscle: :thumbsup:

github2
2021-05-20 07:15
[pact-foundation/pact-jvm] Issue opened by Avkashhirpara

daniel.qu
2021-05-20 18:03
has joined #pact-jvm

vijay.chawla
2021-05-21 08:37
has joined #pact-jvm

tim.walter
2021-05-21 09:12
has joined #pact-jvm

tim.walter
2021-05-21 09:20
Hi folks! :wave: We want to verify pacts from dart and java. The https://github.com/pak3nuh/dart_pact_consumer we are using implements V4 that the JUnit5 extension cannot handle. We provided a https://github.com/pact-foundation/pact-jvm/pull/1369 that calls the V4 PACT conversion function. Can please someone look into this?

ankit.laddha
2021-05-21 14:03
has joined #pact-jvm

dimundo
2021-05-21 14:09
has joined #pact-jvm

include.melaz
2021-05-22 13:15
has joined #pact-jvm

github2
2021-05-23 06:00
[pact-foundation/pact-jvm] New release _https://github.com/pact-foundation/pact-jvm/releases/tag/4_1_21_ published by uglyog

github2
2021-05-23 06:28
[pact-foundation/pact-jvm] New release _https://github.com/pact-foundation/pact-jvm/releases/tag/4_2_6_ published by uglyog

uddhavchopade
2021-05-23 08:32
has joined #pact-jvm

lukasz.wlosek
2021-05-24 08:03
has joined #pact-jvm

komathy_priya_dhanas
2021-05-24 09:26
has joined #pact-jvm

nh.salah
2021-05-24 11:46
has joined #pact-jvm

achuljyan
2021-05-24 15:17
has joined #pact-jvm

github2
2021-05-24 15:46
[pact-foundation/pact-jvm] Issue opened by fuudge

erinc1915
2021-05-24 16:11
has joined #pact-jvm

nzarate
2021-05-24 18:11
has joined #pact-jvm

daniel.qu
2021-05-24 21:16
Has anyone tried `https://github.com/pactflow/example-consumer-wiremock` ? I ran `make test` by following the README and it throws error like ?com.example.products.ProductsPactTest > initializationError FAILED?.

jonathan.arreola
2021-05-24 21:20
has joined #pact-jvm

cesar.consultorjr
2021-05-24 21:39
has joined #pact-jvm

github2
2021-05-24 22:26
[pact-foundation/pact-jvm] Issue closed by fuudge

matt.fellows
2021-05-24 23:52
Thanks Daniel, as discussed this is fixed now

daniel.qu
2021-05-24 23:57
Thanks Matt :+1:

gdfesta
2021-05-25 00:44
has joined #pact-jvm

utsavk3210
2021-05-25 08:37
has joined #pact-jvm

daniel.cardinha
2021-05-25 10:06
has joined #pact-jvm

ryanlevell
2021-05-25 14:17
Are provider side tests thread safe? We increased the surefire forkCount to 3 and it is resulting in jumbled JSON and the error ?unable to load pact file?. My initial suspicion is that multiple threads are downloading the same Pact simultaneously resulting in the jumbled JSON. I was just wondering if this is a potential bug or if parallel testing is just not supported.

dan.haughey
2021-05-25 14:34
has joined #pact-jvm

vince.lee
2021-05-25 14:36
has joined #pact-jvm

pact544
2021-05-25 16:01
has joined #pact-jvm

shlomi
2021-05-25 22:41
has joined #pact-jvm

uglyog
2021-05-25 22:54
They should be, what version of Pact-JVM are you using?

gupta.ratnesh9
2021-05-26 05:31
Hi

matt.fellows
2021-05-26 05:47
did you look at the links I provided?

matt.fellows
2021-05-26 05:47
the `given()` keyword is how you create states


abubics
2021-05-26 05:58
And if you've already got that working in the consumer side, the provider side gives you either the `@State` https://docs.pact.io/implementation_guides/jvm/provider/junit (if using the newer unit test style), or a https://docs.pact.io/implementation_guides/jvm/provider to fulfil (if using any other style, e.g. gradle plugin).

abubics
2021-05-26 05:58
Really depends if you're using a JVM language on both sides of the contract, otherwise it's hard to give you comprehensive advice.

raquel.bautista
2021-05-26 09:38
has joined #pact-jvm

vince.lee
2021-05-26 09:41
@vince.lee has left the channel

aubilla
2021-05-26 09:52
has joined #pact-jvm

aubilla
2021-05-26 09:57
Hi :wave: I'm looking for documentation regarding `GraphQLInteraction` in `pact-jvm` but I haven't found any. Is there a way of contract testing GraphQL endpoints in Java Spring applications with Pact?

vishnuprakash323
2021-05-26 10:46
has joined #pact-jvm

rob.caiger
2021-05-26 11:54
has joined #pact-jvm

lio.lunesu
2021-05-26 17:55
has joined #pact-jvm

nahuel.dallavecchia
2021-05-26 20:24
has joined #pact-jvm

fnguyen
2021-05-26 20:57
is the java implementation of the verifier know for being slower than the others? When i verify a pact on http://pact.net it takes about 4 minutes. in java, verifying the same pact takes one hour. the pattern matching seems exceedingly slow.

jarmy
2021-05-26 21:19
Anyone have any experience running pact verification with the `leiningen plugin`? I'm getting the following error when I run `./lein with-profile pact pact-verify`: ```Error encountered performing task 'pact-verify' with profile(s): 'pact' clojure.lang.ExceptionInfo: No pact definition was found in the project {} at clojure.core$ex_info.invokeStatic(core.clj:4617) at clojure.core$ex_info.invoke(core.clj:4617) at leiningen.pact_verify$pact_verify.invokeStatic(pact_verify.clj:23) at leiningen.pact_verify$pact_verify.doInvoke(pact_verify.clj:17) ``` Here's my straightforward profile: ``` :profiles { :pact { :plugins [[au.com.dius.pact.provider/lein "4.1.20" :exclusions [commons-logging]]] :service-providers { :sod { :protocol "http" :host "localhost" :port 3000 :has-pact-with { :graphql { :pact-file "https://pact-broker.docker.savagebeast.com" } } } } }}```

jarmy
2021-05-26 21:23
On the consumer side, I used this hack for generating a body in the request of a graphql contract: ``` private PactDslJsonBody jsonBody() { return new PactDslJsonBody() .stringType("query", "{query: search(query: \"Drake\" types: [AR] pagination: { limit: 5 }) {items {id}}}"); }```

uglyog
2021-05-26 23:03
You must have something configured incorrectly, I have never seen a verification test run for more than a few minutes. You should enable debug logging and do some profiling.

fnguyen
2021-05-26 23:04
I am not doing the verification but those who do reported it was so slow. i will pass on the message that it's not pact but us. Thanks.

uglyog
2021-05-26 23:14
I'm not that knowledgeable about leiningen, but looking at the docs, I think the `:service-providers` must be in it's own `:pact` block and not under the `:profiles`

mathew.baltes
2021-05-26 23:33
has joined #pact-jvm

matt.fellows
2021-05-26 23:36
yeah no, that?s exceedingly slow

stephen.leece
2021-05-26 23:44
has joined #pact-jvm

jarmy
2021-05-26 23:47
That was indeed it. I made a gross assumption that everything would reside under the profiles

scwang
2021-05-27 05:41
Hey folks , is it possible in pact-jvm to match the values in a map ignoring the keys? Thank you very much


aubilla
2021-05-27 07:00
Great stuff Jason, thanks!

rob.caiger
2021-05-27 07:48
Hi all We have a consumer that basically only cares that a provider?s response is valid json body. We have 2 different versions of the provider, one returns `{}` and the other returns `{"foo": "bar"}` I can?t see an obvious way to handle this. If we set the `.body('{}')` then it does an exact match which fails on the 2nd provider version. If we define a field matcher then that fails on the first. If we omit the body, then the consumer test fails. Any ideas how best to handle it?

uglyog
2021-05-27 07:58
Use `.body(new PactDslJsonBody())`

abubics
2021-05-27 07:59
For example reference: I currently have a contract with 9 interactions, which takes 2.5 seconds. Even if there are many large interactions, it shouldn't be orders of magnitude slower.

rob.caiger
2021-05-27 08:00
Oooh thanks, didn?t know that would work

rob.caiger
2021-05-27 08:00
I?ll give it a try

rob.caiger
2021-05-27 08:38
Looks like this has the same affect as `.body('{}')`

rob.caiger
2021-05-27 08:39
It ends up trying to exact match {} to {?foo?: ?bar?}

uglyog
2021-05-27 08:48
I'll have a play, it shouldn't do that

rob.caiger
2021-05-27 08:48
Thanks

rob.caiger
2021-05-27 08:52
Incase it?s significant, we?re using the new standalone verifier

james_fraser
2021-05-27 09:23
has joined #pact-jvm

uglyog
2021-05-27 09:31
Which one is that?


uglyog
2021-05-27 10:05
Ok, that should be fine

mostafa.zaher
2021-05-27 10:13
has joined #pact-jvm

utsavtiwary10
2021-05-27 10:53
has joined #pact-jvm

utsavtiwary10
2021-05-27 11:01
Hi All. I had a query regarding pact provider side testing. I am working with "au.com.dius.pact.provider:junit5:4.1.16", and I basically wanted to test my provider side test with some already generated contracts locally. So even before I start writing the states and all, I wanted it to pick up the expected pact json from the desired location. Getting the following initialization error: ```Did not find any PactSource annotations. At least one pact source must be set java.lang.UnsupportedOperationException: Did not find any PactSource annotations. At least one pact source must be set at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.findPactSources(PactJUnit5VerificationProvider.kt:118)``` Code snippet for provider: ```@Provider("ProviderService") @PactDirectory("pacts") class ProviderContract { /** * Produce the individual tests for each defined pact * @param[context] the pact verification context */ @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun test(context: PactVerificationContext) { context.verifyInteraction() } }``` I tried putting my json pact under following locations: 1. pacts/ (directly under root project, where the build folder is generated) 2. src/contractTest/resources/pacts/ PS: package name is "com.demo.pact" for above ProviderContract class. Can anyone help, if I am making a mistake?


utsavtiwary10
2021-05-27 11:41
@matt.fellows I am using : ```import au.com.dius.pact.core.model.annotations.PactDirectory``` @PactFolder is deprecated, and under that it was suggested to use @PactDirectory. Hence I went with this. Let me try with ```au.com.dius.pact.provider.junitsupport.loader.PactFolder;```

utsavtiwary10
2021-05-27 11:55
@matt.fellows Thanks it worked. But the above mentioned import is not present in "au.com.dius.pact.provider:junit5:4.1.16". I had to use junit5:4.1.7. Why has it been removed from junit5:4.1.16?

matt.fellows
2021-05-27 11:59
Ah, not sure sorry

matt.fellows
2021-05-27 11:59
Best to consult the docs on the latest annotations and packages to use

aubilla
2021-05-27 13:13
:wave: Hi, I'm trying to contract test my services :interrobang: On the consumer side I'm having a `PactMismatchesException` that looks like this: ```The following mismatched requests occurred: Unexpected Request: method: POST path: /api/pmi/graphql query: {} headers: {Accept-encoding=[gzip], Accept=[application/json], Connection=[Keep-Alive], Host=[localhost:57515], User-agent=[okhttp/4.9.1], Content-type=[application/json; charset=utf-8], X-auth-token=[somelongtoken], Content-length=[102]} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: PRESENT({"query":"query {\n findPatientById (id: 200040588) {\n id\n gender\n userRef\n }\n}"})``` :desktop_computer: I'm trying to mock a GraphQL provider I can consume with the following Pact: ```@Pact(consumer = "PatientClient") public RequestResponsePact findPatientById(PactDslWithProvider builder) { return builder .given("patients exist") .uponReceiving("get patient by id") .path("/api/pmi/graphql") .willRespondWith() .status(200) .body( new PactDslJsonBody() .stringType("{\"data\":{\"findPatientById\":{\"id\":200040588,\"clientId\":3,\"personalInformationId\":200060585,\"userRef\":null,\"patientNumber\":2440,\"gender\":\"U\",\"birthYear\":null,\"weight\":null,\"height\":null,\"medicationHistory\":null,\"patientOrigin\":null,\"patientAnamnesis\":null,\"reasonForReferral\":null,\"fatherOrigin\":null,\"fatherAnamnesis\":null,\"motherOrigin\":null,\"motherAnamnesis\":null,\"userComment\":null,\"motherId\":null,\"fatherId\":null,\"diseases\":[]}}}") ) .toPact(); }``` :technologist: And my test is as simple as I could make it: ``` @Test @PactTestFor(pactMethod = "findPatientById") void testFindPatientById(MockServer mockServer) throws IOException { patientClient.setBaseURL(mockServer.getUrl()); String patients = patientClient.findPatientById(); assertNotNull(patients); }``` How can I determine what is wrong with the request? The error doesn?t give me much information. Should the query field be populated with the same information that's in the body?

matt.fellows
2021-05-27 13:38
Love the emoji :slightly_smiling_face:

matt.fellows
2021-05-27 13:38
From what I can tell, it?s saying that you?re sending a body in your actual request (which makes sense, it?s a graphql query) but you didn?t tell Pact you were going to do it

matt.fellows
2021-05-27 13:38
Hence, the mismatch is that the request body is present, but it wasn?t expecting one

aubilla
2021-05-27 13:46
Thanks for such a quick response. I found out Pact isn't the only thing I need to learn. GraphQL only takes POST and I was not specifying that when building the Pact. I suppose it defaults to GET. Solved it by adding `.method("POST")` to the builder.

nahuel.dallavecchia
2021-05-27 15:18
Hello! I am trying to create a POC using http://pact.io with Java, RestAssured and JUnit5. So far, I was able to create a simple pact and verify it. The problem that I have is when I try to use a URL template instead of a regular path: ```@Pact(consumer = PACT_CONSUMER) public RequestResponsePact createSessionPact(PactDslWithProvider builder) { final Map<String, String> responseHeaders = new HashMap<>(); responseHeaders.put("Content-Type", "application/json; charset=UTF-8"); final DslPart expectedResultBody = new PactDslJsonBody() .stringType("id", "session-1234-1234-1234") .asBody(); return builder .given(ORGANIZATION_DEFINED) .uponReceiving(DESCRIPTION_MDS_SESSION_CREATE) .pathFromProviderState("api/v1/organizations/${organizationId}/sessions", "api/v1/organizations/1234/sessions") .method("POST") .headers("Content-Type", "application/json; charset=UTF-8") .willRespondWith() .status(SC_OK) .headers(responseHeaders) .body(expectedResultBody) .toPact(); }``` I should be able to inject `organizationId` on the provider test using @State. My problem so far is with the consumer test: ```@Test @PactTestFor(pactMethod = "createSessionPact") public void verifyCreateSessionPact(MockServer mockServer) { given() .pathParam("organizationId", 1234) .path("api/v1/organizations/{organizationId}/sessions") .post(mockServer.getUrl()) }``` How can I make a successful call against the mocked provider service in the test pact method?

fnguyen
2021-05-27 19:20
It seems most of the time is spent doing a Myers diff. I am gather more information.

nahuel.dallavecchia
2021-05-27 20:02
This may be solved using `.matchPath(path)` instead, but then I kind of loose the feature of providing the value using the State annotation, right?

fnguyen
2021-05-27 20:31
https://github.com/pact-foundation/pact-jvm/blob/fc669cf7f0e23ad0b9664003ee31c73b54a95ff8/provider/src/main/kotlin/au/com/dius/pact/provider/ResponseComparison.kt#L82 The above line tries to create a diff using external library com.googlecode.java-diffutils:diffutils:1.3.0, specifically method difflib.myers.MyersDiff.buildPath(List<T> orig, List<T> rev) hogging CPU taking several minutes to generate a diff when the response size is large ( around 1 MB or more)

jarmy
2021-05-27 21:26
I have another question with the `leiningen plugin`. When I run the `pact-verify` task, I get the following message: ```Verifying a pact between :pegasus and :hestia [from URL https://pact-broker.docker.savagebeast.com] WARNING: Pact file has no interactions``` This is the `:pact` configuration I have defined: ``` :pact { :service-providers { :hestia { :protocol "http" :host "localhost" :port 3000 :has-pact-with { :pegasus { :pact-source "https://pact-broker.docker.savagebeast.com" } } } } }```

uglyog
2021-05-27 22:51
Good find. I'll add a flag to turn off generating a diff.

uglyog
2021-05-27 22:53
It was't removed from 4.1.16, it was added in 4.1.17

github2
2021-05-27 23:22
[pact-foundation/pact-jvm] Issue opened by jarmy

abubics
2021-05-28 01:07
It's a shame you have such big payloads :cry: makes a lot of things harder

kamoljan
2021-05-28 02:39
has joined #pact-jvm

mathias.duesterhoeft
2021-05-28 08:59
has joined #pact-jvm

aubilla
2021-05-28 11:54
Why are you trying to inject the `organizationId` instead of using a regular path?

nahuel.dallavecchia
2021-05-28 13:36
In this scenario, I can hardcode it. but I would like to cover more general scenarios like creating a session ID and then delete it. In this example, the second part (deleting the session ID) involves something like `DELETE /api/v1/organizations/1234/sessions/${sessionId}` , and that?s similar to the original case I posted here. Currently, for the provider tests, I am hitting live services. The plan is to go against a mock service soon, and in the meanwhile unblock development.

aubilla
2021-05-28 13:57
Creating a session and then deleting it introduces coupling between those two scenarios. I wouldn?t start going down that route if I were you. Hitting live services is also a problem because you end up doing a mix of contract and E2E testing that defeats the purpose of Pact.

aubilla
2021-05-28 14:00
Of course, these are just opinions of mine. I started learning what contract testing was on Tuesday :slightly_smiling_face: I found your use case interesting. I hope you can get an answer that helps you :thumbsup:

nahuel.dallavecchia
2021-05-28 14:00
I see your point! What would be the correct way of tackling those type of scenarios? About the second, I know is not a good practice, but it is a temporary measure so we can have progress. I believe it should be easy to switch to a mock service as soon it is developed.

aubilla
2021-05-28 14:08
You shouldn?t make your tests (or your test data) dependent of each other and thus you should be able to run tests in any order. If you have a test that creates something and fails, that?s gonna make your deletion test fail as well. In this particular case half of your non-passing tests will be false negatives.

aubilla
2021-05-28 14:10
If you, instead of coupling the tests, create your test data beforehand, the creation test might fail but the other one might pass and the success or failure of either will have anything to do with the other.

aubilla
2021-05-28 14:13
Since you are writing the tests, you are the best person to evaluate if it?s worth it to hit live stuff until you can mock them. Are those ?live services? local instances you are running on your environment?

nahuel.dallavecchia
2021-05-28 14:23
I can make them local (bunch of services in a kubernetes cluster accessible locally by using port-forwarding).

aubilla
2021-05-28 15:04
You were so right @matt.fellows and it took me so long to understand :facepalm:

matty_o_connor01
2021-05-28 15:57
has joined #pact-jvm

nathaniel.emmons
2021-05-28 18:25
has joined #pact-jvm

nathaniel.emmons
2021-05-28 18:37
Hi all! I?m having an issue with a provider test not returning values to be injected properly. I?ve followed https://docs.pact.io/implementation_guides/jvm/provider/junit#returning-values-that-can-be-injected (which match https://pactflow.io/blog/injecting-values-from-provider-states/ except that i?m using the PactRunner but i hope that doesn?t matter) and i?ve verified that my provider state method returns the correct map, but it?s seemingly not being used after that, so my test fails. here?s https://gist.github.com/cah-nathanielemmons/9b643c326e5d4fb0bf7f2448bc300e4b of the relevant code, i tried to remove all unnecessary detail. If someone could take a look and see if anything sticks out as being wrong i?d really appreciate it

nathaniel.emmons
2021-05-28 18:43
@nahuel.dallavecchia i might be misunderstanding your question, but in your case, given that setup, i think you just need to get your client code to make a request to the example endpoint you supplied: `"api/v1/organizations/1234/sessions"` . So for example i have a HttpService that takes baseURL and endpoint as constructor params. In my pact consumer test i new up the service, setting the baseURL to `mockServer.getUrl()` and the path to the example endpoint i defined in the second parm of the .pathFromProviderState() method

nathaniel.emmons
2021-05-28 18:44
then i pass that service to some other service that needs to make an HTTP call, and when it does, it will hit the mocked provider endpoint

nahuel.dallavecchia
2021-05-28 18:57
Hi Nate! My problem is that if I specify a template, then I don?t know how to make PactTestFor test work. I tried out using as path the sample path value, and to use a resolved path with the value of the sample and with another completely different value. In all cases, the mock service returned 500 status code. :cry:

nathaniel.emmons
2021-05-28 19:02
Maybe related, maybe not: I have `.numberType("legacyId", 123L)` as part of the expected body of a response, then on the provider side i?m generating ?345? for that value, and the provider test is failing because 345 doesn?t match 123. I thought the second param to methods like `.numberType()` were meant for generating local consumer values?

nathaniel.emmons
2021-05-28 19:03
In my pact file under ?body?: {} for this interation i see `"legacyId": 123,` then under matchingRules i see ```"$.legacyId": { "matchers": [ { "match": "number" } ], "combine": "AND" },``` so this _seems_ correct, even though the provider test is failing

nahuel.dallavecchia
2021-05-28 19:32
Apparently, when you use pathFromProviderState(), for the PactTestFor() test you have to use whatever you defined as sample path, making sure that either template or sample path starts with ?/? otherwise when you call the mock server you will have 500 status code.

kflo
2021-05-28 20:54
how are `providerStates` supposed to be used with message pacts? seems like you could also overload `description` for ?message and state??

kflo
2021-05-28 20:55
unless i misunderstand it also seems that `ProviderVerifier.verifyMessagePact` only supports description and not state?

kflo
2021-05-28 20:57
i do see `StateChange.executeStateChange` but i?m not sure how to use that

kflo
2021-05-28 21:04
seems like states are run automatically before verification, and they delegate to provider URLs?


nathaniel.emmons
2021-05-28 21:13
Yeah, sorry, that?s what i was trying to suggest but i did a bad job of explaining it

uglyog
2021-05-29 03:00
Should be the same, if not, that is a defect

uglyog
2021-05-29 03:01
Is `'345'` a string value?

sapoho3257
2021-05-29 16:10
has joined #pact-jvm

andjela.rajic
2021-05-30 20:00
has joined #pact-jvm

utsavtiwary10
2021-05-31 04:26
Is there a way to verify pact contract at provider side using WebFluxTest with junit5. I can find only this documentation for pact: https://docs.pact.io/implementation_guides/jvm/provider/spring/, but this seems to be for junit4, and classes like WebFluxTarget are not available for junit5. Can anyone help, or point documentation for WebFluxTest with junit5?

uglyog
2021-05-31 04:39
There is no support for WebFlux and JUnit 5 at the moment. Can you raise an issue for that?

utsavtiwary10
2021-05-31 04:47
Okay sure

github2
2021-05-31 04:52
[pact-foundation/pact-jvm] Issue opened by utsavcoding


utsavtiwary10
2021-05-31 04:55
@uglyog Is there a workaround to test webflux application currently with pact?

uglyog
2021-05-31 04:59
Sorry, I don't really know Webflux so I can't answer that. The JUnit 4 support for it was added by a community submission.

uglyog
2021-05-31 05:00
You can try run the test using JUnit 4 (they can be setup to run alongside JUnit 5 tests)

utsavtiwary10
2021-05-31 05:05
alright. Thank you!

sumitsg004
2021-05-31 05:10
has joined #pact-jvm

chris.faulkner
2021-05-31 08:37
Hello - is it possible to add a request header (security token) with spring / junit 5 as part of my verification ? I have looked at this section on the website ```https://docs.pact.io/implementation_guides/jvm/provider/junit5/#modifying-the-requests-before-they-are-sent``` This seems to refer to something only possible with Junit 5 if I am reading it correctly. The sample is like this ``` @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(PactVerificationContext context, HttpRequest request) { // This will add a header to the request request.addHeader("X-Auth-Token", "1234"); context.verifyInteraction(); }``` But the Spring equivalent signature is as follows and has no `HttpRequest` available to modify. ``` @TestTemplate @ExtendWith(PactVerificationSpringProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); }``` Apologies - I am probably missing something obvious. I did try to add HttpRequest but get this error ```No ParameterResolver registered for parameter [java.net.http.HttpRequest request] in method [void xxxxx.pactVerificationTestTemplate(au.com.dius.pact.provider.junit5.PactVerificationContext,java.net.http.HttpRequest)]. ``` I tried the HttpRequest from http://java.net and also the `HttpRequest` in `http://au.com.dius.pact.core.model`

allan.barbosa
2021-05-31 14:08
has joined #pact-jvm

vinicius.grund
2021-05-31 14:35
has joined #pact-jvm

uglyog
2021-05-31 22:55
It's using the Apache HTTP client to make the request, so it needs to be the class from that library: `org.apache.http.HttpRequest`

github2
2021-05-31 23:13
[pact-foundation/pact-jvm] Issue opened by ehmurray8

cemal.onder
2021-06-01 07:00
I used it with junit4 and spring as follows; ```<!--Contract Testing--> <dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>4.2.2</version> <scope>test</scope> </dependency> <!--Using spring instead of junit5 to avoid boilerplate in tests--> <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>spring</artifactId> <version>4.2.3</version> <scope>test</scope> <!--IMPORTANT! Otherwise there will be some strange errors which is hard to find, learned in hard way.--> <exclusions> <exclusion> <artifactId>groovy</artifactId> <groupId>org.codehaus.groovy</groupId> </exclusion> </exclusions> </dependency>``` ``` @RunWith(RestPactRunner::class) .... @TestTarget var target = WebFluxTarget() @Before fun before() { MockKAnnotations.init(this, relaxUnitFun = true) target.controllers = listOf(controller) } ....```

nathaniel.emmons
2021-06-01 13:07
No, it?s an int. Sorry, my use of single quotes in the above message was misleading, should have said `345`

nathaniel.emmons
2021-06-01 13:13
Although, *sigh,* i?m now having trouble recreating that issue, although the first issue i mentioned seems to persist.

nahuel.dallavecchia
2021-06-01 13:38
Hello! I see in the https://docs.pact.io/implementation_guides/jvm/provider/junit that you may use @State like: ```@State(value = "Resource created", action = SETUP) public Map<String, Object> setupCreatedDesignSession(Map<String, Object> map) {..} @State(value = "Resource created", action = TEARDOWN) public void tearDownCreatedDesignSession(Map<String, Object> map) {..}``` I am wondering how the map is used. So far, I can see that it is an empty read only map, even when using pathFromProviderState() on the pact side for example (setup). More context: I am looking for a way to free a resource that is set in setup, but only in same cases, the remaining cases being handled after all remaining pacts are verified, Thanks in advance for any insight about this!

phil.endsley
2021-06-01 13:49
You can use this to inject certain values into the request before it reaches the provider code. For example, if your provider needs to generate a unique id, it can do so in the state handler, and that id will be injected into the request during verification https://docs.pact.io/implementation_guides/jvm/consumer#having-values-injected-from-provider-state-callbacks

nathaniel.emmons
2021-06-01 14:39
Okay, refreshed from the long weekend I think i?ve found my issue in step debugging. It looks like the MockMvcTarget ignores the context when testing the interaction? Is that intended? https://github.com/pact-foundation/pact-jvm/blob/master/provider/spring/src/main/kotlin/au/com/dius/pact/provider/spring/target/MockMvcTarget.kt#L50

nahuel.dallavecchia
2021-06-01 14:40
Hi Phil! Yes, that?s for the State annotation usage. Agreed. You create a map with the needed values and return it to be used as you say. My question is more about the map that comes for free when calling the State annotated method. Who injects it? What values are supposed to have? In what way I can leverage it? Documentation says it can be used, but so mar I have an inmutable empty map.

todd.lemmonds
2021-06-01 15:57
has joined #pact-jvm

alexander.infante
2021-06-01 15:57
has joined #pact-jvm

michael.doyle
2021-06-01 15:58
has joined #pact-jvm

chris.faulkner
2021-06-01 17:19
Thanks !

fnguyen
2021-06-01 17:31
@uglyog should I open an issue for this?

paulorochag
2021-06-01 20:20
has joined #pact-jvm

uglyog
2021-06-01 22:47
Yes, please. Otherwise, it can be forgotten

uglyog
2021-06-01 22:50
No, that sounds like an accidental omission

github2
2021-06-01 23:02
[pact-foundation/pact-jvm] Issue opened by ngufra


uglyog
2021-06-01 23:03
Your provided example looks correct. Can you provide debug logs from the test?


matt.fellows
2021-06-02 01:27
coming in v4!

kflo
2021-06-02 01:27
when is v4 coming?

kflo
2021-06-02 01:28
or i guess i should say, the version of V4 with that in it :smile:

matt.fellows
2021-06-02 01:28
homer bush



kflo
2021-06-02 01:30
that is definitely related, but perhaps not the entire fix

matt.fellows
2021-06-02 01:31
ah right. So one is just ?it?s allowed in the Pact file? and the current problem is doing it within the test suite?

kflo
2021-06-02 01:31
yeah, can?t have the same name for consumer/provider when the consumer/provider uses both REST and messages

kflo
2021-06-02 01:31
which is a bummer for many reasons

kflo
2021-06-02 01:32
but the most painful one is it means i would have to modify our CI/CD setup with more complexity

matt.fellows
2021-06-02 01:32
I know, it?s a pain

matt.fellows
2021-06-02 01:32
I don?t know the interface well enough, so there may well be more recent updates here

kflo
2021-06-02 01:33
just knowing it?s being worked on is enough, we are on the latest version of `pact-jvm` FWIW

kflo
2021-06-02 01:33
it was just unforeseen work

uglyog
2021-06-02 01:36
There are lots of places where things need to be fixed. I've only done the underlying work to be able to support it, it still needs to be propagated throughout the code base.

kflo
2021-06-02 01:36
is there any specific ticket i should watch?

kflo
2021-06-02 01:36
really just need it in the base `consumer`/`provider` JARs

uglyog
2021-06-02 01:37
Let's create a master ticket for it. I'm pretty sure there are going to be lot's of places that need to be updated

kflo
2021-06-02 01:37
thanks @uglyog!

github2
2021-06-02 01:40
[pact-foundation/pact-jvm] Issue opened by uglyog

kflo
2021-06-02 01:44
if it?s helpful, i also wouldn?t mind still doing this in two separate tests, as long as i can re-use consumer/provider names, and the result of the two tests would be a single pact file with both types merged in

abubics
2021-06-02 01:57
That sounds more like structured state (provided in the `given` on the consumer side), which facilitates richer parameterised state to be passed at verification time. Not sure where the docs are for that, though :thinking_face:

nathaniel.emmons
2021-06-02 13:06
Great, thank you. I?ll open an issue in Github and I might see if i can be bold enough as to propose a fix.

nathaniel.emmons
2021-06-02 13:06
(looks like you answered in my second thread, Thanks very much for taking a look!)

jaspal.gill
2021-06-02 15:23
has joined #pact-jvm

wenqiglantz
2021-06-02 18:19
has joined #pact-jvm

kflo
2021-06-02 20:55
@uglyog any idea on timeline for this? just trying to plan accordingly

ch.toimbetov
2021-06-02 21:46
has joined #pact-jvm

uglyog
2021-06-02 22:44
I might have some time this weekend to work on it

kflo
2021-06-02 22:44
well? i don?t want you to work on your weekends? unless you want to

kflo
2021-06-02 22:45
just wondering if it?s two weeks out, or two months out

uglyog
2021-06-02 22:56
More two weeks than two months.... but :man-shrugging:

kflo
2021-06-02 23:00
i know the feeling, haha

kflo
2021-06-02 23:00
i guess i will wait a bit and see what happens. might have to update our CI/CD pipeline to support both types

phil.endsley
2021-06-03 00:52
Yeah... completely missed the point of your original question :sweat_smile: Took some digging, but it looks like you can parameterize the state on the consumer side. Very nifty. Don't see anything in the official docs yet, but here's a starting point to get the general idea across. https://github.com/pact-foundation/pact-jvm/issues/335


xyz1kind
2021-06-03 05:03
has joined #pact-jvm

aftab.shamim2020
2021-06-03 06:02
has joined #pact-jvm

rob.caiger
2021-06-03 08:09
Hi @uglyog did you get chance to look into this? Do you have an idea about what should happen with `.body(new PactDslJsonBody())`? I?d be happy to take a look and try and submit a fix

slu.mendozaharold
2021-06-03 10:33
has joined #pact-jvm

uglyog
2021-06-03 22:33
I'm going to have time this weekend

kflo
2021-06-03 23:18
i am having some issues with the annotated method verification for messages. i?m using this from within scala so bear with me? starting thread

kflo
2021-06-03 23:19
so my `@PactVerifyProvider` annotated method is on the test suite, and when the method is invoked it seems i can?t access any state from the surrounding test suite class

kflo
2021-06-03 23:20
is there some way i can access state outside of the method?

kflo
2021-06-03 23:21
is there more documentation for this stuff i missed somewhere?

kflo
2021-06-03 23:22
i do see `providerMethodInstance` but i?m not sure how to use that

kflo
2021-06-03 23:26
hm, actually the thing throwing the exception is a `@volatile private var` ? maybe related?

kflo
2021-06-03 23:29
basically my tests are trying to start up a server, and then reference the server inside the method that generates the message, and for some reason the `server` (lazy val) is not defined inside the method but has already been referenced outside the method and so should have a value

uglyog
2021-06-04 00:06
Is this based on a JUnit 4/5 test suite, or is it something else?

kflo
2021-06-04 00:06
this is Scalatest

uglyog
2021-06-04 00:07
I know with JUnit 5, there was some sequencing issues. I think it was with Spring integration

uglyog
2021-06-04 00:07
But this sounds different

kflo
2021-06-04 00:07
the problem seems to be a combination of `pact-jvm`, `testcontainers-scala` and `lagom`

kflo
2021-06-04 00:08
i will try to figure out a workaround, i can?t even fully pinpoint what the problem is other than it has to do with `lazy val`

uglyog
2021-06-04 00:09
So, the server will be started up when the `val` is first referenced?

kflo
2021-06-04 00:09
correct

kflo
2021-06-04 00:09
it gets referenced prior to the method being invoked

kflo
2021-06-04 00:10
but the method didn?t seem to know that

uglyog
2021-06-04 00:10
But from within the method call, the `val` is not set, or not accessable?

kflo
2021-06-04 00:10
it is accessible, but not yet initialized

kflo
2021-06-04 00:10
so it tries to call another method, and that one blows up

uglyog
2021-06-04 00:11
Ok, I think it is the test class instance. It is the same issue as the Spring one.

kflo
2021-06-04 00:11
yeah i had a feeling

kflo
2021-06-04 00:11
is there a workaround?

uglyog
2021-06-04 00:11
With the Spring one, the Spring test context was being applied to a different instance of the test class than Pact-JVM was working with

uglyog
2021-06-04 00:12
I need to remember how we fixed that

kflo
2021-06-04 00:12
eventually i want to figure out how to create a `java.lang.reflect.Method` from scala, so i can skip using annotations, but for now it?s easier to use them

uglyog
2021-06-04 00:13
But basically, I think the problem might be that ScalaTest is creating a test class instance, then Pact-JVM is getting a different instance

kflo
2021-06-04 00:13
yeah that could be the case

kflo
2021-06-04 00:14
it is strange though, because if i test with just a simple lazy val, like `lazy val test = "test"` ? that one evaluates fine

kflo
2021-06-04 00:14
must be some magic going on i don?t know about

uglyog
2021-06-04 00:21
Looking at the `providerMethodInstance`, the default implementation is `Function { m -> m.declaringClass.newInstance() }` so that looks like it could be the problem

kflo
2021-06-04 00:21
yeah, i think so as well. i don?t know the proper syntax to provide that in scala, haha

kflo
2021-06-04 00:22
i think this is why i have a general aversion to annotations? they are great until they are not :smile:

uglyog
2021-06-04 00:23
Does ScalaTest have test setup hooks, or before methods like JUnit?

kflo
2021-06-04 00:23
it does, yeah. and some of them are being used by the testcontainers library as well

uglyog
2021-06-04 00:25
You will also need a way of getting the correct test instance, and then set that up in the setup code

uglyog
2021-06-04 00:26
JUnit 5 provides an API to get that

kflo
2021-06-04 00:26
do you have an example?

uglyog
2021-06-04 00:27
Yes, but it depends on the test framework. For JUnit5, we get it from the test context object. For Spring tests, we look it up from the Spring test application context.

uglyog
2021-06-04 00:27
I can point you at both

kflo
2021-06-04 00:28
does `providerMethodInstance` basically specify what `this` is inside the method?

uglyog
2021-06-04 00:29
Yes, it sets the `this` instance



uglyog
2021-06-04 00:33
`requiredTestInstance` is the test class instance that JUNit 5 has started

kflo
2021-06-04 00:33
thanks, i will see if scalatest has something similar

kflo
2021-06-04 00:33
and then i will need to figure out the `Function { m => ? }` syntax for scala

uglyog
2021-06-04 00:38
That is easy, it's just a SAM type. I think under the hood, it will be a `scala.Function1`

kflo
2021-06-04 00:38
i thought so too, but that didn?t seem to work

kflo
2021-06-04 00:40
maybe it?s just the `Any` it?s complaining about

kflo
2021-06-04 00:40
yep, this will make it stop complaining: ```verifier.setProviderMethodInstance(m => m.getDeclaringClass.newInstance().asInstanceOf[AnyRef])``` but it will throw an exception during runtime

uglyog
2021-06-04 00:43
What exception?

kflo
2021-06-04 00:45
oh, actually that works. as `m.getDeclaringClass.getDeclaredConstructor().newInstance().asInstanceOf[AnyRef]` to get rid of the deprecated warning

kflo
2021-06-04 00:45
i think it didn?t work last time because it was in a nested class

kflo
2021-06-04 00:45
:relieved:

uglyog
2021-06-04 00:46
Now you just need to get the correct instance to use

kflo
2021-06-04 00:57
i think it worked!

kflo
2021-06-04 00:57
i just did ```val instance: PactVerifier = this```

kflo
2021-06-04 00:57
and then ```verifier.setProviderMethodInstance(_ => instance)```


uglyog
2021-06-04 00:57
Nice!

kflo
2021-06-04 00:58
thanks for the help, i will get a PR up to fix this in https://github.com/jbwheatley/pact4s

kflo
2021-06-04 00:59
(we are slowly trying to build a scala version of pact on top of the jvm version)

kflo
2021-06-04 01:00
once it becomes more stable perhaps we can try to move it into the foundation org

uglyog
2021-06-04 01:00
:100: and delete what is Pact-JVM because it is useless

kflo
2021-06-04 01:00
yes haha

kflo
2021-06-04 01:00
it was at least useful at one time i hope

uglyog
2021-06-04 01:02
Must have been, I doubt anyone set out to create something useless :smile: But you never know ...

kflo
2021-06-04 01:14
ah, i was able to reproduce this more simply. i think this problem will happen with anything that is mutable (`var`) ? and seemingly also `lazy val`s that interact with the `var`

github2
2021-06-04 02:07
[pact-foundation/pact-jvm] Issue opened by naushadamin

rob.caiger
2021-06-04 07:52
Awesome, thanks

sergio.artero
2021-06-04 10:07
has joined #pact-jvm

v-gabriel.dantas
2021-06-04 15:26
has joined #pact-jvm

leonardo.viana
2021-06-04 18:52
has joined #pact-jvm

github2
2021-06-05 01:19
[pact-foundation/pact-jvm] Issue closed by naushadamin

github2
2021-06-05 02:10
[pact-foundation/pact-jvm] Issue opened by naushadamin


github2
2021-06-06 00:02
[pact-foundation/pact-jvm] New release _https://github.com/pact-foundation/pact-jvm/releases/tag/4_1_22_ published by uglyog


yashdev963
2021-06-07 06:51
has joined #pact-jvm

rob.caiger
2021-06-07 07:58
:thumbsup: Thanks

dimundo
2021-06-07 11:21
hi, will copy this message here ( for bigger audience ) (sorry for crossposting ) https://pact-foundation.slack.com/archives/C9W94RTBQ/p1623061335008000

utsavtiwary10
2021-06-07 11:53
@uglyog Can you please provide me with a link to project or a blog where I can look at WebFluxTarget implementation with junit4 alongwith usage of mocks? I found this only article: https://dzone.com/articles/spring-webflux-support-in-pact-jvm, but it does not contain any mock

kflo
2021-06-07 16:15
does that mean the underlying `Consumer` and `Provider` modules now supports it?

i.pinzari
2021-06-07 17:27
has joined #pact-jvm

kflo
2021-06-07 17:58
is there a list of all the `pact-jvm` system environment variables somewhere?

gurkiratguliani
2021-06-07 19:36
has joined #pact-jvm

gurkiratguliani
2021-06-07 20:27
I have written consumer and provider test and i'm using @PactBroker . It works . However when i add certain more fields in one test in the consumer side, the test starts failing. Shouldn't a new pact file be generated in target/pact folder in consumer side  ? Should i delete the pact file which is uploaded on the @PactBroker url only then new pact file will be generated? I'm using java and spring boot application and this is related to messaging ( using apache kafka ) and not API Testing . (edited)

phil.endsley
2021-06-07 20:38
> However when i add certain more fields in one test in the consumer side, the test starts failing Which test? The consumer test? > Shouldn't a new pact file be generated in target/pact folder in consumer side Yes, if the consumer tests pass, a new pact file will be generated > Should i delete the pact file which is uploaded on the @PactBroker url only then new pact file will be generated You shouldn't have to delete anything

gurkiratguliani
2021-06-07 20:48
Which test? The consumer test? - yes the consumer test starts failing,

gurkiratguliani
2021-06-07 20:49
the pact file gets generated only in the consumer side. If i run the provider test in provider application ( other application ) , no pact file is getting generated in it's test folder

phil.endsley
2021-06-07 20:52
> yes the consumer test starts failing, Ok, so this is working as designed. This is one of the great things about Pact. A pact file is only generated if the consumer tests pass. Basically, Pact is forcing the consumer to verify they're abiding by the contract they defined. If the tests fail, it means your consumer is not fulfilling its side of the contract. > If i run the provider test in provider application ( other application ) , no pact file is getting generated in it's test folder The provider won't generate a pact file. It will consumer one from somewhere, and run verification tests against it. It can then (optionally) publish verification results back to the broker

gurkiratguliani
2021-06-07 20:54
@phil.endsley ``` If the tests fail, it means your consumer is not fulfilling its side of the contract``` How do i change the contract . I think the contract gets generated by whatever is run in the consumer side itself and then provider verifies against it ?

phil.endsley
2021-06-07 21:20
You would just change the definition of the contract. You should be defining a `MessagePact` or something like that somewhere, and the unit test you have with that is failing. Just need to make it pass

gurkiratguliani
2021-06-07 21:29
@phil.endsley for each test, I have defined a MessagePact for example ```@Pact(provider="PROVIDER", consumer="CONSUMER") public MessagePact fuctionName(MessagePactBuilder builder) { PactDslJsonBody body = new PactDslJsonBody(); // building the body here return builder.expectsToReceive("some message").withContent(body).toPact()' }``` , then i have the test ```@Test @PactVerification(value="PROVIDER", fragment="") public void testName() { calling my subscriber function }``` When i change the body inside message pact, the test starts failing.

gurkiratguliani
2021-06-07 21:34
the pact version i'm using 4.0.10

phil.endsley
2021-06-07 21:36
Does the body you're building on the message pact match what you're doing in your actual code?

gurkiratguliani
2021-06-07 21:37
Yes, the body earlier contained few fields of a large DTO which was supposed to be sent, it was working, now I'm trying to set all the fields from the DTO, the test fails

phil.endsley
2021-06-07 21:48
Without seeing the failure, it's hard to know for sure, but if the only difference is changing the body, pact does not think they match. Either something is slightly wrong, or there's a bug.

phil.endsley
2021-06-07 21:48
Either way, I think you'll need more debugging

gurkiratguliani
2021-06-07 22:00
From my understanding, I think the issue is with the contract. I want a new contract to be created but it is validating against the old contract due to which it is causing the test to fail. Is there any way we can generate a new contract ? For that do i need to do st differently ?

gurkiratguliani
2021-06-07 22:11
While building the body using PactDslJsonBody , is it possible to pass a json file rather than individually passing .stringType, .numberType ?

matt.fellows
2021-06-07 22:17
> but it is validating against the old contract that terminology is confusing. The consumer doesn?t validate a contract, it generates one. The provider validates the contract. Perhaps if you could please share your code, we could help

gurkiratguliani
2021-06-07 22:34
@Phil , @matt.fellows I'm able to generate a new contract . the issue was with the List<ObjectA> cars, which caused the test to fail. ObjectA has further properties ( say company, model ) Thanks for your time :)

uglyog
2021-06-07 22:51
Only JUnit4 for now, and it still needs some more work


uglyog
2021-06-07 22:59
Sorry, I don't know of any

uglyog
2021-06-07 22:59
(I've never used WebFlux)

gurkiratguliani
2021-06-07 23:23
@mail_4brad i also have a large json which i need to test, how did you proceed finally ?

gurkiratguliani
2021-06-07 23:28
for List<String> , how can we write corresponding PactDslJsonBody ? say I've a List<String> animals = {"cat","dog"} , I just want to verify the list animals is present.

mail_4brad
2021-06-07 23:39
For now I have hardcoded it using the builder as we?re still in PoC phase. Can?t help thinking that it should be able to be generated though. I found a GitHub issue where someone started doing just that. It would be quite the project though, probably it?s own GitHub collaboration

uglyog
2021-06-07 23:47
But not empty?

gurkiratguliani
2021-06-07 23:48
@uglyog can be empty too ,


gurkiratguliani
2021-06-08 00:05
.eachLike("animals") .closeArray() like this ? @uglyog

gurkiratguliani
2021-06-08 00:06
this is not working ,

gurkiratguliani
2021-06-08 00:13
if the list of string cannot be empty , ```DslPart body = new PactDslJsonBody() .minArrayLike("animals", 1) .closeArray();``` then like this ?

uglyog
2021-06-08 00:17
You need to add at least one item then

gurkiratguliani
2021-06-08 00:19
```DslPart body = new PactDslJsonBody() .minArrayLike("animals", 1) .stringType("dog") .closeArray();``` like this ?


gurkiratguliani
2021-06-08 00:41
in our subscriber class (which we are basically testing using consumer ) , we are using objectMapper to form the dto, when i use either , it throws Parsing Error .

gurkiratguliani
2021-06-08 00:43
for List<String> , it does throw Parsing other for single fields and even objects, i'm not facing any issue.

uglyog
2021-06-08 00:45
You need to check the generated JSON against your DTO

gurkiratguliani
2021-06-08 00:45
It generates json which have values like ```{ "field1" : "String" "animals" : [{}] }``` and other fields are getting populated ( for single fields, like String field1, when i add List<String> animals ( empty use case) , then it throws Parsing error

gurkiratguliani
2021-06-08 00:53
The thing is I'm using List<String> in one of my dtos which i'm sending using Apache kafka and in the subscriber class ( consumer in pact language) , we are extracting it using Object Mapper  : DTO dto = objMapper.readValue(objMapper.readTree(message).get("payload").toString(), DTO.class) // way to extract dto from a message using objectMapper It works perfectly fine when I singular items as well as objects. However for List<String> it is not able to parse it properly

uglyog
2021-06-08 00:57
Ah! Use `eachLike('animals', PactDslJsonRootValue.stringType('dog'))`

gurkiratguliani
2021-06-08 00:58
this would be for when i require minimum 1 element, how to deal with the case if it can be empty too

gurkiratguliani
2021-06-08 01:00
Ah! Use `eachLike('animals', PactDslJsonRootValue.stringType('dog'))` I'm using junit4 with pact version 4.0.10 . my ide shows only 2 methods are possible eachLike(String) eachLike()

uglyog
2021-06-08 01:03
You'll have to upgrade to a later version then

phil.endsley
2021-06-08 01:03
5 minutes too slow :smile: I'd recommend upgrading versions if possible. There may be some breaking changes when you do

phil.endsley
2021-06-08 01:04
And the artifact names changed. I think that's what gets most people when they're looking at versions

gurkiratguliani
2021-06-08 01:24
that's true, now basically i have to have one provider with 4.2.6 while others show still an old version https://mvnrepository.com/artifact/au.com.dius/pact-jvm-consumer-junit https://mvnrepository.com/artifact/au.com.dius/pact-jvm-consumer

gurkiratguliani
2021-06-08 01:24
@phil.endsley


gurkiratguliani
2021-06-08 01:52
now it is giving error : NoSuchMethodError: 'boolean http://au.com.dius.pact.consumer.junit.JUnitTestSupport.confirmsToMessagePactSignature(java.lang.reflect.Method,http://au.com.dius.pact.core.model.PactSpecVersion);

uglyog
2021-06-08 01:54
Make sure all the Pact-JVM jar versions are the same

gurkiratguliani
2021-06-08 02:23
in 4.0.10 , there's no way to check whether List<String> is present ,then ? [ also in my subscriber function, i'm using objMapper to extract the object )

gurkiratguliani
2021-06-08 02:32
if i want to to ensure only the List<String> animals is present, then what is it that should be used ?

gurkiratguliani
2021-06-08 02:32
.eachLike("animals") is not working

uglyog
2021-06-08 02:33
`eachLike` in 4.0.x only supports lists of objects. You need 4.1.x or later

gurkiratguliani
2021-06-08 02:34
yes, i've updated to 4.2.6 now

gurkiratguliani
2021-06-08 02:35
like you suggested this when we have List<String> and in it dog must be present and in my subscriber function, i'm using objectMapper eachLike('animals', PactDslJsonRootValue.stringType('dog')) Similarily is there anything similar in case i want to test that only List<String> is present, I don't want to do any value check ( can be empty too ) and in my subscriber function, i'm using objectMapper

uglyog
2021-06-08 02:37
`eachLike` will generate an example with one value, but will match any array as long as any items in the array are strings. Empty arrays will match

uglyog
2021-06-08 02:39
If you want an empty array in your consumer test, then use ```eachLike("animals") .closeArray()```

github2
2021-06-08 02:39
[pact-foundation/pact-jvm] Issue closed by mefellows

gurkiratguliani
2021-06-08 02:41
this gives a error when it is being parsed to dto in the subscriber class using objectMapper eachLike('animals', PactDslJsonRootValue.stringType('dog')) this works but i don't want the value to be present in this List<String> always

uglyog
2021-06-08 03:09
What error?

gurkiratguliani
2021-06-08 03:51
if anyone is struggling, eachLike(name: String, numberExamples: Int) this works by default eachLike( ) has numberExamples 1 so that is why it was causing issues in parsing

utsavtiwary10
2021-06-08 05:03
@cemal.onder Can you please provide with any more details, related to mocking using WebFluxTarget

bas
2021-06-08 08:11
I'm probably overlooking something simple, but when upgrading my demo project from Pact 3.5.x to 4.0.10 I can't seem to find the `LambdaDsl` class anymore.. It's still there (https://github.com/pact-foundation/pact-jvm/blob/master/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDsl.java) but somehow it's not available in my project... Here are the dependencies I've added: ```<dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-junit</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-java8</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency>``` where `${pact.version}` is set to `4.0.10`. Could anybody help me out here? The entire project is here: https://github.com/basdijkstra/introduction-to-contract-testing

matt.fellows
2021-06-08 08:24
I actually have never used that, so I can?t refer to previous examples

matt.fellows
2021-06-08 08:24
You?ve just hit end of day here in Aus, but hopefully somebody else knows the answer

bas
2021-06-08 08:29
Thanks. If all else fails I can rebuild the example so it doesn't use the `LambdaDsl` anymore but I quite like it because it's nice and expressive

bas
2021-06-08 08:47
Hmm.. For some reason it does find the class now, but with this import: `import io.pactfoundation.consumer.dsl.LambdaDsl;`.. That doesn't look right. Also, it makes the consumer test fail: ```java.lang.AssertionError: Pact Test function failed with an exception, possibly due to ExpectedButNotReceived(expectedRequests=[ method: GET path: /us/99999 query: {} headers: {} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING])``` but that might have something to do with the Spring Boot setup: ```Caused by: java.lang.AssertionError: Expected: (an instance of org.springframework.web.client.HttpClientErrorException and exception with message a string containing "404 Not Found") but: an instance of org.springframework.web.client.HttpClientErrorException <org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:54526/us/99999": localhost:54526 failed to respond; nested exception is org.apache.http.NoHttpResponseException: localhost:54526 failed to respond> is a org.springframework.web.client.ResourceAccessException Stacktrace was: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:54526/us/99999": localhost:54526 failed to respond; nested exception is org.apache.http.NoHttpResponseException: localhost:54526 failed to respond```

bas
2021-06-08 09:28
OK, so throwing away my entire local Maven repo *and* updating the Spring Boot dependency to the latest version, too, seems to have solved the problem, for now. What I still don't understand is why the import needs to be `import io.pactfoundation.consumer.dsl.LambdaDsl` when the class is defined in `http://au.com.dius.pact.consumer.dsl` (https://github.com/pact-foundation/pact-jvm/blob/master/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDsl.java), but if it works :shrug:

bas
2021-06-08 09:43
OK, now that the consumer side seems to work, I'm doing the same at the provider side. Updated Pact to 4.0.10, updated Spring Boot to 2.5.0, but when I run the provider side tests, Pact throws the following exception and the test runs indefinitely: ```2021-06-08 11:37:34.475 INFO 14004 --- [ main] provider.ContractTest : Started ContractTest in 6.927 seconds (JVM running for 10.65) Exception in thread "main" java.lang.NoSuchMethodError: 'com.google.gson.JsonElement com.google.gson.JsonParser.parseReader(java.io.Reader)' at au.com.dius.pact.core.model.DefaultPactReader.loadPactFromFile(PactReader.kt:359) at au.com.dius.pact.core.model.DefaultPactReader.loadFile(PactReader.kt:326) at au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:175) at au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:172) at au.com.dius.pact.provider.junit.loader.PactFolderLoader.load(PactFolderLoader.kt:33) at au.com.dius.pact.provider.junit.PactRunner.initialize(PactRunner.kt:85) at au.com.dius.pact.provider.junit.PactRunner.getChildren(PactRunner.kt:140) at org.junit.runners.ParentRunner.getFilteredChildren(ParentRunner.java:426) at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:351) at com.intellij.junit4.JUnit4IdeaTestRunner.getDescription(JUnit4IdeaTestRunner.java:79) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:51) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)``` Code at https://github.com/basdijkstra/introduction-to-contract-testing

krishna.ramnk
2021-06-08 13:24
has joined #pact-jvm

gurkiratguliani
2021-06-08 13:24
I have upgraded the pact version from 4.0.10 to 4.2.6 Consumer is running properly , however on producer side, I'm facing this issue .

kflo
2021-06-08 20:37
i am having issues with `PACT_VERIFIER_PUBLISH_RESULTS` ? i?ve tried `export PACT_VERIFIER_PUBLISH_RESULTS=true`, `export PACT_VERIFIER_PUBLISH_RESULTS="true"` and specifying it as a command line argument in both those formats (`-DPACT_VERIFIER_PUBLISH_RESULTS=true` for example) but it still doesn?t seem to get picked up by `pact-jvm` :thinking_face:

kflo
2021-06-08 20:39
always gives me `NOTE: Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true')`

kflo
2021-06-08 20:43
maybe due to a forked jvm? investigating

kflo
2021-06-08 20:45
if I: ```println(System.getProperty("PACT_VERIFIER_PUBLISH_RESULTS"))``` in my tests it logs ?true? :thinking_face:

kflo
2021-06-08 20:56
so strange. in debug mode, `System.getProperty` in `pact-jvm` returns a different value (`null`) from `System.getProperty` in my test class

kflo
2021-06-08 20:59
oh? it only looks for `pact.verifier.publishResults` not `PACT_VERIFIER_PUBLISH_RESULTS` env variable?

kflo
2021-06-08 21:00
i think that is the case

kflo
2021-06-08 21:10
yeah it works when i set `pact.verifier.publishResults` explicitly

kflo
2021-06-08 22:47
@uglyog is `SystemPropertyResolver` for this purpose? e.g. would resolve `PACT_VERIFIER_PUBLISH_RESULTS` ? perhaps it needs to be used inside of `publishingResultsDisabled`

uglyog
2021-06-08 23:08
It was moved into the consumer lib, because there was no point having a separate jdk 8 library when the min JVM required is JDK 8

uglyog
2021-06-08 23:11
This error seems to be Springboot forcing an older version of Gson. I never got to the bottom of it, just removed Gson in later versions. People reported that explicitly adding the latest version of Gson to the project helped

matt.fellows
2021-06-08 23:17
Did you change the namespace as well Ron?

uglyog
2021-06-08 23:21
Just a note that if you want to upgrade to 4.1.x, the names of the libraries has changed. See https://github.com/pact-foundation/pact-jvm/releases/tag/4_1_0

uglyog
2021-06-08 23:23
You mean the package. Yes, it had to change with the move.

matt.fellows
2021-06-08 23:25
as in `au.com.dius` -> `io.pactfoundation`?

matt.fellows
2021-06-08 23:25
the groupId I guess

uglyog
2021-06-08 23:26
It doesn't change the name at all, so the environment variable needs to be the same form: `pact.verifier.publishResults`

kflo
2021-06-08 23:26
yes i found that out the hard way :smile:

kflo
2021-06-08 23:26
i was confused by documentation i read

kflo
2021-06-08 23:27
it seems like some of them support the environment variable syntax, like `FOO_BAR`?

uglyog
2021-06-08 23:28
They do? That is a surprise to me

uglyog
2021-06-08 23:28
it changed from `io.pactfoundation.consumer.dsl` -> `http://au.com.dius.pact.consumer.dsl`

kflo
2021-06-08 23:29
maybe not :smile:

matt.fellows
2021-06-08 23:30
ah!

kflo
2021-06-09 00:07
i want to re-use the same message pact for several different test suites ? however, because the suites use the same message descriptions, it?s picking up all the annotated methods for all suites in each suite that gets run ? how can i make it only look in the suite in question and not across suites?

kflo
2021-06-09 00:14
i guess i can just define them once. and reference them in every suite

uglyog
2021-06-09 00:24
Is this in a consumer test?

kflo
2021-06-09 00:24
provider verification

uglyog
2021-06-09 00:24
I've seen examples where there are separate tests

uglyog
2021-06-09 00:25
You probably need to use filters.

kflo
2021-06-09 00:25
basically it would be good if it only scanned methods on the current class, instead of everything in the classpath

uglyog
2021-06-09 00:26
Ah! I think the examples I've seen used a base class or interface that was shared

uglyog
2021-06-09 00:27
Can you raise a GH issue?

kflo
2021-06-09 00:27
sure ? so not possible to do it with current `pact-jvm`?



sagar.kharab
2021-06-09 00:32
has joined #pact-jvm

uglyog
2021-06-09 00:34
I think it can be done by using the filtering mechanisms. Each test inherits a base with all the test methods, but has a filter on it to only run the one

kflo
2021-06-09 01:07
we now have a bunch of suites which use annotated methods, each suite invokes `ProviderVerifier.runVerificationForConsumer` for every provider consumer (just one), and now i see we are getting GC issues related to classpath scanning (probably because every consumer test is scanning the classpath at the same time): ```[39.251s][warning][gc,alloc] ClassGraph-worker-34: Retried waiting for GCLocker too often allocating 256 words [39.251s][warning][gc,alloc] ClassGraph-worker-4: Retried waiting for GCLocker too often allocating 256 words [39.251s][warning][gc,alloc] ClassGraph-worker-19: Retried waiting for GCLocker too often allocating 256 words [39.251s][warning][gc,alloc] ClassGraph-worker-32: Retried waiting for GCLocker too often allocating 10299 words [39.251s][warning][gc,alloc] ClassGraph-worker-48: Retried waiting for GCLocker too often allocating 11794 words [39.341s][warning][gc,alloc] ClassGraph-worker-52: Retried waiting for GCLocker too often allocating 2050 words [39.341s][warning][gc,alloc] ClassGraph-worker-28: Retried waiting for GCLocker too often allocating 5384 words [39.342s][warning][gc,alloc] ClassGraph-worker-31: Retried waiting for GCLocker too often allocating 2050 words``` anyone run into this before?

kflo
2021-06-09 01:08
these annotations will be the death of me

kflo
2021-06-09 01:28
i turned off parallel test execution and it resolved the issue. that sucks


kflo
2021-06-09 01:35
hm, actually it still happens sometimes

kflo
2021-06-09 01:36
i might also be related to communication with the test pact broker

kflo
2021-06-09 01:47
hm, definitely seems related to the annotation tests


kflo
2021-06-09 02:05
wow, apparently running all our tests takes 4GB of memory now


gurkiratguliani
2021-06-09 03:14
i'm sorry Ronald, i didn't follow what causes this error. can you please explain ?

uglyog
2021-06-09 03:16
So, Java errors can contain a message and a cause (another exception). Normally, when an exception is logged, it displays at least the message.

uglyog
2021-06-09 03:17
So looking at your stack trace, you can see the origin in the link I posted has a message associated. This is not being displayed in your screenshot.

uglyog
2021-06-09 03:18
If you look above `InteractionRunner.kt.105`, you can see there are seven things that can cause an error

uglyog
2021-06-09 03:19
So, either you need to look at those seven things, or work out why your IDE or system is not displaying the error

uglyog
2021-06-09 03:19
Without the error message, nobody can help you

uglyog
2021-06-09 03:20
If I run a test and force an error, I get the message

uglyog
2021-06-09 03:21
This is with IntelliJ IDEA

david.vancouvering
2021-06-09 03:36
has joined #pact-jvm

gurkiratguliani
2021-06-09 03:38
I'm using Spring Tool Suite. I'll look more into it and update you.

gurkiratguliani
2021-06-09 04:45
@Provider annotation , should be imported from http://au.com.dius.pact.provider.junitsupport.Provider or http://au.com.dius.pact.provider.junit.Provider ? ( both gives the same error only, just trying to verify with you )

uglyog
2021-06-09 04:47
`http://au.com.dius.pact.provider.junitsupport.Provider`

gurkiratguliani
2021-06-09 04:54
in my consumer side, I have @Rule public MessagePactProviderRule mockProvider = new MessagePactProviderRule("PROVIDER_name",this); do i need to add st like on provider class too ?

gurkiratguliani
2021-06-09 04:56
Currently , my publisher side is like this ```@RunWith(PactRunner.class)```


nuno.pik
2021-06-09 06:58
has joined #pact-jvm

bas
2021-06-09 07:01
Cheers @uglyog, I'll upgrade to the latest versions then and see if that works, if that doesn't work I'll try explicitly adding Gson as a dependency.

bas
2021-06-09 09:11
Hurrah! After some fiddling with imports and versions, it works. Thank you for putting me on the right track, @uglyog. Off to write the next article in my blog post series it is, then..

bas
2021-06-09 10:50
Yeah, it seems like I had some intermediate version (or got my versions mixed up). Now all is updated to the most recent versions and there's no more `io.pactfoundation` in there.

aubilla
2021-06-09 14:07
:wave: I?m trying to do a run of ?pactVerify? against a file on the Provider?s repo and I?m a getting a nasty exception: ```> Could not set unknown property 'pactFile' for ConsumerInfo(name='PatientClient', stateChange=null, stateChangeUsesBody=true, packagesToScan=[], verificationType=REQUEST_RESPONSE, pactSource=null, pactFileAuthentication=[], notices=[], pending=false) of type au.com.dius.pact.provider.ConsumerInfo.``` What could be wrong with this configuration? ```pact { serviceProviders { PatientService { requestFilter = { req -> req.addHeader('X-Auth-Token', 'somel0ngt0k3n') } protocol = 'http' host = 'http://myhost.com' port = 80 path = '/' hasPactWith('PatientClient') { pactFile = file('./pacts/PatientClient-PatientService.json') } } } }```

aubilla
2021-06-09 14:17
My problem comes because I mixed 2 ways of specifying Pact location as seen on the docs here:

aubilla
2021-06-09 14:18
and here

aubilla
2021-06-09 14:19
I was using `pactFile` where I should have used `pactSource`

nathaniel.emmons
2021-06-09 15:03
Is there a way to run `./gradlew pactPublish` and pass a tag along, when publishing pacts as a consumer? `./gradlew --no-daemon pactPublish -Pversion=0.0.1 -Ppact.publish.tags=snapshot` doesn?t seem to be working (same with `tag` singular). I?ve searched documentation but can?t find anything

nathaniel.emmons
2021-06-09 15:04
https://docs.pact.io/implementation_guides/jvm/provider/gradle#publishing-pact-files-to-a-pact-broker shows how to do it via gradle settings but i?m struggling to translate that to running the task via CLI, i guess..

natashakdykes
2021-06-09 16:06
has joined #pact-jvm

kyle.florence
2021-06-09 16:17
I don't know the classpath lib very well, but is it normal for it to take up so much memory?

kyle.florence
2021-06-09 16:17
I guess usually this doesn't happen because there is only one test suite per provider project

kyle.florence
2021-06-09 16:18
But in our case we have like 6-8

kyle.florence
2021-06-09 16:18
Since we are running tests for many different test frameworks for the broker and local files

kflo
2021-06-09 16:32
i imagine this would also be a problem for a provider that has many consumers

jackbwheatley
2021-06-09 16:53
thanks for following up on this @kflo

torbjorn.vatn
2021-06-09 17:30
has joined #pact-jvm

kflo
2021-06-09 22:30
it looks like using `packagesToScan` cuts down the memory consumption by half

uglyog
2021-06-09 23:05
You'll need to setup the Gradle settings using the project values. When you specify `-Pversion=0.0.1` that creates a Gradle project property named `version` which is accessible as `project.version` in the Gradle build

kflo
2021-06-09 23:08
actually, with that applied to all message tests i was able to cut the memory down substantially

kflo
2021-06-09 23:08
from 4GB to 256M

kflo
2021-06-09 23:08
:upside_down_face:

github2
2021-06-09 23:51
[pact-foundation/pact-jvm] Issue opened by solarmosaic-kflorence

kflo
2021-06-09 23:54
@uglyog if you think this is an okay idea i wouldn?t mind helping with it, although i have never worked with kotlin before but how hard can it be :stuck_out_tongue:

uglyog
2021-06-09 23:54
Fine with me

kflo
2021-06-09 23:54
this will give us an easier interface to work with in scala

kflo
2021-06-09 23:55
open to suggestions for names

kflo
2021-06-10 01:09
btw @uglyog is there a reason classpath scanning happens for every consumer instead of just once per provider?

uglyog
2021-06-10 01:12
It wasn't designed that way, if that's what you're asking

uglyog
2021-06-10 01:13
Probably because it made sense to scan when you need to find the method to call

kyle.florence
2021-06-10 01:16
So nothing would break if it were moved, I guess is what I was wondering

uglyog
2021-06-10 01:17
No, should be ok

uglyog
2021-06-10 01:18
But I don't think anyone uses that feature, most people have the methods on the actual test class. But we never know how it is being used out in the wild.

kyle.florence
2021-06-10 01:24
by that feature do you mean annotated method verification, or scanning for each consumer -- i don't see how scanning for each consumer would be beneficial since it would just scan the same things over and over

kyle.florence
2021-06-10 01:24
but it seems like it would cause problems if a provider had many consumers and annotated method verification were used

kyle.florence
2021-06-10 01:25
(sorry for my username changing -- switched between work laptop and personal) :stuck_out_tongue:

uglyog
2021-06-10 01:30
scanning for each consumer

uglyog
2021-06-10 01:31
I don't think anybody has the message methods on different classes. Most seem to put them in the test class, so scanning the classpath is probably unnecessary

kyle.florence
2021-06-10 01:40
yeah i agree, although that's how it works now

s.goel
2021-06-10 08:57
has joined #pact-jvm

uladzislau_danilchyk
2021-06-10 11:18
Hi all! How can get inside method annotated `@State` outcoming request which will be verified? The only one way I know how can I get it is inside general verification method annotated `@TestTemplate` Could anyone help me with that? I need get a request only inside specific state method

nathaniel.emmons
2021-06-10 13:31
Sorry, i might be misunderstanding, but i?m not sure how that relates to my question. Specifying the version via CLI is working fine, since i think pact defaults to using the project version if set. My problem is that i?m not able to set the tag, even though i?m passing in `pact.publish.tags=snapshot` which seems to match the expected gradle settings shown in the docs above

s.goel
2021-06-10 14:17
@s.goel has left the channel

gsinghania
2021-06-10 15:55
Can someone from the Pact Community gives an example Sample for writing a Consumer and its equivalent provider in Spring ?

gurkiratguliani
2021-06-10 15:59
do you need it for api testing or message testing?

kondal.ramidi
2021-06-10 16:13
has joined #pact-jvm

sammomichael
2021-06-10 18:01
How are people checking code coverage with their Pact tests? In other words, is everyone using built-in IDE tools or some other script to determine their api test coverage? I'm guessing the former

matt.fellows
2021-06-10 21:05
howtopact

2021-06-10 21:05
See this page for an animation explaining how pact works https://pactflow.io/how-pact-works

matt.fellows
2021-06-10 21:05
there are two java workshops above that use spring, i?d start there!

matt.fellows
2021-06-10 21:05
Yep, usuallly

matt.fellows
2021-06-10 21:05
if you run it as a separate step in your pipeline, you can use standard coverage tools to get that

richard
2021-06-11 00:13
has joined #pact-jvm

bethskurrie
2021-06-11 09:13
Are there any mobile devs around who can answer some questions for me about how pre-prod deployments/releases for mobile apps works?

bethskurrie
2021-06-11 09:14
Eg. for something like a react UI, or an API, you have a test environment, and a prod environment, and often a bunch of other test environments.

bethskurrie
2021-06-11 09:15
When you verify the pacts, you want to verify the latest master pact, and all the versions that are deployed to those environments.

bethskurrie
2021-06-11 09:15
For a mobile app, you'd want to verify the latest master, and at least the most recent production version (hopefully all the prod versions)

bethskurrie
2021-06-11 09:16
Is there a version between master and prod that should be verified? ie. is there an intermediate stage? the equivalent of a test env for a deployed application?

dimundo
2021-06-11 09:27
outdated master ? :slightly_smiling_face: like test started for `master`, and during run `master+1` appeared

dimundo
2021-06-11 09:29
like prod is `master-1` , `master` is deploying and `master+1` is testing and even `master+2` could appear ? ( just speculating out of mine QA mind :slightly_smiling_face: )

github2
2021-06-11 12:01
[pact-foundation/pact-jvm] Issue opened by knutwannheden

neelofer.tamboli
2021-06-11 13:06
@neelofer.tamboli has left the channel

jwcarman
2021-06-11 14:23
has joined #pact-jvm

github2
2021-06-11 14:54
[pact-foundation/pact-jvm] Issue opened by naushadamin

hello370
2021-06-11 14:58
has joined #pact-jvm

kflo
2021-06-11 17:08
i assume ?mobile app? is essentially the same as releasing any other kind of library/binary. in our case, we do all of our verification while it?s in the feature branch, and when it gets merged it is released to our production artifact repository. while it?s in the feature branch, we publish pre-release versions to an ephemeral repository, so if someone needs to test that version they can, but that?s all pre-merge

kflo
2021-06-11 17:09
(it?s also valid to publish pre-release versions to the same repository as the production versions)

kflo
2021-06-11 17:09
actually, this makes me wonder if it?s possible in pact to release something but not support it :smile:

dimundo
2021-06-11 17:40
forewer ~~alone~~ pending pact ?

bas
2021-06-12 06:33
Shameless plug: the sample consumer and provider I'll be using in my blog post series will also be based on Spring. Work in progress still, but the code is here: https://github.com/basdijkstra/introduction-to-contract-testing. All based on the sample project provided by @kristine.jetzke in their blog series: https://kreuzwerker.de/en/post/introduction-to-consumer-driven-contract-testing

bas
2021-06-12 06:37
Another question (and I am aware that this might not be Pact-related). I'm adding a second set of contract tests to my sample codebase, but for some reason, when I run all the tests in this class: https://github.com/basdijkstra/introduction-to-contract-testing/blob/main/customer-consumer/src/test/java/customer/AddressServiceDeleteContractTest.java, the one that should result in a 204 fails, the other one passes. When I run the failing test individually, it passes. So I'm assuming that it has something to do with residual state from the previous tests (the 404 is run first), but I have no idea how to fix that. Any ideas?

uglyog
2021-06-12 06:45
You are providing a random port for each test, but I can't see how you are using it

uglyog
2021-06-12 06:47
BTW, you can just set the port to 0 and Pact-JVM will automatically use a random port. Then you can get the URL to the mock server with `provider.getMockServer().getUrl()`

bas
2021-06-12 06:55
I guess that's what you get when you build your project based on someone else's code without fully understanding it :rolling_on_the_floor_laughing:. I'll dive into that and see if it improves the situation. I did not know about that Pact feature. By the way, it works fine for this test class: https://github.com/basdijkstra/introduction-to-contract-testing/blob/main/customer-consumer/src/test/java/customer/AddressServiceGetContractTest.java

uglyog
2021-06-12 07:06
I think I know what the issue is. The HTTP client used by the application is caching the connections


bas
2021-06-12 07:16
Thanks @uglyog. That looks promising. Let me dive a little deeper into this. Just adding the `@After` snippet does not work, unfortunately.

bas
2021-06-12 07:20
... but adding a `Connection: close` header to each request by default does. Is this something you'd recommend, @uglyog?

uglyog
2021-06-12 07:32
If it work, sure!

kristine.jetzke
2021-06-12 07:44
The code of the blog post can be found https://github.com/tinexw/cdc-with-pact/tree/junit5

matt.fellows
2021-06-12 07:46
No shameless plugs here if people can beg, borrow or steal it :rolling_on_the_floor_laughing:

vikrant82
2021-06-12 12:16
has joined #pact-jvm

bas
2021-06-13 06:47
Alright.. so I'm making progress. But now, I've got my consumer tests split up into multiple classes, and each class starts like this: ```@RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, properties = "address_provider.base-url:http://localhost:${RANDOM_PORT}", classes = AddressServiceClient.class) public class AddressServiceDeleteContractTest { private static final UUID ID = UUID.fromString("8aed8fad-d554-4af8-abf5-a65830b49a5f"); @ClassRule public static RandomPortRule randomPort = new RandomPortRule(); @Rule public PactProviderRule provider = new PactProviderRule("address_provider", null, randomPort.getPort(), this); @Autowired private AddressServiceClient addressServiceClient;``` When I want to run the tests from all classes in one go (ideally through Maven but for some reason Maven does not want to play nice yet, so I'm doing this from within IntelliJ for now), the tests in the first class run fine, but for the second class, each test throws a connection error: ```org.springframework.web.client.ResourceAccessException: I/O error on DELETE request for "http://localhost:59640/address/8aed8fad-d554-4af8-abf5-a65830b49a5f": Connect to localhost:59640 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:59640 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect``` Shouldn't the mock provider be set up anew for each test? I can't see why this doesn't work..

uglyog
2021-06-14 01:39
Can you confirm that the port the mock server is running on is the same port as the client class is trying to use. I'm unsure what this does: ```address_provider.base-url:http://localhost:${RANDOM_PORT}```

abubics
2021-06-14 05:56
I've had varying size & maturity apps & teams . . . lots of in-between needs & versions :thinking_face: ? Small team - 1 dev per platform (Android, iOS, BFF), building a new app from scratch, we didn't even get around to using `can-i-deploy`, just every build would update contracts or verify, not even trigger builds/verifies from each other. ? Larger team - many flavours of app, and local+dev+staging+prod envs. In that case, the absolute minimum to verify would be latest prod for each, latest staging for each, and latest master for each. That has gaps, so all supported prod versions would be the minimum reasonable set.

abubics
2021-06-14 05:59
As for supported versions, I've used a couple of strategies . . . ? Publish a minimum version in an API endpoint, and the app can lock itself out. ? Notify users in-app that they're using an old app, and some features may no longer work correctly. It depends on what kind of app you've got. If it's just a gateway to a cloudy service, then forcing updates is ok. But if it's an isolated app that runs primarily on-device, and only connects to a back-end sometimes, it's harder (or just less reasonable) to force.

bas
2021-06-14 06:25
Thanks. It seems like there's a problem there indeed: ```System.out.println("USING PORT " + System.getenv("RANDOM_PORT"));``` yields `USING PORT null`

bas
2021-06-14 06:26
That can't be good

bas
2021-06-14 06:26
That's what you get for borrowing other people's code and assuming it'll work fine I guess. Thanks, I know where to look for a solution now.

uglyog
2021-06-14 07:01
BTW, Springboot has support for getting a random port in the tests


bas
2021-06-14 07:36
Hmm... This example is the provider side, my problem is on the consumer. Needs some more investigation on my end, but at least I know where to look now

daniel.bubenheim
2021-06-14 08:05
has joined #pact-jvm

joaoproenca
2021-06-14 10:15
has joined #pact-jvm

e.pittaluga.b
2021-06-14 16:34
has joined #pact-jvm

npatil
2021-06-14 17:28
has joined #pact-jvm

github2
2021-06-15 06:16
[pact-foundation/pact-jvm] Issue opened by knutwannheden

lucas.rolle
2021-06-15 06:48
has joined #pact-jvm

github2
2021-06-15 07:54
[pact-foundation/pact-jvm] Issue opened by mjureczko

caoilte
2021-06-15 11:36
has joined #pact-jvm

caoilte
2021-06-15 11:44
Hello, is anyone able to tell me what the roadmap is for dropping support for the 4.1.x branch? I'm evaluating using pact but my workplace is stuck on JDK 8 for the forseeable future and I want to understand if it's viable for us to adopt pact-jvm.

danielabbitt
2021-06-15 17:12
has joined #pact-jvm

danielabbitt
2021-06-15 17:17
Hey all. I'm aware this may be a daft question, but I have my Pact tests written in JUnit5 in a Spring Boot / Gradle project. How do I publish the Pact file to the Pactflow broker? I can generate the Pact file by running the test but I can't seem to figure out how to publish that file to the broker


tom.borglum
2021-06-15 17:29
has joined #pact-jvm

uglyog
2021-06-15 22:51
4.1.x will be supported for as long as people are using JDK 8. It will not contain new features, but will have important fixes back-ported

matt.fellows
2021-06-15 22:53
There are also our CLI tools, which personally I prefer to use in my CI pipelines


michael.branders
2021-06-16 06:57
has joined #pact-jvm

michael.branders
2021-06-16 07:04
Hi i'm looking in to setting up pact for my company for the first time and i'm kind of stuck. We are using open feign clients in java with spring and with eureka discovery so no urls are added, and we have ribbon set to false so we are using the spring loadbalencer. The problem i'm having in my test is to wire my feign client to the provider that pact is making. So any help in how i can point my client to the pact mock server would be helpfull. Its importend to get this POC working before all other devs can start implementing pact as well. ```09:03:48.235 [boundedElastic-1] WARN o.s.c.l.core.RoundRobinLoadBalancer - No servers available for service: employer-api-access-service 09:03:48.238 [hystrix-employer-api-access-service-1] WARN o.s.c.o.l.FeignBlockingLoadBalancerClient - Load balancer does not contain an instance for the service employer-api-access-service com.netflix.hystrix.exception.HystrixRuntimeException: EmployerApiAccessClient#findUsers(String) failed and no fallback available.``` employer-api-access-service is my provider ```@ExtendWith(PactConsumerTestExt.class) @ExtendWith(SpringExtension.class) @PactTestFor(providerName = "employer-api-access-service", port = "8888") @SpringBootTest() public class EmployerApiAccessContractPactTest { @Autowired private EmployerApiAccessClient employerApiAccessClient; @Pact(provider = "employer-api-access-service", consumer = "employer-api-gateway") public RequestResponsePact findUsers(PactDslWithProvider builder) { return builder.given("should return user if existed") .uponReceiving("Get a user by existing username: username") .path("/users") .method("GET") .query("user=username") .willRespondWith() .status(200) .body(new PactDslJsonArray() .object() .stringType("id", "id") .closeObject()) .toPact(); } @Test @PactTestFor(pactMethod = "findUsers") void testFindUsers() { List<UserDto> userDto = employerApiAccessClient.findUsers("username"); assertThat(userDto).isNotEmpty(); assertEquals(1, userDto.size()); assertEquals("id", userDto.get(0).getId()); } }``` This is the feign client ```@FeignClient(name="employer-api-access-service", configuration = FeignConfiguration.class, decode404 = true) public interface EmployerApiAccessClient { @GetMapping(value = "/users") List<UserDto> findUsers(@RequestParam(required = false) String username); }``` I did find that with ribbon you could use this: ```@SpringBootTest({ // overriding provider address "employer-api-access-service.ribbon.listOfServers: localhost:8888" })``` But we dont use it becouse spring has set it to maintenance mode ``` In order to maintain backward compatibility, is used as the default load-balancer implementation. However, Spring Cloud Netflix Ribbon is now in maintenance mode, so we recommend using Spring Cloud LoadBalancer instead. To do this, set the value of spring.cloud.loadbalancer.ribbon.enabled to false.```

bethskurrie
2021-06-16 07:18
@abubics is there a "staging" env for a consumer mobile application? Not the API, the consumer app.

danielabbitt
2021-06-16 08:16
Is there a way of using the Gradle flow and pass in a version as a command line argument?

danielabbitt
2021-06-16 08:16
I think the CLI might be the way to go but need to work out how it'll fit in to our development process

bas
2021-06-16 08:27
Thanks once again, @uglyog, with your pointers I managed to solve it. Now all tests in all classes use the same port and it works.

gurkiratguliani
2021-06-16 08:28
Hi, I'm trying to using the PactDslJsonBody to build the messagePact. Is there any way i can check for long and double types ? the .numberType() by default generates for int type,

matt.fellows
2021-06-16 08:35
Pretty sure like everything java it's either a property or an env flag to the gradle command

abubics
2021-06-16 08:42
not a staging env, but often a staging app that's bound to the staging API


abubics
2021-06-16 08:46
There are a few ways to set it up, but the main options are 1. apps with per-env config baked in, or 2. apps with a companion app to pick the target API env In the (1) case, you can have multiple of the same app installed on a single device (potentially all different release versions), but they have different config & different bundle/app ID, so they can sit side-by-side. Because of that, you might have many live versions, but that's not a real support case, because they're all internal. If that were the setup, everyone should be aware of how to check the versions, and make sure they're not doing something unreasonable.

gurkiratguliani
2021-06-16 08:57
thanks for the reply Matt . If i understand it correctly , .numberType -> matches all numbers( integer,float and decimals ) .integerType -> for only integer and long type .decimalType -> for floating point numbers only . Is my understanding correct ? So when should we use integerType over integerType since numberType covers for int too ?

bethskurrie
2021-06-16 09:02
Right, so my mental model of "record-deployment" for putting a version on a pre-prod testing device and "record-release" for putting it into the app store seems to map ok to reality @abubics

abubics
2021-06-16 09:12
yep, sounds like that'll work (at least conceptually) :thumbsup:

abubics
2021-06-16 09:17
Yeah, that looks about right. It's important to note that JSON doesn't distinguish between all those different number types, so it's just extra safety that isn't necessarily supported by all consumer & provider platform languages.

jedlicka
2021-06-16 10:12
has joined #pact-jvm

matt.fellows
2021-06-16 11:43
Thanks Andras, was on mobile before but wanting to share the link

matt.fellows
2021-06-16 11:43
TL;DR - if you need precision, don?t use JSON, wrap them in strings

saurabh.goel
2021-06-16 11:44
This is my first attempt to create a simple consumer test but it is not working please see the code and error below ```@ExtendWith(PactConsumerTestExt.class) public class OmaApiClientConsumerPactTest { private static final String METRIC_NAME = "http.client.requests"; private WireMockServer wireMockServer; private PrometheusMeterRegistry meterRegistry; private OmaApiClient omaApiClient; @BeforeAll public void beforeAll() throws MalformedURLException { wireMockServer = new WireMockServer(); wireMockServer.start(); stubFor(post(anyUrl()) .withBasicAuth("foo", "bar") .willReturn(aResponse() .withStatus(HttpStatus.NO_CONTENT.value()))); meterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); omaApiClient = new OmaApiClient("http://localhost:8080", "foo", "bar", 0, 0, 0, new SpringMvcContract(), meterRegistry); } @BeforeEach public void beforeEach() { new ArrayList<>(meterRegistry.getMeters()).forEach(meter -> meterRegistry.remove(meter)); } @AfterAll public void afterAll() { wireMockServer.stop(); } @Pact(consumer = "OPA", provider = "OMA") RequestResponsePact ackOrder(PactDslWithProvider builder) { return builder.given("order exists") .uponReceiving("ack order") .method("POST") .path("/orders/1/ack") .matchHeader("Authorization", "Bearer *") .willRespondWith() .status(204) .headers(Map.of("Content-Type", "application/json; charset=utf-8")) .toPact(); } @Test @PactTestFor(pactMethod = "ackOrder") void ack_whenOrderExist(MockServer mockServer) { omaApiClient.getOrderController().ackOrder("1"); assertMeasured("/ack"); } private void assertMeasured(String uri) { Timer timer = meterRegistry.find(METRIC_NAME) .tags("uri", uri, "method", "POST", "clientName", "localhost", "status", "204") .timer(); assertEquals(1, (int) timer.count()); } }``` error: `http://au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received:` `method: POST` `path: /orders/1/ack` `query: {}` `headers: {Authorization=[Bearer]}` `matchers: MatchingRules(rules={header=MatchingRuleCategory(name=header, matchingRules={Authorization=MatchingRuleGroup(rules=[RegexMatcher(regex=Bearer *, example=null)], ruleLogic=AND)})})` `generators: Generators(categories={})` `body: MISSING`

matt.fellows
2021-06-16 11:46
Can you please enable debug logging and share the full output?

matt.fellows
2021-06-16 11:47
Actually hang on - what is Wiremock doing there?_

matt.fellows
2021-06-16 11:48
It looks like you?re stubbing endpoints with Wiremock - does that redirect HTTP requests to Wiremock?

saurabh.goel
2021-06-16 11:48
i took the wiremock implementation for the Integration tests and used it here

saurabh.goel
2021-06-16 11:51
yes, it is doing this in ITs

matt.fellows
2021-06-16 11:53
so yeah don?t do that, otherwise Pact doesn?t get the request

matt.fellows
2021-06-16 11:53
that?s why you?re getting the error that says it didn?t receive the request

michael.branders
2021-06-16 12:02
Anyone got an idea how i can wire feign to localhost:port and not get the errors i describe above? It seems easy to use pact but not without ribbon that is in maintenance.

saurabh.goel
2021-06-16 12:07
if i do not use a wiremock then how do i initiate the client call?

saurabh.goel
2021-06-16 12:09
when i remove the wiremock, i am getting the feign exception that connection refused. sorry for asking dumb questions and thanks for your patience

matt.fellows
2021-06-16 12:32
Wiremock doesn?t initiate calls, it stubs API endpoints

matt.fellows
2021-06-16 12:32
In a Pact consumer test, Pact mocks your provider (i.e. it?s doinsg what Wiremock would normally do)

matt.fellows
2021-06-16 12:32
The difference is, it will generate a contract at the end of it

matt.fellows
2021-06-16 12:33
If you have both, one won?t see the request (Pact)(

matt.fellows
2021-06-16 12:33
Your API client needs to be configured to point at the Pact mock service, not Wiremock

saurabh.goel
2021-06-16 13:12
do I get the pact mock service by using MockServer?

saurabh.goel
2021-06-16 13:13
and I guess I need to provide its implementation myself like ```MockServer server = new MockServer() { @NotNull @Override public String getUrl() { return null; } @Override public int getPort() { return 0; } @NotNull @Override public <R> PactVerificationResult runAndWritePact(@NotNull BasePact basePact, @NotNull PactSpecVersion pactSpecVersion, @NotNull PactTestRun<R> pactTestRun) { return null; } @NotNull @Override public PactVerificationResult validateMockServerState(@Nullable Object o) { return null; } }```

saurabh.goel
2021-06-16 13:30
it worked i used the MockServer which is passed to the test method

saurabh.goel
2021-06-16 13:30
thanks Matt

saurabh.goel
2021-06-16 13:35
:taco: @matt.fellows

jpasse
2021-06-16 13:45
has joined #pact-jvm

nathan.deamer
2021-06-16 13:48
A consumerVersion can be set in your gradle: ```pact { publish { consumerVersion = 'my overridden version' } }```

phil.endsley
2021-06-16 13:49
By setting it like above, you can then use a Gradle property as the value, and specify that through a command line argument

matt.fellows
2021-06-16 13:49
https://docs.pactflow.io/docs/examples/java/consumer/junit/readme Example there for future. Glad to hear it's working!

danielabbitt
2021-06-16 13:49
I think my confusion was in the version of the plugin I have, it was named `providerVersion` which didn't make much sense!

gurkiratguliani
2021-06-16 13:56
~I have 2 applications A and B . A and B both acts as provider and consumer in each differrent case. In this case, will a double arrow be generated in the pact diagram ? one from A ->B and other from B-> A~

jan.malkiewicz
2021-06-16 14:48
has joined #pact-jvm

maksym.motornyi
2021-06-16 16:20
Is it possible to check if the field is *absent* in the response? I would appreciate if somebody could share a link to the description of such a matcher if it exists.

gurkiratguliani
2021-06-16 17:50
I'm trying to create a publisher , I'm getting this exception : Did not find any PactSource annotations .exactly one pact source should be set Howver i'm clearing describinb @PactBroker and @Provider annotation. can someone let me know what i'm missing ?

matt.fellows
2021-06-16 22:15
no, you can?t do that

matt.fellows
2021-06-16 22:15
can you please share the code?

uglyog
2021-06-16 23:07
You'll need to provide the correct configuration for the Feign client. Looks like there are lots of options: https://cloud.spring.io/spring-cloud-openfeign/reference/html/#spring-cloud-feign-overriding-defaults

uglyog
2021-06-16 23:11
I can see you are using a wiremock server and passing that into your omaApiClient, but you are not using the Pact mock server so the Pact mock server is not receiving any requests.

abubics
2021-06-17 00:57
You can check that with unit testing assertions after the Pact stuff is done, but if you could do that with Pact, it would get in the way of expand-contract backwards-compatible changes :slightly_smiling_face:

gurkiratguliani
2021-06-17 05:58
it was a version issue inmy opinnion. changed both to same version and it vanished

jeen.broekstra
2021-06-17 06:13
has joined #pact-jvm

gurkiratguliani
2021-06-17 06:23
Hi everyone , I'm writing a consumer test which has 5 tests .However when the pact file is getting generated, it contains information about only 3 tests. Can someone please provide their insights on what can be the possible issue here ?. Each test has a different fragment ( MessagePact ) . I'm not sure what i'm missing

uglyog
2021-06-17 06:27
Is the interaction description different for each test?

gurkiratguliani
2021-06-17 06:33
```@Test @PactVerfification(value="PROVIDER" , fragment = "accountFrozenMessagePact") public void verifyAccountFrozenPact() @Pact public MessagePact accountFrozenMessagePact(MessagePactBuilder builder) { PactDslJsonBody body = new PactDslJsonBody(); // building body return builder.expectsToReceive("account frozen").withContent(body).toPact(); }``` for each of the 5 tests, fragment is different , and expectsToReceive is different , expectsToReceive is interaction description , rt?


minijb225
2021-06-17 06:44
has joined #pact-jvm

gurkiratguliani
2021-06-17 07:00
yes ,that is different for each test

uglyog
2021-06-17 07:11
You'll need to look at the debug logs to see what is happening

matt.fellows
2021-06-17 07:24
Are they all message pact tests? Just note you can't mix message pact and HTTP pacts at the moment

gurkiratguliani
2021-06-17 07:25
yes , they are all message pacts

dimundo
2021-06-17 07:28
answer could be very simple check if you have all different `expectsToReceive("A message to say hello")` As if 3 of 5 has same naming - there will be only 3 as a result

dimundo
2021-06-17 07:29
not sure if it is a bug or feature

gurkiratguliani
2021-06-17 07:33
the issue was that 3 out of 5 tests had different fragment and other 2 had same fragment as out of 3.

matt.fellows
2021-06-17 07:34
So what Ron said :stuck_out_tongue:

gurkiratguliani
2021-06-17 07:39
fragment and expectsToReceive both constitute interaction description , i thought only expectsToRecieve can be different

saurabh.goel
2021-06-17 11:18
Hi Guys, My first provider test is stuck with the below error: `Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'local.server.port' in value "${local.server.port}"` i think it is happening as I use ```@LocalServerPort int port;``` and `context.setTarget(new HttpTestTarget("localhost", port));` please let me know how i can fix this.

saurabh.goel
2021-06-17 11:19
whole class is here ``` @Provider("OMA") @PactFolder("/Users/temporaryadmin/IdeaProjects/rps-order-management-application/oma-service/src/test/resources/pacts") @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { OrderControllerImpl.class, OrderProcessingService.class, OrderServiceRegistry.class, TestPersistenceConfiguration.class, OwnDeliveryStatemachineConfiguration.class, VendorDeliveryStatemachineConfiguration.class, CustomerPickupStatemachineConfiguration.class, DefaultErrorHandler.class, OrderEventNotificationProcessor.class, OrderNotificationPublishingEventHandler.class, ShortCodeService.class }) @TestPropertySource("classpath:/application-core-test.properties") @WebAppConfiguration @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class OrderControllerProducerPactTest { private static final String RPS_ORDER_ID = "1"; private static final String RPS_VENDOR_ID = UUID.randomUUID().toString(); private static final String PLATFORM_ORDERS_URL = "http://localhost:8080/orders"; private static final String ACCEPT_ORDER_URL = PLATFORM_ORDERS_URL + "/%s/acceptance"; private static final String ACK_ORDER_URL = PLATFORM_ORDERS_URL + "/" + RPS_ORDER_ID + "/ack"; private static final String DELIVER_ORDER_URL_PATTERN = PLATFORM_ORDERS_URL + "/%s/delivery"; private final ObjectMapper objectMapper = JsonUtil.copyOfObjectMapper(); @LocalServerPort int port; @Autowired protected WebApplicationContext webApplicationContext; @Autowired private RestaurantOrderRepository repository; @Autowired private GroceryOrderRepository groceryOrderRepository; @SpyBean protected RestaurantOrderService restaurantOrderService; @MockBean(name = "restaurantActionProvider") protected ActionProvider actionProviderMock; @MockBean protected OrderNotificationPublicationManager orderNotificationPublicationManagerMock; @MockBean protected ActionMessageSendingEventHandler actionMessageSendingEventHandler; @AfterEach public void tearDownAfterEach() { InvocationContext.getInstance().setRequestId(null); } @BeforeEach public void beforeEach() { repository.deleteAll(); groceryOrderRepository.deleteAll(); } @BeforeEach void setUp(PactVerificationContext context) { reset(restaurantOrderService); InvocationContext.getInstance().setOrGenerateRequestId(null); when(actionMessageSendingEventHandler.canHandle(any(OrderEvent.class))).thenCallRealMethod(); context.setTarget(new HttpTestTarget("localhost", port)); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void verifyPact(PactVerificationContext context, HttpRequest request) { context.verifyInteraction(); } @State("order exists") void toProductsExistState() { // when(productRepository.fetchAll()).thenReturn( // List.of(new Product("09", "CREDIT_CARD", "Gem Visa", "v1"), // new Product("10", "CREDIT_CARD", "28 Degrees", "v1"))); } }```

matt.fellows
2021-06-17 11:33
that seems like a Spring problem rather than a Pact one?

saurabh.goel
2021-06-17 11:49
ok, yes i was able to fix this. thanks

github2
2021-06-17 17:49
[pact-foundation/pact-jvm] Issue opened by naushadamin

npatil
2021-06-17 17:57
Hey Guys, We have a JAVA Spring project with gradle. While running the tests we are observing a failure like below: ```java.lang.NoClassDefFoundError: scala/Serializable at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)``` We are using version 2.1 of springboot. and below are the gradle dependencies we added: ```testImplementation "au.com.dius.pact.provider:junit:4.2.3" testImplementation 'au.com.dius.pact.provider:spring:3.5.4'``` And Pact version is `4.2.3` . Have anyone here faced similar issue? Any pointers will be much appreciated. Thank you.

maksym.motornyi
2021-06-17 18:37
Yeah, got you, thanks

github2
2021-06-17 20:38
[pact-foundation/pact-jvm] Issue closed by mefellows

uglyog
2021-06-17 23:05
You'll need to provide debug logs and the complete stack trace for anyone to be able to help you

npatil
2021-06-18 00:00
Thank you @uglyog!! I will keep it in mind from next time. I was able to resolve this.

michael.branders
2021-06-18 06:03
Now that i got my consumer working, i'm trying to verify the pact i made on my producer. Its alose a spring boot 2 app. The problem I'm having with the test is as followed: ```@ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @Provider("employer-api-access-service") @PactBroker( host = "*******.http://pactflow.io", scheme = "https", port = "443", authentication = @PactBrokerAuth(token = "*******")) @IgnoreNoPactsToVerify(ignoreIoErrors = "true") @TestPropertySource(properties = "server.port=8080") class ContractVerificationTest{ private final static String RESOURCES_CONTRACTS_BASE_PATH = "src/test/resources/contracts/employerGateway/"; @LocalServerPort private int port;``` The test starts on port 8443 https always even is i define it on port 8080 http then i get this error ```14:13:18.613 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "GET /users HTTP/1.1[\r][\n]" 14:13:18.613 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "Host: localhost:8443[\r][\n]" 14:13:18.613 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "Connection: Keep-Alive[\r][\n]" 14:13:18.613 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "User-Agent: Apache-HttpClient/4.5.10 (Java/11.0.8)[\r][\n]" 14:13:18.613 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "Accept-Encoding: gzip,deflate[\r][\n]" 14:13:18.613 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "[\r][\n]" 14:13:18.624 [https-jsse-nio-8443-Acceptor] DEBUG o.a.tomcat.util.threads.LimitLatch - Counting up[https-jsse-nio-8443-Acceptor] latch=1 14:13:18.636 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "HTTP/1.1 400 [\r][\n]" 14:13:18.636 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "Content-Type: text/plain;charset=ISO-8859-1[\r][\n]" 14:13:18.636 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "Connection: close[\r][\n]" 14:13:18.636 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "[\r][\n]" 14:13:18.636 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "Bad Request[\r][\n]" 14:13:18.636 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "This combination of host and port requires TLS.[\r][\n]" 14:13:18.637 [main] DEBUG org.apache.http.headers - http-outgoing-2 << HTTP/1.1 400 14:13:18.637 [main] DEBUG org.apache.http.headers - http-outgoing-2 << Content-Type: text/plain;charset=ISO-8859-1 14:13:18.637 [main] DEBUG org.apache.http.headers - http-outgoing-2 << Connection: close 14:13:18.637 [https-jsse-nio-8443-exec-1] DEBUG o.apache.tomcat.util.net.NioEndpoint - Error during SSL handshake java.io.IOException: Found an plain text HTTP request on what should be an encrypted TLS connection``` Any idea why it always would start on port 8443 an not 8080 like i set it up to be? I have tryed with random port as well but its always 8443

uglyog
2021-06-18 06:10
Check your spring config, looks like it is always enabling TLS which runs on 8443.

michael.branders
2021-06-18 06:10
Ok i will. I'll let you know if i find something

michael.branders
2021-06-18 06:44
Played around a bit with the properties and i got passed it on to the next issue now. There is basic auth on my controler and need to provide username and password somehow.

michael.branders
2021-06-18 06:45
+ "timestamp": "2021-06-18T06:40:31Z", + "status": 401, + "error": "Unauthorized", + "message": "Not authenticated.", + "path": "/users" +}


tomknee1
2021-06-18 08:15
has joined #pact-jvm

michael.branders
2021-06-18 11:43
Do you have examples for the message consumer to test events? In my case AMQP events on rabbit. In java if possible.


matt.fellows
2021-06-18 23:55
There's a few there

rockin291
2021-06-19 05:18
has joined #pact-jvm

github2
2021-06-19 18:00
[pact-foundation/pact-jvm] Issue opened by tinexw

zainamro1
2021-06-20 17:17
has joined #pact-jvm

nferrazzano
2021-06-21 05:23
has joined #pact-jvm

lewis.prescott079
2021-06-21 12:55
has joined #pact-jvm

vlad
2021-06-21 18:23
has joined #pact-jvm

christopher.doherty
2021-06-21 19:01
has joined #pact-jvm

liorra
2021-06-22 04:17
has joined #pact-jvm

stanojevic.boban
2021-06-22 10:20
has joined #pact-jvm

saurabh.goel
2021-06-22 11:18
yes, i made the change and got it to work.

miguel.carneiro
2021-06-22 12:51
has joined #pact-jvm

srinagasai.krishnasan
2021-06-22 17:35
has joined #pact-jvm

github2
2021-06-22 19:12
[pact-foundation/pact-jvm] Issue opened by csydvs

varnit.garg2424
2021-06-23 06:19
has joined #pact-jvm

miguel.carneiro
2021-06-23 11:24
Hi, We are facing an issue in our pipelines when removing a Provider java class, as it stands we should be validating that the consumers are not affected when the provider is deleted or changed. But the pipeline is passing. At the moment, we are creating a branch where we remove Provider classes, expecting the pipeline to fail when tested with all current consumers. To run the pipeline we are using a multiple setep approach, starting with a mvn call with the following mvn arguments ```-Dpactbroker.consumerversionselectors.tags=master -Dpactbroker.providerTags=master -Dpactbroker.host=${PACT_BROKER_HOST} -Dpactbroker.auth.token=${PACT_BROKER_TOKEN} -Dpact.verifier.publishResults=true -Dpact.provider.version=$PACT_PROJECT_VERSION -Dpact.provider.tag=$BITBUCKET_BRANCH``` In the logs we are able to see that we are checking against the consumers, but the following appears > Not all of the 6 were verified. The following were missing: > xxxxCommand > yyyyCommand But it still passes. And a second step where we call can-i-deploy in a docker command ```docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL=https://$PACT_BROKER_HOST -e $PACT_BROKER_TOKEN pactfoundation/pact-cli:latest broker can-i-deploy --broker-base-url $PACT_BROKER_HOST --broker-token $PACT_BROKER_TOKEN --pacticipant ${BITBUCKET_REPO_SLUG} --version $PACT_PROJECT_VERSION --to master --retry-while-unknown 60 --retry-interval 10``` I assume that the first step of the pipeline, the maven call, should fail as the contract will be broken. Are we wrongly configuring pact? We have filtering enabled. fyi @rafael.espillaque @william.pritchard

varun.patil
2021-06-23 12:44
has joined #pact-jvm

varun.patil
2021-06-23 12:47
Hi All, I am not able to run provider tests with the pact folder in my target location .. the tests are getting skipped ..

varun.patil
2021-06-23 12:48
@RunWith(SpringRestPactRunner.class) @Provider("account-service") @PactFolder("pacts") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @Ignore public class AccountSeviceProviderContractTest { @TestTarget public final Target target = new SpringBootHttpTarget(); @State("Ban 3232 exists") public void accountExists() { // nothing to do, real service is used } }

phil.endsley
2021-06-23 12:50
You have @Ignore annotation on your test class

varun.patil
2021-06-23 12:51
Thank you so much phil, now i see some errors :slightly_smiling_face:

github2
2021-06-23 13:35
[pact-foundation/pact-jvm] Issue opened by nickrobison

varun.patil
2021-06-23 16:18
Hi, I am trying to verify pacts created from consumer which i have placed under pacts folder.. and trying to run the above class

varun.patil
2021-06-23 16:18
I am seeing the below error - Did not find any pact files for provider

gurkiratguliani
2021-06-23 22:59
try first running the subscriber ( consumer ) -> that will generate the pact files against which provider verifies

gurkiratguliani
2021-06-23 23:02
Hi everyone, I'm trying to write a consumer test where I know that a string can have only set of values ( say "cats", "dogs") , the variable name is String animals . how do i generate a message pact , From what i have researched , string Matcher needs to be used, like .stringMatcher("animals",regex) i'm struggling to figure out the regex part , any ideas?

phil.endsley
2021-06-23 23:20
I like https://regexr.com/ for regex testing/reference

gurkiratguliani
2021-06-23 23:42
thanks @phil.endsley, was able to get it working

mselvakumar
2021-06-23 23:54
has joined #pact-jvm

mselvakumar
2021-06-24 00:13
Hi Everyone, I have submitted a pull request to pact-jvm https://github.com/pact-foundation/pact-jvm/pull/1387 to fix a minor issue with PactBroker annotation and URL in version 4.1.x. Just wanted to know when this will be looked at and if approved, when this will be released. At the moment, this is stopping us from building and running pact-tests successfully in our builds.

uglyog
2021-06-24 00:48
I would have expected the Maven build to fail if there are unverified interactions, but maybe that has not been implemented as it will need a surrogate test

uglyog
2021-06-24 00:48
Can you raise an issue on github?

github2
2021-06-24 01:52
[pact-foundation/pact-jvm] New release _https://github.com/pact-foundation/pact-jvm/releases/tag/4_1_23_ published by uglyog

srikanth.rachakonda
2021-06-24 02:32
has joined #pact-jvm

mselvakumar
2021-06-24 04:44
Thanks

ali.akbar
2021-06-24 06:58
has joined #pact-jvm

github2
2021-06-24 07:49
[pact-foundation/pact-jvm] Issue opened by miaguicam7

aubilla
2021-06-24 09:24
:waving-from-afar-left: Hi everyone, we are finally integrating Pact company wide and questions started to arise from here and there. :hash: I was wondering what happens if I don?t specify a number for an integerType. Will it match only the type? If the value generated is just a Random number when no number is specified, will that be reflected in the Pact so it won?t be a problem when verifying the Provider?

gurkiratguliani
2021-06-24 09:39
the value generated will be a random number when you use .integerType(string ) param -> if you don't want exact number to match, then it shouldn't be an issue

gurkiratguliani
2021-06-24 09:41
if in the provider, you want to match the exact number, then use .integerValue()

github2
2021-06-24 11:18
[pact-foundation/pact-jvm] Issue opened by mcarn

miguel.carneiro
2021-06-24 11:28
Thanks @uglyog, I just did


matt.fellows
2021-06-24 12:40
I would always set a value if you can, otherwise a new contract will be detected by the broker each time and you won't get pre verified results when you run can-i-deploy

matt.fellows
2021-06-24 12:41
If the contract doesn't change, it will be pre verified each time

github2
2021-06-24 12:47
[pact-foundation/pact-jvm] Issue closed by miaguicam7

aubilla
2021-06-24 13:53
@matt.fellows In that case I need to be :100: % sure that the service will always respond the same. That would imply that the developer working on the Consumer needs to know the data on the Provider side.

matt.fellows
2021-06-24 14:14
No, I'm saying still use a matcher, but also specify a value (otherwise a random one will go into the contract)

matt.fellows
2021-06-24 14:15
I.e. use `integerType` but pass a value to it

aubilla
2021-06-24 14:27
Oh, now I get it. Thank you very much, like always!

erterpstra
2021-06-24 19:20
has joined #pact-jvm

abinzahid
2021-06-25 06:12
has joined #pact-jvm

aliaksandr.valadzko
2021-06-25 11:00
Hey guys We use gradle plugin We started to receive weird messages from `canIDeploy` task when it is *failed* ```canIDeploy -Ppacticipant=serviceA -PpacticipantVersion=versionA -Ppacticipant=serviceB -PpacticipantVersion=versionB Computer says no ?\_(?)_/? There is no verified pact between the latest version of serviceC (versionC) and version versionD of serviceD``` ? for verified interaction we still receive, no issue here ```Computer says yes \o/ ``` ? but for broken interaction we receive inaccurate message, were wrong `pacticipants` are listed ```here is no verified pact between the latest version of serviceC (versionC) and version versionD of serviceD``` So, it looks like `pacticipant` and `pacticipantVersion` parameters are ignored in error messages for failed `canIDeploy` task Is it known issue, and if not, would like me to open it? Also, is it a right place - https://github.com/pact-foundation/pact-jvm? Thanks

e.pittaluga.b
2021-06-25 14:15
Hello Pact team, firstly, just like to thank you all for the great tool! so I am new (very new, in fact) to Pact and am working on a POC. I would like to produce a Pact to verify the interaction between a Java Client accessing a GraphQL API (also written in Java). Can I do this with pact-jvm?

e.pittaluga.b
2021-06-25 14:34
Found some info about this in the thread. Still interested in hearing peoples experiences and whether the Pact can also be validated on the provider side


matt.fellows
2021-06-26 00:30
You can also see the history of the #graphql channel here: https://docs.pact.io/slack/graphql.html

matt.fellows
2021-06-26 00:30
migth be some useful stuff there

uglyog
2021-06-26 03:14
Can you raise an githib issue?

jchandorkar
2021-06-26 09:01
has joined #pact-jvm

wenqiglantz
2021-06-27 02:08
I ran OWASP dependency vulnerability check on my app, which uses Pact, specifically the following dependency. ```<dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>4.2.6</version> </dependency>``` The dependency vulnerability check showed the following results, complaining about two dependency libs within au.com.dius.pact.consumer:junit5:4.2.6, any suggestion on how this can be fixed?

uglyog
2021-06-27 02:10
Please raise a github issue

github2
2021-06-27 02:16
[pact-foundation/pact-jvm] Issue opened by wenqiglantz


rani.sathya
2021-06-27 04:14
has joined #pact-jvm

github2
2021-06-27 06:44
[pact-foundation/pact-jvm] New release _https://github.com/pact-foundation/pact-jvm/releases/tag/4_2_7_ published by uglyog

github2
2021-06-27 11:04
[pact-foundation/pact-jvm] Issue closed by tinexw

cala.dev_pact
2021-06-28 04:07
has joined #pact-jvm

robert.rap
2021-06-28 06:34
has joined #pact-jvm

github2
2021-06-28 07:08
[pact-foundation/pact-jvm] Issue opened by AliaksandrValadzko

v-ratngupta
2021-06-28 07:13
has joined #pact-jvm

v-ratngupta
2021-06-28 07:45
Hi All

v-ratngupta
2021-06-28 07:46
how can i use pathFromProviderState to change param value before Verifying GET api


v-ratngupta
2021-06-28 07:47
in providerState setup method

github2
2021-06-28 11:50
[pact-foundation/pact-jvm] Issue closed by keeping-it-up

e.pittaluga.b
2021-06-28 13:01
Thank you so much for the reply, Matt. I will definitely check it out and write back as necessary!

e.hallowell
2021-06-28 13:28
has joined #pact-jvm

e.hallowell
2021-06-28 13:35
Hi all! Is this the best place to ask questions about the use of the pact using junit? We're using the `PactBroker` annotation with `consumerVersionSelectors` to pull pacts with a particular tag. E.g.: ```@PactBroker( url = "http://some-pact-broker-url", consumerVersionSelectors = { @VersionSelector(tag = "master") })``` And what we find is that pacts are pulled with a tag containing `master`, not matching the tag name exactly (pacts are pulled with tag `XXX-SNAPSHOT-master` for example). Is it possible to specify an exact match?

matt.fellows
2021-06-28 13:54
That doesn't seem right. I think there was a feature request to support wildcards but to my knowledge that's not done yet

matt.fellows
2021-06-28 13:55
Is that the full code? Are you also using WIP Pacts?

matt.fellows
2021-06-28 13:55
E.g. if you're also passing system properties you might accidentally be doing that

e.hallowell
2021-06-28 14:00
Ahh I think I've found the issue and it's not with the tag. The `XXX-SNAPSHOT-master` specifier was actually the version and not the tag :facepalm:. Apologies for the alarm :sweat_smile:

matt.fellows
2021-06-28 23:10
cool, thanks for clarifying!

mishalalexander20
2021-06-29 07:36
has joined #pact-jvm

lukemufc125
2021-06-29 07:57
has joined #pact-jvm

prash471
2021-06-29 09:43
has joined #pact-jvm

martijn.hagens
2021-06-29 10:12
has joined #pact-jvm

lucas.rolle
2021-06-29 10:18
Hey! I'm currently defining a contract using JUnit5 and the "MessagePactBuilder" for asynchronous messages. The messages are in XML format. As far as I know only "PactDslWithProvider" can use a "PactXmlBuilder" body. Is there any way of using the "PactXmlBuilder" with the "MessagePactBuilder"? Or are there other tips how I can define a contract for asynchronous data exchange using XML files?

lucas.rolle
2021-06-29 13:54
Updating to the newest http://au.com.dius.pact.consumer.junit5 dependency solved the problem

github2
2021-06-29 14:15
[pact-foundation/pact-jvm] Issue opened by PRABAREPO

rafael.espillaque
2021-06-29 16:01
hi all, does anyone have a setup like the following up and running? We use Spring + Pact for messages. We have different classes with `@PactVerifyProvider`-annotated methods which need some Spring @Autowired fields. What we see that's happening is that the main `@TestTemplate` class has the autowired fields injected but other tests are instantiated by Pact (not by Spring) so their autowired fields are null. Is this possible to achieve? Can we have @Autowired fields in Pact classes?

jarmy
2021-06-29 17:05
Does the Gradle plugin support WIP pacts? I can't find any reference in the gradle documentation.

mikko.s.koskinen
2021-06-29 17:05
has joined #pact-jvm

uglyog
2021-06-29 23:44
You need to use the Spring specific test template class.

uglyog
2021-06-29 23:44
`@ExtendWith(PactVerificationSpringProvider.class)`

uglyog
2021-06-29 23:46
WIP pacts are a Pact broker feature. The Gradle plugin uses the standard Pact-JVM verifier class, which supports ignoring failures for Pacts marked as pending

uglyog
2021-06-29 23:46
Is that what you are asking?

matt.fellows
2021-06-30 01:07
WIP pacts takes an argument for the earliest date to collect non verified pacts. I'm guessing he's asking if there is an option to specify that in the gradle task itself

matt.fellows
2021-06-30 01:07
I think if I understood correctly, the verifier arguments are available to the task, so yes

zhaoyi0113
2021-06-30 02:13
has joined #pact-jvm

github2
2021-06-30 04:00
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-06-30 04:01
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-06-30 04:01
[pact-foundation/pact-jvm] Issue closed by uglyog

rafael.espillaque
2021-06-30 08:31
thanks @uglyog but I don't see how that helps. I have the annotation already but the `testTemplate` method ends up directly invoking a `PactVerifyProvider` method of class instantiated by Pact from `ProviderVerifier.kt` ```override var providerMethodInstance: Function<Method, Any> = Function { m -> m.declaringClass.newInstance() },``` So @Autowired fields are null, Spring is not involved AFAIK

uladzislau_danilchyk
2021-06-30 09:25
#pact-jvm, hi everyone! Does anybody know how to filter pacts in Pact Provider Verification Test (junit used) by Consumer Version (not by a tag)? thanks in advance!

caoilte
2021-06-30 13:23
@npatil what was the problem/solution? I'm seeing a similar issue.

npatil
2021-06-30 13:44
Hey @caoilte I added below block of dependency in `build.gradle` and it worked fine: ```dependencies { testImplementation ('au.com.dius.pact.provider:junit:4.2.3') { exclude group: 'org.scala-lang', module: 'scala-library' } }``` Hope this help you too.

jarmy
2021-06-30 15:57
I asked because if I try to use `systemProperty 'pactbroker.includeWipPactsSince', '2021-06-28'` in my `au.com.dius.pact.provider:gradle:4.1.20` project I get the following error: ```> Could not find method systemProperty() for arguments [pactbroker.includeWipPactsSince, 2021-06-28] on PactBrokerConsumerConfig(selectors=[ConsumerVersionSelector(tag=feature/contracttests, latest=true, consumer=null, fallbackTag=null), ConsumerVersionSelector(tag=graphql-catalog-consumer-contract, latest=true, consumer=null, fallbackTag=null), ConsumerVersionSelector(tag=master, latest=true, consumer=null, fallbackTag=null), ConsumerVersionSelector(tag=mobile-test, latest=true, consumer=null, fallbackTag=null), ConsumerVersionSelector(tag=production, latest=true, consumer=null, fallbackTag=null), ConsumerVersionSelector(tag=dr, latest=true, consumer=null, fallbackTag=null)], enablePending=true, providerTags=[DEVTOOLS-975-add-pact-verify-test]) of type au.com.dius.pact.provider.gradle.PactBrokerConsumerConfig.```


rafael.espillaque
2021-06-30 16:23
(I use messages, not http interactions)

matt.fellows
2021-06-30 22:46
If I understood correctly, you could just do this: ```pact { serviceProviders { myProvider { fromPactBroker { selectors = latestTags('test') // specify your tags here. You can leave this out to just use the latest pacts includeWipPactsSince = '2021-06-28' enablePending = true // enable pending pacts support providerTags = ['master'] // specify the provider main-line tags } } } }```

jarmy
2021-06-30 22:49
I tried that and got `Could not set unknown property 'includeWipPactsSince' for PactBrokerConsumerConfig`

matt.fellows
2021-06-30 22:57
hmm sorry, might need someone else

matt.fellows
2021-06-30 22:57
I?m assuming you should still be able to set a system property, but it would be nice to see all in once place. I don?t personally like having to look into multiple places to debug these things. I?d prefer either all system properties or all explicit gradle (in this case)


jarmy
2021-06-30 23:05
It sure doesn't. I was able to get the `pactVerify` task to run by using ```System.setProperty("pactbroker.includeWipPactsSince", "2021-06-28")``` but i don't think WIP pacts was utilized. I can't remember if it's only invoked if the contract verification fails...

matt.fellows
2021-06-30 23:19
hmmm it should basically pull in any pacts that haven?t been previously verified. What does a debug log look like - can you see if it?s sent over the wire to the broker?

jarmy
2021-06-30 23:26
I see a lot of entries about pending pacts but nothing about WIP. ```6:20:27.175 [QUIET] [system.out] Verifying a pact between sps (5e3eec8) and collections [PENDING] 16:20:27.175 [QUIET] [system.out] 16:20:27.175 [QUIET] [system.out] Notices: 16:20:27.175 [QUIET] [system.out] 1) The pact at https://pact-broker.docker.savagebeast.com/pacts/provider/collections/consumer/sps/pact-version/f20fb120eac2d03b44dca11fdb6ef25d3b27be0e is being verified because it matches the following configured selection criteria: latest pact for a consumer version tagged 'feature/contracttests', latest pact for a consumer version tagged 'master' (both have the same content) 16:20:27.175 [QUIET] [system.out] 2) This pact is in pending state for this version of collections because a successful verification result for a version of collections with tag 'DEVTOOLS-975-add-pact-verify-test' has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at https://pact.io/pending 16:20:27.175 [QUIET] [system.out] 16:20:27.175 [QUIET] [system.out] [from Pact Broker https://pact-broker.docker.savagebeast.com/pacts/provider/collections/consumer/sps/pact-version/f20fb120eac2d03b44dca11fdb6ef25d3b27be0e]```

jarmy
2021-06-30 23:27
oh, then I see this `wip=false`: ```VerificationNotice(when=after_verification:success_true_published_true, text=This pact is no longer in pending state for any version of collections with tag 'DEVTOOLS-975-add-pact-verify-test', as a successful verification result with this tag has been published. If a verification for a version with fails in the future, it will fail the build. Read more at https://pact.io/pending), VerificationNotice(when=after_verification:success_false_published_true, text=This pact is still in pending state for any version of collections with tag 'DEVTOOLS-975-add-pact-verify-test' as a successful verification result with this tag has not yet been published)], pending=true, wip=false)]]:```

uglyog
2021-06-30 23:31
Can you confirm the version of Pact-JVM you are using?

jarmy
2021-06-30 23:32
I'm using the gradle plugin version `au.com.dius.pact.provider:gradle:4.1.20`

uglyog
2021-06-30 23:51
It doesn't matter whether you use http or message interactions. The default test template class does not know anything about Spring, so your Spring annotated fields will be null. `PactVerificationSpringProvider` knows how to apply the spring context to the test.

sgottipati
2021-07-01 06:02
has joined #pact-jvm

vshankar
2021-07-01 06:06
has joined #pact-jvm

e.generalov
2021-07-01 07:19
has joined #pact-jvm

e.generalov
2021-07-01 07:21
@e.generalov has left the channel

caoilte
2021-07-01 07:50
Thanks @npatil that was exactly the fix I was nosing my way towards! Incidentally, this is a bug. There's no way the main project should need a scala dependency.

rafael.espillaque
2021-07-01 09:57
But the instances of the classes with `@PactVerifyProvider` are still created by Pact (using `Class.newInstance()`) so they're not managed by Spring nor JUnit. So @Autowired fields are null and @BeforeEach methods are not called.

rafael.espillaque
2021-07-01 09:58
This project shows what I mean.

rafael.espillaque
2021-07-01 09:59
The main thing to look at is the new `OtherProducerTest` in the provider side, which is called from the @TestTemplate method in `ProductsKafkaProducerTest`

npatil
2021-07-01 12:25
Yeah I agree.

github2
2021-07-01 13:00
[pact-foundation/pact-jvm] Issue opened by caoilte


eduards.klavins
2021-07-01 13:44
has joined #pact-jvm

felix.gomez
2021-07-01 14:38
has joined #pact-jvm

github2
2021-07-01 16:32
[pact-foundation/pact-jvm] Issue closed by mcarn

bbako
2021-07-01 20:51
has joined #pact-jvm

github2
2021-07-01 23:32
[pact-foundation/pact-jvm] Issue opened by csydvs

phil.armstrong
2021-07-02 06:49
has joined #pact-jvm

gargshubham49
2021-07-02 07:21
has joined #pact-jvm

rafael.espillaque
2021-07-02 10:03
any help with this would be appreciated, please. the project in https://pact-foundation.slack.com/archives/C9UN99H24/p1625133482325700?thread_ts=1624982486.315500&cid=C9UN99H24 (based on @matt.fellows?s kafka example) shows how I intended to split message pact verifications into different classes but spring beans are not autowired on those. How you all guys organize your message pact verifications? Do you have a very big class with lots of `@PactVerifyProvider`-annotated methods?

github2
2021-07-05 07:00
[pact-foundation/pact-jvm] Issue opened by juan-fernandez-enverus

github2
2021-07-05 12:02
[pact-foundation/pact-jvm] Issue closed by juan-fernandez-enverus

vinnys.lins
2021-07-05 13:49
has joined #pact-jvm

talank
2021-07-06 03:52
has joined #pact-jvm

juri.petersen
2021-07-06 07:29
has joined #pact-jvm

leolvicario
2021-07-06 07:36
has joined #pact-jvm

swoichhaa
2021-07-06 08:46
has joined #pact-jvm

ivo.velthoven174
2021-07-06 09:28
has joined #pact-jvm

fjtdg
2021-07-06 12:16
has joined #pact-jvm

adriano.tanoue
2021-07-06 13:31
hello - I have a spec that says a field in a json body should be "RFC4648 base64url encoded". Any way to validate this through a contract?

github2
2021-07-06 13:41
[pact-foundation/pact-jvm] Issue opened by artemptushkin

steve.etherington
2021-07-06 16:44
has joined #pact-jvm

rosh.mjohn
2021-07-07 07:19
has joined #pact-jvm

mahajanalokkumar
2021-07-07 10:41
has joined #pact-jvm

jyiyng2002
2021-07-07 19:57
has joined #pact-jvm

splurgeop
2021-07-07 21:48
has joined #pact-jvm

kapoor.manil
2021-07-07 22:30
has joined #pact-jvm

pashas.2k3
2021-07-08 03:41
has joined #pact-jvm

vijayanaggella
2021-07-08 05:25
has joined #pact-jvm

ananthshenoy03
2021-07-08 05:46
has joined #pact-jvm

sai5i.islam
2021-07-08 06:40
has joined #pact-jvm

poorvasgokhale
2021-07-08 09:08
has joined #pact-jvm

suresh.thammishetti
2021-07-08 11:08
has joined #pact-jvm

pashas.2k3
2021-07-08 13:07
I am exploring usage of Pact in a spring boot service written in Kotlin. I am trying to use Pact but I am getting thrown off by mismatch of `Content-Type is null` error from provider. I verified with another SpringBoot test with autowired TestRestTemplate run on Random port that the header does get attached in response. This is what the spring boot Rest controller looks like (Abridged version) ```data class SupplierModel(     val id: Int,     val name: String,     val currencyId: String,     val catalogId: String,     val countryId: String ) @RestController class CurrencyController @Autowired constructor(val service: CurrencyService) {     @GetMapping("/currency_information") // @GetMapping("/currency_information", produces = [MediaType.APPLICATION_JSON_VALUE])     fun getCurrencyPreference(@RequestParam("supplier_id") supplierId: Int): SupplierModel =          service.getCurrencyPreference(supplierId) }``` Snippet of the testpoint I used to verify the response from the endpoint contains `Content-Type` header ```val url = "/currency_information?supplier_id=1"         val expected = arrayListOf(             SupplierModel(                 1, "foo", "USD", "bar", "nowhere"             )         )         Mockito.`when`(mockService.getCurrencyPreference(Mockito.any()))             .thenReturn(expected)         val response = template.getForEntity(url, SupplierModel::class.java) // Autowired rest template         val actualBody = response.body         assertThat(response.statusCode.is2xxSuccessful)         assertThat(response.headers.contentType!!.includes(MediaType.APPLICATION_JSON))         assertThat(actualBody).isNotNull         assertThat(expected[0]).isEqualTo(actualBody)``` I first ran the consumer Pact test to generate the Pact JSON without issues. Then I tried running the Provider pact test from IntelliJ. It threw this error ```Failures: 1) Verifying a pact between market-consumer and market-provider - request for currency preference includes headers "Content-Type" with value "[application/json; charset=UTF-8]" 1.1) header: Expected a header 'Content-Type' but was missing 1.2) body-content-type: Expected a response type of 'application/json' but the actual type was 'null'``` Looking through the Pact docs(https://docs.pact.io/implementation_guides/jvm/provider/spring/#junit5), I cannot figure out what I was missing The producer test that I used ```@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @Provider("market-provider") @PactFolder("build/pacts") class ContractTestProvider {     @LocalServerPort     private var localPort: Int = 0    @MockBean     private lateinit var currencyService: CurrencyService    @TestTemplate    @ExtendWith(PactVerificationSpringProvider::class)     fun pactVerificationTestTemplate(context: PactVerificationContext) {         context.verifyInteraction()     }     @BeforeEach     fun before(context: PactVerificationContext) {         context.target = HttpTestTarget("localhost", localPort)     }     @State("currencyPreference")     fun `fetch currency preference`() {         Mockito.`when`(currencyService.getCurrencyPreference(456))             .thenAnswer {                 SupplierModel(                     456,                     "fake-supplier",                     "USD",                     "fake-catalog-id",                     "fake-country",                 )             }   } }``` Any ideas? Also what have folks found to work in Spring Boot/JVM world with Pact? EDIT: Apologies on the size of the post, wanted to ensure folks answering had access to the code snippets that live in an enterprise Github

pashas.2k3
2021-07-08 13:43
I found the solution. It was me using a literal numeric value (`456`) instead of `http://Mockito.int()` in case someone else runs into it. Unclear on why it fixed it, but it does seem to have resolved it

uglyog
2021-07-08 23:14
I assume that was causing the provider to not return a valid JSON response

aubilla
2021-07-09 09:23
Hi all :wave: Do you know where has this been moved to? http://docs.pact.io/documentation/provider_states.html


uglyog
2021-07-09 09:34
BTW, there is a search (in the top right corner)

michael.katende
2021-07-09 10:41
has joined #pact-jvm

marcin.baranowski953
2021-07-09 10:42
has joined #pact-jvm

aubilla
2021-07-09 12:06
Thank you! I didn?t see the search box :facepalm:

bedfordwest
2021-07-10 22:21
has joined #pact-jvm

firstamit
2021-07-11 14:07
has joined #pact-jvm

omar554
2021-07-11 21:54
has joined #pact-jvm

k.deepupardha
2021-07-12 10:23
has joined #pact-jvm

lumenofor
2021-07-12 10:46
has joined #pact-jvm

uladzislau_danilchyk
2021-07-12 10:50
Hi everyone! Our provider has endpoint with response like: [{..},{..},{..}] without any key assigned to this array. But I tried to write a pact test using `withBody { eachLike(..) }` and it fails with the error: ```Detected an invalid use of the matchers. If you are using matchers like "eachLike" they need to be assigned to something. For instance: `fruits eachLike(1)` or `id = integer()` ``` Who can help me with that? Is there any possibility to handle such case? cc: @lumenofor

dimundo
2021-07-12 10:52
can you share response example ?

uladzislau_danilchyk
2021-07-12 10:53
yep: ```[ {"id":1, "name": "Some name 1"}, {"id":2, "name": "Some name 2"}, {"id":3, "name": "Some name 3"}, {"id":4, "name": "Some name 4"} ]```

uladzislau_danilchyk
2021-07-12 10:53
@dimundo

dimundo
2021-07-12 10:59
so, there are ?id? and ?name?

dimundo
2021-07-12 11:00
> ] without any key assigned to this array.

uladzislau_danilchyk
2021-07-12 11:00
but only inside array element.


dimundo
2021-07-12 11:02
so you need probably ``` .withContent( eachLike({ name: "Name", id: "id" }) )```

uladzislau_danilchyk
2021-07-12 11:03
@dimundo, why should I use "withContent" instead of "withBody" for response?

dimundo
2021-07-12 11:04
pardon, yes, body ( doing mostly messages, not http )

uladzislau_danilchyk
2021-07-12 11:05
I'm using groovy. and it looks like: ```withBody { eachLike({name: "Name"...}) }``` But id doesnt work and throws the issue with message that expected key before `eachLike`

lumenofor
2021-07-12 11:22
@dimundo, it works fine! ```withBody( eachLike({ ... })```

lumenofor
2021-07-12 11:23
thank you @dimundo for assistance!

dimundo
2021-07-12 11:23
but beware

uladzislau_danilchyk
2021-07-12 11:23
@dimundo , thanks! You are right. Because there is a difference when using `withBody {..}` and `withBody(..)` . Last one is working fine

dimundo
2021-07-12 11:24
if extra key:value will be there , you will get kaboom

lumenofor
2021-07-12 11:24
got it. will keep this in mind.

dimundo
2021-07-12 11:40
ah, no extra will be fine

phil.endsley
2021-07-12 12:38
Have some :taco::taco: @dimundo

jayr.motta
2021-07-12 13:57
has joined #pact-jvm

doug.shattuck
2021-07-12 20:26
has joined #pact-jvm

poorvasgokhale
2021-07-13 06:37
hello team, we are setting up consumer test. TL;DR;We are facing issue *after upgrading `pact-consumer` to `4.2.7` from `3.5.21` , pact .json file is not getting generated when we run contract test using gradle command from terminal.* Earlier we were using ` testImplementation ?au.com.dius:pact-jvm-consumer-java8_2.12:3.5.21?` this version.. when we ran `./gradlew test` it used to generate `.json` file in `target` folder. After upgrading to `testImplementation "au.com.dius.pact:consumer:4.2.7"` , `./gradlew test` is not generating .json file. Note: things are working as expected when we run test in intelliJ for both versions. Has anything changed between pact consumer version `3.5.21` to `4.2.7`?

uglyog
2021-07-13 06:41
What are the consumer tests written with?

uglyog
2021-07-13 06:41
JUnit 4?

poorvasgokhale
2021-07-13 06:45
we are using `kotest` as we are writing contract test for kotlin microservices

poorvasgokhale
2021-07-13 06:49
hey team, we solved the issue. Default folder for pact files is `build/pacts` if it is run inside `gradle` . Previously it was `target/pacts` . Thanks @uglyog for quick response. :slightly_smiling_face:

sorin_balbae
2021-07-13 07:41
has joined #pact-jvm

akara
2021-07-13 10:34
has joined #pact-jvm

nathan.derave
2021-07-13 12:28
has joined #pact-jvm

chris.faulkner
2021-07-13 15:40
Hi - I have been using pact to verify some contracts. Recently I had an an array like this - showing part of the structure in the interaction ?body?. ``` "body": { "nsis": [ { "actualStartDate": "2000-01-31", "nsiId": 100 }, {} ] } ``` So the list was named ?nsis?. I did this using ``` var body = new PactDslJsonBody() .eachLike("nsis") ..... [define fields] .closeArray();``` Now I have a similar requirement but cannot name the list, it?s along these lines ```[ { "id": 2500079873, } ]``` sorry - I have tried eachLike(??) and various things with the PactDslJsonBody and PactDslJsonArray but I can?t find the thing I need to do. Any pointers ?

matthew.schaad
2021-07-13 21:29
has joined #pact-jvm

neenad.jadhavgre
2021-07-13 22:30
has joined #pact-jvm

uglyog
2021-07-14 01:01
Use `PactDslJsonArray.arrayEachLike()` instead of PactDslJsonBody

hugh.paul.mcgowan
2021-07-14 03:39
.

cristian
2021-07-14 06:18
has joined #pact-jvm

michal.bernhard
2021-07-14 11:16
has joined #pact-jvm

koradrop
2021-07-14 13:06
has joined #pact-jvm

github2
2021-07-14 14:01
[pact-foundation/pact-jvm] Issue opened by AbelAlejandro

github2
2021-07-14 18:02
[pact-foundation/pact-jvm] Issue opened by KesarimangalamUmasankarS

richard.jones254
2021-07-14 23:53
has joined #pact-jvm

edanielsen
2021-07-15 00:46
has joined #pact-jvm

abatan.k
2021-07-15 03:48
has joined #pact-jvm

mandeep302755
2021-07-15 04:49
has joined #pact-jvm

mahajanrupali22
2021-07-15 05:46
has joined #pact-jvm

hylke.de.jong
2021-07-15 12:49
has joined #pact-jvm

efemgy
2021-07-15 14:27
has joined #pact-jvm

github2
2021-07-15 17:45
[pact-foundation/pact-jvm] Issue opened by anopows

crazycabo350
2021-07-15 18:16
has joined #pact-jvm

crazycabo350
2021-07-15 20:00
Does anyone have a link to an open source project combining Pact with SpringBoot with quality references to how providers should mock responses?

phil.endsley
2021-07-15 21:37
Have you seen the workshop? https://github.com/pact-foundation/pact-workshop-jvm-spring > how providers should mock responses? > Not entirely sure what you mean by this. The response itself should be real. Of course, you can mock the data needed the same way you usually would. Typically, you can mock out the specific calls you need in the state methods

crazycabo350
2021-07-16 02:42
So mock @Service responses, not the data source or @Repository interfaces.

amreenshaik.basha
2021-07-16 04:06
has joined #pact-jvm

michael.branders
2021-07-16 07:12
My current pact tests are with junit 5: ```<dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>4.1.0</version> <scope>test</scope> </dependency>``` If i want to use the LamdaDSL do i need to add an extra dependency? If i add this one i can use it but my existsing test is failing from now on ```<dependency> <groupId>au.com.dius.pact</groupId> <artifactId>consumer</artifactId> <version>4.2.3</version> <scope>test</scope> </dependency>``` java.lang.NoSuchMethodError: 'http://au.com.dius.pact.consumer.model.MockProviderConfig http://au.com.dius.pact.consumer.model.MockProviderConfig$Companion.httpConfig(java.lang.String, int, http://au.com.dius.pact.core.model.PactSpecVersion)'

francislainy.campos
2021-07-16 10:37

rhian.van.esch
2021-07-16 12:14
has joined #pact-jvm

wilco.van.esch
2021-07-16 12:30
has joined #pact-jvm

karl.morrison
2021-07-16 12:56
has joined #pact-jvm

michael.branders
2021-07-16 14:02
Is there already a beter way to handle REST and massages between the same provider and client? Now i have ro rename my client to something like client-amqp en in rest its client then to avoid this error: Cannot merge pacts as they are not compatible

phil.endsley
2021-07-16 14:05
If you have multiple pact libs, they all need to be the same version. I believe 4.2.x had some breaking changes in the API (packages changed) At some point, the lambda dsl was bundled with everything else, which is probably why it's available in the 4.2.3 version. You should just be able to upgrade the junit5 one and still get it all. I think

phil.endsley
2021-07-16 14:06
Not yet, unfortunately. Coming in v4 I believe

michael.branders
2021-07-16 14:06
Ok i'll try!

dimundo
2021-07-16 14:07
welcome to my reality :slightly_smiling_face:

michael.branders
2021-07-16 14:08
new to pact to its my new reality :slightly_smiling_face:

dimundo
2021-07-16 14:08
been there month ago :smile:


dimundo
2021-07-16 14:09
check thread

michael.branders
2021-07-16 14:10
indeed it is what it is :slightly_smiling_face: at least there is a workaround

dimundo
2021-07-16 14:11
nice to see, that quite a lot uses messages ( and pact for them )

timothyjabez
2021-07-16 17:23
has joined #pact-jvm

kflo
2021-07-16 18:43
FWIW we have been using topic name for provider messages

kflo
2021-07-16 18:44
which is different than the provider name itself. for example, HTTP: `foo`, message: `event.foo` or `command.foo`

ppdnguyen
2021-07-18 16:23
has joined #pact-jvm

cgoodison
2021-07-18 23:56
has joined #pact-jvm

tylerkron
2021-07-19 02:30
has joined #pact-jvm

poorvasgokhale
2021-07-19 09:21
```pact { publish { version = "consumer-service-version-placeholder" pactBrokerUrl = 'http://localhost:9292/' pactDirectory = "path-to-pact-directory" tags=['release'] } }``` @nathaniel.emmons Adding this to gradle settings worked for me. Passing it via gradle cli like `./gradlew :contracttesting:pactPublish -Dpact.publish.tags=dev` did not worked for me as well. Did you found any way to pass tag via gradle command?

poorvasgokhale
2021-07-19 09:28
Rather none of the pact.publish properties can be modified by passing -D to `./gradlew pactPublish` command. :disappointed_relieved:

poorvasgokhale
2021-07-19 09:29
Is this known bug?

sripathi
2021-07-19 12:30
has joined #pact-jvm

nathaniel.emmons
2021-07-19 13:01
@poorvasgokhale no, i was unable to get it working via the gradle command. i gave up and just used the separate create-version-tag https://github.com/pact-foundation/pact_broker-client#create-version-tag in the client CLI as an additional step after publishing the pacts.

nathaniel.emmons
2021-07-19 13:02
Thanks for pointing out that the issue affects all of the pact.publish properties, i had not thought to check that. It sounds like a bug.

calvin.krist
2021-07-19 15:29
has joined #pact-jvm

vinay.viswanadha
2021-07-19 15:30
has joined #pact-jvm

brian.mitchell
2021-07-19 15:37
has joined #pact-jvm

mike.geeves064
2021-07-19 18:07
has joined #pact-jvm

aubilla
2021-07-19 18:32
I have the following Pact in the code ```@Pact(consumer = "PatientClient") public RequestResponsePact findPatientById(PactDslWithProvider builder) { return builder .given("patients exist") .uponReceiving("get patient by id") .path("/api/pmi/graphql") .method("POST") .body(new PactDslJsonBody().stringType("query","{ findPatientById (id: 200016409) { id gender userRef } } ")) .willRespondWith() .status(200) .body( new PactDslJsonBody() .object("data") .object("findPatientById") .integerType("id", 200016409) .stringType("gender", "M") .stringType("userRef", null) .close() .asBody() ) .toPact(); }``` and it?s generating this in the JSON file ```"response": { "status": 200, "headers": { "Content-Type": "application/json; charset=UTF-8" }, "body": { "data": { "findPatientById": { "gender": "M", "id": 200016409 } } },``` I suspect that the different ordering of the fields in the body is responsible for my verification failure in the CI ``` Given patients exist WARNING: State Change ignored as there is no stateChange URL get patient by id Request Failed - Invalid JSON (1:2), found unexpected character 'M' Pending Failures: 1) Verifying a pact between Pact between PatientClient (c375cff5) and PatientService - get patient by id Given patients exist 1.1) Invalid JSON (1:2), found unexpected character 'M' > Task :pactVerify``` Is my suspicion correct or am I doing something very wrong?

bryanw
2021-07-19 19:33
Is anyone successfully using the mvn plugin to pact:can-i-deploy with retryInterval and retriesWhenUnknown? The check immediately returns: ```19:28:24 [INFO] --- maven:4.2.7:can-i-deploy (default-cli) @ xxx --- 19:28:26 Computer says no ¯\_(?)_/¯ 19:28:26 19:28:26 There is no verified pact between the latest version of PetstoreConsumer (876f57c) and the latest version of PetstoreService (fec1397)``` There is a trigger that kicks off the provider validation and the CLI will retry for the specified period. I am trying to use the maven plugin so that I don't have to deploy the ruby toolchain into the environment.

matt.fellows
2021-07-19 21:56
I can?t answer the JVM question

matt.fellows
2021-07-19 21:56
You don?t need to install Ruby for the CLI though

matt.fellows
2021-07-19 21:56
you can use our docker container or download the standalone tools (which happen to bundle Ruby into it, but doesn?t required you to configure/install Ruby manually): https://docs.pact.io/implementation_guides/cli/

matt.fellows
2021-07-19 21:57
Can you please share full debug logs?

matt.fellows
2021-07-19 21:58
Invalid JSON tells me it didn?t get back JSON as a response

matt.fellows
2021-07-19 21:58
ordering of fields is not relevant, Pact should support that in a JSON map type

david.vancouvering
2021-07-19 23:44
Hey, I am trying to use `SpringRestPactRunner` for the first time, and even though I have used `@TestTarget` exactly like in the docs, the pact client is trying to connect to port 80 rather than the generated port. What am I missing? ```package com.ebay.app.contract; import au.com.dius.pact.provider.junit.target.HttpTarget; import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.State; import au.com.dius.pact.provider.junitsupport.TargetRequestFilter; import au.com.dius.pact.provider.junitsupport.loader.PactFolder; import au.com.dius.pact.provider.junitsupport.target.Target; import au.com.dius.pact.provider.junitsupport.target.TestTarget; import au.com.dius.pact.provider.spring.SpringRestPactRunner; import com.ebay.platform.raptor.cosadaptor.token.ISecureTokenManager; import org.apache.http.HttpRequest; import org.junit.Before; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import javax.inject.Inject; @RunWith(SpringRestPactRunner.class) @Provider("viexpio") // Set up name of tested provider @PactFolder("pacts") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ViexpioProviderValidationTest { //@MockBean //SWCModuleUxComponentBuilder swcModuleUxComponentBuilder; @Inject private ISecureTokenManager tokenGenerator; @LocalServerPort private int viexpioServicePort; @Before public void before() { System.out.println("Port number is " + viexpioServicePort); } /** * Add authorization header to every request */ @TargetRequestFilter public void exampleRequestFilter(HttpRequest request) { try { request.addHeader("Authorization", tokenGenerator.getToken().getAccessToken()); } catch (Exception e) { throw new RuntimeException(e); } } /** * Tells Pact how to communicate with the service */ @TestTarget public final Target target = new HttpTarget(viexpioServicePort); @State("item exists") public void itemExists() { System.out.println("here"); } }```

david.vancouvering
2021-07-19 23:45
I get the error ``` 1.1) Connect to 127.0.0.1:80 [/127.0.0.1] failed: Connection refused (Connection refused) at au.com.dius.pact.provider.junit.target.HttpTarget.testInteraction(HttpTarget.kt:80)```

david.vancouvering
2021-07-19 23:45
It's trying to talk to port 80

uglyog
2021-07-19 23:49
`Invalid JSON (1:2), found unexpected character 'M'` means the second character on line 1 is an `M`. If you could provide the actual body it will help to diagnose this

uglyog
2021-07-19 23:51
If you can also provide debug logs, it will help

uglyog
2021-07-19 23:55
It might be a sequence issue. This line `public final Target target = new HttpTarget(viexpioServicePort)` is executed when the test class is instantiated, and Spring probably hasn't injected the port yet.

david.vancouvering
2021-07-19 23:56
ah ok. I had seen someone else use a random port but maybe I misread. I'll try a hardcoded port and see if that makes a difference, thanks!

uglyog
2021-07-19 23:56
Use `SpringBootHttpTarget` instead, it will look the port up from the Spring context

david.vancouvering
2021-07-19 23:57
oh nice ok! Missed that one

david.vancouvering
2021-07-19 23:57
Hm, that symbols is not found. Maybe it's in a newer version of the Pact JVM library?

david.vancouvering
2021-07-19 23:58
``` <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit</artifactId> <version>4.2.2</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>spring</artifactId> <version>4.2.2</version> <scope>test</scope> </dependency>```

uglyog
2021-07-19 23:58
I should be in the `spring` lib

david.vancouvering
2021-07-19 23:59
ok, thanks. I have to jump into a meeting ,I'll dig into this some more later. Random port is preferable since I want to safely run this in CI/CD

david.vancouvering
2021-07-20 00:00
thanks for the quick response

uglyog
2021-07-20 00:00
It was introduced in 4.1.1, so it is in that lib

uglyog
2021-07-20 00:01
Actually, 3.5.14, so it has been around. `http://au.com.dius.pact.provider.spring.target.SpringBootHttpTarget`

mail_4brad
2021-07-20 00:11
.

bryanw
2021-07-20 00:35
@david.vancouvering I built an internal version of the HTTP target to do this because I was not having luck with the SpringBootHttpTarget with random port binding. There was an initialization sequence order problem. @uglyog we happen to work on the same team so I've been down this path with Spring. Because the kotlin class was sealed, I built a "V2" ```public class SpringBootHttpTargetV2 extends HttpTarget { private final SpringBootHttpTargetExtension targetExtension; public SpringBootHttpTargetV2(String path, @NotNull SpringBootHttpTargetExtension targetExtension) { super("http", "localhost", 0, path, false, () -> new HttpClientAuthFactory(targetExtension)); this.targetExtension = targetExtension; } @Override public int getPort() { return targetExtension.getPort(); } @Override protected @NotNull ProviderInfo getProviderInfo(@NotNull PactSource source) { targetExtension.setupTargetEnvironment(); return super.getProviderInfo(source); } }```

david.vancouvering
2021-07-20 00:36
Ah thanks!

uglyog
2021-07-20 00:38
Can I take that code and add it to Pact-JVM?

bryanw
2021-07-20 00:44
Yes, I can provide the relevant source files for you to review/integrate. What I ended up having to do is to have the target callback on an interface to be able to retrieve the port and provider info. Perhaps if this interface is provided to use this as an override otherwise fallback to your current implementation?

uglyog
2021-07-20 00:45
Yeah, makes sense

mail_4brad
2021-07-20 00:56
*Generating pact json from tests* Looking for feedback... ? Following on from https://pact-foundation.slack.com/archives/C5F4KFKR8/p1626654909068400 ? Given the best practices comments around Request matching https://pact-foundation.slack.com/archives/C5F4KFKR8/p1626654909068400 ?Typically, exact matching is most appropriate for Pact tests on the consumer side that are running at the unit test level.? ? Then I want my consumer tests to create the expected json for me without me needing to duplicate the model definitions. Model approach in a unit test: Assemble: 1. Build a model object 2. Stub out the consumer collaborator somewhere to capture, rather than send, the request object * 3. Submit the model object to the consumer collaborator * 4. Capture the json * 5. Remove the collaborator stub (restore original function) * 6. Use this json to build a pact * 7. Include any matching overrides * Activate: 8. Submit the model object to the consumer collaborator Assert: 9. Pact asserts the test fulfils the contract 10. The unit test asserts correct test outcomes. The steps with * are additional to how pact consumer tests are normally run. The good thing is that they become method calls to common code. Re step 6 - I did have to override Matchers to use TypeMatcher with regex for a couple of dynamic uuid fields. What?s missing from this design is that we don?t have a fixed defined contract in code that we then validate our test against. If there?s an error in the test then the contract will propagate that error and we won't know about it. The counter to that is that our own unittest assertions should be picking up where we break a test. It requires more emphasis on good unit tests rather than a consumer pact test simply matching what the pact says. I think that?s a good thing because now we get both. And here?s an excerpt from my now running tests using this technique, showing steps 2-5: ``` @InjectMocks private RecordCreateServiceImpl recordCreateService; @Captor private ArgumentCaptor<PublicApiRequest> captor; ? private String getExpectedJsonFromClient(Referral referral) throws Exception {   // Store the current publicClient from the SUT   Object origClient = ReflectionTestUtils.getField(recordCreateService, "publicClient");      // Update the publicClient to be an argument captor so we can grab the object passed to it   PublicClient mockPublicClient = mock(PublicClient.class);   ReflectionTestUtils.setField(recordCreateService, "publicClient", mockPublicClient);      doReturn(new PublicApiResponse()).when(mockPublicClient).sendDocument(Mockito.any(PublicApiRequest.class), Mockito.anyString());     recordCreateService.createRecordForReferral(referral);     verify(mockPublicClient).sendDocument(captor.capture(), Mockito.anyString());     PublicApiRequest capturedRequest = captor.getValue();     //System.out.println(capturedRequest);           // Restore the original publicClient to the SUT     ReflectionTestUtils.setField(recordCreateService, "publicClient", origClient);           // This is what RestTemplate uses to build json from objects     MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();     new MappingJackson2HttpMessageConverter().write(capturedRequest, MediaType.APPLICATION_JSON, outputMessage);           String jsonBody = outputMessage.getBodyAsString();     //System.out.println(jsonBody);           return jsonBody;   }``` Caveats: ? Yes I know reflection to swap out fields isn?t clean nor future proof, but this is sufficient for a PoC. ? Perhaps having to do this for various services from the client will prove unwieldy. ? Maybe the stars aligned with this one to enable this capturing and it won?t always be this simple. YMMV For completion, here's steps 1,6 and 7: ``` referral = buildValidReferral1(); String json = getExpectedJsonFromClient(referral); PactDslJsonBody matchersPart = new PactDslJsonBody(); MatchingRuleCategory matchers = new MatchingRuleCategory("body"); matchers.addRule("$.dbObjects[*].uuid", new RegexMatcher("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")); matchers.addRule("$.report.reportUuid", TypeMatcher.INSTANCE); matchersPart.setMatchers(matchers); return builder .uponReceiving("a generated Referral containing a person") .path("/api/report") .method("POST") .headers(requestHeaders) .body(matchersPart) // First set matchers .body(json) // Now actual body .willRespondWith() .status(200) .body("") .toPact();```

bryanw
2021-07-20 01:02
@uglyog - what additional logging should I enable? Is this a maven plugin setting?

uglyog
2021-07-20 01:04
Just run with `-X`, but there will be lots of logs

bryanw
2021-07-20 01:05
@matt.fellows - thanks, I'm a little limited by our integration points in our Jenkins CI, I'm trying to find the easiest solution to get pact-cli in place if the maven plugin doesn't get me there. It doesn't look like I can invoke the docker image in our config.

bryanw
2021-07-20 01:21
@uglyog - there really isn't much additional detail: ```01:15:25 [DEBUG] ----------------------------------------------------------------------- 01:15:25 [DEBUG] Goal: au.com.dius.pact.provider:maven:4.2.7:can-i-deploy (default-cli) 01:15:25 [DEBUG] Style: Regular 01:15:25 [DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?> 01:15:25 <configuration> 01:15:25 <latest default-value="">true</latest> 01:15:25 <pactBrokerAuthenticationScheme default-value="basic">basic</pactBrokerAuthenticationScheme> 01:15:25 <pactBrokerPassword>${pactbroker.auth.password}</pactBrokerPassword> 01:15:25 <pactBrokerServerId>${pact.broker.serverId}</pactBrokerServerId> 01:15:25 <pactBrokerToken>${pact.broker.token}</pactBrokerToken> 01:15:25 <pactBrokerUrl>https://redacted</pactBrokerUrl> 01:15:25 <pactBrokerUsername>${pactbroker.auth.username}</pactBrokerUsername> 01:15:25 <pacticipant>PetstoreService</pacticipant> 01:15:25 <pacticipantVersion>${pacticipantVersion}</pacticipantVersion> 01:15:25 <retriesWhenUnknown default-value="0">10</retriesWhenUnknown> 01:15:25 <retryInterval default-value="10">300</retryInterval> 01:15:25 <settings default-value="${settings}"/> 01:15:25 <to default-value="">${pact.tag}</to> 01:15:25 </configuration> 01:15:25 [DEBUG] ======================================================================= 01:15:25 [INFO] 01:15:25 [INFO] --- maven:4.2.7:can-i-deploy (default-cli) @ bryanwconsumer01 --- ... 01:15:26 [DEBUG] Configuring mojo au.com.dius.pact.provider:maven:4.2.7:can-i-deploy from plugin realm ClassRealm[plugin>au.com.dius.pact.provider:maven:4.2.7, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@4b85612c] 01:15:26 [DEBUG] Configuring mojo 'au.com.dius.pact.provider:maven:4.2.7:can-i-deploy' with basic configurator --> 01:15:26 [DEBUG] (f) latest = true 01:15:26 [DEBUG] (f) pactBrokerAuthenticationScheme = basic 01:15:26 [DEBUG] (f) pactBrokerUrl = https://redacted 01:15:26 [DEBUG] (f) pacticipant = PetstoreService 01:15:26 [DEBUG] (f) retriesWhenUnknown = 10 01:15:26 [DEBUG] (f) retryInterval = 300 01:15:26 [DEBUG] (f) settings = org.apache.maven.execution.SettingsAdapter@4a50d04a 01:15:26 [DEBUG] -- end configuration -- 01:15:26 Computer says no ¯\_(?)_/¯ 01:15:26 01:15:26 There is no verified pact between the latest version of PetstoreConsumer (5b926da) and the latest version of PetstoreService (fec1397)```

bryanw
2021-07-20 01:21
One thing to note is that we're using the OSS version of pactbroker: ```x-pact-broker-version: 2.79.0```

uglyog
2021-07-20 01:22
Oh, that's disappointing. Probably no debug statements in that part of the code base. That's on me.

uglyog
2021-07-20 01:23
I'll need to check that version of the broker to see what it returns

uglyog
2021-07-20 01:24
But I think it is quite recent, so I doubt it is that

bryanw
2021-07-20 01:28
the pact-cli works as expected - I have a webhook trigger that does complete and the "pact nirvana" is essentially in place but I would prefer to do this with the maven plugin.

uglyog
2021-07-20 01:28
Can you raise an github issue? It must be a defect

bryanw
2021-07-20 01:29
ok, will do.

matt.fellows
2021-07-20 01:31
> x-pact-broker-version: 2.79.0 that?s fairly new I think, so :crossed_fingers:


abubics
2021-07-20 06:08
I haven't tried `RANDOM_PORT` but this hasn't given me any issues . . . is it just random that's broken? :thinking_face: ```@ExtendWith(SpringExtension::class) @SpringBootTest(webEnvironment = DEFINED_PORT)``` Or is it maybe `RunWith` vs `ExtendWith`?

uglyog
2021-07-20 06:10
Random port works for me

aubilla
2021-07-20 08:06
This is the response I get: ```{ "data": { "findPatientById": { "id": 200016409, "gender": "U", "userRef": null } } }```

ben.clare2
2021-07-20 08:16
has joined #pact-jvm

chris.faulkner
2021-07-20 09:33
This article - really clear and concise. :thumbsup:

github2
2021-07-20 10:33
[pact-foundation/pact-jvm] Issue opened by caoilte

caoilte
2021-07-20 10:35
@uglyog I think you developed the initial xml support so I guess your advice would be of most benefit.

rafael.moral
2021-07-20 11:48
has joined #pact-jvm

danielabbitt
2021-07-20 13:39
Hey all. I'm writing provider tests for a microservice that has 2 controllers so I was planning on splitting my provider tests up to separate classes to reflect each controller. Is this possible? I'm currently facing an issue where it's running all Pacts against both provider test classes which fails as the individual class doesn't satisfy the Pact

github2
2021-07-20 15:25
[pact-foundation/pact-jvm] Issue opened by bawoodruff


david.vancouvering
2021-07-20 15:46
Isn?t ExtendWith junit5? We?re still on junit4, we?re working with old code bases and haven?t wanted to put in the effort to switch

david.vancouvering
2021-07-20 17:33
Hey all. Do you use Scala somewhere? When I add the maven dependencies for Pact, in IntelliJ I am getting this error when we try to start up Akka: ```java.lang.ClassNotFoundException: scala.Serializable at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)```

dimundo
2021-07-20 17:34
#pact-scala-itv has more scala guys ( probably )

david.vancouvering
2021-07-20 17:34
ok thanks

david.vancouvering
2021-07-20 17:35
To clarify, this is a Spring Boot service that happens to use Akka underneath, and I am using the JVM dependencies for Pact

david.vancouvering
2021-07-20 17:36
From the developer's perspective this is all Java

david.vancouvering
2021-07-20 18:02
FYI, yes, the provider junit library includes scala-library. I added an exclusion but still hitting problems so it must be another dependency

andrii.rakhimov
2021-07-20 23:06
has joined #pact-jvm

uglyog
2021-07-20 23:22
There are filters you can use to only run a subset of tests

uglyog
2021-07-20 23:24
It was actually a PR we got, but I have had to maintain it

boris.gordon
2021-07-20 23:25
has joined #pact-jvm

matt.fellows
2021-07-20 23:27
The original JVM implementation was written in Scala (when Pact was created at http://realestate.com.au their tech stack was mostly Ruby, and they were also doing Scala)

matt.fellows
2021-07-20 23:28
It has since been migrated to several intermediate languages, but I believe the current goal is Kotlin

uglyog
2021-07-20 23:31
Can you confirm the character set? Is it UTF-8?

matt.fellows
2021-07-20 23:50
Any chance you could please provide debug level logs of the test Abel? We?ll be able to see what Pact actually receives

mail_4brad
2021-07-21 00:17
Following on from the comment that this isn't checking test vs pact anymore, I would classify that as losing 'conscious control' of the written pact specifications. Normally we need to explicitly change the dsl code for the spec when we change our tests. The validation that the two must match normally saves us from unintended client changes. Is it a problem that we've lost this? Firstly, it's not unique in this, as pact-go has its https://github.com/pact-foundation/pact-go/blob/2.x.x/docs/consumer.md#auto-generate-matchers-from-struct-tags which presumably has the same weakness. But secondly, borrowing an idea from Visual Regression Testing, we could check for deltas as a possible new feature alongside this generation: 1. We already have the previously published consumer contract for each test conveniently stored in our pact broker 2. We could add a new version explicitly against each test (or consumer?) 3. We get pact to check this test spec version against the one in the broker after it's run the consumer contract test 4. If the versions match, but there is a difference between the previous and current contracts for the running test, then fail In this way we're back to 'conscious control'. Now pact is calling out where we've changed the consumer contract for a test and all we need to do is bump a version tag on that test if we want to accept it as the new contract. Contrast this with needing to maintain every field for a builder-generated pact as it stands now. In summary, if this is seen as circumventing a check and balance, then a) is it an issue in the pact-go world?, and b) is a suggestion for gaining that back which isn't required for the generator to be functional, but would provide extra confidence in future.

bryanw
2021-07-21 00:18
@uglyog I tracked this down and just submitted a PR for this issue. The retry predicate was incorrect.

abubics
2021-07-21 01:12
Ah, that probably makes sense :thumbsup:

thanuxxxx
2021-07-21 02:41
Hey guys can anyone confirm that the following code snippet is sufficient for provider side pact verification. :pray: ```URL parameter : params.pactConsumerTags default value 'master' PACT_DEFAULT_ENV = "dev" // let's assume this test is only applicable for dev & after master build we deploy to dev as part of the CI/CD sh "mvn test -Pcontract-tests \ -Dpact.verifier.publishResults=true \ -Dpact.provider.version=${GIT_COMMIT} \ -Dpactbroker.tags=${PACT_DEFAULT_ENV},${params.pactConsumerTags}"```

github2
2021-07-21 07:57
[pact-foundation/pact-jvm] New release _https://github.com/pact-foundation/pact-jvm/releases/tag/4_2_8_ published by uglyog

github2
2021-07-21 09:10
[pact-foundation/pact-jvm] Issue closed by danilchican

brendan.j.donegan
2021-07-21 13:51
has joined #pact-jvm

nathaniel.emmons
2021-07-21 15:31
hey all, i?m seeing some confusing behavior regarding a content type matcher in the pact generated using `http://au.com.dius.pact.consumer.dsl.PactDslWithProvider`: ``` return builder .given("a state") .uponReceiving("get some data") .path(expectedPath) .method("GET") .headers(mapOf("Accept" to "application/fhir+json")) .willRespondWith() .status(200) .headers(mapOf("Content-Type" to "application/fhir+json")) .body(expectedResponseBody.build()) .toPact()``` seems to generate a matcher for the wrong content-type in the pact: ```"header": { "Content-Type": { "combine": "AND", "matchers": [ { "match": "regex", "regex": "application/json(;\\s?charset=[\\w\\-]+)?" } ] } }``` (i?m trying to specify it as application/fhir+json and i?m getting application/json). Anyone have any ideas as to why that might be?

nathaniel.emmons
2021-07-21 15:39
i?m using kotlin with `au.com.dius.pact.consumer:junit5:4.2.5` fwiw

nathaniel.emmons
2021-07-21 15:49
Sorry, i got it. I accidentally pasted a WORKING example above, in a second pact i had been calling `body()` before `headers()` , and body was setting the content-type header first. I?ll leave this thread up in case it helps someone searching for a similar issue in the future.

github2
2021-07-21 18:47
[pact-foundation/pact-jvm] Issue closed by bawoodruff

nathaniel.emmons
2021-07-21 19:41
@poorvasgokhale i was running into similar problems trying to pass properties to ./gradlew test and i realized that i think gradle forks separate JVMs to run the tests or something, and the system properties from the cli -D flags don?t get passed through. If something like that happens for gradle commands in general, that would explain what we were seeing above. https://stackoverflow.com/questions/21406265/how-to-give-system-property-to-my-test-via-gradle-and-d/21406600 discusses this a bit


github2
2021-07-21 21:24
[pact-foundation/pact-jvm] Issue closed by csydvs

github2
2021-07-21 21:24
[pact-foundation/pact-jvm] Issue closed by csydvs

uglyog
2021-07-21 23:10
Can you raise an issue for that. `headers` should always override the values, where `body` should only set it if it is not set

github2
2021-07-22 00:25
[pact-foundation/pact-jvm] Issue opened by bethesque

poorvasgokhale
2021-07-22 04:42
Thanks for pointing this out @nathaniel.emmons . :thumbsup: looks like this is reason..

aubilla
2021-07-22 09:51
These are the logs of the verification in debug ```2021-07-22T11:42:46.797+0200 [QUIET] [system.out] 2021-07-22T11:42:46.797+0200 [QUIET] [system.out] Verifying a pact between Pact between PatientClient (d46b8cee) and PatientService [PENDING] 2021-07-22T11:42:46.798+0200 [QUIET] [system.out] 2021-07-22T11:42:46.798+0200 [QUIET] [system.out] Notices: 2021-07-22T11:42:46.798+0200 [QUIET] [system.out] 1) The pact at https://pact-broker.internal.mydomain.com/pacts/provider/PatientService/consumer/PatientClient/pact-version/94c865ec4c451211e9953bfbfa668eef93c0031a is being verified because it matches the following configured selection criterion: latest pact for a consumer version tagged 'master' 2021-07-22T11:42:46.798+0200 [QUIET] [system.out] 2) This pact is in pending state for this version of PatientService because a successful verification result for a version of PatientService with tag 'master' has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at https://pact.io/pending 2021-07-22T11:42:46.798+0200 [QUIET] [system.out] 2021-07-22T11:42:46.798+0200 [QUIET] [system.out] [from Pact Broker https://pact-broker.internal.mydomain.com/pacts/provider/PatientService/consumer/PatientClient/pact-version/94c865ec4c451211e9953bfbfa668eef93c0031a/metadata/c1tdW3RdPW1hc3RlciZzW11bbF09dHJ1ZSZzW11bY3ZuXT1kNDZiOGNlZQ==] 2021-07-22T11:42:46.801+0200 [QUIET] [system.out] Given patients exist 2021-07-22T11:42:46.801+0200 [QUIET] [system.out] WARNING: State Change ignored as there is no stateChange URL 2021-07-22T11:42:46.802+0200 [DEBUG] [au.com.dius.pact.provider.DefaultStateChange] State Change: "ProviderState(name=patients exist, params={})" -> Ok({}) 2021-07-22T11:42:46.802+0200 [QUIET] [system.out] get patient by id 2021-07-22T11:42:46.803+0200 [DEBUG] [au.com.dius.pact.provider.ProviderVerifier] Verifying via request/response 2021-07-22T11:42:46.854+0200 [DEBUG] [au.com.dius.pact.provider.ProviderClient] Making request for provider au.com.dius.pact.provider.gradle.GradleProviderInfo@3ef1c766[providerVersion=<null>,providerTag=<null>,brokerConfig=au.com.dius.pact.provider.gradle.PactBrokerConsumerConfig([ConsumerVersionSelector(tag=master, latest=true)], true, [master]),name=PatientService,protocol=https,host=https://release-0-9-6.staging.mydomain.com/,port=443,path=/,startProviderTask=<null>,terminateProviderTask=<null>,requestFilter=build_6q62phmlq1uk526hx1lalhtx4$_run_closure19$_closure36$_closure37$_closure39@c8b5db7,stateChangeRequestFilter=<null>,createClient=<null>,insecure=false,trustStore=<null>,trustStorePassword=changeit,stateChangeUrl=<null>,stateChangeUsesBody=true,stateChangeTeardown=false,isDependencyForPactVerify=true,verificationType=REQUEST_RESPONSE,packagesToScan=[],consumers=[ConsumerInfo(name='Pact between PatientClient (d46b8cee) and PatientService', stateChange=null, stateChangeUsesBody=true, packagesToScan=[], verificationType=null, pactSource=BrokerUrlSource(url=https://pact-broker.internal.mydomain.com/pacts/provider/PatientService/consumer/PatientClient/pact-version/94c865ec4c451211e9953bfbfa668eef93c0031a/metadata/c1tdW3RdPW1hc3RlciZzW11bbF09dHJ1ZSZzW11bY3ZuXT1kNDZiOGNlZQ==, pactBrokerUrl=https://pact-broker.internal.mydomain.com/, attributes={}, options={}, tag=null, result=PactBrokerResult(name=Pact between PatientClient (d46b8cee) and PatientService, source=https://pact-broker.internal.mydomain.com/pacts/provider/PatientService/consumer/PatientClient/pact-version/94c865ec4c451211e9953bfbfa668eef93c0031a/metadata/c1tdW3RdPW1hc3RlciZzW11bbF09dHJ1ZSZzW11bY3ZuXT1kNDZiOGNlZQ==, pactBrokerUrl=https://pact-broker.internal.mydomain.com/, pactFileAuthentication=[basic, username, somepassword], notices=[VerificationNotice(when=before_verification, text=The pact at https://pact-broker.internal.mydomain.com/pacts/provider/PatientService/consumer/PatientClient/pact-version/94c865ec4c451211e9953bfbfa668eef93c0031a is being verified because it matches the following configured selection criterion: latest pact for a consumer version tagged 'master'), VerificationNotice(when=before_verification, text=This pact is in pending state for this version of PatientService because a successful verification result for a version of PatientService with tag 'master' has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at https://pact.io/pending), VerificationNotice(when=after_verification:success_true_published_false, text=This pact is still in pending state for any version of PatientService with tag 'master' as the successful verification results with this tag have not yet been published.), VerificationNotice(when=after_verification:success_false_published_false, text=This pact is still in pending state for any version of PatientService with tag 'master' as a successful verification result with this tag has not yet been published), VerificationNotice(when=after_verification:success_true_published_true, text=This pact is no longer in pending state for any version of PatientService with tag 'master', as a successful verification result with this tag has been published. If a verification for a version of PatientService with this tag fails in the future, it will fail the build. Read more at https://pact.io/pending), VerificationNotice(when=after_verification:success_false_published_true, text=This pact is still in pending state for any version of PatientService with tag 'master' as a successful verification result with this tag has not yet been published)], pending=true)), pactFileAuthentication=[basic, username, somepassword], notices=[VerificationNotice(when=before_verification, text=The pact at https://pact-broker.internal.mydomain.com/pacts/provider/PatientService/consumer/PatientClient/pact-version/94c865ec4c451211e9953bfbfa668eef93c0031a is being verified because it matches the following configured selection criterion: latest pact for a consumer version tagged 'master'), VerificationNotice(when=before_verification, text=This pact is in pending state for this version of PatientService because a successful verification result for a version of PatientService with tag 'master' has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at https://pact.io/pending), VerificationNotice(when=after_verification:success_true_published_false, text=This pact is still in pending state for any version of PatientService with tag 'master' as the successful verification results with this tag have not yet been published.), VerificationNotice(when=after_verification:success_false_published_false, text=This pact is still in pending state for any version of PatientService with tag 'master' as a successful verification result with this tag has not yet been published), VerificationNotice(when=after_verification:success_true_published_true, text=This pact is no longer in pending state for any version of PatientService with tag 'master', as a successful verification result with this tag has been published. If a verification for a version of PatientService with this tag fails in the future, it will fail the build. Read more at https://pact.io/pending), VerificationNotice(when=after_verification:success_false_published_true, text=This pact is still in pending state for any version of PatientService with tag 'master' as a successful verification result with this tag has not yet been published)], pending=true)]]: 2021-07-22T11:42:46.855+0200 [DEBUG] [au.com.dius.pact.provider.ProviderClient] method: POST path: /api/pmi/graphql query: {} headers: {Content-Type=[application/json; charset=UTF-8]} matchers: MatchingRules(rules={body=Category(name=body, matchingRules={$.query=MatchingRuleGroup(rules=[au.com.dius.pact.core.model.matchingrules.TypeMatcher@779dad0], ruleLogic=AND)})}) generators: Generators(categories={}) body: PRESENT({"query":"{ findPatientById (id: 200016409) { id gender userRef } } "}) 2021-07-22T11:42:46.869+0200 [DEBUG] [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected: default 2021-07-22T11:42:46.869+0200 [DEBUG] [org.apache.http.client.protocol.RequestAuthCache] Auth cache not set in the context 2021-07-22T11:42:46.869+0200 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection request: [route: {s}->https://https:443][total kept alive: 0; route allocated: 0 of 5; total allocated: 0 of 10] 2021-07-22T11:42:46.869+0200 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection leased: [id: 2][route: {s}->https://https:443][total kept alive: 0; route allocated: 1 of 5; total allocated: 1 of 10] 2021-07-22T11:42:46.869+0200 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Opening connection {s}->https://https:443 2021-07-22T11:42:47.891+0200 [DEBUG] [org.apache.http.impl.conn.DefaultManagedHttpClientConnection] http-outgoing-2: Shutdown connection 2021-07-22T11:42:47.891+0200 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Connection discarded 2021-07-22T11:42:47.891+0200 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection released: [id: 2][route: {s}->https://https:443][total kept alive: 0; route allocated: 0 of 5; total allocated: 0 of 10] 2021-07-22T11:42:47.891+0200 [QUIET] [system.out] Request Failed - https: nodename nor servname provided, or not known 2021-07-22T11:42:47.896+0200 [DEBUG] [au.com.dius.pact.core.pactbroker.PactBrokerClient] Test result = Failed(results=[{message=Request to provider failed with an exception, exception=java.net.UnknownHostException: https: nodename nor servname provided, or not known, interactionId=43cec75f0fbf676ac13a33aa5f8eec6495921d70}], description=Request to provider method failed with an exception) 2021-07-22T11:42:47.897+0200 [DEBUG] [au.com.dius.pact.core.pactbroker.HalClient] Posting JSON to https://pact-broker.internal.mydomain.com/pacts/provider/PatientService/consumer/PatientClient/pact-version/94c865ec4c451211e9953bfbfa668eef93c0031a/metadata/c1tdW3RdPW1hc3RlciZzW11bbF09dHJ1ZSZzW11bY3ZuXT1kNDZiOGNlZQ==/verification-results {"success":false,"providerApplicationVersion":"0.9.7-SNAPSHOT","testResults":[{"interactionId":"43cec75f0fbf676ac13a33aa5f8eec6495921d70","success":false,"mismatches":[],"exceptions":[{"message":"https: nodename nor servname provided, or not known","exceptionClass":"java.net.UnknownHostException"}]}]} 2021-07-22T11:42:47.898+0200 [DEBUG] [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected: default 2021-07-22T11:42:47.898+0200 [DEBUG] [org.apache.http.client.protocol.RequestAuthCache] Auth cache not set in the context 2021-07-22T11:42:47.898+0200 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection request: [route: {s}->https://pact-broker.internal.mydomain.com:443][total kept alive: 0; route allocated: 0 of 5; total allocated: 0 of 10] 2021-07-22T11:42:47.898+0200 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection leased: [id: 3][route: {s}->https://pact-broker.internal.mydomain.com:443][total kept alive: 0; route allocated: 1 of 5; total allocated: 1 of 10]```

matt.fellows
2021-07-22 10:53
There seems to be an error: ```021-07-22T11:42:47.891+0200 [QUIET] [system.out] Request Failed - https: nodename nor servname provided, or not known 2021-07-22T11:42:47.896+0200 [DEBUG] [au.com.dius.pact.core.pactbroker.PactBrokerClient] Test result = Failed(results=[{message=Request to provider failed with an exception, exception=java.net.UnknownHostException: https: nodename nor servname provided, or not known, interactionId=43cec75f0fbf676ac13a33aa5f8eec6495921d70}], description=Request to provider method failed with an exception) 2021-07-22T11:42:47.897+0200 [DEBUG] [au.com.dius.pact.core.pactbroker.HalClient] Posting JSON to https://pact-broker.internal.mydomain.com/pacts/provider/PatientService/consumer/PatientClient/pact-version/94c865ec4c451211e9953bfbfa668eef93c0031a/metadata/c1tdW3RdPW1hc3RlciZzW11bbF09dHJ1ZSZzW11bY3ZuXT1kNDZiOGNlZQ==/verification-results {"success":false,"providerApplicationVersion":"0.9.7-SNAPSHOT","testResults":[{"interactionId":"43cec75f0fbf676ac13a33aa5f8eec6495921d70","success":false,"mismatches":[],"exceptions":[{"message":"https: nodename nor servname provided, or not known","exceptionClass":"java.net.UnknownHostException"}]}]}```

matt.fellows
2021-07-22 10:54
how have you configured the provider?

aubilla
2021-07-22 11:12
Misunderstood your question for a sec.

aubilla
2021-07-22 11:13
This is how the plugin is configured. The provider is a Micronaut app accepting authenticated POST requests on a GraphQL endpoint. ```pact { broker { pactBrokerUrl = 'https://pact-broker.internal.mydomain.com/' pactBrokerUsername = System.getenv("PACT_BROKER_USERNAME") pactBrokerPassword = System.getenv("PACT_BROKER_PASSWORD") } serviceProviders { PatientService { fromPactBroker { selectors = latestTags('master') enablePending = true providerTags = ['master'] } requestFilter = { req -> req.addHeader('X-Auth-Token', 'some token') } protocol = 'https' host = System.getenv("ENV_SERVICE_URL") port = 443 path = '/' } } }``` ~Could it be that the `exception=java.net.UnknownHostException: https: nodename nor servname provided, or not known` is related to the host being resolved through a variable?~ :thinking_face: Discarded EDIT: The host might not be reachable from the CI/CD.

matt.fellows
2021-07-22 11:31
It looks like your ENV var is not being resolved. The request doesn't seem to have a hostname

aubilla
2021-07-22 11:35
Definitely not a Pact issue. Thank you for the help debugging.

matt.fellows
2021-07-22 12:07
Welcome!

francislainy.campos
2021-07-22 13:52
```docker run --rm pactfoundation/pact-cli:latest publish ./target/pacts/ --broker-base-url=http://my-broker.com --consumer-app-version=`git rev-parse HEAD```` Hi, I?m unsure of the path to use here? Tried /target/pacts, target/pacts, ./target/pacts but not of them seem to find my contract

francislainy.campos
2021-07-22 13:56
Thank you

francislainy.campos
2021-07-22 14:13
PWD does not work either. :(

francislainy.campos
2021-07-22 15:11
This worked. Had to mount volumes.

francislainy.campos
2021-07-22 15:11
```docker run --rm -w ${PWD} -v ${PWD}:${PWD} pactfoundation/pact-cli:latest publish ${PWD}/target/pacts --broker-base-url=http://pact-broker-hmh.devel.hmheng-qe.brnp.internal --consumer-app-version=`git rev-parse HEAD````

bryanw
2021-07-22 17:05
Having to reopen - CI is showing this not picking up the updated verification.

github2
2021-07-22 17:11
[pact-foundation/pact-jvm] Issue reopened by bawoodruff

ryn.anderson
2021-07-22 17:41
has joined #pact-jvm

bryanw
2021-07-22 20:01
No, all is good -- it was a pact verification issue

github2
2021-07-22 20:15
[pact-foundation/pact-jvm] Issue closed by bawoodruff

schakalabbi
2021-07-22 21:29
has joined #pact-jvm

v-ratngupta
2021-07-23 03:19
hi

v-ratngupta
2021-07-23 03:23
i have to read OAS file from a enterprise git repo so how can i read the same by using below ```// or in a single constructor AuthorizationValue apiKey = new AuthorizationValue("api_key", "special-key", "header"); OpenAPI openAPI = new OpenAPIV3Parser().readWithInfo( "https://petstore3.swagger.io/api/v3/openapi.json", Arrays.asList(mySpecialHeader, apiKey) );``` like i have to read my openAPi definition from git repo so I'm confused like what value i have to pass in AuthorizationValue's "api_key", "special-key"

v-ratngupta
2021-07-23 03:28
I'm asking here bcz I'm not able to find AuthorizationValue's application example with swagger parser lib

uglyog
2021-07-23 03:52
How is this related to Pact-JVM?

v-ratngupta
2021-07-23 03:55
ohh Sorry. My bad!!

uryadov212
2021-07-23 06:15
@uryadov212 has left the channel

consulting
2021-07-23 12:33
has joined #pact-jvm

galante2123
2021-07-23 14:14
has joined #pact-jvm

dc113604
2021-07-23 14:39
has joined #pact-jvm

kflo
2021-07-23 22:19
what is the easiest way to generate a `datetime` that matches `2021-04-22T18:27:59Z`

kflo
2021-07-23 22:20
this is the format `Instant.now().toString` uses by default

kflo
2021-07-23 22:30
looks like the default format does not include timezone at all. and then if i use the other helper methods (that let me specify pattern), it includes the wrong time zone (system default, but i want UTC)

kflo
2021-07-23 22:31
i guess i will have to use ``` fun datetime( name: String, format: String, example: Instant, timeZone: TimeZone = TimeZone.getDefault() )```

kflo
2021-07-23 22:31
i guess i can make a wrapper for this on our end to reduce boilerplate

kflo
2021-07-23 22:55
oh.. i can?t use that one in the Lambda DSL


kflo
2021-07-23 23:03
``` o.getPactDslObject.datetime( "decisionExpirationDate", DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern, Instant.now(), TimeZone.getTimeZone("UTC") )``` still gives me `+0000` instead of `Z`? :disappointed: ignore the `.now()` i know i?m supposed to use a hard-coded date, just testing

kflo
2021-07-23 23:08
``` o.getPactDslObject.datetime( "decisionExpirationDate", "yyyy-MM-dd'T'HH:mm:ss'Z'", Instant.now(), TimeZone.getTimeZone("UTC") )``` this works but feels even worse lol

kflo
2021-07-23 23:11
really i want the `ISO_INSTANT` format from `DateTimeFormatter`

kflo
2021-07-24 00:19
how do you specify ?empty array? using the lambda DSL syntax?

kflo
2021-07-24 00:22
i can do `o.getPactDslObject.array("name").closeArray()` ? but that seems a bit hacky

kflo
2021-07-24 00:23
i guess the same is true of arrays

kflo
2021-07-24 00:23
there should probably just be a method on the DSL that doesn?t take `Consumer<T>`

uglyog
2021-07-24 01:35
From the Java docs: ```O localized zone-offset offset-O GMT+8; GMT+08:00; UTC-08:00; X zone-offset 'Z' for zero offset-X Z; -08; -0830; -08:30; -083015; -08:30:15; x zone-offset offset-x +0000; -08; -0830; -08:30; -083015; -08:30:15; Z zone-offset offset-Z +0000; -0800; -08:00;```

uglyog
2021-07-24 01:36
You need to use a capital X. So `yyyy-MM-dd'T'HH:mm:ssX`

uglyog
2021-07-24 01:37
It's confusing, you'd think `Z` would be for zone offset with Z for zero, but that would make sense

uglyog
2021-07-24 01:38
Nobody has needed to do that yet

wilkinsweiqiangliang
2021-07-26 01:56
hey guys we are trying to upgrade pact jvm related versions from `4.1.11 -> 4.2.8` , after bump version i get a few package not found error. Would you mind to suggest if our version is not correct?

wilkinsweiqiangliang
2021-07-26 01:56
```error: package au.com.dius.pact.consumer.junit5 does not exist import au.com.dius.pact.consumer.junit5.PactConsumerTestExt;```

wilkinsweiqiangliang
2021-07-26 01:56
```error: cannot find symbol @PactTestFor( ^ symbol: class PactTestFor```

uglyog
2021-07-26 02:04
Make sure you have `au.com.dius.pact.consumer:junit5:4.2.8` as the dependency

wilkinsweiqiangliang
2021-07-26 02:04
yea its already at 4.2.8

wilkinsweiqiangliang
2021-07-26 02:05
we also had `au.com.dius:pact-jvm-provider-junit5` and `au.com.dius:pact-jvm-consumer-junit5` which is at `4.0.10`

uglyog
2021-07-26 02:06
Those are not valid, remove them, you only need the one from above

wilkinsweiqiangliang
2021-07-26 02:06
okay

wilkinsweiqiangliang
2021-07-26 02:06
sure

wilkinsweiqiangliang
2021-07-26 02:09
```import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; import au.com.dius.pact.consumer.junit5.ProviderType;```

wilkinsweiqiangliang
2021-07-26 02:09
after i removed above, seems i cannot resolve these package

uglyog
2021-07-26 02:15
You must have something wrong with your build. The `http://au.com.dius.pact.consumer.junit5` package is from `au.com.dius.pact.consumer:junit5:4.2.8`

wilkinsweiqiangliang
2021-07-26 02:16
:+1: i think might be my build script issue

wilkinsweiqiangliang
2021-07-26 02:16
will double check

uglyog
2021-07-26 02:18
Also, you need to use JVM 11+

wilkinsweiqiangliang
2021-07-26 02:18
yea we are on 13

wilkinsweiqiangliang
2021-07-26 02:25
maybe the problem is using `testImplementation "au.com.dius.pact:consumer:$pactVersion"` instead of `testImplementation "au.com.dius.pact:consumer:junit5:$pactVersion"`

uglyog
2021-07-26 02:26
That could be it

wilkinsweiqiangliang
2021-07-26 02:37
@uglyog :taco: solved

abubics
2021-07-26 02:43
fyi, we ended up with this, and the docs were quite confusing: ```fun LambdaDslObject.zonedDateTime( fieldName: String, example: String = "2021-04-28T00:32:16.450595Z" ): LambdaDslObject = datetime( fieldName, "YYYY-MM-dd'T'HH:mm:ss.SSSSSSXXX", ZonedDateTime.parse(example) )```

dsinecos
2021-07-26 04:49
has joined #pact-jvm

mebenhoeh
2021-07-26 05:20
has joined #pact-jvm

francislainy.campos
2021-07-26 14:04
Hi, is there anything we should do or know about the autogenerated pacts folder as when I run the tests from docker it does not appear there. These are the commands we have for building and running the image ```docker build -f bedrock_tests/Dockerfile -t ed-showcase-pact-container . docker run --rm -v /dev/shm:/dev/shm --shm-size=4g -v $(pwd)/project ed-showcase-pact-container sh start_tests.sh```

matt.fellows
2021-07-26 14:14
See answer in general

dsmileb
2021-07-26 16:06
has joined #pact-jvm

kflo
2021-07-26 18:44
:open_mouth:

kflo
2021-07-26 18:45
which docs?

kflo
2021-07-26 18:48
oh, the java API docs? yeah it?s a bit confusing. lots of time libraries in play as well

kflo
2021-07-26 18:50
and using `X` does work, thanks!

hazel.wright
2021-07-26 19:04
has joined #pact-jvm

github2
2021-07-26 19:36
[pact-foundation/pact-jvm] Issue opened by naushadamin

matt682
2021-07-27 01:32
has joined #pact-jvm

github2
2021-07-27 06:05
[pact-foundation/pact-jvm] Issue opened by IsaacHu

aubilla
2021-07-27 08:26
:sunrise_over_mountains: Morning I?m trying to get my Provider tagged with the branch name like so: ```pact { serviceProviders { PatientService { providerTag = System.getenv("BRANCH_TAG") providerVersion = System.getenv("PROVIDER_VERSION") (...)``` but I?m getting ```> Cannot cast object 'ec555357' with class 'java.lang.String' to class 'java.util.function.Supplier'``` :thread:

aubilla
2021-07-27 08:27
The Provider in the Pact Broker is untagged and it would be great to have at least the branch like I have on the Consumer.

aubilla
2021-07-27 08:28
The difference is that for the Consumer I?m using the CLI and for the Provider, as you?ve seen, I?m using the Gradle plugin.

aubilla
2021-07-27 09:47
:thinking_face: It must be that I?m not putting it in a closure

sagupta
2021-07-27 18:35
has joined #pact-jvm

vbhardwaj.eminent
2021-07-28 05:15
has joined #pact-jvm

miguel.panelo
2021-07-28 07:29
has joined #pact-jvm

otaviio
2021-07-28 07:57
has joined #pact-jvm

patrice.krakow
2021-07-28 10:00
has joined #pact-jvm

david.simpson
2021-07-28 12:51
has joined #pact-jvm

e.alderson004
2021-07-28 17:17
has joined #pact-jvm

uglyog
2021-07-29 03:43
Not sure I understand why you need to Stub out the consumer collaborator and then undo it. Wouldn't the request be based on the model?

uglyog
2021-07-29 03:46
The main thing the Pact DSL gives is all the matchers have been hidden behind the DSL methods with easier to understand terms like `eachLike`, etc. You will need to understand how the matchers work to be able to apply them to the generated JSON

uglyog
2021-07-29 03:47
How are you thinking of dealing with collections?

mail_4brad
2021-07-29 03:54
1/ The request is based on the model. It's stubbed out for the first call where we capture the json payload. Then we make the actual call using the collaborator. (sorry if I missed you question)

mail_4brad
2021-07-29 03:57
2/ noted, but I'm only dealing with the request here. From what I have seen request specs can be all exact* because each spec's stress test is only using the test case provided. And our ratio of spec to test is 1:1. The only reason I've seen so far for making them more fuzzy is documentation of the interface (which isn't a bad reason). Response specs are different entirely and I'm not proposing anything re them. * = when they are generated

mail_4brad
2021-07-29 03:58
3/ I have dealt with a basic array so far in my PoC just by virtue that if a test scenario has 2 items in the list, then the provider test will also contain those 2 same items.

uglyog
2021-07-29 05:31
I think the approach is ok. There is never a right/wrong way to do these, but you seem to have the disadvantages covered to get the benefits of the advantages of it.

uglyog
2021-07-29 05:32
Like you mentioned, any assumptions built into the model will affect the contract tests, so another testing strategy around the models can mitigate that

poorvasgokhale
2021-07-29 05:47
Hello all, is anyone using kotlin and kotest for messagePact consumer test? I see Junit used in all examples available online. But for kotlin ecosystem, kotest seem to be natural choice

abubics
2021-07-29 05:48
I'm using kotlin+kotest, but I haven't done any message pact stuff :cry:

abubics
2021-07-29 05:49
(I might be able to help, if no one else has ideas)

poorvasgokhale
2021-07-29 05:51
I have got request response tests working with kotlin kotest, I am bit struggling with messagePact. If no one else has any examples for messagePact, I will probable seek your help. Thanks @abubics

poorvasgokhale
2021-07-29 05:57
Basically I want to understand what should be implementation of `run` fuction, (like for requestResponsePact it calls mockServer with API.) ```class MessageTestRun() : MessagePactTestRun<Unit> { override fun run(messages: List<Interaction>, context: PactTestExecutionContext?) { messages.forEach { interaction -> ???? //////// what should go here } } }```

abubics
2021-07-29 06:03
If you can provide a link to example Java code, I can help convert it :thumbsup: but probably not for another 3 hours.

poorvasgokhale
2021-07-29 06:07
All examples I can find online are with Junit and use annotation. I am following this example, I got this online https://github.com/christian-draeger/pact-example/blob/master/consumer/src/test/kotlin/com/example/demo/MessagingContractTest.kt

poorvasgokhale
2021-07-29 06:07
It?s kotlin + Junit. Let me know if you could convert it to kotest. Thanks @abubics

mail_4brad
2021-07-29 06:09
Thanks a lot for reviewing it @uglyog. Will need some time to know if it?s worthwhile in practice and we may do both approaches in different consumers and see how our experience compares

jdalessandro
2021-07-29 07:27
has joined #pact-jvm

abubics
2021-07-29 13:30
How do you normally run Pact tests through kotest? I think the only junit-specific stuff in that example is `@Rule` and `@Test`.

abubics
2021-07-29 13:33
My kotest Pact stuff looks like this: ``` class AdminClientPactTest : FeatureSpec({ feature("authentication") { scenario("making unauthorised requests") { val pact = buildPact { uponReceiving("a request without credentials").run { method("GET").matchPath( "/admin/amendments/${RegexUUID}", "/admin/amendments/${ConstUUID}" ) }.willRespondWith().run { status(401) } } val response = pact(auth = false) { checkPublishAmendmentStatus(UUID.randomUUID().toString()) } println("Unauthed response: $response") } }``` for example, where `buildPact` looks like this: ```fun buildPact( builder: PactDslWithProvider.() -> PactDslResponse ): RequestResponsePact = pactBuilder().builder().toPact()``` I guess you just use `expectsToRecieve` instead of `uponReceiving`, and it returns a different type.

abubics
2021-07-29 13:34
Although the link you supplied was for the consumer, not the provider, so maybe there's some other confusion.

abubics
2021-07-29 13:35
In message pact, the provider sends messages, and the consumer receives them.

abubics
2021-07-29 13:38
And there's no provider example in that repo, it says "coming soon" https://github.com/christian-draeger/pact-example#the-provider-1

poorvasgokhale
2021-07-29 13:50
I am interested in consumer side test only for message pact. I have requestResponsePact working on my end. From that example, I don't find `MessagePactProviderRule` for kotest.. it's coming from pact.junit consumer package.. what's equivalent of it in kotest

eric.tang1
2021-07-29 16:22
has joined #pact-jvm

kflo
2021-07-29 18:35
is there some way to inject authentication headers into the requests being made to the provider during verification?

kflo
2021-07-29 18:42
i see here: https://docs.pact.io/provider/handling_auth/ ?Pact-JVM request filter?

kflo
2021-07-29 18:44
i guess `TargetRequestFilter` only works for JUnit?

kflo
2021-07-29 18:45
(for full context, i am trying to do this from scala code, using https://github.com/jbwheatley/pact4s)

kflo
2021-07-29 18:45
@jackbwheatley have you done anything with authentication on the provider side?

kflo
2021-07-29 20:08
it would be handy to have the ability to specify a method on the provider verifier which receives the http request and returns the http request so the user can modify it there if they want

kflo
2021-07-29 20:11
ah, i see it is on `ProviderInfo.requestFilter` ? perfect

jackbwheatley
2021-07-29 21:07
Looks like there are a few things on `ProviderInfo` that we haven't got functionality for, and this seems like a good one to look into next

kflo
2021-07-29 21:08
yep, i?m working on a PR now @jackbwheatley

jackbwheatley
2021-07-29 21:08
Nice

kflo
2021-07-29 21:08
the initial implementation might be a little crude, it will just use the apache `HttpRequest` directly? we can wrap it more in the future if we want to

jackbwheatley
2021-07-29 21:09
I assume that's the http lib being using under the hood?

kflo
2021-07-29 21:09
you can also make it better before it merges, i don?t know `http4s` very well yet haha


jackbwheatley
2021-07-29 21:14
Oh hmm do we need to forward requests, is that why your using http4s?

kflo
2021-07-29 21:15
i wanted to make a new endpoint that requires a bearer token

kflo
2021-07-29 21:15
so i can test the request filter

kflo
2021-07-29 21:15
on the mock provider

jackbwheatley
2021-07-29 21:16
Oh just for tests, no worries then

jackbwheatley
2021-07-29 21:16
I was worried we needed a http client as a dependency

kflo
2021-07-29 21:16
nope, that?s all buried in pact-jvm

jackbwheatley
2021-07-29 21:17
Cool, thanks for looking at this. Hopefully I can review a PR tomorrow! Goodnight from the UK :sleeping:

antklim
2021-07-29 22:25
has joined #pact-jvm


abubics
2021-07-30 00:27
`@Rule` is a junit feature, why do you need it in kotest? :thinking_face:

toffer.lim87
2021-07-30 03:51
has joined #pact-jvm

saurabh.goel
2021-07-30 11:46
Hi Everyone, My provider tests keep failing with status 404, expected 204. for an api test. background: I created a pact like this in my consumer: ``` return builder.given("order exists") .uponReceiving("ack order") .method("POST") .matchPath("/orders/[a-f0-9\\\\-]*/ack", "c12345-0326-1536-dfdf44a-24112") // .matchHeader("Authorization", "Bearer *") .willRespondWith() .status(204) .headers(Map.of("Content-Type", "text/html;charset=utf-8")) .toPact();``` i am creating an order in the @state method in provider. where the order id is 1 Now I want to understand how to ensure the provider test looks with this orderId when it verifies the pact. As per my understanding it is failing with 404 because it cannot find the order.

aphronio
2021-07-30 13:42
has joined #pact-jvm

phil.endsley
2021-07-30 15:29
Usually, this can be done with this: https://docs.pact.io/implementation_guides/jvm/consumer/#having-values-injected-from-provider-state-callbacks But I don't think there's a way to enforce regex matching with it. If you want to enforce the pattern matching, maybe try using state parameters. Then, you could pass the Id into the state method on the provider and create it there.

phil.endsley
2021-07-30 15:31
Don't have a better link handy for jvm, but you should see the options in the dsl for "given" method. https://github.com/pact-foundation/pact-specification/tree/version-3#allow-multiple-provider-states-with-parameters

thanuxxxx
2021-07-30 20:28
Hi, why I am getting this error when I enable pending pact feature ```java.lang.IllegalArgumentException: Pending pacts feature has been enabled, but no provider tags have been specified. To use the pending pacts feature, you need to provide the list of provider names for the provider application version with the providerTags property that will be published with the verification results.``` This is what I have for provider side ```@Provider("myprovider") @PactBroker( scheme = "${pactBroker.scheme}", host = "${pactBroker.host}", enablePendingPacts = "true", includeWipPactsSince = "2021-04-04", authentication = @PactBrokerAuth(username = "${pactbroker.auth.username}", password = "${pactbroker.auth.password}") )``` And this is the CLI command for CI/CD ```sh """mvn test -Pcontract-tests \ -Dpact.verifier.publishResults=true \ -Dpact.provider.version=${GIT_COMMIT} \ -Dpact.provider.tag=${GIT_BRANCH} \ -Dpactbroker.tags=${PACT_DEFAULT_ENV},${params.pactConsumerTags}"""``` Am I missing anything here?

kflo
2021-07-31 00:56
i?m surprised this is still a bug https://github.com/pact-foundation/pact-jvm/issues/497 ? anyone have a workaround?

uglyog
2021-07-31 02:55
Probably because it is not easy to fix

uglyog
2021-07-31 02:57
You need to set the `providerTags` on the `@PactBroker` annotation

github2
2021-07-31 03:41
[pact-foundation/pact-jvm] Issue closed by uglyog

thanuxxxx
2021-07-31 03:41
But I have them in CLI command

thanuxxxx
2021-07-31 03:43
So should I move my provider tag from `CLI` to `@PactProvider`?

thanuxxxx
2021-07-31 03:50
But how do I inject `GIT_BRANCH` into `@PactBroker?`

uglyog
2021-07-31 03:55
You can set `providerTags="${pact.provider.tag}"` on the annotation

github2
2021-07-31 06:05
[pact-foundation/pact-jvm] Issue closed by uglyog

uglyog
2021-07-31 06:19
Actually, it probably just got lost in the history

github2
2021-07-31 06:30
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-07-31 06:48
[pact-foundation/pact-jvm] Issue closed by AbelAlejandro

thanuxxxx
2021-07-31 20:04
Got it! thanks :+1:

bryanw
2021-07-31 22:49
I'd like to be able to share URI specifications between Pact and RestTemplate -- but parameterized paths in Pact JVM are using ${variable} whereas Spring's RestTemplate use {variable} in the path specification. Would it be possible to have an option to change the specifier in Pact JVM?

uglyog
2021-07-31 23:52
Please raise an issue for that

github2
2021-08-01 01:03
[pact-foundation/pact-jvm] New release _https://github.com/pact-foundation/pact-jvm/releases/tag/4_1_24_ published by uglyog

github2
2021-08-01 01:07
[pact-foundation/pact-jvm] Issue opened by bawoodruff


bryanw
2021-08-01 01:08
Thanks!

github2
2021-08-01 01:54
[pact-foundation/pact-jvm] New release _https://github.com/pact-foundation/pact-jvm/releases/tag/4_2_9_ published by uglyog

thanuxxxx
2021-08-01 03:30
It seems `@PactBroker`'s `scheme` ,`host` and some other attributes are deprecated for 4.2.X versions. So what is the alternatives?

github2
2021-08-01 04:05
[pact-foundation/pact-jvm] Issue closed by uglyog

uglyog
2021-08-01 04:07
`url`

github2
2021-08-01 04:19
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-08-01 04:28
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-08-01 04:32
[pact-foundation/pact-jvm] Issue closed by uglyog

fabio882
2021-08-01 19:31
has joined #pact-jvm

mike.key
2021-08-02 03:01
has joined #pact-jvm

eddie
2021-08-02 04:08
has joined #pact-jvm

vbhardwaj.eminent
2021-08-02 05:35
I am getting `java.lang.NoSuchMethodError: 'java.util.List http://au.com.dius.pact.provider.ProviderUtils.findAllPactSources(kotlin.reflect.KClass)'` error on Provider side. I couldn't find much on this on Google. Could anyone guide on how to resolve this issue?

vbhardwaj.eminent
2021-08-02 05:36
My Provider Test is this ::::: ```package com.ebay.ecg.box.gumtree.australia.pactcontract.test; import au.com.dius.pact.provider.junit5.HttpTestTarget; import au.com.dius.pact.provider.junit5.PactVerificationContext; import au.com.dius.pact.provider.junitsupport.IgnoreNoPactsToVerify; import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.State; import au.com.dius.pact.provider.junitsupport.StateChangeAction; import au.com.dius.pact.provider.junitsupport.loader.PactBroker; import au.com.dius.pact.provider.spring.junit5.PactVerificationSpringProvider; import com.ebay.ecg.australia.rest.instanceinfo.InstanceInfo; import com.ebay.ecg.box.boot.persistence.configuration.MySqlTracingEnabledChecker; import com.ebay.ecg.box.gumtree.australia.Application; import com.ebay.ecg.box.gumtree.australia.listing.SyiTransformer; import com.ebay.ecg.box.gumtree.australia.repository.belen.AdRepository; import com.ebay.ecg.box.gumtree.australia.repository.belen.DraftAdRespository; import com.ebay.ecg.box.gumtree.australia.repository.ui.CategoryTemplateRepository; import com.ebay.ecg.box.gumtree.australia.repository.ui.TemplateDetailsRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Bean; import org.springframework.core.env.Environment; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Map; @ExtendWith(SpringExtension.class) @SpringBootTest(classes = Application.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("integeration-test") @Provider("corelistingservice") @PactBroker @IgnoreNoPactsToVerify public class PactVerificationNewTest { @LocalServerPort private int port; @TestConfiguration static class PactVerificationNewTestTestContextConfiguration { @Bean public InstanceInfo instanceInfo() { return new InstanceInfo(); } @Bean public MySqlTracingEnabledChecker mySqlTracingEnabledChecker(Environment environment){ return new MySqlTracingEnabledChecker(environment); } } @Autowired MySqlTracingEnabledChecker mySqlTracingEnabledChecker; @Autowired InstanceInfo instanceInfo; @MockBean AdRepository adRepository; @MockBean DraftAdRespository draftAdRespository; @MockBean CategoryTemplateRepository categoryTemplateRepository; @MockBean TemplateDetailsRepository templateDetailsRepository; @Autowired SyiTransformer syiTransformer; @BeforeEach void setup(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", port)); } @TestTemplate @ExtendWith(PactVerificationSpringProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @State(value = "retrieve DSL", action = StateChangeAction.SETUP) public void retrieveDSL(Map<String, Object> params) { this.syiTransformer.buildNewSyiPageComponentByCategoryId("WEB", 20040L); } }```

matt.fellows
2021-08-02 05:37
I?ve seen these types of errors when you mix and match Pact versions

matt.fellows
2021-08-02 05:37
Can you pleaes share your Pact dependencies?

vbhardwaj.eminent
2021-08-02 05:38
```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.1.17</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.1.17</version> <configuration> <pactBrokerUrl>http://localhost:9292</pactBrokerUrl> <pactBrokerUsername>pact_workshop</pactBrokerUsername> <pactBrokerPassword>pact_workshop</pactBrokerPassword> <tags> <tag>prod</tag> <tag>test</tag> </tags> </configuration> </plugin> </plugins> </build>```


matt.fellows
2021-08-02 05:45
The `@PactBroker` annotation doesn?t have any properties associated with it, so it?s possible that?s the issue (I?m just guessing, but looking at it I can?t see how that would find any pacts)

vbhardwaj.eminent
2021-08-02 05:46
I have seen this documentation on http://Pact.io and I tired with and without plugin, but the same error

vbhardwaj.eminent
2021-08-02 05:47
I have put application.yml ```pactbroker: host: localhost port: "8000" auth: username: pact_workshop password: pact_workshop```

vbhardwaj.eminent
2021-08-02 05:48
And I am building up my provider tests following the example on http://pact.io (https://github.com/pact-foundation/pact-workshop-Maven-Springboot-JUnit5.git)

vbhardwaj.eminent
2021-08-02 05:50
In @uglyog Pact Maven + Springboot + JUnit5 workshop, he has used both dependency and plugin for provider test whereas http://pact.io has suggested to use one of them.

uglyog
2021-08-02 05:58
That method was added in `4.1.11`

matt.fellows
2021-08-02 06:01
Ah yes I see. That?s for consumer tests publishing the contracts

matt.fellows
2021-08-02 06:02
sorry, I?m just trying to help rubber duck debug - hopefully somebody else who?s done it can point to the problem

uglyog
2021-08-02 06:03
It must be your dependencies have an old version of the pact-jvm provider library

uglyog
2021-08-02 06:04
You can see all the dependencies of your project using https://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html


matt.fellows
2021-08-02 06:05
Are you getting the error in the command line or in an IDE Varun?

vbhardwaj.eminent
2021-08-02 06:08
IDE

matt.fellows
2021-08-02 06:09
Does it work from the CLI?

matt.fellows
2021-08-02 06:09
which IDE, out of interest?

vbhardwaj.eminent
2021-08-02 06:09
intellij

vbhardwaj.eminent
2021-08-02 06:10
I don't have maven setup on my CLI, so will have to do some prep before running it from CLI...but intellij works fine for me for other projects

vbhardwaj.eminent
2021-08-02 06:11
do you think I have to rule out this CLI thing, then I can put effort to set up maven on my CLI?

uglyog
2021-08-02 06:12
IntelliJ is probably pulling in an older library. You can try delete the `.idea` directory and then re-importing the project

matt.fellows
2021-08-02 06:13
Does the workshop you referenced work in your IDE?

vbhardwaj.eminent
2021-08-02 06:13
yes

uglyog
2021-08-02 06:15
Also check the external libraries:

uglyog
2021-08-02 06:15
That is the library that has that method

vbhardwaj.eminent
2021-08-02 06:17
my dependency

vbhardwaj.eminent
2021-08-02 06:18
I saw this method but don't know much about Kotlin, why is this error and what is missing in tests to resolve this error

uglyog
2021-08-02 06:19
You have mixed versions

uglyog
2021-08-02 06:19
You have 3.6.13 and 4.1.17


matt.fellows
2021-08-02 06:20
This worries me. I?m now seeing patterns in Java problems :stuck_out_tongue:

vbhardwaj.eminent
2021-08-02 06:21
but I am using only 4.1.17, how it is adding other dependency under the hood not sure

vbhardwaj.eminent
2021-08-02 06:23
let me delete the .m2 for Dius and reimport

uglyog
2021-08-02 06:23
IntelliJ loads all the libraries from all the sub-projects in your project. You might have another one with those dependencies

vbhardwaj.eminent
2021-08-02 06:24
yes I have few others as I was stuck in this problem, so tried few from github

vbhardwaj.eminent
2021-08-02 06:50
I created a new folder for .m2 repository and fresh downloaded the dependencies but getting the same error `java.lang.NoSuchMethodError: 'java.util.List http://au.com.dius.pact.provider.ProviderUtils.findAllPactSources(kotlin.reflect.KClass)'`..Also I am just using 4.1.17 but it imports other dependency as well

uglyog
2021-08-02 06:52
`.m2` won't help, that is just were all the downloads are stored. Delete the `.idea` directory in the project and then import it again.

vbhardwaj.eminent
2021-08-02 07:18
I deleted .idea and build the project again but jvm dependency keeps geting downloaded

uglyog
2021-08-02 07:28
Can you provide your full POM file?

vbhardwaj.eminent
2021-08-02 07:34
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>xx.xxx.xxx.box</groupId> <artifactId>xx-boot-parent</artifactId> <version>v5.4.6</version> </parent> <groupId>xxx.xxx.xxx.xxx.xxxx.australia</groupId> <artifactId>xxxx-xxxx-xxxx</artifactId> <version>{revision}</version> <scm> <connection>scm:git:xxx@github.xx.xxx.tools:xxxxx/xxx-xxx-xxx.git</connection> <developerConnection>scm:git:xxx@github.xx.xxx.tools:xxxxx/xxx-xxx-xxx.git</developerConnection> <url>scm:git:xxx@github.xx.xxx.tools:xxxxx/xxx-xxx-xxx.git</url> <tag>HEAD</tag> </scm> <properties> <buildId>local-SNAPSHOT</buildId> <revision>${buildId}</revision> <xxxx-au-core.version>1.46</xxxx-au-core.version> <core-domain-common.version>v1.4.0</core-domain-common.version> <xxxx-au-xxxx-version>1.221</xxxx-au-xxxxx-version> <msdbpool.version>1.3.6.2</msdbpool.version> <hamcrest.version>1.3</hamcrest.version> </properties> <dependencies> <dependency> <groupId>com.xxx.xxx.xxx.australia</groupId> <artifactId>msdbpool</artifactId> <version>${msdbpool.version}</version> <classifier>J8</classifier> </dependency> <dependency> <groupId>com.xxx.xxx.xxx.australia</groupId> <artifactId>core-domain-common</artifactId> <version>${core-domain-common.version}</version> </dependency> <dependency> <groupId>com.xxxx.xxx.box</groupId> <artifactId>box-boot-persistence</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-gcp-starter-logging</artifactId> </dependency> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-graphite</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <scope>provided</scope> <version>1.18.20</version> </dependency> <dependency> <groupId>com.xxxx.xxx.xxxx.australia</groupId> <artifactId>core-user</artifactId> <version>${xxxx-au-core.version}</version> </dependency> <dependency> <groupId>com.xxxx.xxxx.xxxxx.australia</groupId> <artifactId>core-common</artifactId> <version>${xxxx-au-core.version}</version> </dependency> <dependency> <groupId>com.xxxx.xxxx.xxxxx.australia</groupId> <artifactId>core-util</artifactId> <version>${xxxx-au-core.version}</version> </dependency> <dependency> <groupId>com.xxxx.xxxx.xxxxx.australia</groupId> <artifactId>core-ad2</artifactId> <version>${xxxxxx-au-core.version}</version> </dependency> <dependency> <groupId>com.xx.xxxx.box</groupId> <artifactId>xxxxx-au-xxxxx</artifactId> <version>${xxxxx-au-xxxxx-version}</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> <exclusion> <groupId>org.powermock</groupId> <artifactId>powermock-module-junit4</artifactId> </exclusion> <exclusion> <groupId>org.powermock</groupId> <artifactId>powermock-api-mockito</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>com.vaadin.external.google</groupId> <artifactId>android-json</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-all</artifactId> <version>${hamcrest.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>com.ebay.ecg.box</groupId> <artifactId>box-boot-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>http://au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.1.13</version> <scope>test</scope> </dependency> </dependencies> </project>

uglyog
2021-08-02 07:41
That looks ok. Can you check your boot-parent POM to see if it brings in the older libs?

kflo
2021-08-02 16:40
thanks for the quick turnaround? verifying it now

github2
2021-08-02 22:52
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-08-02 22:54
[pact-foundation/pact-jvm] Issue closed by uglyog

vbhardwaj.eminent
2021-08-03 03:02
Thanks @uglyog and @matt.fellows, the issue is resolved, as @uglyog pointed I removed the old dependency from parent pom and it worked. Now, I am seeing a bit confusing thing on Pact broker. My consumer tests are in jest with mock json having data type of `decimal` but when the pact is published on pact broker its converted to `int.`Therefore, my provider which is in springboot throws an error `Expected 0 (Integer) but received 0.0 (Decimal)`

vbhardwaj.eminent
2021-08-03 03:24
Thanks @uglyog and @matt.fellows, the issue is resolved, as @uglyog pointed I removed the old dependency from parent pom and it worked. Now, I am seeing a bit confusing thing on Pact broker. My consumer tests are in jest with mock json having data type of `decimal` but when the pact is published on pact broker its converted to `int.`Therefore, my provider which is in springboot throws an error `Expected 0 (Integer) but received 0.0 (Decimal)`

uglyog
2021-08-03 03:25
What is in the Pact file?

vbhardwaj.eminent
2021-08-03 03:35
you mean the contract on pacy broker

uglyog
2021-08-03 03:37
Your Jest tests should be creating a Pact file. What are they writing to that file for the field?

matt.fellows
2021-08-03 03:47
That?s a JS/JSON thing.

vbhardwaj.eminent
2021-08-03 03:47
its writing `int`

matt.fellows
2021-08-03 03:48
TL;DR - don?t do `1.0` (JS will convert it to 1), do something like `1.02`. You can see for yourself in a JS console in the browser or in a local node process:

uglyog
2021-08-03 03:48
Your provider than needs to return an integer value, not a floating point one

matt.fellows
2021-08-03 03:48
I responded in another thread

matt.fellows
2021-08-03 03:48
JS/JSON with int/float is fun

matt.fellows
2021-08-03 03:49
JS will cast `1.0` back to an int of `1`

matt.fellows
2021-08-03 03:49
do `1.1` or something that means it doesns?t need to compact it to an int

vbhardwaj.eminent
2021-08-03 03:59
if I have to use `0.0`, is there a way to tackle this

matt.fellows
2021-08-03 04:11
no, JS literally cannot tell the difference and JSON doesn?t have a type other than `number`

matt.fellows
2021-08-03 04:11
it?s not a Pact thing, it?s a JS/JSON thing

matt.fellows
2021-08-03 04:12
A more general point

matt.fellows
2021-08-03 04:13
if you need precision in APIs and you?re using JSON, don?t send it as a number, send it as a string

matt.fellows
2021-08-03 04:13
decimal places will be preserved

matt.fellows
2021-08-03 04:13
you can then parse the string back into a float/decimal/whatever

vbhardwaj.eminent
2021-08-03 06:09
I can send the decimal as string but it will be published as string in a contract at Pact broker. Now when the state check will happen on the provider side then I need to parse the string so that it can match with the `decimal` on provider side. I have read that request auth can be manipulated in Pact but `how can I manipulate the expected response in Pact .`Do you have some example to refer? @uglyog @matt.fellows

uglyog
2021-08-03 06:12
The problem is your provider is returning the value as `0.0` instead of `0`, you should fix that or use a number matcher (V3 spec)

vbhardwaj.eminent
2021-08-03 06:15
provider will not want to change from double to int as they store double values in the same variable for different components

vbhardwaj.eminent
2021-08-03 06:16
I will see `use a number matcher (V3 spec)`

matt.fellows
2021-08-03 06:20
The issue is the other way Ron

matt.fellows
2021-08-03 06:21
Varun - on your consumer test, use a decimal value that is not zero

matt.fellows
2021-08-03 06:21
it will then be stored as a floating point number in the JSON contract and the provider will return a floating point number and the type will match

matt.fellows
2021-08-03 06:21
my general point was not to change to a string, but if you care about precision, encode precise numbers into strings. It was a distraction and probably caused confusion, sorry about that

uglyog
2021-08-03 06:22
No, it's the provider test: Therefore, my provider which is in springboot throws an error `Expected 0 (Integer) but received 0.0 (Decimal)`

uglyog
2021-08-03 06:22
The provider test is expecting an int, but getting a double from the provider

matt.fellows
2021-08-03 06:22
oh, is this the workshop code?

matt.fellows
2021-08-03 06:22
my apologies

uglyog
2021-08-03 06:23
The problem is the Jest test is writing an int into the pact file

uglyog
2021-08-03 06:23
A number type matcher will solve it

matt.fellows
2021-08-03 06:28
Varun - can you please share the Jest test that you have? Is it in the workshop, or is this your code?

vbhardwaj.eminent
2021-08-03 06:30
I took a reference from a JS workshop

matt.fellows
2021-08-03 06:31
right

matt.fellows
2021-08-03 06:31
so Ron, I think we?re talking across one another

vbhardwaj.eminent
2021-08-03 06:31
i am sharing my code

vbhardwaj.eminent
2021-08-03 06:33
`/* eslint-disable import/no-unresolved */` `import path from 'path';` `import { Pact } from '@pact-foundation/pact';` `// eslint-disable-next-line import/no-unresolved` `// import { eachLike } from '@pact-foundation/pact/dsl/matchers';` `import { API } from './api';` `// eslint-disable-next-line no-unused-vars` `import sampledsl from './sampledsl.json';` `const provider = new Pact({` `consumer: 'xxxxx',` `provider: 'xxxxxxx',` `log: path.resolve(process.cwd(), 'logs', 'pact.log'),` `logLevel: 'warn',` `dir: path.resolve(process.cwd(), 'pacts'),` `spec: 2,` `});` `describe('API Pact test', () => {` `beforeAll(() => provider.setup());` `afterEach(() => provider.verify());` `afterAll(() => provider.finalize());` `describe('xxxxx', () => {` `test('xxxxx xxxx', async () => {` `// set up Pact interactions` `await provider.addInteraction({` `state: 'retrieve DSL',` `uponReceiving: 'xxxxx get DSL for xxxxx',` `withRequest: {` `method: 'GET',` `path: '/xxxx/xxxx/xxxxx/web/18297',` `},` `willRespondWith: {` `status: 200,` `headers: {` `'Content-Type': 'application/json',` `},` `body: sampledsl,` `},` `});` `const api = new API(provider.mockService.baseUrl);` `// make request to Pact mock server` `const dslresponse = await api.getCategoryDsl('18297');` `expect(dslresponse).toStrictEqual(sampledsl);` `});` `});` `});`

matt.fellows
2021-08-03 06:33
what does `sampledsl` look like

vbhardwaj.eminent
2021-08-03 06:33
I have placed sampledsl as a json, its quite big

matt.fellows
2021-08-03 06:34
but that?s the bit I need to help you with


matt.fellows
2021-08-03 06:35
It?s not really an issue, more an understanding of how JS/JSON works

vbhardwaj.eminent
2021-08-03 06:36
my sampledsl is too big so I have placed it as it is instead of how it is shown in JS workshop ``` body: eachLike({ id: "09", type: "CREDIT_CARD", name: "Gem Visa" }), },```

matt.fellows
2021-08-03 06:42
I understand that, I would do the same

matt.fellows
2021-08-03 06:43
in any case, if you have a value that is `0.0` it will be treated as an integer. There?s no getting around it, it?s just how JS works. Make it something like `0.1` in your consumer, and if you use the `like` matcher, any decimal value on the provider side will match

matt.fellows
2021-08-03 06:43
OR, as Ron said, update to the v3 and just use the `number` matcher (doesn?t care if it?s an `int` or `decimal` etc.)

vbhardwaj.eminent
2021-08-03 06:44
thanks Matt, I am exploring v3

vbhardwaj.eminent
2021-08-03 06:58
it worked --> willRespondWith: { status: 200, headers: { 'Content-Type': 'application/json', }, body: `decimal(sampledsl),` }, });

vbhardwaj.eminent
2021-08-03 07:01
I hope my understanding with this method is correct, it will overlook exact decimal match. And rest of the keys:values will be exact match

matt.fellows
2021-08-03 07:02
hmmmm

matt.fellows
2021-08-03 07:02
is `sampledsl` a decimal value?

matt.fellows
2021-08-03 07:02
`decimal` says ?ensure the provider returns a decimal number, but don?t care about the exact value?

vbhardwaj.eminent
2021-08-03 07:03
its a very long JSON payload but some part of it will look like this

vbhardwaj.eminent
2021-08-03 07:03
{ "id": "xxxxxxx", "componentType": "SECTION", "label": "xxxxxx", "description": "xxxxxxxxxxx", "disclaimers": "", "childComponents": [ { "id": "xxxxxxx", "componentType": "GROUP", "label": "BUNDLE", "description": "", "childComponents": [ { "id": "xxxxxxxx", "componentType": "xxxxxxx", "name": "selectedFeatures", "componentAttributes": { "defaultOption": { "Free": { "id": "xxxxxxxxx", "componentType": "xxxxxx", "componentAttributes": { "color": "xxxxxx", "title": "Free", "subTitle": "xxxxxxxx", "bundlePrice": 0.0, "bundleDetails": [ "xxxxxxx", "xxxxxxx" ], "recommended": true } } }, "options": [ { "Free": { "id": "xxxxxx", "componentType": "xxxxx", "componentAttributes": { "color": "xxxxx", "title": "Free", "subTitle": "xxxxxxx", "bundlePrice": 0.0, "bundleDetails": [ "xxxxx", "xxxxx" ], "recommended": true } } }, { "Plus": { "id": "xxxxxxx", "componentType": "xxxxx", "componentAttributes": { "color": "xxxxxx", "title": "Plus", "subTitle": "xxxxxx", "bundlePrice": 10.0, "bundleDetails": [ "xxxxx", "'xxxxx' add-on", "xxxxx link" ], "recommended": false } } },

vbhardwaj.eminent
2021-08-03 07:03
look at the bundleprice, which is a decimal

matt.fellows
2021-08-03 07:06
so is it not clear why wrapping that JSON payload in the `decimal` matcher is not going to work?

vbhardwaj.eminent
2021-08-03 07:11
I am validating my understanding on decimal wrapper, that it will do two things: 1. match exact decimal value b/w expected and actual. 2. will not affect the boolean and strings

matt.fellows
2021-08-03 07:12
1. Yes 2. No, matchers must be applied at the level they are designed to match. `decimal` matches a single value

matt.fellows
2021-08-03 07:12
i.e. `"bundlePrice": decimal(0.1)`

matt.fellows
2021-08-03 07:13
`like` is an example of a matcher that cascades, so you can pass in an object


vbhardwaj.eminent
2021-08-03 07:14
but I have used the decimal on the sampledsl, which is big json payload. And the test have passed on the provider side

vbhardwaj.eminent
2021-08-03 07:14
body: decimal(sampledsl),

matt.fellows
2021-08-03 07:17
it might work now, but I wouldn?t recommend it. Now, every value needs to match exactly, except for decimals (i?m guessing)

matt.fellows
2021-08-03 07:18
if you ever have an integer, then you won?t be able to differentiate. you?re probably better off wrapping the whole payload in a `like` and adjusting any floating point numbers so they are?t `x.0` and are instead `x.1`. Is there a good reason why you can?t just change those?

vbhardwaj.eminent
2021-08-03 07:24
I am not creating a json on consumer side because its 1300 lines long json payload, so I have placed a sample json provided by provider in the root. And refer it as sampledsl in the pact code. All the examples you have shared is building the Json so you can manipulate them and they are very small json.

matt.fellows
2021-08-03 07:25
Does the consumer need all 1300 lines or just a subset of it?

vbhardwaj.eminent
2021-08-03 07:26
yes, consumer is building UI based on this Json payload from provider

matt.fellows
2021-08-03 07:27
I?d highly recommend reading and watching this video: https://docs.pact.io/consumer/

matt.fellows
2021-08-03 07:27
I?m worried that your consumer tests are going to be brittle

matt.fellows
2021-08-03 07:28
And learn how `like` and `eachLike` work. 1300 lines matching on exact values is going to be a pain in the butt for the provider if they ever change their data

saurabh.goel
2021-08-03 16:00
thanks @phil.endsley. i understood and it does look like exactly what i need. But, i believe i need to do some work at the producer side too. in order to generate such Id and then ensuring that it is available for the interaction verifier. If you have any example from the producer side. kindly share that too.

vbhardwaj.eminent
2021-08-03 23:33
Morning @matt.fellows, the video was very helpful from Beth. Thanks Matt. Now, I have understood the difference b/w `like` and `eachlike.` Actually, I have gone through most of the videos on Pactflow channel when I was setting up myself to write the contract test with Pact/spring contract. But actual understanding of concepts happening when I am implementing the tests. Could you `please share the provider side best practice` as Beth only consumer side in that video. And I couldn't find the provider side video on Pactflow channel. `Would I able to find the slides` for these videos on http://Pact.io as I am planning to do presentation with my FE/BE teams.

matt.fellows
2021-08-04 01:08
Yeah, I mostly learn by doing also

matt.fellows
2021-08-04 01:08
I don?t think we have a recording of provider best practices, but check out the AMA page on our docs - there?s definitely a few things there. Also, there is a page in the docs about provider best practices too


matt.fellows
2021-08-04 01:10
(that includes provider best practices too)

vbhardwaj.eminent
2021-08-04 01:10
Thanks Matt!

marvin.kienitz
2021-08-05 07:20
has joined #pact-jvm

marvin.kienitz
2021-08-05 07:23
Hey, I'm using the Maven Plugin to publish our pacts and want to also verify my providers with it. For Async Providers that's no problem, as they require no running service. But the HTTP Providers require that a service is available, but I am unable to find, if I can somehow start the service before the providers are being verified (for example with testcontainers). My endgoal is, that the publishing of pacts and the verification will be included in the normal build-cycle. Here I cannot rely on the fact, that a service is already running.

vbhardwaj.eminent
2021-08-05 08:38
@marvin.kienitz Clarifying on your problem that @Springboottest and testcontainer are not able to solve your problem

marvin.kienitz
2021-08-05 08:40
If I would verify my publishers via JUnit I could use testcontainers (that's what we used before), but when verifying publishers via the maven plugin I have no ability to do that.

vbhardwaj.eminent
2021-08-05 08:43
have you tried this dependency ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.1.17</version> <scope>test</scope> </dependency>```

vbhardwaj.eminent
2021-08-05 08:44
i am running tests using this dependency with @springboottest

marvin.kienitz
2021-08-05 08:44
I do not want to use JUnit as stated. Also I'm not using Spring.

vbhardwaj.eminent
2021-08-05 08:44
ohh I see

vbhardwaj.eminent
2021-08-05 08:46
Sorry mate then I might not have any input, hopefully experts will answer soon

danieljak
2021-08-05 10:09
has joined #pact-jvm

tausif2909
2021-08-05 13:03
Hello, After upgrading pact-broker to `2.80.0` from `2.23.4` my consumer build start failing while publishing the pacts to pact-broker, It publishes the first pact fine, but while publishing the second one it throws below error:

tausif2909
2021-08-05 13:03
```[INFO] [INFO] --- pact-jvm-provider-maven:4.0.10:publish (default-cli) @ flex-publishindexer-acceptance-tests --- Publishing 'flex-publishindexer-service-flex-authentication-service.json' ... HTTP/1.1 200 OK Publishing 'flex-publishindexer-service-flex-fastobject-service.json' ... [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 34.221 s [INFO] Finished at: 2021-08-05T17:07:50+05:30 [INFO] ------------------------------------------------------------------------ [ERROR] Premature end of chunk coded message body: closing chunk expected -> [Help 1] org.apache.http.ConnectionClosedException: Premature end of chunk coded message body: closing chunk expected at org.apache.http.impl.io.ChunkedInputStream.getChunkSize (ChunkedInputStream.java:266) at org.apache.http.impl.io.ChunkedInputStream.nextChunk (ChunkedInputStream.java:225) at org.apache.http.impl.io.ChunkedInputStream.read (ChunkedInputStream.java:184) at org.apache.http.conn.EofSensorInputStream.read (EofSensorInputStream.java:135) at sun.nio.cs.StreamDecoder.readBytes (StreamDecoder.java:284) at sun.nio.cs.StreamDecoder.implRead (StreamDecoder.java:326) at sun.nio.cs.StreamDecoder.read (StreamDecoder.java:178) at java.io.InputStreamReader.read (InputStreamReader.java:184) at java.io.BufferedReader.read1 (BufferedReader.java:210) at java.io.BufferedReader.read (BufferedReader.java:286) at java.io.Reader.read (Reader.java:140) at kotlin.io.TextStreamsKt.copyTo (ReadWrite.kt:123) at kotlin.io.TextStreamsKt.copyTo$default (ReadWrite.kt:120) at kotlin.io.TextStreamsKt.readText (ReadWrite.kt:107) at au.com.dius.pact.core.pactbroker.HalClient.uploadJson (HalClient.kt:443) at au.com.dius.pact.core.pactbroker.PactBrokerClient.uploadPactFile (PactBrokerClient.kt:193) at au.com.dius.pact.provider.maven.PactPublishMojo.execute (PactPublishMojo.kt:77) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) [ERROR] [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ConnectionClosedException```

univ.anirudh
2021-08-05 13:22
has joined #pact-jvm

james.perepiczka
2021-08-05 16:29
has joined #pact-jvm

james.perepiczka
2021-08-05 16:35
Hi, Whenever I try and do a pactVerify in Gradle, I get the error '`No annotated methods were found for interaction'. You need to provide a method annotated with @PactVerifyProvider("a task outcome response from worker") on the classpath that returns the message contents.` but if I run the provider tests directly it pulls the contracts from the broker and validates them fine. Is there any extra config I need in the build.gradle file?

j3rry.wan9
2021-08-05 21:44
has joined #pact-jvm

uglyog
2021-08-05 22:55
With Maven, you can use the integration test phase, which has a pre- and post- phase for starting and shutting down apps. You'll need to find the Maven plugins to do that.

uglyog
2021-08-05 22:55
Then you need to bind the pact:verify goal to run as the integration test phase.

uglyog
2021-08-05 22:56
TBH, it will be easier to do this with Gradle

uglyog
2021-08-05 22:58
Is there a proxy running in front of your broker? What version of Pact-JVM are you using?

uglyog
2021-08-05 22:59
By "I run the provider tests directly", do you mean running them as unit tests?

sadikshahidain
2021-08-06 02:14
has joined #pact-jvm

tausif2909
2021-08-06 06:11
```<dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-junit5</artifactId> <version>4.0.10</version> </dependency>``` I am using this version, It was publishing all the interactions perfectly fine till we were on `2.23.4`

tausif2909
2021-08-06 06:22
we moved our pact-broker to kubernetes

uglyog
2021-08-06 06:26
`Premature end of chunk coded message body` means there was an HTTP error

uglyog
2021-08-06 06:26
That's why I asked about the proxy server

uglyog
2021-08-06 06:27
Did you only move the updated version to kubernetes?

tausif2909
2021-08-06 06:44
Yes. but one thing is that in the terraform file , we are redirecting to the new url , previously it was on something like `http://pact.abc.net` now we are redirecting it to `http://pact.xyz.net`

tausif2909
2021-08-06 06:45
something like this: ``` resource "aws_route53_record" "pact" {``` ```+ Added: zone_id = var.route53_id``` ```+ Added: ttl = 60``` ```+ Added: type = "CNAME"``` ```+ Added: name = "http://pact.abc.net"``` ```+ Added: records = ["http://pact.ci.xyz.net"]``` ```+ Added: }```

uglyog
2021-08-06 06:46
Something is interfering with the HTTP response from the broker. It is a networking issue

tausif2909
2021-08-06 06:49
ok, thanks for the response, let me check with the ops

marvin.kienitz
2021-08-06 11:10
actually I have already bound the pact:verify to the post-integration phase, but thanks for the hint, to start the application with a separate Plugin.

marvin.kienitz
2021-08-06 11:13
I got it working, that I start our infrastructure and app before the REST providers are verified. Unfortunately I'm using Testcontainers and thus the Port of the App is basically random. *Any idea how I can tell the Pact Maven Plugin to use a dynamic port?* maybe via env vars, that I set previously. One easy solution, of course, is to set a fixed forwarded port, but this will cause other headaches.

tausif2909
2021-08-06 11:52
It worked with local setup of pact-broker with latest version, means that was not an upgrade issue.. I have reported to our ops team to fix that. Thanks @uglyog

ganginenik
2021-08-06 18:14
has joined #pact-jvm

uglyog
2021-08-07 00:48
You can try modify the URI using a request filter: https://github.com/pact-foundation/pact-jvm/tree/master/provider/maven#modifying-the-requests-before-they-are-sent but it would be better if there is a JVM system property you can set.

uglyog
2021-08-07 00:48
Please raise an issue for that

github2
2021-08-07 06:28
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-08-07 06:35
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-08-08 03:33
[pact-foundation/pact-jvm] Issue closed by uglyog

github2
2021-08-08 03:40
[pact-foundation/pact-jvm] Issue closed by uglyog

kflo
2021-08-08 21:26
how can i publish pact-jvm to my local maven repository?

kflo
2021-08-08 21:28
i tried `./gradlew publishToMavenLocal` but it resulted in an error

kflo
2021-08-08 21:28
`> Task :consumer:signMavenPublicationPublication FAILED` `FAILURE: Build failed with an exception.`


kflo
2021-08-08 22:07
should probably update the documentation

kflo
2021-08-08 22:08
can we just disable signing for local publish?

uglyog
2021-08-08 22:33
How do you know when it is a local publish versus a non-local one?

kflo
2021-08-08 22:33
well i did call `publishToMavenLocal`

uglyog
2021-08-08 22:37
Sure, but the build config doesn't know that

kflo
2021-08-08 22:43
ugh now i?m stuck on: > Execution failed for task ?:consumer:signMavenPublicationPublication?. > > org.bouncycastle.openpgp.PGPException: unknown public key algorithm encountered

uglyog
2021-08-08 22:45
Just comment out build.grade:193

uglyog
2021-08-08 22:45
```signing { sign publishing.publications.mavenPublication }```

kflo
2021-08-08 22:47
yeah i tried that too

kflo
2021-08-08 22:47
but then it failed on Execution failed for task ?:pact-jvm-server:signServerDistributionPublication?. > Cannot perform signing task ?:pact-jvm-server:signServerDistributionPublication? because it has no configured signatory

kflo
2021-08-08 22:48
i?m not sure why it doesn?t like my public key? it was created with default gpg options

uglyog
2021-08-08 22:51
Try comment out applying the plugin on line 22



kflo
2021-08-08 22:53
it doesn?t seem to list the acceptable algorithms? this one is using algorithm 22, whatever that means


uglyog
2021-08-08 22:55
Check your gpg version. Mine is ```$ gpg --version gpg (GnuPG) 2.2.20 libgcrypt 1.8.7 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Home: /home/ronald/.gnupg Supported algorithms: Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA Cypher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256 Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed, ZIP, ZLIB, BZIP2```

kflo
2021-08-08 22:55
? pact-jvm git:(message-handler-verification-1379) ? gpg --version gpg (GnuPG) 2.3.1 libgcrypt 1.9.3 Copyright (C) 2021 Free Software Foundation, Inc.

uglyog
2021-08-08 22:56
Also, make sure you have configured the gradle properties correctly: https://central.sonatype.org/publish/publish-gradle/#credentials

kflo
2021-08-08 22:56
yep i have those ones now

kflo
2021-08-08 22:56
it just doesn?t like my public key algorithm

kflo
2021-08-08 22:56
i can generate a new key? but i don?t know which algorithm it wants

uglyog
2021-08-08 22:57
should be RSA


uglyog
2021-08-08 22:57
Ah, you also need to comment out pact-jvm-server/build.gradle:85

kflo
2021-08-08 23:00
maybe we can have a `System.env.DISABLE_SIGNING` or something


kflo
2021-08-08 23:05
Daemon will be stopped at the end of the build after running out of JVM memory ERROR: Metaspace java.lang.OutOfMemoryError: Metaspace

kflo
2021-08-08 23:05
do i need to configure that somewhere?

uglyog
2021-08-08 23:07
What JVM version are you using?

kflo
2021-08-08 23:07
? pact-jvm git:(message-handler-verification-1379) ? java --version openjdk 11.0.11 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

uglyog
2021-08-08 23:10
There is a JVM parameter for that: `-XX:MaxMetaspaceSize`

kflo
2021-08-08 23:10
how do i provide that to gradlew? i don?t know gradle very well

uglyog
2021-08-08 23:10
You can set it with `GRADLE_OPTS` environment variable

uglyog
2021-08-08 23:11
`GRADLE_OPTS='-XX:MaxMetaspaceSize=350m'`

uglyog
2021-08-08 23:11
You will have to find the value that works

kflo
2021-08-08 23:16
would be nice to put some defaults in the project `gradle.properties`


uglyog
2021-08-08 23:18
The problem is the defaults need to be different depending on the machine and JVM version used

kflo
2021-08-08 23:19
depending on the machine seems odd, but at least for development a JDK version can be recommended?

kflo
2021-08-08 23:20
2G was not enough, but it seems to like 3G so far? but now i get this

kflo
2021-08-08 23:20
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ?:provider:maven:pluginDescriptor?. > Process ?command ?sh?' finished with non-zero exit value 127


kflo
2021-08-08 23:23
> commandLine ?sh?, ?-c?, ?mvn -f ${buildDir}/poms/pom.xml --settings src/main/resources/settings.xml -e -B org.apache.maven.plugins:maven-plugin-plugin:3.6.1:descriptor?

kflo
2021-08-08 23:23
¯\_(?)_/¯

kflo
2021-08-08 23:25
i guess i am missing `mvn`, will install it

kflo
2021-08-08 23:29
okay it finally succeeded :sweat_smile:

uglyog
2021-08-08 23:30
:tada:

github2
2021-08-09 02:05
[pact-foundation/pact-jvm] New release _https://github.com/pact-foundation/pact-jvm/releases/tag/4_3_0-beta_0_ published by uglyog

james.perepiczka
2021-08-09 08:41
Yes, I found out what the issue was. I needed to add the module to the test class path, is there a way of specifying the classpath to use in gradle for the pactVerify task? We ended up doing something like the below, which one of our devs thought was a bit hacky ```pactVerify.doFirst{ test { classpath += files('src/contract-test/java') } }```

marvin.kienitz
2021-08-09 11:29
I got it working by customizing the request, thanks for that! But I agree, it would be handier to have a system property that can be set

github2
2021-08-09 12:04
[pact-foundation/pact-jvm] Issue opened by JapuDCret


marvin.kienitz
2021-08-09 13:00
is there a way to allow insecure SSL for the Pact *Broker*? There are ways to configure it for the client, that'll be used for the providers: 1. https://docs.pact.io/implementation_guides/jvm/provider/maven/#enabling-insecure-ssl 2. https://docs.pact.io/implementation_guides/jvm/provider/maven/#modifying-the-http-client-used

github2
2021-08-09 15:24
[pact-foundation/pact-jvm] Issue opened by JapuDCret


george.south
2021-08-09 21:51
@george.south has left the channel

uglyog
2021-08-09 23:02
What's the point of running the broker over TLS if you are just going to enable insecure SSL? It defeats the purpose of using a secure protocol.

uglyog
2021-08-09 23:06
The plugin runs as part of the Gradle process, so you need to add it to the build classpath (not the project). You can use the `buildscript` block to do that.

xiaoyewang
2021-08-10 01:13
has joined #pact-jvm

mfellows_admin
2021-08-10 02:52
has joined #pact-jvm

marvin.kienitz
2021-08-10 07:20
I agree, but unfortunately we (large organization) are limited by our internal IT, which only provides SSL certificates that have too long expiry times and are therefore not accepted by browsers (or the HalClient for that matter). So it would be nice to have this option

qingyuliu
2021-08-10 09:27
has joined #pact-jvm

saurabh.goel
2021-08-10 09:35
Hi All, How can I log what and how the context.verifyInteraction(); is doing internally? Also, How do i know what data is available to the context. I am asking these questions because I believe I created the required data through the state method but my tests still fail with 404 error

marvin.kienitz
2021-08-10 09:45
can you post the whole error message? Also: a 404 might hint to a provider for which no consumers exist

saurabh.goel
2021-08-10 09:46
Verifying a pact between Pact between OPA (1.0.6) and OMA Notices: 1) The pact at http://localhost/pacts/provider/OMA/consumer/OPA/pact-version/e1b91513c5ee3e4c1a21d25020d01dd08993ab02 is being verified because the pact content belongs to the consumer version matching the following criterion: * latest version of a consumer that has a pact with OMA (1.0.6) [from Pact Broker http://localhost/pacts/provider/OMA/consumer/OPA/pact-version/e1b91513c5ee3e4c1a21d25020d01dd08993ab02/metadata/c1tdW2xdPXRydWUmc1tdW2N2XT0xNw] Given order exists ack order returns a response which has status code 204 (FAILED) has a matching body (OK)

saurabh.goel
2021-08-10 09:47
Failures: 1) Verifying a pact between OPA and OMA - ack order 1.1) StatusMismatch: expected status of 204 but was 404 2021-08-10 11:17:34,804 [WARN] main a.c.d.p.p.DefaultTestResultAccumulator RQID=82ba5fbc418c4917af89c1ed7cabeb1a - Not all of the 2 were verified. The following were missing: 2021-08-10 11:17:34,804 [WARN] main a.c.d.p.p.DefaultTestResultAccumulator RQID=82ba5fbc418c4917af89c1ed7cabeb1a - cancel order java.lang.AssertionError: Failures: 1) Verifying a pact between OPA and OMA - ack order 1.1) StatusMismatch: expected status of 204 but was 404 at http://au.com.dius.pact.provider.junit5.PactVerificationContext.verifyInteraction(PactJUnit5VerificationProvider.kt:97) at com.deliveryhero.services.oma.service.OrderControllerProducerPactTest.pactVerificationTestTemplate(OrderControllerProducerPactTest.java:145) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestTemplateMethod(TimeoutExtension.java:81) at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.NodeTestTask$DefaultDynamicTestExecutor.execute(NodeTestTask.java:198) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:138) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$2(TestTemplateTestDescriptor.java:106) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:274) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:106) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:221) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

marvin.kienitz
2021-08-10 09:47
its not a 404, but a 204 - does your provider maybe respond with a different HTTP code, than your consumer asks for?

saurabh.goel
2021-08-10 09:48
yes , so it expects 204, but the interaction is returning 404, which means order does not exist

saurabh.goel
2021-08-10 09:48
basically the ack api which i am testing should return 204 if the order exists and 404 if it does not exist

saurabh.goel
2021-08-10 09:49
as i created the order with id=1 in the state method, i would like to get a 204.

saurabh.goel
2021-08-10 09:50
but i do not know what id value is being used by the verify.interaction() method when running the test for pact.

saurabh.goel
2021-08-10 09:50
that is why i wanted to know how to log it, and also a way to see which orders exist in the context

marvin.kienitz
2021-08-10 09:51
could you not also check your service? but I had the same problem, its not easy to get information about the verification process

saurabh.goel
2021-08-10 09:52
actually the service is in prod and works correctly, all the IT tests written work correctly. As this is my first contract test in this project. i am sure i am making a mistake somewhere in the setup. rather then the service being wrong

saurabh.goel
2021-08-10 09:53
@matt.fellows maybe you know :pray:

marvin.kienitz
2021-08-10 09:57
the service is probably fine, but maybe with the logs of it you can get the info that you need

saurabh.goel
2021-08-10 09:57
hmm, yes let me see :people_hugging:

dhairyapatel071996
2021-08-10 20:06
has joined #pact-jvm

beem132
2021-08-10 21:21
has joined #pact-jvm

uglyog
2021-08-10 23:08
You can enable DEBUG logging to see all the details. But the request made will be the one in the Pact file.

rfang
2021-08-11 00:49
has joined #pact-jvm

vbhardwaj.eminent
2021-08-11 06:50
Hi, How can I find out which version of pact spec is used by ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.1.17</version> <scope>test</scope> </dependency>``` My consumer is JS which is using version 2(mentioned in pact file generated on consumer side) and provider is JVM , and as per http://Pact.io -`The current version of the specification is 3.0 for the JVM implementation, and 2.0 for all others.`


vbhardwaj.eminent
2021-08-11 07:19
I used this command `npm i -S @pact-foundation/pact@latest` but still getting "metadata": { "pactSpecification": { "version": "2.0.0" } }

marvin.kienitz
2021-08-11 07:21
that's correct IMO, because v3 is only available as the beta stream If you would use `@pact-foundation/pact@beta` then it should display v3

vbhardwaj.eminent
2021-08-11 07:22
does that mean I have to use v2 on provider side

vbhardwaj.eminent
2021-08-11 07:22
can I rely on Beta>?

subhashnarla
2021-08-11 07:29
has joined #pact-jvm

marvin.kienitz
2021-08-11 07:31
The API is incomplete (see https://github.com/pact-foundation/pact-js/discussions/681), but I would say, if you mostly use it to define Consumer Pacts, it should work. if there are incompatibilities between v2 and v3 I don't know :disappointed:

vbhardwaj.eminent
2021-08-11 07:32
@tjones/@matt.fellows, could you guide on this concern?

matt.fellows
2021-08-11 08:20
The interface to the beta almost certainly will change over time, but it is reliable in the sense that it works and can generate/verify a v3 pact

subhashnarla
2021-08-11 08:20
I am new to pact but was able to create contract testing project using pactfolder..however I want to integrate to a pactbroker like http://pactflow.io ....i have the account but unable to integrate my code to it...there are no java/maven examples that i could refer to...Can you point me to any examples (not teh curl commands but ways to publish/verify contract via http://pactflow.io using a springboot project)


matt.fellows
2021-08-11 08:21
JVM can generate a v2 or a v3 spec, by default it will generate a v3

matt.fellows
2021-08-11 08:21
look at the JVM docs for specifyinsg the version you need

subhashnarla
2021-08-11 08:35
Any idea on 13:59:12.569 [main] DEBUG http://au.com.dius.pact.provider.junit.loader.PactBrokerLoader - Failed to get provider URL from the pact broker http://au.com.dius.pact.core.pactbroker.NotFoundHalResponse: No HAL document found at path 'https://sn.pactflow.io/pacts/provider/Provider_Test/latest'

vbhardwaj.eminent
2021-08-11 08:48
@matt.fellows,my concern is that my consumer is in React-JS which will generate v2, and provider is in JVM which is using junit5spring dependency 4.1.17 to do a verification of pact. `Is it a concern?` as the documentation on http://pact.io says - `The Pact Specification is a document that governs the structure of the actual generated Pact files to allow for interoperability between languages (consider, for example, a JavaScript consumer connecting to a Scala JVM-based provider) , using semantic versioning to indicate breaking changes.` `Each language implementation of Pact needs to implement the rules of this specification, and advertise which version(s) are supported, corresponding closely to which features are available.` `The current version of the specification is 3.0 for the JVM implementation, and 2.0 for all others.`

lucas.rolle
2021-08-11 09:35
Hey everybody, is there a way of defining the "standalone" declaration while using the http://au.com.dius.pact.consumer.xml.PactXmlBuilder? Or should I use a different Pact Builder? The generated XML always uses standalone="no" although I need standalone="yes" and I don't find a way of defining the declaration. Best wishes from Germany

tjones
2021-08-11 09:37
Hmm. I think that's a bit misleading - you should be able to verify V2 pacts with the JVM implementation

vbhardwaj.eminent
2021-08-11 09:43
Thanks for clarifying Tim, that means provider is not concerned as it has to play by the matcher rules set by consumer (v2 spec in my case). Its just v3 has some more matchers available which v2 doesn't have.

lucas.rolle
2021-08-11 09:44
Maybe this documentation could help you: https://docs.pactflow.io/

matt.fellows
2021-08-11 10:09
Each subsequent implementation can read the versions prior to it, but not the other way around

matt.fellows
2021-08-11 10:12
Howtolearn

2021-08-11 10:12
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

matt.fellows
2021-08-11 10:12
There is a maven and springboot workshop therr

matt.fellows
2021-08-11 10:13
It doesn't talk to Pactflow, but the only difference is you use a token (in Pactflow) not user/pass as with OSS


matt.fellows
2021-08-11 10:14
What does your config look like? Looks like you're passing a pact file to the broker annotation, but that doesn't accept a path to a pact file. It just needs the base URL http://sn.pactflow.io

tjones
2021-08-11 10:18
Yes. We should update that documentation, since that's not how semver works.

jkdihenkar
2021-08-11 10:43
has joined #pact-jvm

christian.kampka
2021-08-11 10:51
has joined #pact-jvm

ashwinparthasarathy30
2021-08-11 11:23
has joined #pact-jvm

saurabh.goel
2021-08-11 13:37
Hi All, I am facing error while adding auth header and query parameter while creating the pact. I have tried the following things: ```.headerFromProviderState("abc","Basic ${auth}", "Basic asdhasd=") =========== Map<String, String> headers = new HashMap<String, String>(); headers.put("Authorization", "Basic asdadsdawsd="); .headers(headers) ==================```

saurabh.goel
2021-08-11 13:42
thanks @uglyog I saw this, but could not find how to enable that?

dimundo
2021-08-11 13:57
because of this ? `"Basic ${auth}", "Basic asdhasd="`

saurabh.goel
2021-08-11 13:59
hey dmitry, i have tried with and without expression. but it always fails. also i am even not able to send a query parameter

saurabh.goel
2021-08-11 14:00
for auth header i am now sending it directly fro m the provider by updating the httprequest in the provider state

saurabh.goel
2021-08-11 14:00
but what about the query param?

dimundo
2021-08-11 14:01
can you split problem to 2 ? ? does basic auth works ? ? do query params added ?

saurabh.goel
2021-08-11 14:03
? does basic auth works ? yes ? do query params added ? Nope :disappointed:

dimundo
2021-08-11 14:04
there is nothing about query param in initial things

saurabh.goel
2021-08-11 14:06
``` .queryParameterFromProviderState("vendorId","rpsVendorId=${vendorId}", "rpsVendorId=1")```

saurabh.goel
2021-08-11 14:06
```.query("rpsVendorId=1")```

saurabh.goel
2021-08-11 14:07
both failed

saurabh.goel
2021-08-11 14:09
i tried adding it in the path also directly" ```.pathFromProviderState("/orders/${id}/cancellation?rpsVendorId=${vendorId}","/orders/1/cancellation?rpsVendorId=1")``` but even this fails

dimundo
2021-08-11 14:10
how it fails?

saurabh.goel
2021-08-11 14:11
this is the error message feign.FeignRetryableWithStatusException: status 500 reading OrderController#cancel(String,Cancellation): request: ------------- url: http://localhost:54815/orders/1/cancellation body: {"reason":null,"owner":null,"stage":null,"source":null,"timestamp":null,"causedBy":null} headers: Authorization=Basic Zm9vOmJhcg== Content-Length=88 Content-Type=application/json response: ------------- status: 500 headers: access-control-allow-origin=* content-length=491 content-type=application/json date=Wed, 11 Aug 2021 14:08:09 GMT x-pact-unexpected-request=1 body: { "error": "Unexpected request : \tmethod: POST\n\tpath: \/orders\/1\/cancellation\n\tquery: {}\n\theaders: {Accept=[*\/*], Connection=[keep-alive], Host=[localhost:54815], User-agent=[Java\/11.0.10], Authorization=[Basic Zm9vOmJhcg==], Content-type=[application\/json], Content-length=[88]}\n\tmatchers: MatchingRules(rules={})\n\tgenerators: Generators(categories={})\n\tbody: PRESENT({\"reason\":null,\"owner\":null,\"stage\":null,\"source\":null,\"timestamp\":null,\"causedBy\":null})" } at com.deliveryhero.services.opa.service.oma.OmaApiClient.lambda$buildController$0(OmaApiClient.java:109) at feign.AsyncResponseHandler.handleResponse(AsyncResponseHandler.java:96) at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138) at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89) at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100) at com.sun.proxy.$Proxy33.cancel(Unknown Source) at com.deliveryhero.services.opa.service.oma.OmaApiClientConsumerPactTest.cancel_whenOrderExist(OmaApiClientConsumerPactTest.java:128) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74) at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:221) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

dimundo
2021-08-11 14:13
does `/orders/1/cancellation` work at all?

dimundo
2021-08-11 14:13
error 500 says no

saurabh.goel
2021-08-11 14:13
yes it works once i remove the queryparam entry from the pact builder

saurabh.goel
2021-08-11 14:14
i was able to generate the pact.

dimundo
2021-08-11 14:14
i mean in real world, not in pact

saurabh.goel
2021-08-11 14:15
yes it works :slightly_smiling_face: it is in production. the IT tests works so all is good there

dimundo
2021-08-11 14:16
```url: http://localhost:54815/orders/1/cancellation body: {"reason":null,"owner":null,"stage":null,"source":null,"timestamp":null,"causedBy":null} headers: Authorization=Basic Zm9vOmJhcg== Content-Length=88 Content-Type=application/json response: ------------- status: 500```

saurabh.goel
2021-08-11 14:19
i know you are pointing to 500 error. but the api works. the issue comes when i try to add the query param.

saurabh.goel
2021-08-11 14:20
thanks, i will keep digging, i believe i am making some basic mistake while adding the query param during the pact generation

dimundo
2021-08-11 14:20
w/o query param its just localhost, and probably 200

saurabh.goel
2021-08-11 14:21
so ```http://localhost:54815/orders/1/cancellation``` is path parameter ```but when i try http://localhost:54815/orders/1/cancellation?rpsVendorId=1``` ```it gives error, and does not even show me the ?rpsVendorId=1 portin which i wish to add through queryparams```

saurabh.goel
2021-08-11 14:23
see this is how i am generating the pac ``` return builder.given("order exists", "id", "1") .uponReceiving("cancel order") .method("POST") .pathFromProviderState("/orders/${id}/cancellation?rpsVendorId=${vendorId}","/orders/1/cancellation?rpsVendorId=1") // .willRespondWith() .status(204) .headers(Map.of("Content-Type", "text/html;charset=utf-8")) .toPact(); }``` if i remove the rosVendorId portion from the request it works

andrew.jensen
2021-08-11 16:18
has joined #pact-jvm

matt.fellows
2021-08-11 22:57
the debug flag is up to how you run it

matt.fellows
2021-08-11 22:58
if it?s gradle, it would be something like `./gradlew clean test --debug`

uglyog
2021-08-11 23:02
Can you raise an issue for that

uglyog
2021-08-11 23:04
Don't add the query parameters to the path, there is a separate field for that

vivekkurhe1993
2021-08-12 03:44
has joined #pact-jvm

vbhardwaj.eminent
2021-08-12 05:12
Hi, `How to instruct springboot with java provider to validate against write tag?` I using this dependency but no plugin. Also, I pass my broker details application.yml ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.1.17</version> <scope>test</scope> </dependency>```

matt.fellows
2021-08-12 05:17
do you mean the ?right tag??

vbhardwaj.eminent
2021-08-12 05:19
yes

vbhardwaj.eminent
2021-08-12 05:19
I made a typo error

matt.fellows
2021-08-12 05:21
You might need to give us more detail. Are you using Maven? Gradle? JUnit?

matt.fellows
2021-08-12 05:21
Also, what have you tried so far? There are lots of examples / workshops out there

vbhardwaj.eminent
2021-08-12 05:26
Maven/Junit ```@TestTemplate @ExtendWith(PactVerificationSpringProvider.class)``` I tried this in application.yml ```pactbroker: host: "localhost" port: "8000" auth: username: password: tags: ["prod","master"]```

aakbar
2021-08-12 06:05
has joined #pact-jvm

vbhardwaj.eminent
2021-08-12 06:16
@matt.fellows/@uglyog, please guide

matt.fellows
2021-08-12 06:18
We?re curretnly in a company update for a few hours, so I wouldn?t expcet much from us for a bit

matt.fellows
2021-08-12 06:18
I don?t know how to answer I?m afraid, but I?d be looking to the maven workshop as aguide

matt.fellows
2021-08-12 06:18
If you?re mixing maven/JUnit that?s probably part of the challenge

matt.fellows
2021-08-12 06:18
http://docs.pact.io is your friend

vbhardwaj.eminent
2021-08-12 06:20
`nws I will wait`, but I am not mixing as I am only using junit5spring maven dependency but no maven plugin as mentioned here https://docs.pact.io/implementation_guides/jvm/provider/maven


ringo
2021-08-12 07:38
Hello, I see in the feature list that Pact now supports message based contracts in the JVM implementation. In our Java services, we use Google Cloud Pub/Sub. Can I use Pact message contracts in this setup? Any example that someone can point me to?

github2
2021-08-12 07:47
[pact-foundation/pact-jvm] Issue opened by LucasRll


uglyog
2021-08-12 07:52
With message based contract tests, the tests have been abstracted from the queuing/publishing implementation, so it should work with anything. Read https://dius.com.au/2017/08/22/contract-testing-serverless-and-asynchronous-applications/ and https://dius.com.au/2018/10/01/contract-testing-serverless-and-asynchronous-applications-part-2/ for the general strategy on how to do it

uglyog
2021-08-12 07:55
Have a look at https://github.com/pactflow/example-provider-js-sns, it is testing AWS SNS which I assume will be similar to the Google one

ringo
2021-08-12 07:56
@uglyog thanks for the pointers. This is the information I didn't find so far. Will investigate it. Tnx.

uglyog
2021-08-12 07:56
No prob, here is the example SNS consumer: https://github.com/pactflow/example-consumer-js-sns

tm.buga
2021-08-12 08:55
has joined #pact-jvm

yanivhad
2021-08-12 08:58
has joined #pact-jvm

saurabh.goel
2021-08-12 10:46
:thank_you:

mahajanrupali22
2021-08-12 11:54
I am using pact DSL in Kotlin as below to pass the null values for field ?MOB?. In POST API call with body I have passed liked below but when I run the test case then I am getting error with mismatch for fields. Out of the two fields its giving me only one field ?Name? and JSON file is not generated  ```val PostRequest = PactDslJsonBody() ?.nullValue("MOB") .stringType("Name") `Request(http://HttpMethod.POST, postApiPath, mapOf("EMPDetails to arrayListOf(linkedMapOf("MOB" to null, "Name" to "JohnDoe"))))```` *Errors* Expected a Map with keys [MOB,Name] but received one with keys [Name]

francois.fernandes
2021-08-12 11:55
has joined #pact-jvm

christopher.doherty
2021-08-12 13:07
think that `nullValue` is interpreted as the field existing but it's value is equal to null essentially this ```{ "MOB": null, "Name": "string" }``` vs this ```{ "Name": "string" }``` so if the field doesn't exist, I think you need to leave it out of the contract

mahajanrupali22
2021-08-12 13:20
We need "MOB" filed and some times its value can be null and some times it will take value as string format.

christopher.doherty
2021-08-12 13:21
I'm pretty new to pact testing but I believe that is what provider state is there to handle, so you have one contract for a state where it exists, and another for a state where it doesn't exist

jackbwheatley
2021-08-12 15:53
Hello, when adding options to `ProviderInfo` during verification, does `"includeWipPactsSince"` have to be a string, or can I pass it a `java.util.Date`?

matias.waterloo
2021-08-12 16:17
Hello, how safe is to use V4?


kyle.florence
2021-08-12 16:18
it?s unfortunate though that providing a different type doesn?t cause any error, it just seems to ignore the option

kyle.florence
2021-08-12 16:19
i?m curious in general why pact-jvm uses so much loose typing, it feels very un-java. although i guess the project also has a lot of groovy/kotlin

uglyog
2021-08-12 22:57
Those values are just pass-through. I've had this discussion on another thread about that.

uglyog
2021-08-12 22:58
So unfortunately in this instance, whatever you give is just being passed on as JSON to the broker.

uglyog
2021-08-12 22:58
@matt.fellows :point_up:

uglyog
2021-08-12 23:26
@kflo Can you raise an issue?

uglyog
2021-08-12 23:28
It is not completely implemented yet. For instance, you can use V4 combined Pacts in Pact-JVM but you have to have a single test that verifiers both the HTTP and message interactions, you can't separate them yet.

uglyog
2021-08-12 23:29
Also most language implementations haven't updated the DSLs to support the new features

uglyog
2021-08-12 23:29
Is there a feature you are looking to use?

saurabh.goel
2021-08-13 07:50
Hello, How or where can i set the provider version? pact is taking the default version when i push the verification results

saurabh.goel
2021-08-13 08:36
thanks, i was able to solve this.

poorvasgokhale
2021-08-13 09:09
You can set it as system property. `System.setProperty("pact.provider.version", "1.0")`

saurabh.goel
2021-08-13 09:52
:thank_you:

matias.waterloo
2021-08-13 11:21
to have http and message in a single pact file

matias.waterloo
2021-08-13 11:22
all of our projects are jvm

srinagasai.krishnasan
2021-08-13 14:35
Anyone here tried running a server through `gretty` using `startProviderTask` within `pact`. I am having problems as the gretty server once it starts running, it won't be considered as 100% executed task. I need this gretty task to be called as 100% so I can verify Pact. Lifecycle should be : gretty starts the war -> pact verification -> gretty stops the war What's actually happening is : gretty starts the war (server isup and running all good) but the task never executes 100% . So it's not going to `pactVerification` task

saurabh.goel
2021-08-13 14:35
Hello, How does pact work with callbacks? as the role of provider and consumer is kind of reversed here. who creates the pact in this situation?

johnathan.gilday
2021-08-13 16:40
has joined #pact-jvm

ben.kaiser
2021-08-13 17:47
has joined #pact-jvm

kyle.florence
2021-08-13 17:59
yes i can

github2
2021-08-13 18:00
[pact-foundation/pact-jvm] Issue opened by kflorence


dbekman
2021-08-13 20:51
has joined #pact-jvm

uglyog
2021-08-14 04:26
Use the spawn plugin to execute it as a child-process

uglyog
2021-08-14 04:26
What do you mean by callbacks?

uglyog
2021-08-14 04:32
With the consumer tests it will work fine. On the provider, you will have to verify all interactions in the same test.

saurabh.goel
2021-08-14 10:50
i have an api, it has a callback url. now i want to test the contract of the callback response.

uglyog
2021-08-15 00:52
That's no different from normal HTTP, there are just two interactions. Your API calls the provider, and then the second one the provider calls your API. Two different pacts.

sadikshahidain
2021-08-15 03:08
@sadikshahidain has left the channel

chen
2021-08-15 09:34
has joined #pact-jvm

saurabh.goel
2021-08-15 12:24
Cool, thanks, this is what i was thinking, will try and implement one now.

matias.waterloo
2021-08-15 15:02
excellent! should I expect breaking changes since V4 isnt completely finished? is it stable enough to use it on production?

uglyog
2021-08-15 22:54
We can't guarantee that there won't be breaking changes, because it is still a work in progress.

vbhardwaj.eminent
2021-08-16 05:47
Hi, Is there a way to add branch name and env name for provider? Like we do `-Dpact.provider.tag=dev` to add tag, can I do `-Dpact.provider.branch=pact-test` `-Dpact.provider.env=test`

matt.fellows
2021-08-16 06:02
Unless I?m mistaken, Branch/Env are not yet supported concepts in Pact JVM, where are you getting this idea from? (not an accusation, I?m concerned some documentation has leaked somewhere leading to confusion)

vbhardwaj.eminent
2021-08-16 06:07
no worries Matt, I saw this in one of pact broker image and I liked this idea but couldn't find a way to implement it. Hence I reached out

vbhardwaj.eminent
2021-08-16 06:08
might be @uglyog can confirm


marvin.kienitz
2021-08-16 06:35
is there a `startProviderTask` equivalent for the Pact Maven Plugin?

uglyog
2021-08-16 06:35
There are other Maven plugins that can provide that functionality

tom.willmott
2021-08-16 13:47
has joined #pact-jvm

github2
2021-08-16 16:05
[pact-foundation/pact-jvm] Issue opened by pepperbob

franklin.lucena89
2021-08-16 16:52
has joined #pact-jvm

david.vancouvering
2021-08-17 02:35
Hey. Does the SpringRestPactRunner work with the `@ClassRule` annotation? Or is that not supported? I am trying to set up a WireMock stub of a downstream service

github2
2021-08-17 03:13
[pact-foundation/pact-jvm] Issue closed by uglyog

uglyog
2021-08-17 03:15
Yes, it should

uglyog
2021-08-17 03:15
What issue are you getting?

david.vancouvering
2021-08-17 03:15
I am getting an error in a test initializer complaining that the wiremock service did not appear to be started

david.vancouvering
2021-08-17 03:16
But I am trying another approach where I mock the component in my service rather than wiremocking the dependent service that it calls

david.vancouvering
2021-08-17 03:16
I'll get back to you if I get stuck there again

david.vancouvering
2021-08-17 03:16
thanks!

ram.tripathi
2021-08-17 06:33
has joined #pact-jvm

ricardo.neto
2021-08-17 09:22
has joined #pact-jvm

andrew.patterson
2021-08-17 14:55
has joined #pact-jvm

pshah
2021-08-17 15:31
has joined #pact-jvm

dimundo
2021-08-17 16:16
hi! i?m checking this one https://github.com/pact-foundation/pact-jvm/pull/1147/files i see there are tests, that ? returned consumerPacts are ok, ? and ``` shortDescription 'latest' 'verificationProperties' { pending true wip true notices = [ ... when 'before_verification' text 'This pact is in pending state for this version of Bar because a successful verification result for Bar has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at https://pact.io/pending'``` but cant see something, that will actually check, that `If this verification fails, it will not cause the overall build to fail` is it in some other part ?


dimundo
2021-08-17 16:19
tl;dr - build fails if wip pact check fails :disappointed:

dimundo
2021-08-17 19:38
so, to clarify a bit previous message ? consumer adds new message contract to pact in branch ? provider (not knowing about it) runs test against test env tag + wip enabled expected ? verification passes, disregarding that wip part fails observed ? verification fails as wip part fails

jarmy
2021-08-17 20:31
Hello. How would I go about constructing a `PactDslJsonBody` for the following `AR` elements inside the `similarArtists` array? ``` "similarArtists": [ "AR:166771", "AR:328253", "AR:5050", "AR:59", "AR:148859" ],``` This seems to do the trick but I was wondering if there was a better way ``` .array("similarArtists") .stringType("AR:166771") .stringType("AR:328253") .stringType("AR:5050") .stringType("AR:59") .stringType("AR:148859") .closeArray()```

uglyog
2021-08-17 22:50
It shouldn't fail the build

uglyog
2021-08-17 22:51
Can you raise an issue for that

dylanchase26
2021-08-18 04:11
has joined #pact-jvm

github2
2021-08-18 05:47
[pact-foundation/pact-jvm] Issue opened by dimkin-eu


satish.chandra
2021-08-18 05:54
has joined #pact-jvm

marvin.kienitz
2021-08-18 10:11
I'm getting a `No HAL document found at path` for a Provider that has no consumer pacts, yet. Even though, I have set the plugin config var `failIfNoPactsFound` to true AND annotated the class with `@IgnoreNoPactsToVerify` ```[ERROR] Failed to execute goal au.com.dius.pact.provider:maven:4.2.8:verify (verify-pact-contracts) on project fulfillment-order-planning-service: Execution verify-pact-contracts of goal au.com.dius.pact.provider:maven:4.2.8:verify failed: Call to fetch pacts from Pact Broker failed with an exception: No HAL document found at path 'http://localhost:9292/pacts/provider/MyEventProvider/for-verification' -> [Help 1]```

marvin.kienitz
2021-08-18 10:13
This is my basic config: ``` <plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>${pact.version}</version> <configuration> <pactBrokerUrl>${pact.brokerUrl}</pactBrokerUrl> <projectVersion>${project.version}</projectVersion> <trimSnapshot>true</trimSnapshot> <!-- the pact broker has issues parsing SNAPSHOT versions --> <skipPactPublish>false</skipPactPublish> <failIfNoPactsFound>false</failIfNoPactsFound><!-- FIXME: set to true, once the initial pacts are available --> <tags> <tag>dev</tag> </tags> <systemPropertyVariables> <pact.verifier.publishResults>true</pact.verifier.publishResults> </systemPropertyVariables> <serviceProviders> <serviceProvider> <name>MyEventProvider</name> <verificationType>ANNOTATED_METHOD</verificationType> </serviceProvider> </serviceProviders> </configuration> <executions> <execution> <id>publish-pact-contracts</id> <phase>test</phase> <goals> <goal>publish</goal> </goals> </execution> <execution> <id>verify-pact-contracts</id> <phase>post-integration-test</phase> <goals> <goal>verify</goal> </goals> </execution> </executions> </plugin>```

poorvasgokhale
2021-08-18 11:23
1. To specify array of strings with key as `similarArtists` ```.array("similarArtists") .stringType() .closeArray()``` 2. To specify array of these exact values with key as `similarArtists` ```.array("similarArtists") .stringValue("AR:166771") .stringValue("AR:328253") ... // so on for all values .closeArray()```

poorvasgokhale
2021-08-18 11:25
In general, PACT is to specify expectation in terms of JSON and not values. I would go for option 1 normally unless there is specific need to add exact values in the contract.

marvin.kienitz
2021-08-18 15:30
This might be related to https://github.com/pact-foundation/pact-jvm/issues/455 (and the deprecation of the property `failIfNoPactsFound`). But then there needs to be another way for the Pact Plugin, because I think it does not check for the annotation


marvin.kienitz
2021-08-18 15:59
Can the `loadPactsFromPactBroker` method handle a 404?. https://github.com/pact-foundation/pact-jvm/blob/c5b91dabde1110e6856ef3195fea6298f8352000/provider/maven/src/main/kotlin/au/com/dius/pact/provider/maven/PactProviderMojo.kt#L137-L188 here's also the debug log ```[ERROR] Failed to execute goal au.com.dius.pact.provider:maven:4.2.8:verify (verify-pact-contracts) on project fulfillment-order-planning-service: Execution verify-pact-contracts of goal au.com.dius.pact.provider:maven:4.2.8:verify failed: Call to fetch pacts from Pact Broker failed with an exception: No HAL document found at path 'http://localhost:9292/pacts/provider/MyEventProvider/for-verification' -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal au.com.dius.pact.provider:maven:4.2.8:verify (verify-pact-contracts) on project fulfillment-order-planning-service: Execution verify-pact-contracts of goal au.com.dius.pact.provider:maven:4.2.8:verify failed: Call to fetch pacts from Pact Broker failed with an exception at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:64) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:564) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution verify-pact-contracts of goal au.com.dius.pact.provider:maven:4.2.8:verify failed: Call to fetch pacts from Pact Broker failed with an exception at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:64) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:564) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: java.lang.RuntimeException: Call to fetch pacts from Pact Broker failed with an exception at au.com.dius.pact.provider.ProviderInfo.hasPactsFromPactBrokerWithSelectors (ProviderInfo.kt:95) at au.com.dius.pact.provider.maven.PactProviderMojo.loadPactsFromPactBroker (PactProviderMojo.kt:186) at au.com.dius.pact.provider.maven.PactProviderMojo.execute (PactProviderMojo.kt:111) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:64) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:564) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: au.com.dius.pact.core.pactbroker.NotFoundHalResponse: No HAL document found at path 'http://localhost:9292/pacts/provider/FOP-Event-PlannedPackageReleased-Provider/for-verification' at au.com.dius.pact.core.pactbroker.HalClient.handleHalResponse (HalClient.kt:304) at au.com.dius.pact.core.pactbroker.HalClient.access$handleHalResponse (HalClient.kt:142) at au.com.dius.pact.core.pactbroker.HalClient$postJson$3.invoke (HalClient.kt:479) at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith (KotlinLanguageSupport.kt:38) at au.com.dius.pact.core.pactbroker.HalClient.postJson (HalClient.kt:477) at au.com.dius.pact.core.pactbroker.PactBrokerClient$fetchPactsUsingNewEndpoint$2.invoke (PactBrokerClient.kt:291) at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith (KotlinLanguageSupport.kt:38) at au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchPactsUsingNewEndpoint (PactBrokerClient.kt:290) at au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchConsumersWithSelectors (PactBrokerClient.kt:249) at au.com.dius.pact.provider.ProviderInfo.hasPactsFromPactBrokerWithSelectors (ProviderInfo.kt:84) at au.com.dius.pact.provider.maven.PactProviderMojo.loadPactsFromPactBroker (PactProviderMojo.kt:186) at au.com.dius.pact.provider.maven.PactProviderMojo.execute (PactProviderMojo.kt:111) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:64) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:564) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) [ERROR] [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException```

jarmy
2021-08-18 16:13
Ah, TIL that you can just use `.stringType()` . Thanks @poorvasgokhale!

saurabh.goel
2021-08-18 18:47
Hi Everyone, I recently implemented the ProviderStateCallback to inject a field in my contract test. But, I was writing the tests from both provider and consumer side. What if the provider and consumer are two different teams. . Is there a way for the customer to know which provider states already exist. what parameters the provider state is injecting already. if consumer writes a new test which requires providerStateCallback, do we need to request this from the provider or is there a way pact can enable this communication.

flynnhandley
2021-08-18 22:30
has joined #pact-jvm

matt.fellows
2021-08-18 22:37
Good question

matt.fellows
2021-08-18 22:37
we?ve talked about making a command or visualisation in the broker for this

matt.fellows
2021-08-18 22:38
but no feature request has been raised - maybe pop it in here https://pact.canny.io/feature-requests ?

uglyog
2021-08-18 23:05
`@IgnoreNoPactsToVerify` is used by JUnit tests, not when verifying using the Maven plugin

saurabh.goel
2021-08-18 23:22
Thanks matt, i have added the post.

github2
2021-08-19 04:04
[pact-foundation/pact-jvm] Issue opened by jigarnprajapati

marvin.kienitz
2021-08-19 05:37
@uglyog yes, I figured as much, but why does the plugin property `failIfNoPactsFound` not work then?

uglyog
2021-08-19 05:48
Because an exception is being raised, and that flag is only a check if no pacts are found (i.e the list is empty)

marvin.kienitz
2021-08-19 05:54
@uglyog but isn't the response from the broker correct if there are no pacts and the plugin should be able to handle this (especially when the flag `failIfNoPactsFound` is set)? ```$ curl -i http://localhost:9292/pacts/provider/MyEventProvider/for-verification ... HTTP/1.1 404 Not Found Vary: Accept Content-Type: application/hal+json;charset=utf-8 Date: Thu, 19 Aug 2021 05:53:44 GMT Server: Webmachine-Ruby/1.5.0 Rack/1.3 X-Pact-Broker-Version: 2.79.1 X-Content-Type-Options: nosniff Content-Length: 57 {"error":"No provider with name 'MyEventProvider' found"}```

github2
2021-08-19 06:15
[pact-foundation/pact-jvm] Issue opened by JapuDCret

marvin.kienitz
2021-08-19 06:16
I submitted an issue, so it's easier to read https://github.com/pact-foundation/pact-jvm/issues/1419

thomaswtsang
2021-08-19 16:53
has joined #pact-jvm

chris005
2021-08-19 19:07
has joined #pact-jvm

franklin.lucena89
2021-08-19 22:27
Hey people how are you?

franklin.lucena89
2021-08-19 22:29
I'm new to Pact and I was wondering if there's a way to configure a service like consumer and provider, for eg. my use case is that my service consume data from other's microservices but also provide data to some other services

franklin.lucena89
2021-08-19 22:29
Is this configuration possible? how can I reach the goal?

matt.fellows
2021-08-19 23:18
Of course. An application can be both a consumer and a provider. What?s your specific chalenge?

srimuralixi
2021-08-20 02:18
has joined #pact-jvm

vbhardwaj.eminent
2021-08-20 03:20
Hi, I have a springboot maven provider - When pact test runs for a state to assert 404, my code throws a RuntimeException, even if the exception is being handled, the test execution get interrupted and does not go back to the Controller (Where I expect to return a Http error code). Could anyone please clarify why I am seeing this behaviour?

matt.fellows
2021-08-20 03:23
might be worth sharing a code snippet and the problem

matt.fellows
2021-08-20 03:23
Most HTTP clients throw errors for non successful calls, so they would need to be appropriately handled/detected

vbhardwaj.eminent
2021-08-20 03:25
returns 404 correctly when I trigger the request from Postman but when pact test is run on provider then I get exception is null. I ran both scenarios in debug mode mode. With postman when the exception occurs it goes back to controller and send out the response whereas with pact it goes to `PactVerificationStateChangeExtension` and throws a nullpointer.

matt.fellows
2021-08-20 03:32
that seems to imply your state change is erroring, not the `404` request itself

vbhardwaj.eminent
2021-08-20 04:52
I am able to fix the issue and test passing now for 404, but now I am returning null back to controller when resource not found. And then throwing my custom exception, hence getting 404. But I am still confused why this behaviour of Pact, because as best practice I will have custom exception when resource not available and controller will automatically catch it and sends back to the cosumer. `Does PACT expect me to write the service in a way which I did now?` And this is not a best practice the way I did the implementation to get the test passed.

vbhardwaj.eminent
2021-08-20 04:52
I?m using Custom runtime exemption and I throw it when a record wasn?t found in my DB. This exception is being thrown in my service layer. ```@ResponseStatus(code = HttpStatus.NOT_FOUND, reason = "Invalid category id") public class CategoryNotFoundException extends RuntimeException {``` Why in case of RuntimeExceptions the call doesn?t go back to the controller and stops at my service layer?

vbhardwaj.eminent
2021-08-20 04:59
@matt.fellows @uglyog, could you please assist?

uglyog
2021-08-20 05:05
Please provide the stack trace and logs so we can try help you

vbhardwaj.eminent
2021-08-20 05:19
I am doing an implementation on your pact maven springboot workshop similar to what I have in my service. I will create a new branch and raise a PR and you can have a look.

manika.goel
2021-08-20 05:38
has joined #pact-jvm

akanksha.sharma
2021-08-20 06:31
has joined #pact-jvm


vbhardwaj.eminent
2021-08-20 06:56
I have added the productservice class and custom exception class in provider to illustrate the issue I am facing

vbhardwaj.eminent
2021-08-20 06:57
This is the state which is throwing null pointer exceptionm

uglyog
2021-08-20 07:02
You need to handle the exception here: ``` Product product = productService.getProduct(productId); if (product != null) { productService.deleteById(productId); }```

uglyog
2021-08-20 07:02
product will never be null with the changes you made

vbhardwaj.eminent
2021-08-20 07:25
product is null if I pass id 50L

vbhardwaj.eminent
2021-08-20 07:26
and I saw your sql scripts and we don't have an id 50L

vbhardwaj.eminent
2021-08-20 07:29
and if i handle the exception where you have mentioned then the whole purpose of Pact will be defeated because i want to talk service layer and not change anything else. And I followed the same approach for 200 and it works fine. why does it throw null pointer in case of 404?

franklin.lucena89
2021-08-20 12:08
Well I have a spring boot/maven project, and I'm using the maven plugin to verify and deploy my pact tests to a local docker container with the pact broker, but this maven plugin needs to be configure with a service Provider, in my case how do I can to handle this approach of set the same service like consumer and provider as well?

franklin.lucena89
2021-08-20 12:08
Thank you very much for your reply @matt.fellows

jonah
2021-08-20 14:42
has joined #pact-jvm

tlzhou
2021-08-20 15:02
has joined #pact-jvm

franklin.lucena89
2021-08-20 17:44
Hey guys, it's me again, now I am having this error when I do mvn pact:verify ` ```Failed to execute goal au.com.dius.pact.provider:maven:4.1.11:verify (default-cli) on project auth-service: No pact files were found for provider 'AuthService' ```

franklin.lucena89
2021-08-20 17:45
Can anyone tell me why is this error?

uglyog
2021-08-21 03:12
Your confusion is based on the fact you're expecting Pact tests to behave in the same way as Postman. You should read through the docs to get a better understanding on how Pact works. See https://docs.pact.io/getting_started/how_pact_works and https://pactflow.io/blog/how-is-pact-different-than-postman/

uglyog
2021-08-21 03:15
Now, coming back to your question. With a Postman test, Postman acts like a browser, and sets a HTTP request to your application. Spring handles the request, and passes it on to your controller. The controller calls the service layer, and an exception is raised, which is caught by the Spring framework. As you have defined an exception advice class, Spring then knows to return a 404 response back to Postman.

uglyog
2021-08-21 03:19
With Pact, things are running in a unit test. The first thing Pact will do, is invoke any provider state handler to put the application into the correct state before the HTTP request is made. In your case, the handler is calling the same service layer, and that is failing with an exception. In this case, Pact will get the exception and then fail the test. It will not even bother to make the HTTP request. So the controller is never invoked, and no 404 response is received.

uglyog
2021-08-21 03:20
You need to fix the provider state handler to not throw any exception back to Pact.

uglyog
2021-08-21 03:21
Then it will make the HTTP request, which will result in the 404 response

vbhardwaj.eminent
2021-08-21 03:27
I did what you suggested and it worked. Thanks for clarifying @uglyog and I am feeling quite satisfied the way Pact works.

vbhardwaj.eminent
2021-08-21 03:30
Picking up from your line 'application into correct state', what do you mean by it exactly?

uglyog
2021-08-21 03:55
It should setup the data for that interaction


uglyog
2021-08-21 09:09
Because when the Pact verifier got all the pact files to verify, there were none for provider `AuthService`

vbhardwaj.eminent
2021-08-22 07:13
Hi @uglyog, the article is bit confusing because as a provider when I go to see the state on pact broker then I can see the query param key is wrong ( name instead of firstname) and I will talk to consumer to get it fixed. So, the question of going wrong with the query param is not possible. My approach as a provider is to get the state from the contract published on pact broker, and I see the path variables and response expected. Then create a state in provider and make a call to service layer so that expected status code and response can be returned. Also, as a provider I don't care what test data has been used in path variable because as a provider I only cares to send the correct status code and response. With regard to response it has been already agreed that PACT-JS consumer will use like matcher, which matches the properties json schemas and data types not values.

ramya.sri
2021-08-23 03:52
has joined #pact-jvm

tjones
2021-08-23 06:33
I'm using the `junit5` runner for verification, but I'm getting an incorrect "No Pact files were found to verify": I have: ```@Provider("application-hub-api") @Consumer("application-hub-frontend") @PactBroker(host = "/pact-broker/", scheme = "https"``` but when I run the test I get: ```au.com.dius.pact.provider.junit.loader.NoPactsFoundException: No Pact files were found to verify Provider: application-hub-api Consumer: application-hub-frontend Source: Pact Broker https:///pact-broker/: tags=[latest]``` A get for: ```/pact-broker/pacts/provider/application-hub-api/consumer/application-hub-frontend/latest``` returns the pact correctly. What am I doing wrong?

uglyog
2021-08-23 06:35
If you enable debug logs, you will see the requests made to the broker

uglyog
2021-08-23 06:36
I'm curious about `tags=[latest]`

tjones
2021-08-23 06:36
how do I do that?

uglyog
2021-08-23 06:36
Where is that being set?

uglyog
2021-08-23 06:37
What version of Pact-JVM are you using?

tjones
2021-08-23 06:38
4.0.10 (pact-jvm-provider-junit5)

tjones
2021-08-23 06:38
Everything is default, the only other set up is: ``` @BeforeEach void setupTestTarget(PactVerificationContext context) { context.setTarget(new HttpTestTarget(server.getHost(), server.getPort())); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); }```

tjones
2021-08-23 06:39
auth provided via `PACT_BROKER_PASSWORD` and `PACT_BROKER_USERNAME` environment variables

tjones
2021-08-23 06:41
> `tags=[latest]` > Where is that being set? I'm not setting it at all, as far as I know

uglyog
2021-08-23 06:42
I think the issue is the older versions of Pact-JVM used to default to a tag of `latest` if none are specified.

tjones
2021-08-23 06:42
Isn't this the latest version?

marvin.kienitz
2021-08-23 06:42
has someone an idea about this?


tjones
2021-08-23 06:43
Can I specify no tags?

uglyog
2021-08-23 06:43
No, the libs were renamed with 4.1

uglyog
2021-08-23 06:44
Yes, you can try add `tags={}` to the annotation


uglyog
2021-08-23 06:46
`au.com.dius.pact.provider:junit5:4.1.25` if you are using JDK 8

tjones
2021-08-23 06:47
I have jdk 11

tjones
2021-08-23 06:47
``` <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit</artifactId> <version>4.2.9</version> <scope>test</scope```

tjones
2021-08-23 06:48
Oh, maybe I need `junit5`?


tjones
2021-08-23 06:49
Ok, now I get: ```{"timestamp":"2021-08-23T06:49:20.020Z","level":"WARN","thread":"main","logger":"au.com.dius.pact.core.pactbroker.HalClient","message":"Failed to fetch the root HAL document","context":"default"}```

tjones
2021-08-23 06:50
How do I enable debug logs?

tjones
2021-08-23 06:50
(also the `@PactBroker` annotation is way nicer in the latest version)

uglyog
2021-08-23 06:53
What information are you looking for?

uglyog
2021-08-23 06:54
That looks like an authentication issue

uglyog
2021-08-23 06:55
Logging settings are dependant on your project setup

tjones
2021-08-23 06:55
Could be. Does pact-jvm read `PACT_BROKER_PASSWORD` etc from the env?

uglyog
2021-08-23 06:55
If it is a Springboot app, it needs to be configured in Spring

tjones
2021-08-23 06:55
Micronaut

uglyog
2021-08-23 06:56
Oh, no, it does JVM system properties

tjones
2021-08-23 06:56
oh right

tjones
2021-08-23 06:56
we should standardise on those :slightly_smiling_face:

marvin.kienitz
2021-08-23 06:56
If I am doing something wrong, or if this is a known bug

tjones
2021-08-23 06:57
```-Dpactbroker.auth.username=whatever``` Like this?

tjones
2021-08-23 06:57
(forgive me. The JVM is a mystery to me)

uglyog
2021-08-23 06:57
Are you using Maven or Gradle?

tjones
2021-08-23 06:57
Maven

tjones
2021-08-23 06:57
:disappointed:

tjones
2021-08-23 06:58
CI will pass the properties in via the env variables

tjones
2021-08-23 06:58
so I just need to hook that up

uglyog
2021-08-23 06:58
Ok, the system properties need to be set on the Maven test plugin (surefire)

tjones
2021-08-23 06:58
Sweet, that's probably enough info for me to find out how to do that

tjones
2021-08-23 06:58
thank you!


uglyog
2021-08-23 07:02
That issue has not been fixed yet

tjones
2021-08-23 07:05
legend, thanks Ron!


tjones
2021-08-23 07:12
Oh no. Even after setting that, I'm still getting the HAL error

tjones
2021-08-23 07:13
I'll have to figure out debug logs

tjones
2021-08-23 07:18
Hmm. It's not much more helpful: ```{"timestamp":"2021-08-23T07:16:30.030Z","level":"DEBUG","thread":"main","logger":"au.com.dius.pact.provider.ProviderUtils","message":"Pact source does not have a constructor with one argument of type Class","context":"default"} {"timestamp":"2021-08-23T07:16:30.030Z","level":"DEBUG","thread":"main","logger":"au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader","message":"Loading pacts from pact broker for provider application-hub-api and consumer version selectors []","context":"default"} {"timestamp":"2021-08-23T07:16:30.030Z","level":"DEBUG","thread":"main","logger":"au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader","message":"Authentication: Basic","context":"default"} {"timestamp":"2021-08-23T07:16:30.030Z","level":"DEBUG","thread":"main","logger":"au.com.dius.pact.core.pactbroker.HalClient","message":"Fetching: /","context":"default"} {"timestamp":"2021-08-23T07:16:30.030Z","level":"WARN","thread":"main","logger":"au.com.dius.pact.core.pactbroker.HalClient","message":"Failed to fetch the root HAL document","context":"default"}```

tjones
2021-08-23 07:19
Oh, I think this might be a broker config issue

tjones
2021-08-23 07:19
the hal browser says ```{ "message": "no Route matched with those values" }```

tjones
2021-08-23 07:19
which I don't think is coming from the broker?

matt.fellows
2021-08-23 07:20
hmm, is it possible that the request is going to some other host?

matt.fellows
2021-08-23 07:21
(flying in late to this conversation, so, sorry if you?ve covered it, hard to see everything in threads)

tjones
2021-08-23 07:21
I think it's an issue with the routing to the broker. `<HOST>/pact-broker` doesn't work, but . `<HOST>/pact-broker/` does

matt.fellows
2021-08-23 07:21
proxy?

matt.fellows
2021-08-23 07:21
ah

tjones
2021-08-23 07:22
Well, the error message in Pact-JVM is correct :joy:

tjones
2021-08-23 07:23
I guess it could be improved if the JVM debug logs said what it was receiving

matt.fellows
2021-08-23 07:23
is that DEBUG or TRACE? :stuck_out_tongue:

tjones
2021-08-23 07:24
DEBUG, for users :stuck_out_tongue:

uglyog
2021-08-23 07:25
Normally, if debug logs are enabled (at root level), you get the HTTP requests and responses logged


tjones
2021-08-23 07:25
Weird

uglyog
2021-08-23 07:26
You might have to set `org.apache.http=DEBUG` to get those on your project

tjones
2021-08-23 07:28
(I don't think Micronaut uses Apache)

uglyog
2021-08-23 07:30
Pact-JVM does


tjones
2021-08-23 07:35
Adding that to the system properties didn't give more output :disappointed:

uglyog
2021-08-23 07:39
No, it needs to be set in the logging config

tjones
2021-08-23 07:48
```... <root level="DEBUG"> <appender-ref ref="SPLITTER-OUT"/> <appender-ref ref="SPLITTER-ERR"/> </root> <logger name="org.apache.http" level="DEBUG" /> </configuration>```

tjones
2021-08-23 07:48
Still no dice (this is logback.xml)

uglyog
2021-08-23 07:50
Yeah, that should work. Make sure it is in the test classpath (not app)

tjones
2021-08-23 07:51
ahhh, that's probably the problem

tjones
2021-08-23 07:51
update: it was not the problem

tjones
2021-08-23 07:51
:man-shrugging:

tjones
2021-08-23 08:10
@uglyog: We've fixed the issue so the HAL browser works in the browser, but it's still failing in pact-jvm

tjones
2021-08-23 08:14
Hmm. I think there's still problems with the way this broker is being hosted

matt.fellows
2021-08-23 08:14
is there a proxy in front of it?

tjones
2021-08-23 08:14
Ignore this for now. I'll check back if it looks like pact is at fault

tjones
2021-08-23 08:14
> is there a proxy in front of it? No idea


matt.fellows
2021-08-23 08:15
Because of HAL, the links in the response need to be aware of the host and path it?s running on

matt.fellows
2021-08-23 08:15
otherwise the links are bogus

tjones
2021-08-23 08:15
Right

matt.fellows
2021-08-23 08:15
proxies/gateways can mess with the headers and hide things from the broker, which means the responses can get out of whack with what?s intended

matt.fellows
2021-08-23 08:17
You can probably test this by hitting the root URL and checkinsg that the links have the correct host, path etc. in them

tjones
2021-08-23 08:17
Right now the root URL isn't loading because all the scripts + assets it needs are 404ing. So I don't think pact is at fault

matt.fellows
2021-08-23 08:18
ah, that?s a good sign the BASE_URL isn?t set correctly

tjones
2021-08-23 08:33
Ok. The broker is now all fixed (HAL works fine in the browser), but pact JVM is still unhappy.

tjones
2021-08-23 08:35
I've tried giving the annotation the credentials directly, to make sure there's nothing broken in the property chain, but no dice - the error is unchanged

joseramonrivera21
2021-08-23 08:49
has joined #pact-jvm

tjones
2021-08-23 08:56
I think this is a problem with pact-jvm, because I'm able to run the ruby verifier

tjones
2021-08-23 09:03
I just noticed the `caused by` part says it's because of `Request to path '/' failed with response 'HTTP/1.1 403 Forbidden'`

tjones
2021-08-23 09:03
However, the credentials are correct

tjones
2021-08-23 09:04
```@PactBroker(url = "https://example.com/pact-broker", authentication = @PactBrokerAuth(username ="username here", password = "password here"))```

tjones
2021-08-23 09:05
could it be one of: 1) Using https? 2) Having a path other than `/` 3) specifiying the auth directly?

tjones
2021-08-23 09:05
The HAL browser and ruby verifier all work fine

uglyog
2021-08-23 09:09
You might need to enable preemptive basic auth, because it looks like the proxy is not handling the auth correctly. The Apache HTTP client first sends an unauthenticated request, and then expects an auth challenge if it is a protected resource

tjones
2021-08-23 09:10
Right. It's also weird that it's getting a 403 and not a 401 (which is what I get on the command line with curl + no auth)

tjones
2021-08-23 09:11
how do I enable that?


tjones
2021-08-23 09:13
I now get: ```{"timestamp":"2021-08-23T09:13:17.017Z","level":"WARN","thread":"main","logger":"au.com.dius.pact.core.pactbroker.HalClient","message":"Using preemptive basic authentication with the pact broker at https://<url>","context":"default"} {"timestamp":"2021-08-23T09:13:17.017Z","level":"WARN","thread":"main","logger":"au.com.dius.pact.core.pactbroker.HalClient","message":"Failed to fetch the root HAL document","context":"default"}```

tjones
2021-08-23 09:14
ah - the path in the error message is just the host, though, It doesn't include the path

uglyog
2021-08-23 09:16
Oh, you were using the `host`. Use `url` instead

tjones
2021-08-23 09:17
I'm using url now (I had to when I upgraded to the latest version)

tjones
2021-08-23 09:19
I can't get a 403 from curl though

tjones
2021-08-23 09:19
even if I try the baseurl and the creds

tjones
2021-08-23 09:30
Broker version: 2.81.0 au.com.dius.pact.provider:junit5 version 4.2.9

tjones
2021-08-23 09:33
Could it be that the fix for this issue isn't in the junit5 package?: https://stackoverflow.com/questions/62411232/using-pact-broker-with-a-path


uglyog
2021-08-23 09:55
That's in common code used by all components

uglyog
2021-08-23 10:06
Looks like `org.slf4j:jcl-over-slf4j:1.7.32` is needed to get the HTTP client logs

uglyog
2021-08-23 10:07
With that, I get: ```20:05:44.096 [Test worker] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request GET / HTTP/1.1 20:05:44.097 [Test worker] DEBUG o.a.h.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED 20:05:44.097 [Test worker] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED 20:05:44.098 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> GET / HTTP/1.1 20:05:44.098 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Type: application/json 20:05:44.098 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept: application/hal+json, application/json 20:05:44.098 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: http://test.pact.dius.com.au 20:05:44.098 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive 20:05:44.098 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.13 (Java/11.0.12) 20:05:44.099 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate 20:05:44.099 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "GET / HTTP/1.1[\r][\n]" 20:05:44.099 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Type: application/json[\r][\n]" 20:05:44.099 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept: application/hal+json, application/json[\r][\n]" 20:05:44.099 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: http://test.pact.dius.com.au[\r][\n]" 20:05:44.099 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]" 20:05:44.099 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.13 (Java/11.0.12)[\r][\n]" 20:05:44.099 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]" 20:05:44.099 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]" 20:05:44.149 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 401 Unauthorized[\r][\n]" 20:05:44.150 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Mon, 23 Aug 2021 10:05:44 GMT[\r][\n]" 20:05:44.150 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Type: text/plain[\r][\n]" 20:05:44.150 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Length: 0[\r][\n]" 20:05:44.150 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "Connection: keep-alive[\r][\n]" 20:05:44.150 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "Vary: Accept[\r][\n]" 20:05:44.150 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "WWW-Authenticate: Basic realm="Restricted area"[\r][\n]" 20:05:44.150 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "X-Pact-Broker-Version: 2.82.0[\r][\n]" 20:05:44.150 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "X-Pact-Broker-Git-Sha: 3cf421ac[\r][\n]" 20:05:44.150 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "X-Pactflow-Git-Sha: f0638948a[\r][\n]" 20:05:44.150 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "X-Content-Type-Options: nosniff[\r][\n]" 20:05:44.150 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "Strict-Transport-Security: max-age=63072000; includeSubDomains; preload[\r][\n]" 20:05:44.150 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "X-Request-Id: 4a03a49aa64839a4bb96daa39b96bc6c[\r][\n]" 20:05:44.150 [Test worker] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]" 20:05:44.152 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 401 Unauthorized 20:05:44.152 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Mon, 23 Aug 2021 10:05:44 GMT 20:05:44.152 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: text/plain 20:05:44.152 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Length: 0 20:05:44.152 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << Connection: keep-alive 20:05:44.152 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << Vary: Accept 20:05:44.152 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << WWW-Authenticate: Basic realm="Restricted area" 20:05:44.152 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << X-Pact-Broker-Version: 2.82.0 20:05:44.152 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << X-Pact-Broker-Git-Sha: 3cf421ac 20:05:44.152 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << X-Pactflow-Git-Sha: f0638948a 20:05:44.152 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << X-Content-Type-Options: nosniff 20:05:44.152 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << Strict-Transport-Security: max-age=63072000; includeSubDomains; preload 20:05:44.153 [Test worker] DEBUG org.apache.http.headers - http-outgoing-0 << X-Request-Id: 4a03a49aa64839a4bb96daa39b96bc6c```

denny.duttig
2021-08-23 10:10
has joined #pact-jvm

akansha.saraswat3
2021-08-23 10:50
has joined #pact-jvm

tjones
2021-08-23 11:11
Aha! This is great, thanks. Using that I can see that the request is correct

tjones
2021-08-23 11:11
I was able to reproduce the problem using curl - the server is rejecting that user agent for some reason.

tjones
2021-08-23 11:12
must be an explicit deny -if I change it to `Pact-JVM` it passes

tjones
2021-08-23 11:13
This (again) suggests that the problem is not in Pact-JVM or the Pact Broker.

tjones
2021-08-23 11:17
Aha! This user agent is forbidden by default in the Kong `bot-detection` plugin

tjones
2021-08-23 11:17
Thank you so much for the detailed back and forth + help with the logging!

tjones
2021-08-23 11:18
(I don't suppose there's an easy way to change the user agent? Looks like it has to be done programatically)

tjones
2021-08-23 11:19
otherwise I'll see if I can get that plugin disabled

tjones
2021-08-23 11:25
Also, when I tried downgrading to an earlier version using `host` and `scheme`, the error masks the real cause: ```au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify Provider: application-hub-api Consumer: application-hub-frontend```

tjones
2021-08-23 11:25
(but the debug logs show the real cause)

marvin.kienitz
2021-08-23 13:43
I pushed changes to hopefully fix this https://github.com/pact-foundation/pact-jvm/pull/1421

franklin.lucena89
2021-08-23 14:49
Hi guys, I have a question, when I look in to the docs and also some github example projects I always look that the consumer and provider side are in the same project, the thing is that I have two separate project (two different micro services) and I have to test it with pact, is there a way to develop pact test considering this architecture? can I just for example code only the provider side tests to one of the microservices? also, how I need to tell pact provider it's another different service that belongs to another project? Please, can you help me?

phil.endsley
2021-08-23 15:08
Yes, I think what you want to do is the most common scenario. They're only bundled together in examples to make it easier to navigate. Just include the consumer parts in the consumer project, and provider parts in the provider project.

franklin.lucena89
2021-08-23 15:13
Hey, thank you very much for the reply, for example in this docs https://docs.pact.io/implementation_guides/jvm/provider/maven/#to-use-it configure the maven plugin and setup the provider and its consumer with its pactSource, this pact source might be the consumer pact url into the pact broker?

phil.endsley
2021-08-23 15:17
If you're using pact broker, see the section about configuring that. https://docs.pact.io/implementation_guides/jvm/provider/maven/#verifying-pact-files-from-a-pact-broker

franklin.lucena89
2021-08-23 15:42
cool I will read about it, thanks!

franklin.lucena89
2021-08-23 16:22
Hey, I was reading about this docs you share with me and I get a doubt with if one service act like a consumer but also a provider, how do I need to configure my POM to get things work?

phil.endsley
2021-08-23 16:25
If you know what to add to your pom for consumer, and you know what to add to your pom for provider, you just add both

phil.endsley
2021-08-23 16:25
If you're just starting out and struggling, maybe try to get a poc working just between two applications. Only consumer for one, and only provider for the other. Don't try and do it all at once

phil.endsley
2021-08-23 16:26
Once you get that working and it makes sense, start expanding

franklin.lucena89
2021-08-23 16:28
Ok thanks for the advise! I'll try to do some basic test as a start point

kyle.florence
2021-08-23 18:08
@uglyog looks like there is a hole in the pact broker test coverage

sushant.soni
2021-08-23 21:10
has joined #pact-jvm

srinagasai.krishnasan
2021-08-23 21:36
Hello Team, any examples for dynamic keys support?


srinagasai.krishnasan
2021-08-23 21:41
Yes, I am having hard time understanding `eachKeyLike` . It will say yes to any kind of string?

srinagasai.krishnasan
2021-08-23 21:42
Use case is ```{ "anns": { "ob1-dynamic": {...}, "ob2-dynamic": {...}, } }```

srinagasai.krishnasan
2021-08-23 21:43
how do I support this using DSL

uglyog
2021-08-23 23:02
There are lots of holes. I keep plugging them up as I find them, but I'm astounded the ship hasn't sunk



uglyog
2021-08-23 23:10
On the `HttpClientBuilder` class

tjones
2021-08-23 23:11
ah, awesome! Thank you

kyle.florence
2021-08-23 23:56
lol

matt.fellows
2021-08-24 00:23
I think a better metaphor is the https://en.wikipedia.org/wiki/Ship_of_Theseus. Pact JVM was originally written in Scale, replaced by several languages (e.g. Java, groovy, Kotlin) and now pact4s exists, which is scala.

matt.fellows
2021-08-24 00:23
Which one is the original JVM? :stuck_out_tongue:

kyle.florence
2021-08-24 01:19
:dizzy_face:

kyle.florence
2021-08-24 01:19
Should have never strayed from scala, clearly ;)

matt.fellows
2021-08-24 01:19
hahaha

ajaiswal595
2021-08-24 11:00
has joined #pact-jvm

pd287515778
2021-08-24 12:48
has joined #pact-jvm

franklin.lucena89
2021-08-24 20:11
Hi guys, I develop my first consumer test but I need to run the mvn test command just for this single one class I built, I'm using this shell command ```mvn -Dtest=LoginControllerPactTest test -f pom.xml``` and my test run successfully but the pact file is not generated, does anyone knows why is that or how can I get this use case work?

uglyog
2021-08-24 23:25
Enable debug logs. It will log were the file is being written.

tjones
2021-08-25 01:28
I have the following `junit5` annotators for the verifier - how do I get it to publish the pact back? Also, if I specify a providerVersionTag, is there an easy way to get it to be the branch? I don't particularly want to hard code `main`, in case the tests run on a branch: ```@Provider("application-hub-api") @Consumer("application-hub-frontend") @PactBroker( url = "https://broker.example.com/pact-broker", consumerVersionSelectors = { @VersionSelector(tag= "main") }, enablePendingPacts = "true", authentication = @PactBrokerAuth(username = "${PACT_BROKER_USERNAME}", password = "${PACT_BROKER_PASSWORD}"))```

uglyog
2021-08-25 01:33
Good question. Maybe @phil.endsley or one of the others have an example of how they do it

uglyog
2021-08-25 01:34
For publishing the results, there is a system property for it


tjones
2021-08-25 01:45
Aha! Thank you

hwebster
2021-08-25 05:30
has joined #pact-jvm

hoangvo
2021-08-25 05:43
has joined #pact-jvm

jobjingjo
2021-08-25 06:20
has joined #pact-jvm

franklin.lucena89
2021-08-25 13:17
Hello, I'm running a consumer test and I have this error ` ```java.lang.AssertionError: Pact Test function failed with an exception: I/O error on GET request for "http://kubernetes.docker.internal:61954/channel/entitlement/2f7cf71b-5fa0-4c17-bd07-7dbfee81b45a": Unexpected end of file from server; nested exception is java.net.SocketException: Unexpected end of file from server at java.base/sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:866) at java.base/sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:689) at java.base/sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:863) at java.base/sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:689) at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1615) at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520) at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:527) at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:82) at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:739) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:674) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:583) at com.techinsights.auth.pact.controller.LoginControllerPactTest.shouldGetChannels(LoginControllerPactTest.java:131)``` anyone knows why is this error?

sagarsitap596
2021-08-25 14:10
has joined #pact-jvm

franklin.lucena89
2021-08-25 14:20
Hey guys, have some other question, is pact available to test DTOs, DAOs and service classes?

sagarsitap596
2021-08-25 15:18
```@BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", 8080, "/")); }``` instead of localhost how can I provide cname / server domain without port url ?

franklin.lucena89
2021-08-25 16:09
Does anyone know why pact it's throwing this error or how could I solve it? ```java.lang.NoClassDefFoundError: org/antlr/v4/runtime/CharStreams at au.com.dius.pact.core.support.Version.parse(Version.java:78) at au.com.dius.pact.core.model.DefaultPactReader.pactFromJson(PactReader.kt:213) at au.com.dius.pact.core.model.DefaultPactWriter.writePact(PactWriter.kt:95) at au.com.dius.pact.consumer.BaseMockServer.verifyResultAndWritePact(MockHttpServer.kt:163) at au.com.dius.pact.consumer.BaseMockServer.runAndWritePact(MockHttpServer.kt:144) at au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest(ConsumerPactRunner.kt:32) at au.com.dius.pact.consumer.junit.BaseProviderRule.runPactTest(BaseProviderRule.java:183) at au.com.dius.pact.consumer.junit.BaseProviderRule$1.evaluate(BaseProviderRule.java:99) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283) at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) Caused by: java.lang.ClassNotFoundException: org.antlr.v4.runtime.CharStreams at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) at au.com.dius.pact.core.support.Version.parse(Version.java:78) at au.com.dius.pact.core.model.DefaultPactReader.pactFromJson(PactReader.kt:213) at au.com.dius.pact.core.model.DefaultPactWriter.writePact(PactWriter.kt:95) at au.com.dius.pact.consumer.BaseMockServer.verifyResultAndWritePact(MockHttpServer.kt:163) at au.com.dius.pact.consumer.BaseMockServer.runAndWritePact(MockHttpServer.kt:144) at au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest(ConsumerPactRunner.kt:32) at au.com.dius.pact.consumer.junit.BaseProviderRule.runPactTest(BaseProviderRule.java:183) at au.com.dius.pact.consumer.junit.BaseProviderRule$1.evaluate(BaseProviderRule.java:99) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283) at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)```

kyle.fischer
2021-08-25 16:31
has joined #pact-jvm

datasmithadvtech
2021-08-25 19:43
has joined #pact-jvm

todor.m.kolev
2021-08-25 19:59
has joined #pact-jvm

todor.m.kolev
2021-08-25 20:38
Hi, I'm looking for ideas/an example on how to validate a date field from response body. For example, say the provider response contains a datetime in a specific format and the consumer relies on it to be in that specific format, then if the provider changes the format of the field I want the contract verification to fail. Any ideas?

kyle.florence
2021-08-25 21:06
we use the `LambdaDsl` and have done it with: ```lambdaDslObject.getPactDslObject.datetime( name, "yyyy-MM-dd'T'HH:mm:ssX", example, TimeZone.getTimeZone("UTC") )``` where name is the field name and example is an `Instant` (java time)

kyle.florence
2021-08-25 21:07
this is for ISO 8601 instant format, like ?2000-01-31T01:00:00Z?

uglyog
2021-08-25 23:19
The server closed the connection before the body was read.

sushmitha.amin
2021-08-26 04:31
has joined #pact-jvm

sagarsitap596
2021-08-26 06:27
Hi team, anyone has example of how queryParam is mentioned in contract json file ?

marvin.kienitz
2021-08-26 06:36
here is an example, where we have the queryParam `fields` set to `descriptions` ```{ "consumer": { "name": "MyConsumer" }, "interactions": [ { "description": "GET single entity", "providerStates": [ { "name": "Entities exist", "params": { "entityExample001": "123456" } } ], "request": { "matchingRules": { "path": { "combine": "AND", "matchers": [ { "match": "regex", "regex": "/my-service/entity/123456" } ] } }, "method": "GET", "path": "/my-service/entity/123456", "query": { "fields": [ "descriptions" ] } }, "response": { "body": { // ... }, "generators": { // ... }, "headers": { // ... }, "matchingRules": { "body": { // ... }, "header": { // ... } }, "status": 200 } }, ], "metadata": { "pact-jvm": { "version": "4.2.8" }, "pactSpecification": { "version": "3.0.0" } }, "provider": { "name": "MyProvider" } }```

matt.fellows
2021-08-26 06:57
why do you want to see it in the JSON file?

robert.strehli
2021-08-26 09:24
Hey, I have question. I know there are request filters to modify the request headers on provider side. I would need the same thing but for query parameters. So I would like to add a parameter `?code=abcd` (which I cannot persist this in the contract). Is there something or maybe I just oversee another possibility? (using Junit4 and maven)

sagarsitap596
2021-08-26 09:36
Contract is basically a .json file, right ?

matt.fellows
2021-08-26 09:42
Can't you do that with request filters?

abubics
2021-08-26 10:06
it is, but it's generated by testing actual code, not hand-edited :slightly_smiling_face: you'd usually only read/edit it for debugging

robert.strehli
2021-08-26 10:26
Yes, you are totally right. Just oversaw it because it's deprecated

matt.fellows
2021-08-26 11:49
hmmm that I can?t answer, sorry!

matt.fellows
2021-08-26 11:50
What @abubics said. The JSON file is the contract, yes, but I think of it a bit like a Java `.class` file. It?s important, but you really care more about the source code and rarely would you open up a class file to see what?s in it

matt.fellows
2021-08-26 11:51
But I?m also asking, because it seems you might want to be looking in it for other reasons. http://e.gs there something wrong with your contract file?

shwetastar98
2021-08-26 12:35
has joined #pact-jvm

sagarsitap596
2021-08-26 12:36
``` @Provider("api-provider") @PactFolder("pact") public class SearchPIDTest { @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", 8080, "/")); } @State({ "search id 112342"}) void toDefaultState() { } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context, HttpRequest request) { request.addHeader("Cookie", "277da602-d436-47ab-99b4-37020341ac89"); context.verifyInteraction(); } }``` How do I pass actual api server cname instead of localhost. I tried ```@BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("http://xyz.com")); }``` but seems like pact sdk append port 8080 by default. which is not required.

contact
2021-08-26 12:44
has joined #pact-jvm

marvin.kienitz
2021-08-26 12:46
You can set the port yourself: ```context.setTarget(new HttpTestTarget(host, port, path));```

matt.fellows
2021-08-26 13:17
It looks like you?re trying to test an externally hosted API (you mentioned cname)

matt.fellows
2021-08-26 13:17
you can do this, but it?s not recommended

matt.fellows
2021-08-26 13:17
(I know you?re doing a POC, so it?s probably OK, but just know that?s not how you would normally run these tests)

malena.cadima
2021-08-26 16:07
has joined #pact-jvm

todor.m.kolev
2021-08-26 16:15
That worked nicely, thank you!

franklin.lucena89
2021-08-26 21:11
Hey guys, question, when I run the mvn pact:verify at the pact broker, the host that set up at the maven plugin it's get call, but the thing is that I don't really make clear what is the right way to test it, pactProviderRule have a localhost configure it and a 1234 port, how can I run the test with this localhost url instead of calling POM plugin configuration?

louis.ss
2021-08-27 01:42
has joined #pact-jvm

sagarsitap596
2021-08-27 12:02
My application is deployed on kubernetes and we access it by cname.

sagarsitap596
2021-08-27 12:10
I am getting java.lang.AssertionError: 0 - Path expression "data" does not start with a root marker "$". In contract ,response.body and response,matchingRules.body is same. Cant figure out from logs whats wrong. could you please help ?

matt.fellows
2021-08-27 12:14
Sure but it's best not to do it that way, you should think of it a bit like a unit test. You don't unit test a remote API

sergio.amorim
2021-08-27 14:40
has joined #pact-jvm

franklin.lucena89
2021-08-27 19:33
Hello, I'm running some test using the maven plugin and I'm setting it like this ``` <plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.1.0</version> <configuration> <serviceProviders> <!-- You can define as many as you need, but each must have a unique name --> <serviceProvider> <name>EntitlementService</name> <pactBrokerUrl>http://localhost:9292/</pactBrokerUrl> <consumers> <!-- Again, you can define as many consumers for each provider as you need, but each must have a unique name --> <consumer> <name>AuthService</name> <!-- currently supports a file path using pactSource or a URL using pactUrl --> <pactUrl>http://localhost:9292/pacts/provider/EntitlementService/consumer/AuthService/version/0.0.1</pactUrl> </consumer> </consumers> </serviceProvider> </serviceProviders> </configuration> </plugin>``` and when I run the mvn pact:verify command I get this failure ```Failures: 1) Verifying a pact between AuthService and EntitlementService - Get channels by user id 1.1) Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect 2) Verifying a pact between Pact between AuthService (0.0.1) and EntitlementService - Get channels by user id 2.1) Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect``` What I'm doing wrong?

phil.endsley
2021-08-27 19:36
This is in your provider, right? Is the provider running on localhost:8080 when you execute this command?

franklin.lucena89
2021-08-27 19:45
I get this error in both sides consumer and provider, actually I can't completely understand how pacts works, I'm trying to do a POC and I already develop my consumer test, but for the provider I'm having a hard time


uglyog
2021-08-28 03:31
To use the Maven plugin to verify your provider app, you need to have your app running

slin
2021-08-29 23:51
has joined #pact-jvm

shane.robinson
2021-08-30 00:30
has joined #pact-jvm

br.maher
2021-08-30 04:35
has joined #pact-jvm

kwongyun
2021-08-30 15:57
has joined #pact-jvm

franklin.lucena89
2021-08-30 22:58
Hey guys, how can I runt a consumer test using https protocol to call an external endpoint?

matt.fellows
2021-08-30 23:00
consumer tests need to talk to the mock provided by Pact, I?m confused by the question?

franklin.lucena89
2021-08-30 23:05
turns out that my provider it's a micro service that is running on an https url, so when I try to call it I need to do it under this protocol

franklin.lucena89
2021-08-30 23:08
I'm trying to do this aproach https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit/src/test/java/au/com/dius/pact/consumer/junit/pactproviderrule/PactProviderHttpsTest.java but I'm getting this issue ```java.lang.NoSuchMethodError: 'void kotlin.jvm.internal.FunctionReferenceImpl.<init>(int, java.lang.Class, java.lang.String, java.lang.String, int)' at io.ktor.server.netty.NettyApplicationEngine$Configuration$httpServerCodec$1.<init>(NettyApplicationEngine.kt) at io.ktor.server.netty.NettyApplicationEngine$Configuration$httpServerCodec$1.<clinit>(NettyApplicationEngine.kt) at io.ktor.server.netty.NettyApplicationEngine$Configuration.<init>(NettyApplicationEngine.kt:69) at io.ktor.server.netty.NettyApplicationEngine.<init>(NettyApplicationEngine.kt:72) at io.ktor.server.netty.Netty.create(Embedded.kt:14) at io.ktor.server.netty.Netty.create(Embedded.kt:12) at io.ktor.server.engine.EmbeddedServerKt.embeddedServer(EmbeddedServer.kt:79) at au.com.dius.pact.consumer.KTorMockServer.<init>(KTorMockServer.kt:79) at au.com.dius.pact.consumer.KTorMockServer.<init>(KTorMockServer.kt:38) at au.com.dius.pact.consumer.MockHttpServerKt.mockServer(MockHttpServer.kt:54) at au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest(ConsumerPactRunner.kt:31) at au.com.dius.pact.consumer.junit.BaseProviderRule.runPactTest(BaseProviderRule.java:183) at au.com.dius.pact.consumer.junit.BaseProviderRule$1.evaluate(BaseProviderRule.java:99) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)```

matt.fellows
2021-08-30 23:15
but in your _consumer_ test, you don?t talk to a real provider

matt.fellows
2021-08-30 23:15
you must talk to the mock service from Pact

0x06065a
2021-08-31 00:02
has joined #pact-jvm

matt.thomas
2021-08-31 05:29
has joined #pact-jvm

abhi.nandan964
2021-08-31 10:19
has joined #pact-jvm

franklin.lucena89
2021-08-31 18:37
Question, I'm trying to evaluate the keys that came on the body of provider response (the response it's a json object) so I'm found this command ```.like("key", "example")``` but when I run the verify it actually verifying both keys and values. So my question is how do I can accomplish this goal?

shivi.btech08
2021-08-31 21:03
has joined #pact-jvm

uglyog
2021-08-31 22:34
It's verifying both keys and values, but only the type of the values.

franklin.lucena89
2021-08-31 22:39
it's there a way using this statement to allow the reception of null values? I mean, my response body have some key that are string type but also I can receive a null value for that key for example: ```{"key": "string}``` but also can be ```{"key": null}``` How can I test this body considering that sometimes I get this null value?

uglyog
2021-08-31 22:43
You need two different contract tests, one where the value is a string and one where it is null

jarmy
2021-08-31 23:47
I ran into something similar with my gradle+springboot project. IIRC, there were multiple `scala-library` dependencies on the classpath. Using `force('org.scala-lang:scala-library:2.12.10')` solved it

david.vancouvering
2021-08-31 23:48
Thanks, Jason. I found a way to exclude it in maven, I should have reported back here. Yours looks like gradle syntax?

jarmy
2021-08-31 23:48
Yep, it's gradle

david.vancouvering
2021-08-31 23:48
For maven, it's something like this: ``` <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>spring</artifactId> <version>4.2.8</version> <scope>test</scope> <exclusions> <exclusion> <artifactId>scala-library</artifactId> <groupId>org.scala-lang</groupId> </exclusion> </exclusions> </dependency>```

david.vancouvering
2021-08-31 23:49
`<exclusions>` being the trick

jarmy
2021-08-31 23:53
I believe I tried the exclusion trick on the pact.provider dependency without any success

david.vancouvering
2021-08-31 23:54
I put it for both the `spring` and `junit` artifacts of `pact.provider` and it did the trick

jarmy
2021-08-31 23:54
yeah, I just tested putting it on both deps and it seems to work

qingyuliu
2021-09-01 02:12
Hi, I have a question about upload pact file to pact broker from the consumer side. Here is how my plugin defined: ```<plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>${pact-jvm-provider-maven.version}</version> <configuration> <pactBrokerUrl>http://localhost:8085</pactBrokerUrl> </configuration> <executions> <execution> <phase>install</phase> <goals> <goal>publish</goal> </goals> </execution> </executions> </plugin> <properties> <pact-jvm-provider-maven.version>4.1.7</pact-jvm-provider-maven.version> </properties>``` And I got the error: [ERROR] No plugin found for prefix 'pact' in the current project and in the plugin groups [org.mortbay.jetty, com.ebay.raptor.build, org.codehaus.mojo, org.sonatype.maven.plugins, org.apache.maven.plugins], I've tried many different versions of the pact-jvm-provider-maven like 4.1.23, 4.1.11, etc, Can anyone help me solve this problem?

uglyog
2021-09-01 02:14
Is `<properties>` at the correct place? Compare your project to https://github.com/uglyog/pact-maven-springboot-test


kpuengpanich
2021-09-01 07:14
has joined #pact-jvm

ringo
2021-09-01 07:28
To test web APIs with Pact, I see three "processes" in place: the JVM running the tests, the JVM running the microservice under test, and the process running any contracts of a dependent service. Correct me if I'm wrong. While reading this blog article on message based architectures (https://dius.com.au/2017/08/22/contract-testing-serverless-and-asynchronous-applications/), the code snippets seem to call directly into the code. This lets me thing that the tests run now in the same JVM as the microservice itself. Is there an option to also write message based tests "out-of-band" from my microservice?

uglyog
2021-09-01 07:32
They run in the test JVM, not the microserivce JVM. Same as unit tests.

mhmtyuceoz
2021-09-01 07:35
has joined #pact-jvm

ringo
2021-09-01 07:57
But PACT message based tests do not run against a fully running microservice in a separate JVM, right? Asking because I think it is difficult then to combine the two styles in a single technical setup.

uglyog
2021-09-01 07:58
Why does it need to run against the fully running microservice in a separate JVM?

ringo
2021-09-01 08:03
Because that is the technical setup (I assumed) for the web API based tests, and we have microservices having an API *and* handling messages. So, I'm searching for a setup which can handle such "functional tests" against the microservice under test.

matt.fellows
2021-09-01 08:45
You're right, pact can't currently test this way

matt.fellows
2021-09-01 08:45
It really is a unit test and needs access to the code

franklin.lucena89
2021-09-01 10:38
Thanks a lot for your help

srinagasai.krishnasan
2021-09-01 15:13
@phil.endsley @uglyog Do you have any inputs?

david.vancouvering
2021-09-01 16:39
Hey, I am encountering weird problems when I include the `provider.junit.target` and `provider.junit` libraries in my Maven dependencies. First of all, abstract test classes are failing with InstantiationException whereas in the past they just weren't run. Secondly, the Jenkins mult-module plugin is failing with a SAX parsing exception when it tries to publish the surefire plugin reports generated as part of running tests. I remove these dependencies, the problems go away. I can only surmise that somehow these plugins are either overriding how Junit works or are requiring a different version of junit than what I am using otherwise? I can keep digging but I was hoping perhaps someone could help me understand why this might be happening and any suggestions to resolve it. Thanks!

david.vancouvering
2021-09-01 16:43
I ran mvn dependency:tree and saw this... ```[INFO] +- au.com.dius.pact.provider:junit:jar:4.2.2:test [INFO] | +- org.apache.httpcomponents:fluent-hc:jar:4.5.12:test [INFO] | | \- commons-logging:commons-logging:jar:1.2:compile [INFO] | +- junit:junit:jar:4.13:compile``` I'll try excluding junit from this dependency and see if that resolves the issue. Any reason I should avoid this?

david.vancouvering
2021-09-01 16:57
Yep that did it! ``` <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit</artifactId> <version>4.2.2</version> <scope>test</scope> <exclusions> <exclusion> <groupId>junit</groupId> <artifactId>junit</artifactId> </exclusion> <exclusion> <artifactId>scala-library</artifactId> <groupId>org.scala-lang</groupId> </exclusion> </exclusions> </dependency>```

jarmy
2021-09-01 18:44
Hi. My colleague @srinagasai.krishnasan and I are having a tough time figuring how we'd generate a `PactDslJsonBody` for our use case where the same _request_ yields different responses with dynamic keys. For example, `PE:6990877, PC:4, and TL:50` are always dynamic ``` "result": { "annotations": { "PE:6990877": { "name": "745: Getting Out", "duration": 3544 }, "PC:4": { "name": "This American Life", "duration": 4358 }, "TL:50": { "name": "740: There. I Fixed It", "duration": 4358 } }, }``` We've tried `eachKeyLike` (https://docs.pact.io/implementation_guides/jvm/consumer/junit/#matching-any-key-in-a-map) but cannot get it to work. I feel like others would have run into this issue. Any help would be appreciated.

franklin.lucena89
2021-09-01 19:01
I think you have to use `.like()` statement just for validate de keys but not the values

srinagasai.krishnasan
2021-09-01 20:28
Even with `.like("PE:690877", getHashMapOfObject())` the matcher generated will look like this ```"$.http://result.annotations.PE:6990877": { "combine": "AND", "matchers": [ { "match": "type" } ] },``` Since that key is not present, it's failing.

franklin.lucena89
2021-09-01 20:30
uh ok, I think that will have to create two different pact, one with all fields and one with the missing one

srinagasai.krishnasan
2021-09-01 20:51
I'm sry I don't follow. I have tried adding matchers without building the body for the `annotations` part. It didn't seem to consider those matchers at all. Eg: This is under `body` category. ``` matchers.addRule("$.result.annotations.*", TypeMatcher.INSTANCE); matchers.addRule("$.result.annotations.*.name", TypeMatcher.INSTANCE);```

uglyog
2021-09-01 23:03
`eachKeyLike` will compare the value of `ob1-dynamic` (`{...}`) and `ob2-dynamic` (`{...}`) to the value of the field from the expected object.


uglyog
2021-09-01 23:10
This generates: ```{ "articles": [ { "variants": { "0032": { "description": "sample description" } } } ] }```

uglyog
2021-09-01 23:11
And can match any variant of an article (i.e. there can be any number of attributes similar to `"0032"`

david.vancouvering
2021-09-02 00:39
Hey, all. It looks like I still have the problem with the Jenkins multi-module plugin hitting a SAX error processing reports in the `target/surefire-reports` directory when I include the pact junit jars in my pom. I noticed that the output in this directory differs *significantly* between when I include the dependencies or not. Without dependencies, it just has XML files in the directory. With the pact dependencies, a bunch of other stuff is in this directory - other directories, HTML files, CSS files, etc. (see below) When I ran the maven enforcer plugin, it found a bunch of conflicting dependencies, but none of them were between the pact libraries and junit or surefire. I was wondering if anybody had any ideas. Should I be using a newer/older version of the Pact libraries? ```? LoyaltyModule git:(dvc/VALAR-247-pact) ? ls target/surefire-reports Surefire suite com.ebay.app.viexpio.module.loyalty.builder.NectarComponentBuilderTest.txt TEST-com.ebay.app.viexpio.module.loyalty.LoyaltyModuleAcceptanceTest.xml com.ebay.app.viexpio.module.loyalty.builder.RewardsURLBuilderTest.txt TEST-com.ebay.app.viexpio.module.loyalty.builder.BucksComponentBuilderTest.xml com.ebay.app.viexpio.module.loyalty.config.LoyaltyConfigProviderTest.txt TEST-com.ebay.app.viexpio.module.loyalty.builder.CouponComponentBuilderTest.xml com.ebay.app.viexpio.module.loyalty.model.LoyaltyModuleRequestTest.txt TEST-com.ebay.app.viexpio.module.loyalty.builder.LoyaltyModuleUxComponentBuilderTest.xml com.ebay.app.viexpio.module.loyalty.provider.LoyaltyModuleDataProviderTest.txt TEST-com.ebay.app.viexpio.module.loyalty.builder.LoyaltyTrackingBuilderTest.xml emailable-report.html TEST-com.ebay.app.viexpio.module.loyalty.builder.NectarComponentBuilderTest.xml failed.png TEST-com.ebay.app.viexpio.module.loyalty.builder.RewardsURLBuilderTest.xml index.html TEST-com.ebay.app.viexpio.module.loyalty.config.LoyaltyConfigProviderTest.xml jquery-1.7.1.min.js TEST-com.ebay.app.viexpio.module.loyalty.model.LoyaltyModuleRequestTest.xml junitreports TEST-com.ebay.app.viexpio.module.loyalty.provider.LoyaltyModuleDataProviderTest.xml navigator-bullet.png bullet_point.png old collapseall.gif passed.png com.ebay.app.viexpio.module.loyalty.LoyaltyModuleAcceptanceTest.txt skipped.png com.ebay.app.viexpio.module.loyalty.builder.BucksComponentBuilderTest.txt testng-reports.css com.ebay.app.viexpio.module.loyalty.builder.CouponComponentBuilderTest.txt testng-reports.js com.ebay.app.viexpio.module.loyalty.builder.LoyaltyModuleUxComponentBuilderTest.txt testng-results.xml com.ebay.app.viexpio.module.loyalty.builder.LoyaltyTrackingBuilderTest.txt testng.css```

uglyog
2021-09-02 00:45
Can you provide the conflicting dependencies? But this feels like the Jenkins multi-module plugin might be needed older dependencies.

vbhardwaj.eminent
2021-09-02 05:06
Hi, I am writing provider side pact test and wondering if I can see some examples of WebMvcTest. PACT-JVM workshop has example for SpringbootTest not WebMvcTest. My provider is in Maven, Java and I am using junit5spring dependency for pact. Also, on http://pact.io the WebMvcTest example is not compete.

matt.fellows
2021-09-02 05:15
As you can imagine, it?s very difficult providing examples and workshops that combine every single combination of technology/framework, that also remain up to date

matt.fellows
2021-09-02 05:15
perhaps you could share the specific problem you?re having and then guidance could be shared?

giancarlo.dipaolanton
2021-09-02 05:17
has joined #pact-jvm

volkan.tufekci
2021-09-02 08:47
has joined #pact-jvm

yassine
2021-09-02 10:59
has joined #pact-jvm

franklin.lucena89
2021-09-02 12:57
Hi everyone, morning. I have a question, I'm developing my pact test and I was wondering if there's a way append new pact files with a timestamp as part of the file name and if is this a good practice?

dimundo
2021-09-02 13:12
there is pact version and tags, why extra entity ?

dimundo
2021-09-02 13:13
and yes :smile:

franklin.lucena89
2021-09-02 13:14
Time zone issue!

franklin.lucena89
2021-09-02 13:16
So, it's a good practice to store at pact folder all version of pact files?

dimundo
2021-09-02 13:16
Why ? you have pact broker for that

franklin.lucena89
2021-09-02 13:17
Ok, the best way might overwrite the last one, right?

dimundo
2021-09-02 13:17
and as a good practice noone publishes pacts from local machine, only CI does that

dimundo
2021-09-02 13:18
and CI does that on clean machine, nothing is owerwritten

franklin.lucena89
2021-09-02 13:19
ok, thank a lot for your help!

matt.fellows
2021-09-02 13:23
:taco: for @dimundo, thank you for being so helpful!

srinagasai.krishnasan
2021-09-02 13:29
The problem here is one key could be like `AB:1234567` other could be `CD:123456` . The size of string might vary. Would it cover this scenario as well?

connor.beck
2021-09-02 13:39
has joined #pact-jvm

abubics
2021-09-02 13:49
For a little more context, if you have Pact configured to point to a directory (very normal setup), and you have different revisions of the same contract, they almost certainly won't all pass (because they have real differences) :bananadance:

franklin.lucena89
2021-09-02 14:22
Hey guys, question, we have three different environment's , so my question is, do we need to have a pack broker for each environment?

dimundo
2021-09-02 14:23
you need tag for every env

dimundo
2021-09-02 14:23
as envs arent ready for jvm

franklin.lucena89
2021-09-02 15:05
Ok thank!

franklin.lucena89
2021-09-02 15:08
Hi, I'm creating this PactDslJsonBody ``` DslPart respBody = new PactDslJsonBody() .eachLike("channels", new PactDslJsonBody() .like("id", "1") .like("name", "ChannelName") .like("entitled", true) .like("internalId", UUID.randomUUID()) .like("showChannel", true) .like("periodStartDate", new Date()) .like("periodEndDate", new Date()) .like("whitelistBlacklist", "null") .like("seminarContentAccess", "null") );``` and the generated file looks like this ``` "body": { "channels": [ { "entitled": true, "id": "1", "internalId": null, "name": "ChannelName", "periodEndDate": null, "periodStartDate": null, "seminarContentAccess": "null", "showChannel": true, "whitelistBlacklist": "null" } ] },``` why I'm getting those values null?

maurits.out
2021-09-02 15:12
has joined #pact-jvm

phil.endsley
2021-09-02 15:13
Can't tell you why they're null, but best practice is to hard code example values instead of them being random. If they're random (new uuid, new date, etc...), A new value will be generated each time the contract is generated. Your contracts will never be the same, even if you generate it from the same commit/version. If you ever use pact broker, you'll be losing out on the pre-validated contracts feature, so you'll be running tests/verifications way more than you need to.

franklin.lucena89
2021-09-02 15:15
The thing is what I'm trying to do it's to validate the field and type of value but not the actual value, I don't know if is this the best way to do it

phil.endsley
2021-09-02 15:33
As a disclaimer, I almost never look at the generated file. What you described is best practice. I'm saying the content of your generated contract is going to change every time you generate your contract. Because of that, you'll be missing out on some great features that cut out a lot of unnecessary work. For the example values, instead of using `new Date()`, use `new Date(1630596700338)`. Instead of `UUID.randomUUID()`, use `UUID.fromString("61a6b9aa-9ef3-43ba-b076-16e3859056b0")`. It makes the example values the same, so the contract doesn't change on each build

phil.endsley
2021-09-02 15:34
As a side note, it looks like you're getting `null` when you use an object as a parameter to `like`. I haven't played around with that matcher yet, but maybe try the old way of matching? ex: `.date` or `.uuid`?

franklin.lucena89
2021-09-02 15:38
ahmm I get you now! actually I don't ever tested those matcher I will take a look and run my test, thank u very much for the help

philipchardwick
2021-09-02 16:40
I'm moving this https://pact-foundation.slack.com/archives/C9VPNUJR2/p1630572354082300 here since I've spent a while debugging and I'm not getting close to anything. I have a Gradle build which is publishing pacts from the `pactPublish` task using latest version 4.2.10, but for some pact files it gets a ```> Task :pactPublish FAILED Caching disabled for task ':pactPublish' because: Build cache is disabled Task ':pactPublish' is not up-to-date because: Task has not declared any outputs despite executing actions. Publishing 'one-pact.json' ... Failed - our-pact-broker:443 failed to respond Publishing 'another-pact.json' ... Failed - our-pact-broker:443 failed to respond Publishing 'other-pact.json' ... Failed - our-pact-broker:443 failed to respond Publishing 'last-one.json' ... Failed - our-pact-broker:443 failed to respond :pactPublish (Thread[Daemon worker,5,main]) completed. Took 1.354 secs.``` The pact broker CLI publishes these files fine, and I can publish these files fine to a new pact broker running locally in docker compose. I've tried updating versions of commons-lang3 and Kotlin as suggested in a few issues similar to this https://github.com/pact-foundation/pact-jvm/issues/1176 but that hasn't changed anything (but maybe because the gradle plugin classpath is separate from the test classpath hence a dodgy dependency still exists when running the task?) Any other ideas?

kumasaka.tk
2021-09-02 21:24
has joined #pact-jvm

uglyog
2021-09-02 23:19
This is normally due to a proxy. The JVM HTTP client uses JVM system properties, not environment variables, so it won't be picking up any proxy settings

uglyog
2021-09-02 23:21
The key makes no difference

uglyog
2021-09-02 23:21
As long as the values have the same structure

tjones
2021-09-03 01:03
With pending pacts and the JUnit runner, IntelliJ is showing the failing tests as passing when they're more "skipped" because they failed, I think. Is there a way to get better feedback with pending pacts?

uglyog
2021-09-03 01:45
JUnit4?

tjones
2021-09-03 02:06
Junit5

uglyog
2021-09-03 02:08
I think the problem is if a test is marked as skipped, it does not get run. We don't want that.

uglyog
2021-09-03 02:15
Does it not have pending in the description?

tjones
2021-09-03 02:54
This is what we see - but it's not great, because you have to manually click on the passing tests to see if they really are passing

uglyog
2021-09-03 02:58
Maybe pending should come first in the description

uglyog
2021-09-03 03:19
If you have an idea on how to improve it, please raise an issue for that.

tjones
2021-09-03 04:36
I think it would be ideal if the "failing but ignored because pending" appeared as skipped or some other non-success in the UI. But I don't know if that's possible.

uglyog
2021-09-03 06:44
Can't do that. It is an error to generate a `Test Started` event followed by a `Test Skipped` event. JUnit fails with something like an invalid state error.

uglyog
2021-09-03 06:53
But that might have been JUnit 4. With JUnit 5, you have to give the list of test contexts to run, up front.

philipchardwick
2021-09-03 06:55
We don't use a proxy, also I think if it was a proxy issue, all pact publishing would fail but some (small pacts) do get published successfully

philipchardwick
2021-09-03 07:27
Do you have any suggestions of how to narrow this down? How do you generally investigate these errors?

uglyog
2021-09-03 07:29
I can't think of a condition that would cause one request to work and another to not respond which is not related to a proxy server.

uglyog
2021-09-03 07:30
Is the broker running on k8s?

philipchardwick
2021-09-03 07:30
Yes

uglyog
2021-09-03 07:30
@matt.fellows, any ideas?

philipchardwick
2021-09-03 07:30
Behind an nginx ingress which does TLS

uglyog
2021-09-03 07:31
Ok, that would be a place to start

philipchardwick
2021-09-03 07:31
Strange thing is the pact broker CLI uses the same endpoint and route to the broker and that publishes it fine

uglyog
2021-09-03 07:33
If you can capture the headers from the CLI call and from the Pact-JVM call, we could look at that

philipchardwick
2021-09-03 07:34
Yeah - one difference I notice is that the JVM always does a call without auth first and then adds auth in the second call, whereas the CLI just adds the `Authorization` header always

uglyog
2021-09-03 07:36
You can try enabling preemptive auth, but I don't see how that would only affect large files

philipchardwick
2021-09-03 07:36
Yeah worth a shot, thanks!

matt.fellows
2021-09-03 07:51
The only thing I can think of is that the CLI and the JVM implementation may have different retry / timeout logic

matt.fellows
2021-09-03 07:51
so on a clean instance (with no load), database writes are likely to be faster

matt.fellows
2021-09-03 07:52
on the real thing, there is load so it could be slower (and with traffic, contention, leading to locks etc.)

matt.fellows
2021-09-03 07:52
Logs should reveal if retries are happening and how long the requests are taking

matt.fellows
2021-09-03 07:52
It?s also possible that nginx has a timeout configured, but then you?d expect to see that with the Ruby CLI too

philipchardwick
2021-09-03 07:59
So that was unexpected... the preemptive auth allowed 3 out of 4 to work! The last one, is getting a 500, I think because we use a read only filesystem - I don't know if it's trying to write the error to a file or if it's buffering the request to a file

matt.fellows
2021-09-03 10:32
aha - buffering to disk is definitely a possibility

srinagasai.krishnasan
2021-09-03 14:56
ah, I think that's the problem here. For objects with key `PE:6990877` We have some unique values compared to the values for the key `PC:4` . Now would you tell us how to handle that scenario?

valeriia.danylenko
2021-09-03 18:26
has joined #pact-jvm

franklin.lucena89
2021-09-03 19:27
Hey guys, I'm having this wired behavior on test when run it on my bitbucket pipeline, my response body is this ``` new PactDslJsonBody() .eachLike("channels", new PactDslJsonBody() .like("id", "1") .like("name", "ChannelName") .like("entitled", true) .uuid("internalId", internalId) .like("showChannel", true) .datetime("periodStartDate", "EEE, d MMM yyyy", new Date()) .datetime("periodEndDate", "EEE, d MMM yyyy", new Date()) .like("whitelistBlacklist", "null") .like("seminarContentAccess", "null") ); ``` and the generated pact file look's like this ``` "body": { "channels": [ { "entitled": true, "id": "1", "internalId": "33ef37db-24f3-327f-b520-847dcd549e9f", "name": "ChannelName", "periodEndDate": "Fri, 3 Sep 2021", "periodStartDate": "Fri, 3 Sep 2021", "seminarContentAccess": "null", "showChannel": true, "whitelistBlacklist": "null" } ]``` but bitbucket pipeline it's throwing this ```[ { "entitled":true, "i[nternalId":"33ef37db-24f3-327f-b520-847dcd549e9f", "periodStartDate":"Fri, 3 Sep 2021", "whitelistBlacklist":"null", "name":"ChannelName", "showChannel":true, "id":"1", "seminarContentAccess":"null", "periodEndDate":"Fri, 3 Sep 2021]" } ]}> but was:<... [ { "entitled":true, "i[d":"1", "internalId":"33ef37db-24f3-327f-b520-847dcd549e9f", "name":"ChannelName", "periodEndDate":"Fri, 3 Sep 2021", "periodStartDate":"Fri, 3 Sep 2021", "seminarContentAccess":"null", "showChannel":true, "whitelistBlacklist":"null]" } ] }>``` any idea of this error?

todor.m.kolev
2021-09-03 19:37
Hey, I am working on a simple POC and facing the following issue. Does this mean anything to anybody - I've published my Provider and tagged it with 'SIT'. Then when the consumer CD pipeline kicks in, it publishes the new pact and I have a webhook which triggers the provider verification test. That test pulls the pact with the tag that was passed in as part of the webhook, verifies it and publishes the results setting `providerTags` to `SIT`. Verification passes and publishing of verification results fails :/ ```[info] VerifyPactsSpec: Verifying a pact between PlayerAPI (311873b0) and SessionAPI Notices: 1) The pact at https://myusername.pactflow.io/pacts/provider/SessionAPI/consumer/PlayerAPI/pact-version/d3ba11f0c0976d04eb134f35a8a36a8d37836030 is being verified because the pact content belongs to the consumer version matching the following criterion: * latest version tagged 'UNITY-2799_pact-poc' (311873b0) [from Pact Broker https://myusername.pactflow.io/pacts/provider/SessionAPI/consumer/PlayerAPI/pact-version/d3ba11f0c0976d04eb134f35a8a36a8d37836030/metadata/c1tdW3RdPVVOSVRZLTI3OTlfcGFjdC1wb2Mmc1tdW2xdPXRydWUmc1tdW2N2XT01Nw] a request to create a Player session in a specific universe returns a response which has status code 201 (OK) has a matching body (OK) Failures: 1491) ... 1.1) Publishing verification results failed - Publishing tag 'UNITY-2799_pact-poc' failed: Request failed with HTTP/1.1 404 Not Found Publishing verification results failed with an exception: Request failed with HTTP/1.1 400 Bad Request```

uglyog
2021-09-04 01:02
You can't do that

uglyog
2021-09-04 01:15
Don't do this: ```.eachLike("channels", new PactDslJsonBody() <---```

uglyog
2021-09-04 01:15
Rather:

uglyog
2021-09-04 01:16
```.eachLike("channels") .like("id", "1")```

uglyog
2021-09-04 01:19
What version of Pact-JVM are you using? Can you provide debug logs?

uglyog
2021-09-04 01:25
With these types of errors, it's always the unexpected that gets you :smile:

matt.fellows
2021-09-04 06:12
Also your workflow sounds a little strange. It sounds like maybe your provider build triggers a consumer build which then triggers another provider build?

matt.fellows
2021-09-04 06:13
Can you please elaborate?

todor.m.kolev
2021-09-04 08:21
Did you mean debug logs from the pact broker or... ? I've posted the debug log from running the verification test. I am using pact4s 0.0.16 which under the hood seems to be using dius.pact 4.2.9 In my case, consumer publishing a new contract triggers the provider pipeline. The provider pipeline then checks out a git tag (i.e the source code that's currently in my SIT environment) and only executes the verification test. Consumer build and provider build don't trigger each other outside of what I just described. With this, what I am basically saying is: I am about to release a new version of my consumer, I've just merged my changes in my consumer's code base main branch and I've published my new contract to pactflow. That has triggered the provider verification test using it's codebase that's currently in SIT (by first checking out the SIT git tag as described above). All this is so I can then run `can-i-deploy --to SIT` on consumer side before I deploy to SIT.

matt.fellows
2021-09-04 12:19
Debug logs from pact4s (pact JVM)

matt.fellows
2021-09-04 12:20
What I can see above is definitely not debug level logs, we should be able to see the network calls to the broker

irmt06
2021-09-04 22:51
has joined #pact-jvm

wenqiglantz
2021-09-05 00:54
Check out my article on Medium on using Pact for testing event driven pub/sub messaging with Dapr within Spring Boot microservices.  https://medium.com/codex/consumer-driven-contract-testing-with-pact-f8a28a8a7c3c

sarajcarbajal
2021-09-06 08:23
Hello, I want to verify the pacts generated by the consumer side (a consumer made with Springboot JVM + Maven) In the consumer side, I defined the following Pact: ```@SpringBootTest @ExtendWith(PactConsumerTestExt.class) class ConsumerContractTest { @Pact(consumer = "Student", provider = "StudentService") public RequestResponsePact getStudent(PactDslWithProvider builder) { Map<String, Object> parameters = new HashMap<>(); parameters.put("name", "sara"); parameters.put("email", ""); parameters.put("studentNumber", 23); return builder.given("Student 1 exists", parameters) .uponReceiving("get student with ID 1") .pathFromProviderState("/student/${id}", "/student/1") .method("GET") .willRespondWith() .status(200) .headers(Map.of("Content-Type", "application/json")) .body(newJsonBody(object -> { object.valueFromProviderState("id", "${id}", "1"); object.stringType("name", "Sara"); object.stringType("email", ""); object.numberType("studentNumber", 23); }).build()) .toPact(); } @Test @PactTestFor(pactMethod = "getStudent") void getStudent_whenStudentExist(MockServer mockServer) { Student expected = new Student(); expected.setId("1"); expected.setName("Sara"); expected.setEmail(""); expected.setStudentNumber(23); RestTemplate restTemplate = new RestTemplateBuilder().rootUri(mockServer.getUrl()).build(); Student student = new StudentService(restTemplate).getStudent("1"); assertEquals(expected, student); } }```

sarajcarbajal
2021-09-06 08:26
maven dependencies configured are below: ```<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>4.2.10</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.2.10</version> </plugin> </plugins> </build>``` and the Pact generated is below: ```{ "consumer": { "name": "Student" }, "interactions": [ { "description": "get student with ID 1", "providerStates": [ { "name": "Student 1 exists", "params": { "email": "", "name": "sara", "studentNumber": 23 } } ], "request": { "generators": { "path": { "dataType": "STRING", "expression": "/student/${id}", "type": "ProviderState" } }, "method": "GET", "path": "/student/1" }, "response": { "body": { "email": "", "id": "1", "name": "Sara", "studentNumber": 23 }, "generators": { "body": { "$.id": { "dataType": "STRING", "expression": "${id}", "type": "ProviderState" } } }, "headers": { "Content-Type": "application/json" }, "matchingRules": { "body": { "$.email": { "combine": "AND", "matchers": [ { "match": "type" } ] }, "$.id": { "combine": "AND", "matchers": [ { "match": "type" } ] }, "$.name": { "combine": "AND", "matchers": [ { "match": "type" } ] }, "$.studentNumber": { "combine": "AND", "matchers": [ { "match": "number" } ] } } }, "status": 200 } } ], "metadata": { "pact-jvm": { "version": "4.2.10" }, "pactSpecification": { "version": "3.0.0" } }, "provider": { "name": "StudentService" } }``` In the Provider side, I defined the following validation: ```@EnableMongoRepositories @Provider("StudentService") @Consumer("Student") @PactFolder("src/pacts") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @AutoConfigureDataMongo class ProviderContractTest { @LocalServerPort int port; @Autowired private StudentRepository studentRepository; @Autowired MongoTemplate mongoTemplate; Logger logger = LoggerFactory.getLogger(ProviderContractTest.class); @BeforeEach void setUp(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", port)); mongoTemplate.dropCollection(Student.class); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void verifyPact(PactVerificationContext context) { context.verifyInteraction(); } @State(value = "Student 1 exists", action = StateChangeAction.SETUP) public void student1Exists(Map<String, Object> params) { http://logger.info("Inside Provider state: 'Student 1 exists' setup method"); http://logger.info("Student details from Consumer: " + params.toString()); Student aux = new Student("3", params.get("name").toString(), (Long) params.get("studentNumber"), params.get("email").toString()); studentRepository.save(aux); } }``` maven dependencies configured are below: ```<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency> <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.2.10</version> <scope>test</scope> </dependency> <dependency> <groupId>de.flapdoodle.embed</groupId> <artifactId>de.flapdoodle.embed.mongo</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>com.github.javafaker</groupId> <artifactId>javafaker</artifactId> <version>${javafaker.version}</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.2.10</version> <configuration> <serviceProviders> <serviceProvider> <name>StudentService</name> <protocol>http</protocol> <host>localhost</host> <port>8081</port> <path>/</path> <pactFileDirectory>src/pacts</pactFileDirectory> </serviceProvider> </serviceProviders> </configuration> </plugin> </plugins> </build>``` and when I run `mvn pact:verify` the following error is shown: ``` Provider git:(master) ? mvn pact:verify [INFO] Scanning for projects... [INFO] [INFO] ------------------------< com.example:Provider >------------------------ [INFO] Building Provider 0.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven:4.2.10:verify (default-cli) @ Provider --- Loading pact files for provider StudentService from /Users/sara.jimenez/Documents/QA/STANDARDS/pact-jvm-example/Provider/src/pacts Found 1 pact files Verifying a pact between Student and StudentService [Using File /Users/sara.jimenez/Documents/QA/STANDARDS/pact-jvm-example/Provider/src/pacts/Student-StudentService.json] Given Student 1 exists WARNING: State Change ignored as there is no stateChange URL get student with ID 1 returns a response which has status code 200 (OK) has a matching body (FAILED) NOTE: Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true') Failures: 1) Verifying a pact between Student and StudentService - get student with ID 1 Given Student 1 exists has a matching body 1.1) body: $ Type mismatch: Expected Map {"email":"","id":"","name":"Sara","studentNumber":23} but received List [] -{ - "email": "", - "id": "", - "name": "Sara", - "studentNumber": 23 -} +[ + +] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------``` The springboot application and mongodb are running before starting with the test. I don?t know why the provider state is not working correctly

uglyog
2021-09-06 09:20
As indicated by: ```Given Student 1 exists WARNING: State Change ignored as there is no stateChange URL``` The state change handler was not executed

uglyog
2021-09-06 09:22
You don't use the Maven plugin if you use unit tests: Refer to the comment on https://github.com/pact-foundation/pact-jvm/tree/master/provider/maven

sarajcarbajal
2021-09-06 10:23
thanks you. I mixed several dependencies and it is working now.

divyalakshmi.gk
2021-09-07 01:46
has joined #pact-jvm

constantin.jaeck
2021-09-07 02:24
has joined #pact-jvm

narendra_uppara
2021-09-07 07:17
has joined #pact-jvm

nikuplanchiwar
2021-09-07 08:03
has joined #pact-jvm

sdomeracki
2021-09-07 10:22
has joined #pact-jvm

gibraltor999
2021-09-07 12:03
has joined #pact-jvm

srinagasai.krishnasan
2021-09-07 14:30
Any idea on how we can handle that?

norway.martin
2021-09-07 18:38
has joined #pact-jvm

uglyog
2021-09-07 23:20
Pact doesn't support different shaped values with that matcher. You will have to have different tests, one with the one format and the other with the other format.

adamdullenty
2021-09-08 08:23
has joined #pact-jvm

martin.a.harkins
2021-09-08 12:15
has joined #pact-jvm

franklin.lucena89
2021-09-08 14:30
Hey guys, is there a way to get application.yml file properties into a provider test class? the thing is that I'm using this ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit</artifactId> <version>4.1.21</version> </dependency>``` for my provider and in my test class I'm doing this ```@PactBroker(url = "${pact.broker.url}", authentication = @PactBrokerAuth(username = "pactBrokerUser", password = "pactBrokerPassword") )``` but when I try to run the test,, it throws me this error `Could not resolve property "pact.broker.url" in the system properties or environment variables and no default value is supplied`

phil.endsley
2021-09-08 14:35
I think you need artifactId = spring instead

franklin.lucena89
2021-09-08 14:55
this dependency? `<dependency>` `<groupId>http://au.com.dius</groupId>` `<artifactId>pact-jvm-provider-spring</artifactId>` `<version>4.0.10</version>` `</dependency>`

phil.endsley
2021-09-08 15:02
No


franklin.lucena89
2021-09-08 15:07
Oh that one! my bad! thank you very much for your help, now I'm able to get properties

todor.m.kolev
2021-09-08 17:37
So I am getting the following error: ```{"@timestamp":"2021-09-08T17:47:34.204+00:00","@version":1,"message":"PUT JSON request failed with status HTTP/1.1 400 Bad Request","logger_name":"au.com.dius.pact.core.pactbroker.HalClient","thread_name":"pool-1-thread-1-ScalaTest-running-VerifyPactsSpec","level":"ERROR","level_value":40000} {"@timestamp":"2021-09-08T17:47:34.208+00:00","@version":1,"message":"Publishing verification results failed with an exception","logger_name":"au.com.dius.pact.core.pactbroker.PactBrokerClient","thread_name":"pool-1-thread-1-ScalaTest-running-VerifyPactsSpec","level":"ERROR","level_value":40000,"stack_trace":"java.io.IOException: Attempted read from closed stream.\n\tat org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:165)\n\tat org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:135)\n\tat java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)\n\tat java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)\n\tat java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)\n\tat java.base/java.io.InputStreamReader.read(InputStreamReader.java:181)\n\tat java.base/java.io.Reader.read(Reader.java:229)\n\tat org.apache.http.util.EntityUtils.toString(EntityUtils.java:227)\n\tat org.apache.http.util.EntityUtils.toString(EntityUtils.java:308)\n\tat au.com.dius.pact.core.pactbroker.HalClient$postJson$2.invoke(HalClient.kt:189)\n\tat au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:38)\n\tat au.com.dius.pact.core.pactbroker.HalClient.postJson(HalClient.kt:177)\n\tat au.com.dius.pact.core.pactbroker.HalClient.postJson(HalClient.kt:167)\n\tat au.com.dius.pact.core.pactbroker.PactBrokerClient.publishVerificationResults(PactBrokerClient.kt:377)\n\tat au.com.dius.pact.core.pactbroker.PactBrokerClient.publishVerificationResults(PactBrokerClient.kt:363)\n\tat au.com.dius.pact.provider.DefaultVerificationReporter.publishResult(VerificationReporter.kt:106)\n\tat au.com.dius.pact.provider.DefaultVerificationReporter.reportResults(VerificationReporter.kt:84)\n\tat au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer(ProviderVerifier.kt:728)\n\tat au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer$default(ProviderVerifier.kt:705)\n\tat au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer(ProviderVerifier.kt)\n\tat pact4s.PactVerifyResources.verifySingleConsumer(PactVerifyResources.scala:36)\n\tat pact4s.PactVerifyResources.verifySingleConsumer$(PactVerifyResources.scala:33)\n\tat com.williamhill.platform.session.integration.routes.VerifyPactsSpec.verifySingleConsumer(VerifyPactsSpec.scala:37)\n\tat pact4s.PactVerifyResources.$anonfun$verifyPacts$14(PactVerifyResources.scala:64)\n\tat java.base/java.util.ArrayList.forEach(ArrayList.java:1541)\n\tat pact4s.PactVerifyResources.verifyPacts(PactVerifyResources.scala:64)\n\tat pact4s.PactVerifyResources.verifyPacts$(PactVerifyResources.scala:44)\n\tat com.williamhill.platform.session.integration.routes.VerifyPactsSpec.verifyPacts(VerifyPactsSpec.scala:37)\n\tat com.williamhill.platform.session.integration.routes.VerifyPactsSpec.$anonfun$new$2(VerifyPactsSpec.scala:82)\n\tat scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)\n\tat org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)\n\tat org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)\n\tat org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)\n\tat org.scalatest.Transformer.apply(Transformer.scala:22)\n\tat org.scalatest.Transformer.apply(Transformer.scala:20)\n\tat org.scalatest.flatspec.AnyFlatSpecLike$$anon$5.apply(AnyFlatSpecLike.scala:1812)\n\tat org.scalatest.TestSuite.withFixture(TestSuite.scala:196)\n\tat org.scalatest.TestSuite.withFixture$(TestSuite.scala:195)\n\tat org.scalatest.flatspec.AnyFlatSpec.withFixture(AnyFlatSpec.scala:1685)\n\tat org.scalatest.flatspec.AnyFlatSpecLike.invokeWithFixture$1(AnyFlatSpecLike.scala:1810)\n\tat org.scalatest.flatspec.AnyFlatSpecLike.$anonfun$runTest$1(AnyFlatSpecLike.scala:1822)\n\tat org.scalatest.SuperEngine.runTestImpl(Engine.scala:306)\n\tat org.scalatest.flatspec.AnyFlatSpecLike.runTest(AnyFlatSpecLike.scala:1822)\n\tat org.scalatest.flatspec.AnyFlatSpecLike.runTest$(AnyFlatSpecLike.scala:1804)\n\tat org.scalatest.flatspec.AnyFlatSpec.runTest(AnyFlatSpec.scala:1685)\n\tat org.scalatest.flatspec.AnyFlatSpecLike.$anonfun$runTests$1(AnyFlatSpecLike.scala:1880)\n\tat org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:413)\n\tat scala.collection.immutable.List.foreach(List.scala:333)\n\tat org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)\n\tat org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:396)\n\tat org.scalatest.SuperEngine.runTestsImpl(Engine.scala:475)\n\tat org.scalatest.flatspec.AnyFlatSpecLike.runTests(AnyFlatSpecLike.scala:1880)\n\tat org.scalatest.flatspec.AnyFlatSpecLike.runTests$(AnyFlatSpecLike.scala:1879)\n\tat org.scalatest.flatspec.AnyFlatSpec.runTests(AnyFlatSpec.scala:1685)\n\tat org.scalatest.Suite.run(Suite.scala:1112)\n\tat org.scalatest.Suite.run$(Suite.scala:1094)\n\tat http://org.scalatest.flatspec.AnyFlatSpec.org$scalatest$flatspec$AnyFlatSpecLike$$super$run(AnyFlatSpec.scala:1685)\n\tat org.scalatest.flatspec.AnyFlatSpecLike.$anonfun$run$1(AnyFlatSpecLike.scala:1925)\n\tat org.scalatest.SuperEngine.runImpl(Engine.scala:535)\n\tat org.scalatest.flatspec.AnyFlatSpecLike.run(AnyFlatSpecLike.scala:1925)\n\tat org.scalatest.flatspec.AnyFlatSpecLike.run$(AnyFlatSpecLike.scala:1923)\n\tat http://com.williamhill.platform.session.integration.routes.VerifyPactsSpec.org$scalatest$BeforeAndAfterAll$$super$run(VerifyPactsSpec.scala:37)\n\tat org.scalatest.BeforeAndAfterAll.liftedTree1$1(BeforeAndAfterAll.scala:213)\n\tat org.scalatest.BeforeAndAfterAll.run(BeforeAndAfterAll.scala:210)\n\tat org.scalatest.BeforeAndAfterAll.run$(BeforeAndAfterAll.scala:208)\n\tat com.williamhill.platform.session.integration.routes.VerifyPactsSpec.run(VerifyPactsSpec.scala:37)\n\tat http://org.scalatest.tools.Framework.org$scalatest$tools$Framework$$runSuite(Framework.scala:318)\n\tat org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:513)\n\tat sbt.ForkMain$Run.lambda$runTest$1(ForkMain.java:413)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base/java.lang.Thread.run(Thread.java:834)\n"} {"@timestamp":"2021-09-08T17:47:34.209+00:00","@version":1,"message":"Failed to publish verification results - Publishing verification results failed with an exception: Attempted read from closed stream.","logger_name":"au.com.dius.pact.provider.DefaultVerificationReporter","thread_name":"pool-1-thread-1-ScalaTest-running-VerifyPactsSpec","level":"ERROR","level_value":40000}```

todor.m.kolev
2021-09-08 17:55
Looks like something is closing the stream prematurely...

franklin.lucena89
2021-09-08 18:01
I'm having this issue with test class, at top of the class declaration where I set `@PactBroker` annotation I'm able to access properties, but inside the class where I set `@TestTarget` object don't

phil.endsley
2021-09-08 18:32
Are you running your test with a spring context? Ex: SpringBootTest or similar

franklin.lucena89
2021-09-08 18:32
with SpringBootTest

franklin.lucena89
2021-09-08 20:28
How can I setup values to my provider `@TestTarget` object according to my context props? ex: ``` @Value("${pact.entitlement.host}") private String host; @TestTarget public final Target target = new HttpTarget("https", host, 0, "/");``` when I run this test class, always get an error because `host` var it's null

uglyog
2021-09-08 22:38
This line ```public final Target target = new HttpTarget("https", host, 0, "/");``` is executed when the test class is instantiated. The spring properties will not have been applied yet

uglyog
2021-09-08 22:39
If you want to use the spring properties, you need to use a before method to setup the target

rocco.smit
2021-09-09 06:20
has joined #pact-jvm

lucas.rolle
2021-09-09 08:05
Hey everyone, I'm trying to define a multipart body containing a JSON-Payload and a file upload. I stumbled across this https://github.com/pact-foundation/pact-jvm/issues/123 and the .withFileUpload(...) function works like a charm. However I can't define the JSON-Payload part of the message. Example POST Message: ```PRESENT(--jRjKig8srZS18bjZFtTm02iFjsYrVLVW7zIw5GN4 Content-Type: application/json Content-Disposition: form-data; name="testData" Content-Length: 15 {"Test":"test"} --jRjKig8srZS18bjZFtTm02iFjsYrVLVW7zIw5GN4 Content-Type: application/octet-stream Content-Disposition: form-data; name="pdfFile" Content-Length: 4 TEST --jRjKig8srZS18bjZFtTm02iFjsYrVLVW7zIw5GN4-- )``` Currently I'm just getting the JSON part or the file part. Any tips how I can create this pact body using the PactDslWithProvider builder? Thanks

todor.m.kolev
2021-09-09 09:07
Actually, I've had another look at it and it seems that this is the actual error: ```{"@timestamp":"2021-09-08T18:04:55.217+00:00","@version":1,"message":"Response body: {\"errors\":{\"provider_version\":[\"can't be blank\",\"Version number '' cannot be parsed to a version number. The expected format (unless this configuration has been overridden) is a semantic version. eg. 1.3.0 or 2.0.4.rc1\"]}}","logger_name":"au.com.dius.pact.core.pactbroker.HalClient","thread_name":"pool-1-thread-1-ScalaTest-running-VerifyPactsSpec","level":"DEBUG","level_value":10000}``` which I am debugging atm...

andrei_mironau
2021-09-09 10:00
has joined #pact-jvm

febin.sathar
2021-09-09 10:17
has joined #pact-jvm

todor.m.kolev
2021-09-09 11:16
It looks like it's a gitlab issue, sorry about the noise!

jcaromiq
2021-09-09 11:47
has joined #pact-jvm

franklin.lucena89
2021-09-09 13:35
```@TestTarget public Target target; @Before public void setup() { target = new HttpTarget("https", host, port, path); }``` Hi, I'm doing this but still getting null value error

franklin.lucena89
2021-09-09 18:58
Hi, I'm doing some provider test, and I need to set the `@TestTarget` host and port values from an application.yml file, I'm trying to do this ```@TestTarget public Target target; @Before public void setup() { target = new HttpTarget("https", host, port, path); }``` but I'm getting this error `kotlin.TypeCastException: null cannot be cast to non-null type http://au.com.dius.pact.provider.junitsupport.target.Target` can anyone help me with this issue?

mirko.zipris
2021-09-09 20:08
has joined #pact-jvm

franklin.lucena89
2021-09-09 21:49
this is my entire class configuration ```@Value("${pact.entitlement.host}") private String host; @Value("${pact.entitlement.port}") private int port; @Value("${pact.entitlement.path}") private String path; @TestTarget public Target target; @Before public void setup() { target = new HttpTarget("https", host, port, path); }``` This is my yml file, btw ```pact: providers: - id: Some Service host: path: "/" port: 0 env: stage``` but I'm getting this error `kotlin.TypeCastException: null cannot be cast to non-null type http://au.com.dius.pact.provider.junitsupport.target.Target`  can anyone help me with this issue?

uglyog
2021-09-09 23:01
That was implemented to support image uploads as multipart post requests. There is no DSL support for adding arbitrary content types as different parts.

uglyog
2021-09-09 23:02
Can you check that the values are actually set in the before method?

franklin.lucena89
2021-09-09 23:03
Yes, they are getting set at before method @uglyog

uglyog
2021-09-09 23:03
There is a `SpringBootHttpTarget` which will look up the port from the Spring context

uglyog
2021-09-09 23:04
But it won't set a different host name, it will use localhost

uglyog
2021-09-09 23:05
Can you provide the full stack trace?

franklin.lucena89
2021-09-09 23:05
I read about it, but according to my services architecture need to call to an external host

franklin.lucena89
2021-09-09 23:07
```kotlin.TypeCastException: null cannot be cast to non-null type au.com.dius.pact.provider.junitsupport.target.Target at au.com.dius.pact.provider.junit.InteractionRunner.lookupTarget(InteractionRunner.kt:269) at au.com.dius.pact.provider.junit.InteractionRunner.interactionBlock(InteractionRunner.kt:237) at au.com.dius.pact.provider.junit.InteractionRunner.run(InteractionRunner.kt:170) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:159) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)```

uglyog
2021-09-09 23:18
Looks like that won't work, the target has to be set before the @Before methods are executed

uglyog
2021-09-09 23:18
You might have to upgrade to JUnit 5 to do this

franklin.lucena89
2021-09-09 23:19
that is a really bad news because the whole project have unit test developed under junit4

uglyog
2021-09-09 23:20
You can try setting the default value, then overriding it with a new one in the before, but it may not work

uglyog
2021-09-09 23:21
BTW, You can run JUnit 4 and 5 together

franklin.lucena89
2021-09-09 23:22
actually I tried to override it value but always call to localhost at 8080 port

franklin.lucena89
2021-09-09 23:23
running both junit versions wouldn't be any dependency mismatch issue?

uglyog
2021-09-09 23:43
No, you actually run everything with the JUnit 5 engine, but it has a legacy engine that then runs the JUint 4 tests


dotelnp
2021-09-10 06:48
has joined #pact-jvm

thanuxxxx
2021-09-10 16:04
Question, I have like 3 resources eg `customer, order, products`. What is the best practice to write tests (provider side)? Can I have 3 pact test classes or just keep one class for all pact tests?

thanuxxxx
2021-09-10 16:08
Right now I have only one class for pact test but is is getting bigger and hard to read

sameer.patil
2021-09-10 18:42
has joined #pact-jvm

b.1.alpha
2021-09-10 19:17
has joined #pact-jvm

franklin.lucena89
2021-09-10 19:19
Hey, I'm using the junit 5 maven dependency to make a provider test, and I'm doing this configuration ```@ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @Provider("provider") @Consumer("consumer") @PactBroker(host = "${pact.broker.host}", port = "${pact.broker.port}", authentication = @PactBrokerAuth(username = "${pact.broker.username}", password = "${pact.broker.password}") ) @ActiveProfiles("test")``` and my yml file is like this ``` pact: broker: host: http://localhost port: 9292 username: pactBrokerUser password: pactBrokerPassword``` and when I try to run the test, I'm getting this error ` ```java.lang.RuntimeException: Could not resolve property "pact.broker.host" in the system properties or environment variables and no default value is supplied at au.com.dius.pact.core.support.expressions.SystemPropertyResolver.resolveValue(SystemPropertyResolver.kt:20) at au.com.dius.pact.core.support.expressions.ExpressionParser.replaceExpressions(ExpressionParser.kt:81) at au.com.dius.pact.core.support.expressions.ExpressionParser.parseExpression(ExpressionParser.kt:58) at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.getPactBrokerSource(PactBrokerLoader.kt:245) at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.description(PactBrokerLoader.kt:83) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.resolvePactSources(PactJUnit5VerificationProvider.kt:78) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:40) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:100) at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:271) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:104) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:40) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)``` Any idea on how to solve this?

thanuxxxx
2021-09-10 19:37
Are you extend with `PactVerificationSpringProvider.class`? Show us your `@TestTemplate` code

franklin.lucena89
2021-09-10 19:40
This is my entire class ```public class AuthServicePactTest { @Autowired @Qualifier("pactProperties") private PactProperties pactProperties; @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @BeforeEach public void setupTestTarget(PactVerificationContext context) { context.setTarget(new HttpsTestTarget(pactProperties.getEntitlement().getHost(), pactProperties.getEntitlement().getPort())); } @State("A user id as part of the path") public void toGetState() { pactProperties.getEntitlement().getHost(); } }```

thanuxxxx
2021-09-10 19:41
Change `PactVerificationInvocationContextProvider.class` to `PactVerificationSpringProvider.class`

franklin.lucena89
2021-09-10 20:05
Still the same error

thanuxxxx
2021-09-10 20:06
Have you tried without ``` @BeforeEach public void setupTestTarget(PactVerificationContext context) { context.setTarget(new HttpsTestTarget(pactProperties.getEntitlement().getHost(), pactProperties.getEntitlement().getPort())); }```

franklin.lucena89
2021-09-10 20:10
Yes, I tried, but the error came from the `@PactBroker` annotation

thanuxxxx
2021-09-10 20:17
Is that a new error? what is that?

franklin.lucena89
2021-09-10 20:18
Actually now is working fine! Thank you very much for your help!

franklin.lucena89
2021-09-10 20:18
drink's on me! :smile:

abubics
2021-09-10 23:21
What's your current provider verification setup?

abubics
2021-09-10 23:21
(I've used the state change endpoint, and the `@ExtendWith(...) @SpringBootTest(...) @Provider(...) @PactFolder(...)` Junit style, and both of those only require managing state changes. Since all you have to do is trigger the state change, you can carve up your code however you like, as long as it gets executed at the right time.)

naushad_amin
2021-09-11 23:15
has joined #pact-jvm

naushad_amin
2021-09-11 23:18
Hello, anyone here uses spring-cloud-contract integration with pact? I am trying to use spring-cloud-contract-pact library to automate producer side of contract test. I am unable to determine how to set bearer token for pactflow to authenticate.

jose_rodriguez
2021-09-13 13:16
has joined #pact-jvm

kyle_evans
2021-09-13 13:16
has joined #pact-jvm

rahul.louis
2021-09-13 15:55
has joined #pact-jvm

a.koka
2021-09-13 17:01
has joined #pact-jvm

thanuxxxx
2021-09-13 18:21
My setup is like you mentioned. State change endpoint. Is that even possible to split those tests into separate tests cases like `consumerPactTest,` `orderPactTest,` and `productsPactTest?`

thanuxxxx
2021-09-13 18:25
my case a single Pact (contract) contains tests cases for consumer, order, and products resources,

efloresambrosio
2021-09-13 20:09
has joined #pact-jvm

abubics
2021-09-14 03:01
If you want to split the state-setting functions into separate files, they can still be bound with the `@State` annotation in the `@SpringBootTest(...)` file, and delegate to other files/classes. That's just regular programming extraction :slightly_smiling_face:

abubics
2021-09-14 03:01
I can't think of an easy way to make separate `@SpringBootTest(...)` classes, though.

olle_hallin
2021-09-14 05:50
has joined #pact-jvm

a.babenko
2021-09-14 14:00
has joined #pact-jvm

vasavi.balanagu
2021-09-14 16:49
has joined #pact-jvm

samuel.sjoberg
2021-09-14 21:49
has joined #pact-jvm

domingo
2021-09-14 23:51
has joined #pact-jvm

daniel.qu
2021-09-15 00:47
I wrote a few provider contract tests using Junit 5. They all work in Intellij. However, when I try to run these tests using ConsoleLauncher, it cannot find those tests. Error msg is like this ```org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160)``` Here is my cmd, `java -jar tools/junit-platform-console-standalone-1.8.0.jar --classpath "provider/target/test-classes" -select-class com.myns.ArchiveProviderContractTests --reports-dir='reports'` In `ArchiveProviderContractTests`, I use `@TestTemplate` annotation, not use `@Test` annotation, as guided by this http://pact.io https://docs.pact.io/implementation_guides/jvm/provider/junit5. I suspect ConsoleLauncher doesn?t recognize `@TestTemplate`. is anything missing? Thanks

pradeepkumarstudent20
2021-09-15 03:32
has joined #pact-jvm

anchit.99
2021-09-15 08:41
Is there a way of deleting the existing pact first before creating a new one? I've tried setting pact.writer.overwrite=true but I would like to delete the file first.

anchit.99
2021-09-15 10:39
Never mind. I called Java's File methods to delete them. :+1:

bryan
2021-09-15 15:16
has joined #pact-jvm

franklin.lucena89
2021-09-15 18:25
Hey guys, I have a question, is there a way to publish consumer test to pact broker without using maven plugin? currently I'm using consumer junit 5 version

dboxler
2021-09-15 18:35
has joined #pact-jvm

franklin.lucena89
2021-09-15 21:48
How can I use the tag feature on consumer side?

francisco.moreno
2021-09-15 22:08
has joined #pact-jvm

francisco.moreno
2021-09-15 22:08
Hi all, do you know how to disable pending pacts in java?

francisco.moreno
2021-09-15 22:11
```@PactBroker(enablePendingPacts = "false")``` I've already set this property but still not working

uglyog
2021-09-15 23:06
:rolling_on_the_floor_laughing: Most people struggle with enabling pending pacts

uglyog
2021-09-15 23:09
That should disable it. Actually, any value other than `true` should work.

uglyog
2021-09-15 23:09
What are you seeing, are the pending pacts not failing?

francisco.moreno
2021-09-15 23:14
I always get this output

uglyog
2021-09-15 23:22
Ok, that is the broker saying it is pending. Pact-JVM will ignore that if `enablePendingPacts` is false

franklin.lucena89
2021-09-15 23:33
We set username and password for our pact broker and now our provider is unable to get connected to it ```pactbroker: host: pact.broker.host port: pact.broker.port scheme: https auth: username: pact.broker.user password: pact.broker.password``` this is my config file and this how I set the pact broker annotation ```@PactBroker``` I'm using junit 5. I always get a 401 error

uglyog
2021-09-15 23:41
Is this in Spring config? You need to use the spring extension, the normal JUnit one won't know how to load those properties

franklin.lucena89
2021-09-15 23:45
this is the dependency I'm using ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.2.0</version> </dependency>``` the annotation it's recognizing the host, port and scheme values but not the auth, so that's why I don't know what is happens

uglyog
2021-09-16 00:01
That config looks ok, I can't see anything wrong

abubics
2021-09-16 00:44
You can use the pact-broker CLI, or manually POST to the broker . . . or do you mean from within your test code?

franklin.lucena89
2021-09-16 00:48
is there a way to do it right from the test code?

abubics
2021-09-16 01:07
I'm not sure, it's my first time using the annotation approach, and we're not using a broker quite yet :sweat_smile: someone else should know (and the https://docs.pact.io/roadmap/feature_support/ sounds like there is)

francisco.moreno
2021-09-16 02:35
yeah I get that. That's why I don't understand why the "mvn verify" command still passes

francisco.moreno
2021-09-16 02:36
I can see the error in the console log, but the command passes

keerthisiv
2021-09-16 03:59
has joined #pact-jvm

adelina.simion
2021-09-16 08:41
has joined #pact-jvm

akke.luukkonen
2021-09-16 10:29
has joined #pact-jvm

naushad_amin
2021-09-16 12:38
I tried something like this: `ProviderInfo providerInfo = new ProviderInfo("siteapi", "localhost", "8181");` `MockProviderConfig mockProviderConfig = providerInfo.mockServerConfig();` `ConsumerPactBuilder consumerPactBuilder = new ConsumerPactBuilder("siteapi-consumer");` `PactDslWithProvider builder = new PactDslWithProvider(consumerPactBuilder, "siteapi");` `void writePact() {` `String pactDirectory = 'pacts'` `File pactFile = getSiteByPrimaryDCAbbrevRequestNotFound(builder).fileForPact(pactDirectory)` `DefaultPactWriter defaultPactWriter = new DefaultPactWriter()` `defaultPactWriter.writePact(pactFile,getSiteByPrimaryDCAbbrevRequestNotFound(builder),mockProviderConfig.pactVersion )` `}`

franklin.lucena89
2021-09-16 13:22
thank for your help, `getSiteByPrimaryDCAbbrevRequestNotFound` where is this method came from?

alejandro.pena
2021-09-16 13:37
has joined #pact-jvm

uladzislau_danilchyk
2021-09-16 13:42
Hi everyone! I have an error in Pact-jvm. It was working before. But today - not. error: ```[2021-09-16T13:06:48.424Z] * What went wrong: [2021-09-16T13:06:48.424Z] A problem occurred configuring project ':modules:mname'. [2021-09-16T13:06:48.424Z] > Could not resolve all artifacts for configuration ':modules:mname:classpath'. [2021-09-16T13:06:48.425Z] > Could not download matchers-4.1.19.jar (au.com.dius.pact.core:matchers:4.1.19) [2021-09-16T13:06:48.425Z] > Could not get resource 'https://plugins.gradle.org/m2/au/com/dius/pact/core/matchers/4.1.19/matchers-4.1.19.jar'. [2021-09-16T13:06:48.425Z] > Could not GET 'https://jcenter.bintray.com/au/com/dius/pact/core/matchers/4.1.19/matchers-4.1.19.jar'. [2021-09-16T13:06:48.425Z] > Read timed out [2021-09-16T13:06:48.425Z] > Could not download pactbroker-4.1.19.jar (au.com.dius.pact.core:pactbroker:4.1.19) [2021-09-16T13:06:48.425Z] > Could not get resource 'https://plugins.gradle.org/m2/au/com/dius/pact/core/pactbroker/4.1.19/pactbroker-4.1.19.jar'. [2021-09-16T13:06:48.425Z] > Could not GET 'https://jcenter.bintray.com/au/com/dius/pact/core/pactbroker/4.1.19/pactbroker-4.1.19.jar'. [2021-09-16T13:06:48.425Z] > Read timed out``` Is there any solution for that? My code: ```id 'au.com.dius.pact' version '4.1.19'```

uladzislau_danilchyk
2021-09-16 13:43
I don't understand why bintray is used now.

franklin.lucena89
2021-09-16 14:07
I verified my credentials and are working fine, this is really confusing to me

krishna.ramnk
2021-09-16 16:47
@uglyog I am trying to migrate a Junit4 PACT test (working fine before migration) to JUnit5 but with new ExtendWith and PactTestFor annotations I am getting the below error : `Method bookABC does not conform required method signature 'public http://au.com.dius.pact.core.model.RequestResponsePact xxx(PactDslWithProvider builder)'`

krishna.ramnk
2021-09-16 18:27
Finally it worked after cleaning up the dependencies which were coming from pact-junit5_2.12 and later changed to pact-jvm-consumer-junit5

uglyog
2021-09-16 22:50
What is the error in the console?

uglyog
2021-09-16 23:01
Try with the latest version. Also, debug logs may help

matt.fellows
2021-09-16 23:19
hmmm that is strange. I thought bintray was retired? Is it a gradle configuration?

uladzislau_danilchyk
2021-09-17 07:20
@matt.fellows, yep. it's gradle

bbleach
2021-09-17 07:30
has joined #pact-jvm

brendan.j.donegan
2021-09-17 13:00
Hi. I am updating some of our provider frameworks to use Pact Flow and after adding the auth parameter to the PactBroker decorator to provide the token, I am seeing this exception in the logs: ```[ERROR] com.org.service.pact.provider.PactProviderTest.pactTestTemplate(PactVerificationContext, HttpRequest)[2] Time elapsed: 0.334 s <<< ERROR! kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Reflection on built-in Kotlin types is not yet fully supported. No metadata found for public open val length: http://kotlin.Int defined in kotlin.String[DeserializedPropertyDescriptor@4981c2d3] at com.org.service.pact.provider.PactProviderTest.pactTestTemplate(PactProviderTest.java:32)```

brendan.j.donegan
2021-09-17 13:00
The thing is the publish works fine, but I would like to clean up that error to avoid confusing anyone

franklin.lucena89
2021-09-17 14:50
I just upgrade my version to 4.2.11 and it's working fine!

franklin.lucena89
2021-09-17 15:00
Hi guys, question, how can I tag my consumer test? I doing it on the provider but I can't find anything related to consumer tagging, did anyone do this?

dimundo
2021-09-17 15:01
> pact-broker create-version-tag --pacticipant

dimundo
2021-09-17 15:01
`pacticipant` not consumer/provider

franklin.lucena89
2021-09-17 15:02
is there a way to do it with maven?

franklin.lucena89
2021-09-17 15:03
something like `mvn pact:publish create-tag-version`?

jarmy
2021-09-17 16:53
Looks like you can use `tags` in the plugin definition or use `pact.consumer.tags` https://docs.pact.io/implementation_guides/jvm/provider/maven/#publishing-pact-files-to-a-pact-broker

franklin.lucena89
2021-09-17 17:10
yes but this is for provider, not sure about consumer

phil.endsley
2021-09-17 20:19
@jarmy is correct. Even though it's under the provider section of docs, only consumers publish pacts. That section linked is for consumers. Have you tried it?

franklin.lucena89
2021-09-17 22:52
this works, but how can I set tags according to the git branch?

uglyog
2021-09-18 01:26
What are you doing at `PactProviderTest.java:32`?

brendan.j.donegan
2021-09-18 09:25
That's the call to verifyInteraction

uglyog
2021-09-18 23:29
Can you provide that code?

rushideshpandes
2021-09-20 13:11
has joined #pact-jvm

gemhar
2021-09-20 14:33
has joined #pact-jvm

jarmy
2021-09-20 16:19
you can do this in a number of ways: use a env variable (e.g `-Dpact.consumer.tags=${env.BRANCH_NAME}`), use a script to get the branch name, etc.

naushad_amin
2021-09-20 17:00
that?s custom for my app

ukrainian1991
2021-09-20 19:26
Hi, I have arrays in json which could be empty [] or contain an object. Is it possible to match this somehow?


jsegall
2021-09-20 21:37
has joined #pact-jvm

rahul.louis
2021-09-20 23:48
Hi All, question related to using Pact DSL for building an object of type `Map<String, Integer>`

rahul.louis
2021-09-20 23:51
Anyone that can point me to documentation (or discuss here) on how I can build this object?

uglyog
2021-09-20 23:58
How is that represented in JSON?

ukrainian1991
2021-09-21 09:13
I agree with statements in the docs. But how could I verify such array ```"params": [ { "name": "account.100.enable", "title": "Line Active", "validation": null, <<<< null "type": "select", "options": [ <<<<< non empty { "name": "Disabled", "value": "0" }, { "name": "Enabled", "value": "1" } ], "value": "0" }, { "name": "account.100.label", "title": "Label", "validation": { <<<< non null "type": "string", "min": 0, "max": 99, "length": 0, "pattern": "", "mandatory": false }, "type": "text", "options": [], <<<<< empty "value": "" },```

ukrainian1991
2021-09-21 09:16
and there are a lot of objects in the array. It's impossible to describe them all

dalkire
2021-09-21 13:30
has joined #pact-jvm

krishna.ramnk
2021-09-21 15:39
@uglyog I have a contract test to verify (pact verify) against an external provider over a https layer (being given credentials) but I could not find any example for https testing. Can you please help

marvin.kienitz
2021-09-21 15:41
Are you using the JUnit runner, the Pact Maven plugin or something else?

krishna.ramnk
2021-09-21 15:41
I am using Pact-jvm-junit5 framework

krishna.ramnk
2021-09-21 15:42
which uses PactVerificationInvocationcontextProvider

marvin.kienitz
2021-09-21 15:43
You can set an HttpsTestTarget and configure it, if so desired: https://docs.pact.io/implementation_guides/jvm/provider/junit5#httpstesttarget this might be of help a little bit lower is also an example to add Request headers (e.g. if you need an Authorization header)

krishna.ramnk
2021-09-21 15:48
Yes , I had used to try something like ```context.setTarget(HttpsTestTarget.fromUrl(new URL( providerUrl)));``` However , I am getting back an error "0 - expected status of 201 but was 404"

krishna.ramnk
2021-09-21 15:48
The same url however passes with 201 using postman (POST call) but fails to verify through pact

marvin.kienitz
2021-09-21 15:49
then it probably is not the exact same URL, but that's just my guess

krishna.ramnk
2021-09-21 15:49
Full code is nearly this ```@ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) throws Exception { context.setTarget(HttpsTestTarget.fromUrl(new URL( providerUrl))); }```

krishna.ramnk
2021-09-21 15:51
The url I want to handle is somewhatlike this ```https://blog.com/Api/CreateApp?username=foo&password=pwd``` The above url along with a json body returns 201 with a body back in response when run as POST call using POSTMAN

franklin.lucena89
2021-09-21 16:39
hey I'm running my consumer test with the maven plugin version 4.1.27 into a certain package, but the thing is I'm always getting `No test execute` error, why is this error?

rahul.louis
2021-09-21 17:15
Something similar to: ```{ "field1": { // Map<String, Integer> representation "key1": 1, "key2": 2, "key3": 3 } }```

rahul.louis
2021-09-21 17:19
This https://github.com/pact-foundation/pact-jvm/issues/313 is close to what I am trying. Is there anyway I can use `eachKeyLike` to achieve this?

ukrainian1991
2021-09-21 18:09
Hi, Is it possible to write matcher for empty array ? ```"params": []```

franklin.lucena89
2021-09-21 18:25
thank for your help guys! it was really helpful

hakan.celebi
2021-09-21 19:43
has joined #pact-jvm

franklin.lucena89
2021-09-21 20:44
@uglyog I was testing my consumer with the junit5 4.2.9 version and the maven plugin version 4.1.27, and whenever I ran the `mvn test` command it always fails because a No test were found! error, I had to downgrade to junit 4.2.9 version and do the arrangements to solve the issue, this could be a bug?

uglyog
2021-09-21 23:04
That URL has query parameters. That is not how you are meant to use Pact. The URL to provide to `HttpsTestTarget` should be the base URL for the provider. The actual URL that gets sent is then constructed from the base URL and the interaction in the Pact file.

uglyog
2021-09-21 23:16
If you are using JUnit 5, you don't need to use the Maven plugin. It will run as part of the normal Maven test phase.

uglyog
2021-09-21 23:21
Just use an empty array

ukrainian1991
2021-09-22 06:57
Hi, I am aware of optional fields in docs, but is it possible to create a matcher for such array somehow ```"params": [ { "name": "account.100.enable", "title": "Line Active", "validation": null, <<<< null "type": "select", "options": [ <<<<< non empty { "name": "Disabled", "value": "0" }, { "name": "Enabled", "value": "1" } ], "value": "0" }, { "name": "account.100.label", "title": "Label", "validation": { <<<< non null "type": "string", "min": 0, "max": 99, "length": 0, "pattern": "", "mandatory": false }, "type": "text", "options": [], <<<<< empty "value": "" },```

ukrainian1991
2021-09-22 06:58
array list is huge, so I cant describe all of the items separatelly

uglyog
2021-09-22 07:01
There is no support for conditional matching, i.e. if `validation` is null then match `options` using X. You need to use different tests for those.

uglyog
2021-09-22 07:01
But there is an "array contains" matcher, that can detect if a matching item exists in a list

ukrainian1991
2021-09-22 07:05
Is there a way just to assert that validation field is in an object. No matter it is null or not? i.e it exists

matt.fellows
2021-09-22 07:08
You could setup the scenario such that you get back an array with exactly two items, and then use matchers on the nested items, rather than an `EachLike` on the top level array

matt.fellows
2021-09-22 07:08
You could then use a provider state to indicate this scenario is being tested

ukrainian1991
2021-09-22 07:10
Or If to try a workaround, is it possible to make example for field not just a primitive, but an object?

ukrainian1991
2021-09-22 07:10
@matt.fellows Can I find an example somewhere? Maybe in tests in github repo?

uglyog
2021-09-22 07:11
If you use a like matcher with an empty example object, that may work

matt.fellows
2021-09-22 07:13
> @matt.fellows Can I find an example somewhere? Maybe in tests in github repo? mmm not for this specific scenario

matt.fellows
2021-09-22 07:14
All I?m saying is don?t apply a matcher at the top level (i.e. it _must_ be an array with exactly two items). And then for the two objects, set the matchers for the scenarios you need

abubics
2021-09-22 07:14
It's worth thinking about which scenarios are significant. You might want to have one explicit test for the first combination, and another test for the second combo. It seems that trying to combine the different cases is getting in the way of clear tests maybe.

matt.fellows
2021-09-22 07:14
I knew Andras would complete the sentence for me, so, thank you!

ukrainian1991
2021-09-22 07:15
What is `like` matcher? Cant find something similar in docs. But I find this one ```/** * Combine all the matchers using OR * * @param name Attribute name * @param value Attribute example value * @param rules Matching rules to apply */ public LambdaDslObject or(String name, Object value, MatchingRule... rules) { object.or(name, value, rules); return this; }```

matt.fellows
2021-09-22 07:15
sorry, I was talking JS speak but the principle is the same.

matt.fellows
2021-09-22 07:15
one moment

ukrainian1991
2021-09-22 07:17
@abubics I have a huge response, and there are nested structures. It's one case and I want just to assert common structure

ukrainian1991
2021-09-22 07:18
Its GET request for device settings, and I receive just list of options

ukrainian1991
2021-09-22 07:18
some options have `validation`, others not

uglyog
2021-09-22 07:19
If you just use an empty object in the test, it will check that it is the same type but ignore all the attributes

abubics
2021-09-22 07:20
The way you describe it sounds like the cases are ? the `validation` is `null` and the `options` is not empty; and ? the `validation` is not `null` and the `options` is empty; which is two significant & distinct cases. I might've misinterpreted your example, though.

abubics
2021-09-22 07:21
If there are several optional fields, you can have a case where all the optional fields are missing, and another where they're all present, and that would cover all bases.

abubics
2021-09-22 07:21
But if certain combinations are significant, I'd have a test for each.

ukrainian1991
2021-09-22 07:23
@abubics you are right, but i am confused how its possible to write two different tests on the same request. Are you talking about the next: ... ```.body( nested matcher for the case where validation is null, options are empty) .body( nested matcher for the case where validation is null, options are empty)```

abubics
2021-09-22 07:24
Oh, you can have as many tests as you like for the same endpoint. Don't chain the bodies, make a whole new `uponReceiving`.

matt.fellows
2021-09-22 07:25
think of it as a different scenario you?re testing

ukrainian1991
2021-09-22 07:25
One more point, there are a lot of options, its time consuming and unnecessary to depict which one is for the first case, which one for the second

matt.fellows
2021-09-22 07:25
they are separate unit tests

ukrainian1991
2021-09-22 07:25
I just want to assert structure

ukrainian1991
2021-09-22 07:26
Even I can ignore params ...., but I need to provide a proper example

abubics
2021-09-22 07:26
yep, structure is what Pact mostly asserts on :thumbsup: you can have one item in the array per test, if you like

abubics
2021-09-22 07:27
or if you want to have a less specific test, you can have several distinct items, but the matching specificity also goes down, so your reasoning power suffers

ukrainian1991
2021-09-22 07:28
@uglyog can you say a bit more about you message with empty object?

ukrainian1991
2021-09-22 07:30
```newJsonBody { b -> b.newArray("profile_meta_info") { newObject { stringValue("name", "Base_station") stringValue("title", "Base station") eachLike("subtabs" ) { o -> o.stringType("name", "Status_Base_Mode") o.stringType("title", "Base mode") o.newArray("subtabs" ) { } o.eachLike("params") { k -> k.stringValue("name","station.allowed.1.mac") k.stringValue("title","MAC of Pre-register Base") //k.stringMatcher("validation", k.stringValue("type", "text") //k.stringMatcher("options","\\[\\]|.*name.*value.*", []) k.stringValue("value", "") } } newArray("params" ) { } } } }.build()```

abubics
2021-09-22 07:30
For example, in the current app I'm working on, we have a list/search endpoint with maybe 9 query parameters. The response is always the same shape, but certain state & params combinations will yield objects with different values. So we have about 20 tests that only really vary on query params, but if a single one fails, we know which bit of the code is broken.

ukrainian1991
2021-09-22 07:31
yes, I got it, but in my case its one response and one request. Request is always the same and list of options is huge,with the same structure

uglyog
2021-09-22 07:34
I think `k.object("validation", { -> })` will create an empty object in the test

abubics
2021-09-22 07:35
Have you read about https://docs.pact.io/getting_started/provider_states/ yet? I think that would help break the one huge response into individual significant scenarios.

abubics
2021-09-22 07:36
It also gives you the facility to provide error cases, etc, which I can assume are valid (but unwanted) scenarios.

ukrainian1991
2021-09-22 07:38
I have read about provider states, but I do not undestand how it could help here. There is no way to change the state, response is always the same, but there are options with different `validation` . And moreover It not so crucial in this case to assert each option

ukrainian1991
2021-09-22 07:40
There would be e2e tests on this matter

abubics
2021-09-22 07:40
> There is no way to change the state That is a bit concerning . . . Pact provides hooks for this, so I guess you mean your infrastructure/architecture isn't set up with that facility?

abubics
2021-09-22 07:41
The states I'm imagining would be something like ? given validation style for option 1 ? given validation style for option 2 ? etc and just one element that does match what you expect.

ukrainian1991
2021-09-22 07:42
I just do not dig in this direction. I am talking about the fact that ? the `validation` is `null`  and the `options` is not empty; and ? the `validation` is not `null`  and the `options` is empty; is the matter of one exact GET request get_device_profile_info

abubics
2021-09-22 07:44
Maybe that helps get to the crux of the issue. Why do you have to have more than one element in that array at a time, if they all follow the same schema?

ukrainian1991
2021-09-22 07:48
It's just what I have in the response) I need for the generated example by pact at least one option, for example ```"params": [ { "name": "account.100.enable", "title": "Line Active", "validation": null, <<<< null "type": "select", "options": [ <<<<< non empty { "name": "Disabled", "value": "0" }, { "name": "Enabled", "value": "1" } ], "value": "0" },``` But when I would verify a provider, I get full response with a lot of options and list items would differ: ? the `validation` is `null`  and the `options` is not empty; and ? the `validation` is not `null`  and the `options` is empty;

matt.fellows
2021-09-22 07:49
I guess what Andras is saying, is that you _should_ be able to control this list, and therefore the conditions to be able to slice and dice your testing needs

abubics
2021-09-22 07:49
Yeah, being able to change what the provider responds with is pretty fundamental to this style of testing :slightly_smiling_face:

ukrainian1991
2021-09-22 07:50
There is no such a possibility

matt.fellows
2021-09-22 07:50
If you think carefully about how Pact needs to match on the actual provider?s response you?ll see why this is hard to do

ukrainian1991
2021-09-22 07:50
Provider will answer for request get_device_configs_list full response of 17000 rows in json :smiley:

matt.fellows
2021-09-22 07:51
You can?t control that during your provider verification?

matt.fellows
2021-09-22 07:51
What it seems like you are asking for is more of a schema type test. Pactflow has a feature that allows you to do this form of checking (called bi-directional contracts), but it is separate from contract testing with Pact that is more stringent in its checks

abubics
2021-09-22 07:51
Also, don't you have different environments with different data in them?


matt.fellows
2021-09-22 07:52
it will allow heterogenous structures to be included in an array (and the examples _must_ be present), but it will ignore all those that don?t match - this may have unintended consequences in your situation if there are scenarios not covered

ukrainian1991
2021-09-22 07:55
So, will try to use arrayContains

matt.fellows
2021-09-22 07:56
Can I ask - are you running provider verifications against your locally running provider or a deployed environment?

ukrainian1991
2021-09-22 07:56
I got the idea about provider states. That I need to change providers answer and rreturn only options with `validation` But it would be incorrect in general because its unreal situation

ukrainian1991
2021-09-22 07:57
@matt.fellows Initially it was locally running provider, but now it's deployed dev + staging env

ukrainian1991
2021-09-22 07:58
Thank you all for your time

abubics
2021-09-22 08:14
good luck! :rocket:

krishna.ramnk
2021-09-22 11:45
@uglyog I had even tried to use the url without auth parameters but could not find support to add authentication headers to the url using HttpsTestTarget

krishna.ramnk
2021-09-22 11:46
I have actually set the endpoint url separate in the consumer contract as http url but having struggle to populate this https url in the pact verification state

vuttithatkrongyot
2021-09-22 15:34
Hi team, I have a quick question about UTF-8 (Thai characters) I have pact dsl code like this ```@Pact(consumer = "customer") RequestResponsePact getCountryResponseFromCif(PactDslWithProvider builder) { DslPart body = new PactDslJsonBody() .object("status") .integerType("code", 1000) .stringType("description", "Success") .closeObject() .object("data") .eachLike("countryList") .stringType("countryCode", "AU") .stringType("countryRefCode", "AUS") .stringType("countryNameTH", "??????????") .stringType("countryNameEN", "AUSTRALIA") .closeArray() .closeObject(); return builder .uponReceiving("Country source of income list") .method("GET") .path("/v1/country") .willRespondWith() .status(200) .headers(Map.of("Content-Type", "application/json;charset=utf-8")) .body(body) .toPact(); }``` But the generated contract it shown like this ```"response": { "body": { "data": { "countryListFromCif": [ { "countryCode": "AU", "countryNameEN": "AUSTRALIA", "countryNameTH": "\u0E2D\u0E2D\u0E2A\u0E40\u0E15\u0E23\u0E40\u0E25\u0E35\u0E22", "countryRefCode": "AUS" } ] }, "status": { "code": 1000, "description": "Success" } }, "headers": { "Content-Type": "application/json;charset=utf-8" }, ...``` How can I generate a contract with Thai characters? What should I add more in my code?

nrobison
2021-09-22 15:39
has joined #pact-jvm

slack1
2021-09-22 15:57
has joined #pact-jvm

uladzislau_danilchyk
2021-09-22 16:04
Hi guys! I like you're doing and I think you are on a right way. I want to say Thank you for this product. But I found the issue related to Pact Broker jvm lib (`au.com.dius.pact.provider:junit5:4.2.3` ) and described it on a github. It's related to filtering by consumers list: https://github.com/pact-foundation/pact-jvm/issues/1447 Could you help me with that? Cause it's critical for our project. Thank you an advance!

franklin.lucena89
2021-09-22 16:14
The thing is that I just trying to run `mvn test` but the consumer pact test are not getting execute so in a second step I try to run `mvn test -Dtest="consumer.test.package"` I'm having this `No test were found! error`

calise
2021-09-22 17:06
has joined #pact-jvm

uglyog
2021-09-22 23:24
That looks correctly encoded for JSON. The JSON spec says to encode non-ascii characters using \uxxx hex format

uglyog
2021-09-22 23:26
That is a Maven configuration problem. You should also not mix major versions (junit5 4.2.9 and maven plugin 4.1.27)

uglyog
2021-09-22 23:27
Maven surefire (the plugin that runs unit tests), is not finding any tests to run. This is not a Pact issue. Maybe try getting a normal unit test to work with Maven first.

uglyog
2021-09-22 23:43
You can add authentication headers by injecting the request into the test method. See https://github.com/pact-foundation/pact-jvm/tree/master/provider/junit5#modifying-the-requests-before-they-are-sent

bryanw
2021-09-23 01:03
I'm hitting a NoClassDefFoundError with fromJson() here: ```linkUrl:432, HalClient (au.com.dius.pact.core.pactbroker) fetchConsumersWithSelectors:238, PactBrokerClient (au.com.dius.pact.core.pactbroker) loadPactsForProvider:220, PactBrokerLoader (au.com.dius.pact.provider.junitsupport.loader) load:118, PactBrokerLoader (au.com.dius.pact.provider.junitsupport.loader) initialize:96, PactRunner (au.com.dius.pact.provider.junit) getChildren:152, PactRunner (au.com.dius.pact.provider.junit) getFilteredChildren:276, ParentRunner (org.junit.runners) getDescription:225, ParentRunner (org.junit.runners) getDescription:79, JUnit4IdeaTestRunner (com.intellij.junit4) startRunnerWithArgs:51, JUnit4IdeaTestRunner (com.intellij.junit4) startRunnerWithArgs:33, IdeaTestRunner$Repeater (com.intellij.rt.junit) prepareStreamsAndStart:235, JUnitStarter (com.intellij.rt.junit) main:54, JUnitStarter (com.intellij.rt.junit)```

bryanw
2021-09-23 01:04
This is a 1.8 based service that I'm trying to validate as a Provider -- pact version 4.1.27

uglyog
2021-09-23 01:14
That's normally the result of version mismatches of pact libraries. If you check the tree of your dependencies, you might be able to pinpoint where that is coming from

gemhar
2021-09-23 03:51
@gemhar has left the channel

uladzislau_danilchyk
2021-09-23 08:03
@uglyog, hi! Could you help me with that? Thank you in advance!

nareshnavinash
2021-09-23 09:28
has joined #pact-jvm

radu.simu
2021-09-23 09:38
has joined #pact-jvm

aterrong
2021-09-23 09:42
has joined #pact-jvm

vuttithatkrongyot
2021-09-23 10:32
So, is there any way to generate contract that have Thai characters? or some way to decode \uxxx back to Thai character?

nisharaveendran30
2021-09-23 10:34
has joined #pact-jvm

sujithsukumaranm
2021-09-23 10:36
has joined #pact-jvm

marcin.baranowski953
2021-09-23 10:53
Hello, I have hard time with PactBroker annotation. When trying to run tests I get: ```Invalid pact broker host specified ('${pactbroker.host:}'). Please provide a valid host or specify the system property 'pactbroker.host'. java.lang.IllegalArgumentException: Invalid pact broker host specified ('${pactbroker.host:}'). Please provide a valid host or specify the system property 'pactbroker.host'.``` My *application.yaml* has: ```pactbroker: host: "https://valid-host" port: 443 protocol: "https" auth: token: "tokenValue"``` I use gradle and my only pact dep is: ``` testImplementation("au.com.dius.pact.provider:junit5spring:4.2.11")``` My Test: ```@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @Provider("provider") @PactBroker public class PactTest extends AbstractIntegrationTest { @LocalServerPort int port; @Value("${pactbroker.host}") String host; @BeforeEach public void setupTestTarget(PactVerificationContext context) { System.out.println("host"); System.out.println(host); context.setTarget(new HttpTestTarget("localhost", port)); } @TestTemplate @ExtendWith(PactVerificationSpringProvider.class) public void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } }``` Host value is assigned correctly in test file. Why Pact doesn't see these values? What should I change?

marvin.kienitz
2021-09-23 11:01
I don't think that the Pact JUnit runner does anything with the application.yml, or anything Spring-specific for that matter. You can set these values via System environment variables. Or you could also look at the ValueResolver API, and then configure the @PactBroker annotation to use your custom ValueResolver

matt.fellows
2021-09-23 11:39
You don't seem to be using the PactBroker annotation above, and are just assigning it to an unused String. Is that intended?


marcin.baranowski953
2021-09-23 11:46
@marvin.kienitz This example tells something different: https://docs.pact.io/implementation_guides/jvm/provider/junit5spring/ @matt.fellows yes it was intended - just printing to make sure the properties are correctly grabbed from application.yaml Please take a look at this example: https://github.com/pact-foundation/pact-workshop-Maven-Springboot-JUnit5/tree/step11#step-11---using-a-pact-broker

matt.fellows
2021-09-23 11:50
Have you checked the dependencies? I don't k one, but it seems it's a spring/pact integration that would be needed there

sureshbabudevaki
2021-09-23 12:01
has joined #pact-jvm

marcin.baranowski953
2021-09-23 12:03
The same spring boot version: *2.4.3*

greg.hinsley
2021-09-23 12:29
has joined #pact-jvm

matt.fellows
2021-09-23 13:19
Ah sorry, I don't really speak java. I'm sure it's going to be something simple tho

matt.fellows
2021-09-23 13:19
Hopefully somebody else can spot it!

aubilla
2021-09-23 14:56
:wave: Hi folks, I?m using the requestFilter to tweak my requests for Provider verification and I?m adding a few headers: ```requestFilter = { req -> req.addHeader('Authorization', 'Bearer ' + token) req.addHeader('Accept', 'application/json') req.addHeader('Content-Type', 'application/json; charset=UTF-8') }``` :smiling_imp: For some evil reason I?m seeing an ugly exception on the running provider: ```16:36:46.471 166398 [default-nioEventLoopGroup-1-2] ERROR [correlation_id:,] i.m.h.s.netty.RoutingInBoundHandler - Unexpected error occurred: UTF-8,application/json java.nio.charset.IllegalCharsetNameException: UTF-8,application/json at java.base/java.nio.charset.Charset.checkName(Charset.java:308) at java.base/java.nio.charset.Charset.lookup2(Charset.java:482) at java.base/java.nio.charset.Charset.lookup(Charset.java:462) at java.base/java.nio.charset.Charset.forName(Charset.java:526) at java.base/java.util.Optional.map(Optional.java:265) at io.micronaut.http.util.HttpUtil.lambda$resolveCharset$0(HttpUtil.java:66) at java.base/java.util.Optional.flatMap(Optional.java:294) at io.micronaut.http.util.HttpUtil.resolveCharset(HttpUtil.java:63) at io.micronaut.http.HttpMessage.getCharacterEncoding(HttpMessage.java:67) at io.micronaut.http.netty.AbstractNettyHttpRequest.getCharacterEncoding(AbstractNettyHttpRequest.java:197) at io.micronaut.http.netty.AbstractNettyHttpRequest.createDecoder(AbstractNettyHttpRequest.java:256) at io.micronaut.http.netty.AbstractNettyHttpRequest.decodePath(AbstractNettyHttpRequest.java:261) at io.micronaut.http.netty.AbstractNettyHttpRequest.getPath(AbstractNettyHttpRequest.java:237) at io.micronaut.http.server.netty.RoutingInBoundHandler.channelRead0(RoutingInBoundHandler.java:404) at io.micronaut.http.server.netty.RoutingInBoundHandler.channelRead0(RoutingInBoundHandler.java:146) at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:102) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.micronaut.http.netty.reactive.HandlerPublisher.channelRead(HandlerPublisher.java:351) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.micronaut.http.netty.stream.HttpStreamsHandler.channelRead(HttpStreamsHandler.java:254) at io.micronaut.http.netty.stream.HttpStreamsServerHandler.channelRead(HttpStreamsServerHandler.java:121) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93) at io.netty.handler.codec.http.HttpServerKeepAliveHandler.channelRead(HttpServerKeepAliveHandler.java:64) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.flow.FlowControlHandler.dequeue(FlowControlHandler.java:200) at io.netty.handler.flow.FlowControlHandler.channelRead(FlowControlHandler.java:162) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:311) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:425) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:829)``` :question: Have you come across something like this before? If the request headers are correctly set (like they seem to be), why could they be malformed when reaching the Provider? I?ve tried running the very same request from Postman and it works fine so I guess something is happening within the Gradle plugin `"http://au.com.dius.pact" version "4.1.0"`

franklin.lucena89
2021-09-23 16:35
Hey guys, I have a question, I'm running my consumer test on local machine and with the `mvn test` command the pact files are getting generate inside my pact folder but in my bitbucket pipeline Im trying to do something like ```- step: name: Build and Test script: - mvn clean test - step: name: Publish Pact results size: 2x image: pactfoundation/pact-cli:latest services: - docker script: - pact-broker publish MY_PACTS_FOLDER -b=$PACT_BROKER_BASE_URL -u=$PACT_BROKER_USER -p=$PACT_BROKER_PASSWORD --branch=$BITBUCKET_BRANCH -g -a=$BITBUCKET_COMMIT -v``` but inside the docker container the pact folder it's empty, what I'm missing here?

bryanw
2021-09-23 18:12
Thanks, I typically set the version in a property -- just checked the effective pom.xml and the versions are consistent. I've tried dropping to 4.1.20 with the same result. I've also tried explicitly configuring the dependency modules (e.g. .support/.core). Cleared the maven cache, rebuilt again with 4.1.27 -- still getting this error with the 1.8 engine.

thanuxxxx
2021-09-23 23:07
Which is the most recent version of `http://au.com.dius.pact.provider.junit5` which was compiled using Java8? I am unable to update the most recent version due to this error https://stackoverflow.com/questions/60612488/error-class-file-has-wrong-version-55-0-should-be-52-0-when-building-alfresco

jarmy
2021-09-23 23:28
cc @matt.fellows

bryanw
2021-09-23 23:44
Tracked this down -- added the dependency for apache commons, guava: ``` <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.12.0</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>30.1.1-jre</version> </dependency>```

matt.fellows
2021-09-23 23:44
For the example you shared above, each object for the dynamic keys has the same shape. Is there an example where that?s not the case?

matt.fellows
2021-09-23 23:45
i.e. ``` "result": { "annotations": { "PE:6990877": { "name": "745: Getting Out", "duration": 3544 }, "PC:4": { "name": "This American Life", "duration": 4358 }, "TL:50": { "name": "740: There. I Fixed It", "duration": 4358 } }, }``` Should work, but this won?t: ``` "result": { "annotations": { "PE:6990877": { "name": "745: Getting Out", "duration": 3544 }, "different": { "some": "abc", "other": 1234, } }, }```

matt.fellows
2021-09-23 23:46
(this is a case where bi-directional would help if there is a schema that defines it)


thanuxxxx
2021-09-24 03:19
Any idea why I am getting this error? I have maven plugin which targeted to Java 11 ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <release>11</release> </configuration> </plugin>``` It runs fine locally in my machine but giving this error in Jenkins CI/CD ```/home/jenkins/workspace/...../utils/ContractTestContext.java:[3,40] cannot access au.com.dius.pact.provider.junit5.PactVerificationContext [2021-09-24T03:06:47.780Z] [ERROR] bad class file: /home/jenkins/workspace/....../?/.m2/repository/au/com/dius/pact/provider/junit5/4.2.8/junit5-4.2.8.jar(au/com/dius/pact/provider/junit5/PactVerificationContext.class) [2021-09-24T03:06:47.780Z] [ERROR] class file has wrong version 55.0, should be 52.0 [2021-09-24T03:06:47.780Z] [ERROR] Please remove or make sure it appears in the correct subdirectory of the classpath.```

uglyog
2021-09-24 03:59
Your CI is probably not running JDK 11

uglyog
2021-09-24 04:00
`junit5-4.2.8.jar` needs JDK 11

nyman.robin
2021-09-24 07:07
has joined #pact-jvm

saurabh.goel
2021-09-24 08:08
Hi All, I tried creating a message pact. it is showing as below in the broker. But is also says "_Note: this contract could not be parsed to a v1 or v2 Pact, showing raw content instead._" at the top. could anyone help me understand why the parsing did not work? `{` `"consumer": {` `"name": "VA"` `},` `"provider": {` `"name": "OMA"` `},` `"messages": [` `{` `"_id": "ed34efdce6796af251e47d8861f52493ab4202d0",` `"description": "A message with Cancelled state with all required fields",` `"providerStates": [` `{` `"name": "A own delivery order is cancelled",` `"params": null` `}` `],` `"contents": {` `"oldState": "WAITING",` `"newState": "CANCELLED",` `"rpsOrderId": "oma_8ef77245-ceb9-4808-9cf1-590afde09ccb\"",` `"platformOrderId": "od-testOrder1",` `"platformGlobalKey": "T",` `"isTest": false,` `"reason": "TOO_BUSY",` `"owner": "VENDOR",` `"stage": "CONFIRMATION",` `"timestamp": "2021-09-22T16:28:02.686Z",` `"rpsId": "139096",` `"platformId": "3330",` `"gEId": "TB_KW"` `},` `"matchingRules": {` `},` `"metaData": {` `"source": "OMA 0.0.1-SNAPSHOT",` `"traceId": "25311e7e26da48bcaba225e5c4ddc897",` `"type": "RestaurantOwnDelivery.Cancelled",` `"version": 1` `}` `},]` `}`

saurabh.goel
2021-09-24 08:51
Hey guys, How can I validate the metadata of the message pact. I can see the context.verifyinteraction is only expecting message.content. Is this behaviour intentional?

ricardo.paquito
2021-09-24 10:36
has joined #pact-jvm

matt.fellows
2021-09-24 11:12
You return a MessageAndMetadata from it



abramenkov.valentin
2021-09-24 12:42
has joined #pact-jvm

saurabh.goel
2021-09-24 12:44
Thanks Matt, I did return a message and metadata. but then the validation failed. only when I pass back only message.content to @PactVerifyProvider it works. The test says that it is comparing both content and metadata. But i cannot figure out which metadata it is. Is there a way i could print logs, of actual comparison.

jarmy
2021-09-24 17:15
@srinagasai.krishnasan can you chime in on Matt's query?

leo.tang
2021-09-24 17:56
has joined #pact-jvm

srinagasai.krishnasan
2021-09-24 18:07
```"result": { "annotations": { "PE:6990877": { "name": "745: Getting Out", "duration": 3544 }, "TR:123": { "name": "838 colors", "some": "abc", "other": 1234, } }, }```

jarmy
2021-09-24 18:09
so they _do_ have different shapes

matt.fellows
2021-09-24 23:48
So the only way to test this with Pact is to write to separate tests, one for each shape

matt.fellows
2021-09-24 23:49
Using provider states to vary what shaped data is returned

jyotiguptaofficial
2021-09-25 13:00
has joined #pact-jvm

mattandaey
2021-09-25 20:32
has joined #pact-jvm

marcin.baranowski953
2021-09-27 08:23
Anybody can help?

saurelio58
2021-09-27 12:39
has joined #pact-jvm

thanuxxxx
2021-09-27 15:22
Don't you have a `junit5-4.2.X` jar with JDK 8? We use JDK 8 as company standard and our developers are not happy when running JDK 11. I could use previous `junit5 4.1.x` versions but they don't have support for `eachKeyLike` matcher. Any thoughts?

francisco
2021-09-27 18:27
has joined #pact-jvm

saurelio58
2021-09-27 18:30
Pact & Quarkus

saurelio58
2021-09-27 18:30
I am attempting to convert the code in pact-foundation/pact-workshop-Maven-Springboot-JUnit5 (branch step7) to use Quarkus. I have the provider executing. When I run 'mvn verify' to run the Pact tests I am getting a NullPointerException on the first reference to productRepository in the @State code. The existing code has an @Autowired for productRepository. Quarkus uses @Inject and I have updated the code. The message in the log is: ```ERROR [au.com.diu.pac.pro.jun.PactVerificationStateChangeExtension] (main) Provider state change callback failed: java.lang.NullPointerException``` I am new to Quarkus so this might be something about how Quarkus works. Does anyone have example code of a provider test that uses Quarkus?

uglyog
2021-09-27 22:40
No, 4.2.x has min JDK 11, 4.1.x supports min JDK 8

jamesatroughton
2021-09-28 10:42
has joined #pact-jvm

francislainy.campos
2021-09-28 14:44
Hi, we?re also getting this error but testing locally outside a pact broker.

francislainy.campos
2021-09-28 14:45
Every time an error is happening rather than provider information on it we get this kotlin message instead.

francislainy.campos
2021-09-28 14:45
```<pact.version>4.1.23</pact.version>```

francislainy.campos
2021-09-28 15:21
Same happens with version 4.0.10 and these dependencies

francislainy.campos
2021-09-28 15:21
```<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <antisamy.version>1.5.7</antisamy.version> <aspectjweaver.version>1.8.9</aspectjweaver.version> <camel.version>2.23.0</camel.version> <hystrix.version>1.5.7</hystrix.version> <java.version>1.8</java.version> <junit.version>4.12</junit.version> <powermock.version>2.0.0</powermock.version> <assertj.version>2.1.0</assertj.version> <pdfbox.version>1.8.10</pdfbox.version> <dropwizard-metrics.version>3.1.2</dropwizard-metrics.version> <json-path.version>2.5.0</json-path.version> <!--Enterprise Components Dependencies. Upgrade this version using feat/Assignment_Api branch --> <common-token.version>3.1.2.1</common-token.version> <extras-security.version>3.1.2.1</extras-security.version> <rest.api-instrumentation.version>3.1.2.1</rest.api-instrumentation.version> <session-management.version>3.1.2.1</session-management.version> <!-- End --> <jdbcsniffer.version>2.3.4</jdbcsniffer.version> <event-sdk.version>1.0.601</event-sdk.version> <nexus-schema.version>0.1.0-202104151435.bc81f30</nexus-schema.version> <nexus-event.version>1.1.1</nexus-event.version> <beanutils.version>1.9.2</beanutils.version> <docker.image.prefix>com-hmhco-core-services</docker.image.prefix> <docker.registry>http://docker.dev.aws.rpcsys.hmco.com</docker.registry> <logstash-logback-encoder.version>5.1</logstash-logback-encoder.version> <jsontoken.version>1.1</jsontoken.version> <log4j.version>2.14.1</log4j.version> <rest-assured.version>4.2.0</rest-assured.version> <micrometer.version>1.3.5</micrometer.version> <pact.version>4.0.10</pact.version> <maven.surefire.version>3.0.0-M5</maven.surefire.version> <sonar.version>3.7.0.1746</sonar.version> <jacoco-maven-plugin.version>0.8.5</jacoco-maven-plugin.version> <liquibase.version>3.8.9</liquibase.version> <dd-trace-api.version>0.78.3</dd-trace-api.version> <log4j.version>1.2.17</log4j.version> <http.client.version>4.5.3</http.client.version>```

franklin.lucena89
2021-09-28 21:28
hey guys, question, how do I tag my provider version with the commit number using junit5?

jake.thacker
2021-09-28 22:06
has joined #pact-jvm

craig.schwarzwald
2021-09-28 22:37
has joined #pact-jvm

bryanw
2021-09-29 00:57
Moving from 4.2.9 to 4.2.13 we're seeing this issue: ```ava.lang.IllegalAccessError: class au.com.dius.pact.consumer.junit.BaseProviderRule tried to access private method 'void au.com.dius.pact.core.support.expressions.ExpressionParser.<init>()' (au.com.dius.pact.consumer.junit.BaseProviderRule and au.com.dius.pact.core.support.expressions.ExpressionParser are in unnamed module of loader 'app') at au.com.dius.pact.consumer.junit.BaseProviderRule.<init>(BaseProviderRule.java:51) at au.com.dius.pact.consumer.junit.PactProviderRule.<init>(PactProviderRule.java:26) at au.com.dius.pact.consumer.junit.PactProviderRule.<init>(PactProviderRule.java:46) at com.ebay.app.storefront.pact.FeedbackExpSvcPactTest.<init>(FeedbackExpSvcPactTest.java:93)```

uglyog
2021-09-29 01:04
Can you check that they have the correct version of `au.com.dius.pact.core:support` in your project dependencies?

uglyog
2021-09-29 01:04
It also needs to be `4.2.13`

bryanw
2021-09-29 01:10
Thanks - checking.

bryanw
2021-09-29 01:12
BTW, we rely on maven dependencies to pull core:support, etc. Checking if we landed in a cache dependency hole

uglyog
2021-09-29 01:15
Something has gone wrong with the transitive dependencies, I think


uglyog
2021-09-29 01:18
Yeah, I just checked all the POMs on maven central

uglyog
2021-09-29 01:19
Can you run the Maven dependency tree plugin on the project?

bryanw
2021-09-29 01:24
Thanks Ron, I'm waiting on a pull of dependencies - this may be our infrastructure getting in the way, I'll let you know if this remains an issue after confirming the dependencies.


uglyog
2021-09-29 01:25
How to do this depends on how you run your tests (with Maven or Gradle)

bryanw
2021-09-29 02:00
@uglyog - Tracked this down, dependency chain that I had to exclude from a different test provider rule. 4.2.9 was being pulled in.

bryanw
2021-09-29 02:01
Thanks for the pointer. Now to figure out how to address this compatibility issue.

bryanw
2021-09-29 04:03
@uglyog Ignore doesn't seem to work as expected? ```[DEBUG] Configuring mojo au.com.dius.pact.provider:maven:4.2.13:can-i-deploy from plugin realm ClassRealm[plugin>au.com.dius.pact.provider:maven:4.2.13, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@2c13da15] [DEBUG] Configuring mojo 'au.com.dius.pact.provider:maven:4.2.13:can-i-deploy' with basic configurator --> [DEBUG] (s) = fdbksvc [DEBUG] (f) ignore = [IgnoreSelector(name=fdbksvc, version=null)] [DEBUG] (f) pactBrokerAuthenticationScheme = basic [DEBUG] (f) pactBrokerInsecureTLS = false [DEBUG] (f) pactBrokerUrl = https://<redacted> [DEBUG] (f) pacticipant = storefrontxs-svc [DEBUG] (f) pacticipantVersion = f4b2442 [DEBUG] (f) retriesWhenUnknown = 15 [DEBUG] (f) retryInterval = 30 [DEBUG] (f) settings = org.apache.maven.execution.SettingsAdapter@4ee5b2d9 [DEBUG] -- end configuration -- [DEBUG] Matrix Query: /matrix?q[][pacticipant]=storefrontxs-svc&latestby=cvp&q[][version]=f4b2442&latest=true&ignore[][pacticipant]=fdbksvc [INFO] canIDeploy: Retrying request as there are unknown results [1/15] ... [INFO] canIDeploy: Retrying request as there are unknown results [15/15] Computer says no ¯\_(?)_/¯ There is no verified pact between version f4b2442 of storefrontxs-svc and the latest version of fdbkexp (no such version exists)```

uglyog
2021-09-29 04:13
Hmm, the query parameter is there: `ignore[][pacticipant]=fdbksvc`

uglyog
2021-09-29 04:14
Ah! You specified the version, not the consumer name.

bryanw
2021-09-29 04:14
-ignore=fdbksvc

uglyog
2021-09-29 04:15
Sorry, my mistake. It is the name of the other side

bryanw
2021-09-29 04:16
I'm testing with a mvn cli within IntelliJ: ```-X pact:can-i-deploy -Dpactbroker.pacticipant=storefrontxs-svc -Dpactbroker.pacticipantVersion=f4b2442 -Dignore=fdbksvc```

bryanw
2021-09-29 04:16
pactbroker issue?

uglyog
2021-09-29 04:16
Should it not be `-ignore=fdbkexp`?

bryanw
2021-09-29 04:17
:facepalm:

bryanw
2021-09-29 04:19
Checking, still getting unknown results.

bryanw
2021-09-29 04:21
Running the query against the matrix is still returning the fdbkexp service

uglyog
2021-09-29 04:23
Can you check the same call with the pact CLI?

bryanw
2021-09-29 04:56
The matrix is including the same pacticipant even with the ignore option. Sigh.


franklin.lucena89
2021-09-29 12:35
thanks for your help!

owain.hunt
2021-09-29 12:58
has joined #pact-jvm

ukrainian1991
2021-09-29 13:15
Hi, I have to assure structure of api response. I add just basic checks, but it takes 15 minutes to finish execution Response is 2.85 MB and 266 000 rows. Yes, it's huge :smiley:, but as I understand correctly PACT parses all response... Is it possible to speed up it somehow?

matt.fellows
2021-09-29 13:35
I do recall something about size but that might have been logging or presenting a diff. Keen to find out tho what options you have. No way or reducing the number of rows? That would be my starting point (this also leads me to think that you're testing against a deployed provider and not local - am I right?)

ukrainian1991
2021-09-29 13:38
Yes, it's a deployed provider, but if I bring it locally it would be the same

ukrainian1991
2021-09-29 13:40
It's a dictionary content in response, with static data

tjones
2021-09-29 23:43
Not sure if this is a broker question or a JVM question but this JUnit5 wrapper annotation is not failing the build (it says the pact is pending, when we have explicitly disabled it): ```@PactBroker( url = "https://<our-broker>", authentication = @PactBrokerAuth(username = "${PACT_BROKER_USERNAME}", password = "${PACT_BROKER_PASSWORD}"), providerTags = {"main"}, enablePendingPacts = "false")``` We get: ```Verifying a pact between application-hub-frontend (1.20.0) and application-hub-api [PENDING] Notices: 1) The pact at https://<our-broker>/pacts/provider/application-hub-api/consumer/application-hub-frontend/pact-version/55746a08bd275132c3f34db1fdde4f1ccaa24cef is being verified because the pact content belongs to the consumer version matching the following criterion: * latest version of application-hub-frontend from the main branch 'main' (1.20.0) 2) This pact is in pending state for this version of application-hub-api because a successful verification result for application-hub-api has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at https://docs.pact.io/go/pending```

tjones
2021-09-29 23:43
How can we get it to not be pending?

uglyog
2021-09-29 23:47
I think pending is on by default in the broker now. `enablePendingPacts` just sets the `includePendingStatus` attribute on the request to the broker.

tjones
2021-09-29 23:47
Can we turn it off?

uglyog
2021-09-29 23:48
I imagine there is an environment variable somewhere for that

tjones
2021-09-29 23:48
This is broker version 2.85.0, I don't see anything in the release notes about making pending the default

tjones
2021-09-29 23:48
Is this a broker bug, if `enablePendingPacts` is set to false?

uglyog
2021-09-29 23:50
I don't know. That just makes it not set that attribute. If the Pacts are coming back marked as pending, they will be treated as pending regardless of that value.

uglyog
2021-09-29 23:50
Probably a @bethskurrie question

tjones
2021-09-29 23:50
I'll post in #pact-broker

uglyog
2021-09-29 23:51
Probably no need, Beth will see it here

uglyog
2021-09-29 23:51
(she is not working today)

tjones
2021-09-30 00:24
> I don't know. That just makes it not set that attribute If pending pacts is to be the default in the future, should `enablePendingPacts="false"` set the attribute to false in the request?

uglyog
2021-09-30 00:25
That is a good point

matt.fellows
2021-09-30 00:33
Can you please share the debug logs Tim? It would be good to see what is being sent to the broker's pacts for verifications endpoint


tjones
2021-09-30 00:48
@uglyog : https://github.com/pact-foundation/pact-jvm/pull/1455 (disclaimer: I did this in the github interface, so it might not compile)

matt.fellows
2021-09-30 00:51
That?s the point though, if you can run it locally, you could probably truncate the static data so it?s not so slow

matt.fellows
2021-09-30 00:52
i.e. is it necessary to contract test every single value or just a representative sample? I?d hazard a guess at no, but without further context I couldn?t say for sure

tjones
2021-09-30 01:26
I don't know how this compiled before

tjones
2021-09-30 01:27
``` fun fetchConsumersWithSelectors( providerName: String, selectors: List<ConsumerVersionSelector>, providerTags: List<String> = emptyList(), includeWipPactsSince: String? ): Result<List<PactBrokerResult>, Exception>``` ^ This interface isn't the same as the one on the class

tjones
2021-09-30 01:31
Update: I am an idiot

tjones
2021-09-30 01:35
@uglyog: Added tests and fixed the compile

abubics
2021-09-30 01:47
sounds closely related to the thread we had the other day about controlling responses with provider state :)

ukrainian1991
2021-09-30 06:43
@abubics yes=) I have overcome matching issues, but now performance is on the way=) Will try to minify response...

damtsisa
2021-09-30 06:58
has joined #pact-jvm

morsisdivine
2021-09-30 09:23
has joined #pact-jvm

franklin.lucena89
2021-09-30 13:32
hey guys, I tagging my provider using junit5 version setting this system property `pact.provider.tag` with the commit number and also setting this `pact.provider.version` with the commit number, but I'm getting both tag and branch name tagged with the same value (commit number). why I'm having this issue?

patrice.jy.thomas
2021-09-30 15:05
has joined #pact-jvm

saurelio58
2021-09-30 15:22
I don't follow what you mean by 'using junit5'

franklin.lucena89
2021-09-30 15:24
I mean, I'm doing this ```Properties props = System.getProperties(); String[] commit = setProperties("git log --format=%H,%B -n 1") .lines().collect(Collectors.joining(",")).split(","); props.setProperty("pact.provider.version", commit[0]); props.setProperty("pact.provider.tag", commi[1]);``` but always get provider branch name set as `commit[1]` value (the commit message)

franklin.lucena89
2021-09-30 15:27
both branch and tag are the same

saurelio58
2021-09-30 15:28
are you writing branch when you mean version?

saurelio58
2021-09-30 15:29
```pact.provider.version is what you have in the code example```

franklin.lucena89
2021-09-30 15:30
to this `pact.provider.version` property I'm setting the commit version

franklin.lucena89
2021-09-30 15:30
and for this one `pact.provider.tag` I'm setting the commit message

franklin.lucena89
2021-09-30 15:30
I'm not setting the branch

saurelio58
2021-09-30 15:33
sorry but I am confused - I also do not know what the ```String[] commit = setProperties("git log --format=%H,%B -n 1") .lines().collect(Collectors.joining(",")).split(",");``` does

saurelio58
2021-09-30 15:33
Hopefully someone can help

franklin.lucena89
2021-09-30 15:34
that's a custom function that actually do this ```Process process = Runtime.getRuntime().exec(command); process.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader( process.getInputStream())); return reader;``` I'm using this to get the commit number and message at runtime


saurelio58
2021-09-30 16:04
However, my issue is in the @State code referencing an object that has been added with @Inject. The reference is null.

kschendster
2021-09-30 16:46
has joined #pact-jvm

adam.dubnytskyy
2021-09-30 17:49
has joined #pact-jvm

stefano.varesi
2021-09-30 17:51
has joined #pact-jvm

steven.yi
2021-09-30 20:17
has joined #pact-jvm

calcorbin
2021-09-30 23:09
has joined #pact-jvm

osikwemhev
2021-10-01 01:45
has joined #pact-jvm

kentaro
2021-10-01 10:05
has joined #pact-jvm

vitali.domashkevitsh
2021-10-01 10:08
has joined #pact-jvm

vitali.domashkevitsh
2021-10-01 10:20
hey, using all latest consumer packages here, with a gradle and junit5 where can I set insecureTLS to true?

matt.fellows
2021-10-01 10:22
insecure to what - publishing pacts (the broker) or to a local mock server?

vitali.domashkevitsh
2021-10-01 10:23
to the broker

matt.fellows
2021-10-01 10:23
what are you using to publish - gradle?

matt.fellows
2021-10-01 10:23
what have you tried so far?

vitali.domashkevitsh
2021-10-01 10:24
yes, a gradle task

matt.fellows
2021-10-01 10:24
please read the gradle docs and let me know if it?s not clear


vitali.domashkevitsh
2021-10-01 10:26
tried setting systemProp.pactbroker.insecureTLS=true in gradle properties

matt.fellows
2021-10-01 10:26
I can?t see that mentioned in the docs

vitali.domashkevitsh
2021-10-01 10:27
found nothing related to this in docs :thinking_face:

matt.fellows
2021-10-01 10:27
where are you looking?

matt.fellows
2021-10-01 10:28
The search functionality on our docs is quite good :wink:

matt.fellows
2021-10-01 10:28
but there is a whole section on gradle, including these settings

vitali.domashkevitsh
2021-10-01 10:31
this one is for provider verify, I?m looking for a consumer publish one

matt.fellows
2021-10-01 10:32
good point

jamesatroughton
2021-10-01 10:32
Hi There, I am writing some contract tests where the consumer is a ruby service and the provider is a java service. I have a requirement to be able to inject a value into the contract that will be used against the provider (a random `id` that is a UUID generated by the DB). I understand that if my consumer was a java service I can use the `valueFromProviderState`method when generating the body to create a contract with a placeholder and a default value. However there doesn't seem to be an equivalent functionality in pact Ruby. Is there another way to over write the value on the provider side before the request is sent to validate the contract? Many thanks

matt.fellows
2021-10-01 10:32
have you tried just adding it to your trust store Vitali?

matt.fellows
2021-10-01 10:33
ah, generated by the DB :stuck_out_tongue:

matt.fellows
2021-10-01 10:33
request filters are the only thing that comes to mind

jamesatroughton
2021-10-01 10:35
Thanks i will give that a look

vitali.domashkevitsh
2021-10-01 10:38
not really, I?ve first tried what seemed a low hanging fruit :slightly_smiling_face: but thanks for the advise, will check it out

matt.fellows
2021-10-01 10:40
no worries, strange that other parts of the JVM have docs about it, so it?s either undocumented, not required because you can use native JVM stuff like a truststore, or not supported (might be worth a scan of the GH issues just in case)

seb983
2021-10-01 11:30
has joined #pact-jvm

vannessa.andrade
2021-10-01 14:44
has joined #pact-jvm

mickfagan
2021-10-02 10:36
has joined #pact-jvm

maxim.matviyuk
2021-10-03 16:48
has joined #pact-jvm

jonathan.a.stern
2021-10-03 20:38
has joined #pact-jvm

robert.strehli
2021-10-04 08:42
Hey, I'm using maven in my consumer project and I'm using the command `mvn pact:publish` to publish the pacts to the pact broker. I just wanted to check if there is an update of that maven dependency. but now I see there is no update of `pact-jvm-provider-maven` since Apr2020. Additionally this functionality isn't mentioned anymore in the pact docs (or I can't find it). My question is this functionality still available in another package?


matt.fellows
2021-10-04 08:46
I would just use the Pact CLI if you can

robert.strehli
2021-10-04 08:53
Ah great thanks. Didn't check the provider part or find it :slightly_smiling_face: Thanks for the advice too!

matt.fellows
2021-10-04 09:02
No. FWIW I just use the search, it's pretty good

franklin.lucena89
2021-10-04 15:26
Hi guy, I'm having struggle tagging my consumer/provider inside the pact broker, I'm trying to tag it like this `pact.provider.version: "COMMIT_NUMBER"` `pact.provider.tag: "COMMIT_MESSAGE"` but I'm getting the branch name tagged it with the *"COMMIT_MESSAGE"* too, I don't know why is this behavior. This is the code I'm using to do this at provider side ```@BeforeAll public static void setup() throws IOException, InterruptedException { Properties props = System.getProperties(); String[] commitMessage = setProperties("git log --format=%H,%B -n 1") .lines().collect(Collectors.joining(",")).split(","); props.setProperty("pact.provider.version", commitMessage[0]); props.setProperty("pact.provider.tag", commitMessage[1]); props.setProperty("pact.verifier.publishResults", "true"); } private static BufferedReader setProperties(String command) throws IOException, InterruptedException { Process process = Runtime.getRuntime().exec(command); process.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader( process.getInputStream())); return reader; }```

chris.ramsden
2021-10-04 16:40
has joined #pact-jvm

brian.fung
2021-10-05 04:57
has joined #pact-jvm

elekberhacizade
2021-10-05 05:27
has joined #pact-jvm

ankit.wadhwana
2021-10-05 12:23
has joined #pact-jvm

zhaopeng
2021-10-05 12:24
has joined #pact-jvm

bjorn.johansson
2021-10-05 13:16
has joined #pact-jvm

pcting
2021-10-05 18:57
has joined #pact-jvm

pcting
2021-10-05 19:26
@pcting has left the channel

aulia.ahn
2021-10-06 00:01
has joined #pact-jvm

muralis
2021-10-06 01:21
has joined #pact-jvm

lakapoor777
2021-10-06 08:47
has joined #pact-jvm

garry.jeromson973
2021-10-06 09:52
has joined #pact-jvm

jbecker
2021-10-06 16:21
Does anyone have any good strategies for tying the provider mocks created in the consumer's pact definition directly to mocks used in the consumer's unit tests? I'm trying to implement a model similar to what Martin Fowler describes https://martinfowler.com/bliki/IntegrationTest.html where my integration tests are written as "narrow integration tests", relying on test doubles (mocks), but I want to use pact to make sure those same mocks are being verified by Pact to be accurately representing the providers they are mocking. I could go the manual route of using Mockito and designing a mock by hand which behaves the same way as the pact fragment I've already defined, but I'm hoping maybe there's a way to automate this? Or maybe someone else has another clever idea to solve the same problem?

anagha.sulakhe
2021-10-06 16:27
has joined #pact-jvm

jbecker
2021-10-06 16:36
Or maybe is the idea more that you shouldn't need mockito at all if you write all your integration tests as pact tests using the pact fragments as your test doubles?

jbecker
2021-10-06 16:38
I am willing to accept that maybe I'm over-thinking this. I'm having a hard time finding others on google who are having this same issue and I'm not sure if it's because I'm doing something fundamentally wrong :shrug:

uladzislau_danilchyk
2021-10-06 16:41
Hi everyone! Our team faced the issue described in ticket above. It's related to Pact broker / JVM lib. I don't know how to properly determine on whose side the problem is. Could you help us with that? Thank you in advance!


franklin.lucena89
2021-10-06 20:38
hi everyone, question, is there a way to do this ```@WebMvcTest @Provider("myAwesomeService") @PactBroker class ContractVerificationTest { @Autowired private MockMvc mockMvc; @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new MockMvcTestTarget(mockMvc)); } }``` but using the application context? I know `@WebMvcTest` annotation only load the mvc components, but I'm trying to use the MockMvc object and when I try to run the test always get a Failed to load application context error

uglyog
2021-10-06 21:34
Just to understand what you are asking, are you referring to mocking the other collaborators during the integration test? Ie. if service A talks to B, and B talks to C and D, you are referring to mocking C and D during the test of A to B?

tjones
2021-10-06 22:15
I'm also unclear on the question. Another angle might be - > Does anyone have any good strategies for tying the provider mocks created in the consumer's pact definition directly to mocks used in the consumer's unit tests? Do you mean the objects unmarshalled from the mock responses in the consumer's API calls? Coupling these with the unit tests (which mock the consumer's API layer) is a good idea. Depending on your framework and language, it might be automatic. For example, with strongly typed languages, this is kind of automatic unless the content of the object is only loosely typed by nature (eg using a `String` property when it's really either `"someType"` or `"someOtherType"` would mean you need to do proper coupling manually). In looser typed languages like JS, you can tie the test fixtures together, so that the expected object in the pact test is the same as the object used in the unit tests. There are some neat ways to make this easy, which I can elaborate on if that's what you're asking

matt.fellows
2021-10-06 23:00
The broker logs are in your pact broker (are you self hosting?)

matt.fellows
2021-10-06 23:01
For JVM it depends on how you log output

uglyog
2021-10-06 23:13
This exception is not related to the pact broker

franklin.lucena89
2021-10-07 00:34
I'm doing this ```@WebMvcTest @ExtendWith(SpringExtension.class) @Provider("Provider") @Consumer("Consumer") @PactBroker(url = "pact_url", authentication = @PactBrokerAuth(username = "pact_user", password = "pact_password") ) @ActiveProfiles("test") @IgnoreNoPactsToVerify class ProviderClass { @Autowired private MockMvc mockMvc; @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context, HttpRequest request) throws Exception { generateSessionToken(request); //This method set a bearer token at header context.verifyInteraction(); } @BeforeEach public void setupTestTarget(PactVerificationContext context) { context.setTarget(new MockMvcTestTarget(mockMvc)); } @State("Provider state") public void toGetState() { } }``` but when I run the test I'm getting this error ```org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [au.com.dius.pact.core.model.HttpRequest request] in method [void com.techinsights.entitlement.pact.consumer.AuthServicePactTest.pactVerificationTestTemplate(au.com.dius.pact.provider.junit5.PactVerificationContext,au.com.dius.pact.core.model.HttpRequest) throws java.lang.Exception]``` The error is related to the HttpRequest param at this function ```void pactVerificationTestTemplate(PactVerificationContext context, HttpRequest request) throws Exception {``` Is there a way to set a request header using this approach?

uglyog
2021-10-07 00:40
You are using the wrong class for the request. It should be `org.apache.http.HttpRequest`

franklin.lucena89
2021-10-07 00:49
I tested with that class too and it's still the same ```org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [org.apache.http.HttpRequest request] in method [void com.techinsights.entitlement.pact.consumer.AuthServicePactTest.pactVerificationTestTemplate(au.com.dius.pact.provider.junit5.PactVerificationContext,org.apache.http.HttpRequest) throws java.lang.Exception].```

uglyog
2021-10-07 00:54
Oh, wait, you are using WebMvcTest. There is no actual request, it is all emulated by MockMVC


franklin.lucena89
2021-10-07 01:02
I'm doing this ``` @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context, MockHttpServletRequestBuilder request) throws Exception { generateSessionToken(request); context.verifyInteraction(); }``` but still the same

franklin.lucena89
2021-10-07 01:04
FYI I'm using this dependency ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.2.14</version> </dependency>```

uglyog
2021-10-07 01:08
For spring, you need to use `@ExtendWith(PactVerificationSpringProvider.class)`, not `@ExtendWith(PactVerificationInvocationContextProvider.class)`

franklin.lucena89
2021-10-07 01:13
O ok, now is working thanks!

franklin.lucena89
2021-10-07 01:14
think this docs https://docs.pact.io/implementation_guides/jvm/provider/junit5spring#usage need to be updated, it suggest to use `@ExtendWith(PactVerificationInvocationContextProvider.class)`

uglyog
2021-10-07 01:18
done!

ian.hamilton
2021-10-07 06:13
@robert.strehli I have this exact problem now. Did you ever find anything to help with this?

matt.fellows
2021-10-07 06:22
What?s deprecated? The request filters feature?

ian.hamilton
2021-10-07 06:26
in the HttpRequest library the setParams is deprecated.

robert.strehli
2021-10-07 06:31
@ian.hamilton I don't use this solution anymore, because I don't need the parameter anymore. But I did this: ``` URI uri = new URIBuilder(request.getRequestLine().getUri()).addParameter("code", "abcd").build(); ((HttpRequestBase) request).setURI(uri);```

ian.hamilton
2021-10-07 06:31
@robert.strehli - thanks! will give that a try

matt.fellows
2021-10-07 06:38
oh, not in Pact - a separate library?

uladzislau_danilchyk
2021-10-07 08:53
@matt.fellows, do you have any thoughts?

mesut.gunes
2021-10-07 09:03
has joined #pact-jvm

matt.fellows
2021-10-07 11:43
Just responded. Short answer is I don?t know (yet)

francisco.moreno
2021-10-07 12:06
Hi, do you have any working example where I can see the "mvn verify" step fails in the provider side

francisco.moreno
2021-10-07 12:06
I mean, when using a PactBroker

francisco.moreno
2021-10-07 12:07
I've playing arraound the enablePendingPacts flags but the build it's always pasing

francisco.moreno
2021-10-07 12:27
I don't quite undertand why it has a diferent behaviour with @PactFolder and @PactBroker . with pactBroker the build always passes even though there are errors in the verification

franklin.lucena89
2021-10-07 12:59
I have a question, how can I test with the mockMvc an authtenticated controller? I mean each endpoint from my controller have a @PreAuthorize annotation and right now when i try to run the test it always fails because a 401 error

franklin.lucena89
2021-10-07 13:06
forget about it, I could solve my issue

jbecker
2021-10-07 13:50
This is for Java, sorry. To clarify with an example, I have a `consumer-service` which defines a pact fragment with `provider-service` which says "when I make a GET rest request, I receive a 200 response". Then I have a pact verification test for this pact fragment which essentially tests to make sure my `ProviderServiceClient` is actually making the rest call I think it's making and my pact fragment is correctly mocking out the 200 response, and that's all working. Now say I want to write an integration test, and one of the things I know that test is doing is invoking my `ProviderServiceClient`'s rest call. So I'm building my `ProviderServiceClient` with Mockito so I can mock out this rest call, but it looks a lot like the pact fragment I already created, and if I ever need to change something (like if `provider-service` starts returning a body with the 200 in the response) I have to change it in both places. So in the interest of the DRY (Don't Repeat Yourself) principle, I can't help but think there is a way to have my mock for my integration test automatically generated from my pact fragment. Unless maybe the idea is that I just write all my integration tests using my pact fragments as mocks instead of using Mockito?

saurabh.goel
2021-10-07 15:00
Hi, i am trying to run tests on the provider side through failsafe plugin through this comand (mvn -Dit.test=OpaConsumerContractVerifierIT verify). They work when i provide pactfolder but when i use pactbroker i get "no pact files found" error. `http://au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException:` `No Pact files were found to verify` `Provider: OMA` `Source: Pact Broker https://<<my brokerurl correctly described>>` also when i run from my ide the tests run with the pact broker too. so the values are correct and it is able to access the broker. Has anyone witnessed something similar? code excerpt for provider class declaration ```@ExtendWith(SpringExtension.class) @Provider("OMA") //@PactBroker(host = "${pactbroker.host}", scheme = "${pactbroker.scheme}", port = "${pactbroker.port}", // authentication = @PactBrokerAuth(username = "${pactbroker.username}", password = "${pactbroker.password}")) @PactBroker(host = "<<broker url truncated>>", scheme = "https", port = "443", authentication = @PactBrokerAuth(username = "vendor_pact_user_name", password = "vendor_pact_password")) //@PactFolder("<<absolutepath truncated>>/target/mypacts") //@Consumer("OPA") public class OpaConsumerContractVerifierIT extends AbstractOrderEventDrivenTest {```

tjones
2021-10-07 15:04
Right! You mean integration tests as in "integrating the units of your consumer", not "integrating multiple services"?

jbecker
2021-10-07 15:05
"Integration tests" as in "testing the integration points of my consumer with its external dependencies"

jbecker
2021-10-07 15:06
As per the article I linked in the original post

tjones
2021-10-07 15:06
Usually what I do is share the object that you assert on in the pact test. Your pact test will look something like: 1) Set up the expected request and response 2) Fire the real request using `ProviderServiceClient`'s implementation 3) Assert that the object that is returned from `ProviderServiceClient` is equal to the expected unmarshalled object.

tjones
2021-10-07 15:07
It's this expected unmarshalled object that I would share for your mocks of `ProviderServiceClient`

tjones
2021-10-07 15:09
If your expected unmarshalled object is just a representation of the json, then in some pact frameworks (Ruby and JS for sure) we have methods to take the request expectation, strip the matchers from it, and then return the example object

tjones
2021-10-07 15:10
I'm not sure what that would look like in Java, because I'm not sure how the unmarshalling into a java object would work (but that might be my limited knowledge).

jbecker
2021-10-07 15:11
> 2) Fire the real request using `ProviderServiceClient`'s implementation Not really sending the "real" request though, right? Since this is intended to be an isolated test? Or are we still misunderstanding each other?

tjones
2021-10-07 15:11
but, yes, you can probably do this. If you're asking how to autogenerate that object, then probably you don't have complex unmarshallers that change the shape of the object

tjones
2021-10-07 15:11
In a pact test, you send the real request to the pact mock

jbecker
2021-10-07 15:11
Right right, okay good. Same page

tjones
2021-10-07 15:11
The "unit under test" is `ProviderServiceClient`

tjones
2021-10-07 15:13
It's possible to write pact tests without step three in my description, because pact won't know that you didn't assert on the result of the `ProviderServiceClient` call. But you need that step, because otherwise you don't know that you can unmarshall the request correctly.

jbecker
2021-10-07 15:13
Right, agreed

tjones
2021-10-07 15:15
I would say that in an ideal world, you should go further and share that expected object with the what's returned from the mocks for `ProviderServiceClient` in other tests. Because the consuming classes of `ProviderServiceClient` have some say in what a "correct" object looks like

tjones
2021-10-07 15:15
(which is what you're asking about, if I understand correctly)

jbecker
2021-10-07 15:16
> If your expected unmarshalled object is just a representation of the json, then in some pact frameworks (Ruby and JS for sure) we have methods to take the request expectation, strip the matchers from it, and then return the example object Can you link me to an example of where this is done? Even if it's not Java, seeing an example would probably help me a lot

tjones
2021-10-07 15:18
I think I talked about this here - at least it looks like I did from the slide at this timestamp: https://www.youtube.com/watch?v=wkld_wRsTDE&t=2371s

tjones
2021-10-07 15:19
I'm not sure what time that particular discussion starts, sorry

jbecker
2021-10-07 15:19
It sounds like, if I'm understanding you correctly, I maybe don't want to use Mockito to copy the expectation from the pact mock, but instead I should try and use the pact mock itself in my integration tests? Is that mostly right?

tjones
2021-10-07 15:19
I'm heading to bed here, but I can check back in the morning

tjones
2021-10-07 15:19
hmm, not exactly

jbecker
2021-10-07 15:20
No worries, I'll watch your talk. I appreciate the attention!

tjones
2021-10-07 15:21
There are a few components: 1) The setup for the pact mock (the pact interaction) 2) Pact's mock server, which sends a mock response 3) The unmarshalled result from that response 4) The expected object that you're comparing that unmarshalled result from I'm proposing using #4, which I don't think of as the pact mock - because it's an object that is independent of pact. However, depending on your scenario, you could generate #4 from #1.

tjones
2021-10-07 15:22
That's what I talk about on that slide

tjones
2021-10-07 15:23
I'll check back tomorrow

jbecker
2021-10-07 15:23
Thank you! :thumbsup:

uladzislau_danilchyk
2021-10-07 15:41
@matt.fellows, I attached the logs file. Please, have a look at this issue as soon as possible. Thanks

jbecker
2021-10-07 16:20
I watched your whole segment of this event to get the whole context and you were right on. That's exactly what I was looking for, thank you!

francisco.moreno
2021-10-07 17:39
Someone has been able to disable PendingPacts when using the @PactBroker. ?. I would like to "mvn verify" fail when running in the local environment, but it always ends with the build as correct.

francisco.moreno
2021-10-07 17:40
when using @PactFolder everything seems to be working as expected

francisco.moreno
2021-10-07 18:15
I've just seen this was fixed in the last version (4.2.14). Thanks for the amazing job!

francisco.moreno
2021-10-07 18:31
I've seen it has been fixed in the last release. thanks for the support

robert.strehli
2021-10-08 09:29
yeah, not in pact. The `setParam` in `org.apache.http.HttpRequest` is deprecated or is already not existing anymore.

vandana.bhaskersen
2021-10-08 09:58
has joined #pact-jvm

uladzislau_danilchyk
2021-10-08 10:30

matt.fellows
2021-10-08 12:11
I think you?re going to need to update first Danil, have you tried that?

uladzislau_danilchyk
2021-10-08 12:11
@matt.fellows not yet. Before do that I think to spin-up another newest Pact Broker and test WIP pacts enabled there. But it requires some efforts from our DevOps team:)

uladzislau_danilchyk
2021-10-08 12:14
@matt.fellows, why do you think that this problem is absent on a newest version of Pact Broker? Does the code was changed in this area for the new version?

matt.fellows
2021-10-08 12:16
I?m not sure, but the behaviour/response looks strange. That being said, I know features have been added since that version, including some changes to pending/WIP (from memory). Given you?re 10 versions behind, it seems a prudent move anyway.

matt.fellows
2021-10-08 12:17
This commit `db643d3c` also seems relevant, and probably adds the qualification you are after

tjones
2021-10-08 12:20
Awesome! Really pleased it helped!

uladzislau_danilchyk
2021-10-08 12:22
ok. Thanks! I will try. But at the same time it would be great if @bethskurrie finds time to investigate attached logs file.

franklin.lucena89
2021-10-08 14:18
Hi guys, I'm adding more test cases to my consumer and when I try to verify on my provider I'm making a mismatch body to make it fails, and it's actually failing but the test still pass successfully why is this happens?

dimundo
2021-10-08 14:30
pending pact ?

dimundo
2021-10-08 14:30
never been green

dimundo
2021-10-08 14:30
so never fail

franklin.lucena89
2021-10-08 14:50
oh ok, I get it

franklin.lucena89
2021-10-08 14:52
so once I verify the pact, next time should fail, right?

franklin.lucena89
2021-10-08 21:41
with this version ```<dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>4.2.14</version> </dependency>``` my pact file are not getting generated when the maven test command get run on my pipeline, why is this error?

matt.fellows
2021-10-08 21:46
If pending is enabled yes

ad.redouani
2021-10-09 15:11
has joined #pact-jvm

amulyadoss
2021-10-09 21:09
has joined #pact-jvm

farshad.falaki
2021-10-10 19:13
has joined #pact-jvm

franklin.lucena89
2021-10-11 21:18
Hey guys, question, with junit4 consumer dependency when I try to execute more than one test for a provider controller, the pact file that is getting generated only have the last test interaction, how can I have one pact file with all the interaction im creating on my pact test? this is the structure I have ```@Pact(consumer = "MyConsumer") public void firstEndpoint(PactDslWithProvider builder) { // Some code here } @Test @PactVerification(value = "MyProvider", fragment = "firstEndpoint") public void firstEndpointTest() { //Some code here } @Pact(consumer = "MyConsumer") public void secondEndpoint(PactDslWithProvider builder) { // Some code here } @Test @PactVerification(value = "MyProvider", fragment = "secondEndpoint") public void secondEndpointTest() { //Some code here }``` The pact file I'm specting is like this ``` "consumer": { "name": "MyConsumer" }, "interactions": [ { "description": "First Interaction", //some stuff ... }, { "description": "Second Interaction" //some other stuff ... } ]``` but the actual file is like this ``` "consumer": { "name": "MyConsumer" }, "interactions": [ { "description" : "First Interaction", //the result of the last test executed } ]```

mike.geeves064
2021-10-11 21:53
Not answering the question as such, but are they all getting pushed up to your broker ok? Depending on what you're wanting to do with them you could just look at them on the broker?

franklin.lucena89
2021-10-11 22:05
no, the thing is that if I set the `pact.writer.overwrite` property to *true,* the pact files are getting overwritten and if I set it to *false* the test get fail during execution on this error `java.lang.NoClassDefFoundError: org/antlr/v4/runtime/CharStreams`

uglyog
2021-10-11 23:12
`pact.writer.overwrite` set to true will force each test to overwrite the pact file, so you will only have one interaction

franklin.lucena89
2021-10-11 23:23
yeah I know, but if I don't set this, always get this error `java.lang.NoClassDefFoundError: org/antlr/v4/runtime/CharStreams` instead of merged interactions


franklin.lucena89
2021-10-12 00:06
that solved the issue! thank a lot!

jhopkinwilliams
2021-10-12 02:01
has joined #pact-jvm

saurabh.goel
2021-10-12 08:34
Hey guys, is there a way to inject host server as parameter in pactUrl? ```@PactUrl(urls="${pacturlbase}/pacts/provider/OMA/consumer/OPA/latest/master", auth = @Authentication(username ="${pactbroker.username}", password = "${pactbroker.password}"))``` I get `Illegal character in path at index 1: ${pactbrokerhost}` context: i was having issues with fetching pacts from pact broker so using pacturl instead.

josephhaig
2021-10-12 08:52
has joined #pact-jvm

matt.fellows
2021-10-12 09:31
what issues are you having with fetching pacts?

margarita.lukjanska
2021-10-12 10:12
has joined #pact-jvm

saurabh.goel
2021-10-12 10:42
I keep getting no pact files present when i use pact broker : i asked the query https://pact-foundation.slack.com/archives/C9UN99H24/p1633618800333900

matt.fellows
2021-10-12 11:54
Can you please share the debug logs to see why no Pacts are found?

matt.fellows
2021-10-12 11:55
The broker annotation is what you should be using, not the local one if you?re looking to do this properly in the long term.

matt.fellows
2021-10-12 11:55
I suspect that annotation doesn?t allow injection of spring variables

matt.fellows
2021-10-12 11:57
Are you saying that it _does_ work from the IDE, but not from the terminal? That tells me the IDE is configured definitely


saurabh.goel
2021-10-12 12:01
yeah, pact url is not allowing that.

matt.fellows
2021-10-12 12:02
But you don?t want that anyway, you want to use the `PactBroker` annotation

matt.fellows
2021-10-12 12:02
let?s get to the bottom of that

matt.fellows
2021-10-12 12:03
If it works in your IDE but not the command line, my guess is some property is not flowing through correctly. debug logs should show what?s happening there. Please get the command to log debug and share that here, and we can look into it further

saurabh.goel
2021-10-12 12:03
i have been trying to make pact broker work for 3 days. :slightly_smiling_face:

saurabh.goel
2021-10-12 12:03
how can i get the debug logs

matt.fellows
2021-10-12 12:26
I don?t know maven, but probably there is a flag to increase logging. Somebody on your team must know?

matt.fellows
2021-10-12 12:26

saurabh.goel
2021-10-12 12:26
the application logs? yes i can increase them

matt.fellows
2021-10-12 12:27
Well, whatever process is running your pact tests

matt.fellows
2021-10-12 12:27
so I guess so

matt.fellows
2021-10-12 12:27
those logs will tell you what is happening

saurabh.goel
2021-10-12 12:27
ok

saurabh.goel
2021-10-12 13:32
I updated the provider version to 4.2.13 and now i get `http://au.com.dius.pact.core.pactbroker.InvalidNavigationRequest: Failed to fetch the root HAL document` i am providing the properties as below in the pom.xml ```<pactbroker.url>https://mybrokerurl:443/</pactbroker.url> <pactbroker.username>vendor_pact_user_name</pactbroker.username> <pactbroker.password>vendor_pact_password</pactbroker.password>```

saurabh.goel
2021-10-12 14:07
i will redeploy the pact broker. and then let you know how it went

oak155online
2021-10-12 14:17
has joined #pact-jvm

saurabh.goel
2021-10-12 14:37
so, now i get `[ERROR] pactVerificationTestTemplate{PactVerificationContext, HttpRequest} Time elapsed: 6.203 s <<< ERROR!` `com.github.michaelbull.result.UnwrapException: called Result.unwrap on an Err value http://javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated` error from terminal. and it still works with same settings from the IDE settigns below ```@ExtendWith(SpringExtension.class) @Provider("OMA") @Consumer("OPA") @PactBroker(url="https://brokerurl", authentication = @PactBrokerAuth(username ="vendor_pact_user_name", password = "vendor_pact_password"))```

saurabh.goel
2021-10-12 14:39
this command from terminal works `pact-broker describe-version --pacticipant=OPA --broker-base-url=https://pacturl/ -u=vendor_pact_user_name -p=vendor_pact_password`

saurabh.goel
2021-10-12 14:40
only the command to run tests from terminal fails `mvn clean install -X -Dit.test=OpaConsumerContractVerifierIT`

saurabh.goel
2021-10-12 15:03
i updated the provider version to 4.3.0-beta.4 and now i get the pact files from broker

saurabh.goel
2021-10-12 16:38
Now i get `org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [org.apache.http.HttpRequest request] in method [public void com.deliveryhero.services.oma.service.contract.OpaConsumerContractVerifierIT.pactVerificationTestTemplate(http://au.com.dius.pact.provider.junit5.PactVerificationContext,org.apache.http.HttpRequest)].` this is how i have defined the method ``` @TestTemplate @ExtendWith(PactVerificationSpringProvider.class) public void pactVerificationTestTemplate(PactVerificationContext context, HttpRequest request) { // add opa related auth header request.addHeader("Authorization", "Basic token=="); context.verifyInteraction(); }```

matt.fellows
2021-10-12 22:09
Saurabh, as mentioned previously, I?d suggest printing out the debug logs so that you can see _why_ you are getting these errors

matt.fellows
2021-10-12 22:10
for example, why it can?t fetch the root HAL document

matt.fellows
2021-10-12 22:10
That is less likely to be a broker problem, and more likely a configuration problem (settings aren?t populating correctly, IDE is out of sync with terminal, proxy etc.). I?d stay away from the beta version if this is for real use

matt.fellows
2021-10-12 22:11
Upgrading the broker is not a bad thing, so it?s good you?ve done that

matt.fellows
2021-10-12 22:11
I?m _assuming_ it has a self-signed certificate, hence the encryption problem?

filipovic
2021-10-13 06:51
has joined #pact-jvm

saurabh.goel
2021-10-13 09:20
i tried getting the debug logs, but they also show nothing additional.

saurabh.goel
2021-10-13 09:21
i iwll look more into the ssl cert

stefan.smith
2021-10-13 09:37
has joined #pact-jvm

v-ratngupta
2021-10-13 10:26
hi

v-ratngupta
2021-10-13 10:27
how can i use ```<requestFilter> // This is a Groovy script that adds an Authorization header to each request request.addHeader('Authorization', 'Bearer eyJhbGciOiJSUzI1NiIsIm') </requestFilter>``` im using pact plugin in java and i have to pass auth token at pact verification so how can i pass in req

saurabh.goel
2021-10-13 10:37
so there is ssl cert, i am running the latest pact broker image. my dependencies are 4.2.14. and i get the below log in broker when i try to run tests through terminal `2021-10-13 10:22:32.599373 I [6:puma server threadpool 002] pact-broker -- Fetching pacts for verification by OMA -- {:provider_name=>"OMA", :params=>{"consumerVersionSelectors"=>[{"consumer"=>"Vendor Availability", "latest"=>true}], "includePendingStatus"=>false}}` `2021-10-13 10:22:33.349217 I [6:puma server threadpool 002] pact-broker -- Fetching pacts for verification by OMA -- {:provider_name=>"OMA", :params=>{"consumerVersionSelectors"=>[{"consumer"=>"OPA", "latest"=>true}], "includePendingStatus"=>false}}` which is the same entry when i run the tests through IDE. But still i get `<error message="called Result.unwrap on an Err value http://javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated" type="com.github.michaelbull.result.UnwrapException">com.github.michaelbull.result.UnwrapException: called Result.unwrap on an Err value http://javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated` `</error>` Usually mvn has -X flag for debug logs. But i do not get any more info then what i shared above on using this flag. still attaching the file here.

v-ratngupta
2021-10-13 13:07
and for verification i'm using cli command 'mvn pact:verify -DpactBrokerUrl=http://10.38.98.32:8080/brokerUrl} -DstateChangeUrl=http://localhost:8080/v1/pact-statestatechangeurl} -DproviderName=provider'

saurabh.goel
2021-10-13 13:14
Hi Everyone. My provider pact tests are unable to fetch pacts from broker unless i use 4.3.0-beta.4 version. but in this version i get `pactVerificationTestTemplate{PactVerificationContext, HttpRequest}[1] Time elapsed: 8.58 s <<< ERROR!` `org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [org.apache.http.HttpRequest request] in method [public void com.deliveryhero.services.oma.service.contract.OpaConsumerContractVerifierIT.pactVerificationTestTemplate(http://au.com.dius.pact.provider.junit5.PactVerificationContext,org.apache.http.HttpRequest)].` I need to use the HttpRequest object to add Authorization headers for my requests. what is the new way to achieve the same in this new version.

warren
2021-10-13 16:45
has joined #pact-jvm

michael.stein
2021-10-13 19:02
has joined #pact-jvm

vuttithatkrongyot
2021-10-13 20:27
Is there any way to add metadata into pact file (REST API not message queue) by using Pact DSL when test and build pact file?

saurabh.goel
2021-10-13 21:40
Hey @matt.fellows , I really want to make this work. is there a possibility to get paid support. I will be paying out of my pocket so a reasonable amount would be nice. :slightly_smiling_face: I am sure if we get on a call. you or someone from your team will make short work of it. :pray: Thanks in advance!

uglyog
2021-10-14 00:24
The DSL doesn't have any support for that, but if you use the resulting Pact model that the DSL builds, you can add to the metadata there.

uglyog
2021-10-14 00:28
If it works in your IDE but not the command line, that means your dependencies are not correct in your project. The IDE may be using a different set of Jar files than is configured in your POM.

uglyog
2021-10-14 00:29
Previous people who have had this problem, it was because there was a parent POM being used that was causing different jar files to be loaded.

uglyog
2021-10-14 00:33
Doing a Google search on `SSLPeerUnverifiedException: peer not authenticated` turned up https://stackoverflow.com/questions/9578129/exception-javax-net-ssl-sslpeerunverifiedexception-peer-not-authenticated

uglyog
2021-10-14 00:33
That was caused by an expired certificate.

uglyog
2021-10-14 00:34
But more likely, from https://www.ibm.com/docs/en/tivoli-netcoolimpact/7.1?topic=issues-ssl-connection-fails-peer-not-authenticated-error Cause This exception indicates that the Java application's truststore was unable to validate the certificate chain. This can occur when the external target's certificates have not been imported into the truststore or one or more of the certificates have expired.

uglyog
2021-10-14 00:35
You need to make sure the certificate used by the Pact broker is trusted by the JVM that is running your tests


saurabh.goel
2021-10-14 08:07
thanks a lot @uglyog i will try all this and update here. :pray:

matt.fellows
2021-10-14 08:32
:taco: for @uglyog (might need it after his lunch today :rolling_on_the_floor_laughing:)

saurabh.goel
2021-10-14 09:07
:taco: for @uglyog and some :beers:

hwillj
2021-10-14 14:52
has joined #pact-jvm

saurabh.goel
2021-10-14 15:06
update: it worked out of the box on the build machine and my colleague's machine. still not working on mine, even with above things. but it is not critical anymore. Thanks a lot guys! for your time and help!!

matt.fellows
2021-10-14 23:06
Glad to hear, but also? damn!

matt.fellows
2021-10-14 23:06
is there somebody else on the team who could take a look at your setup?

fengniy
2021-10-15 02:09
has joined #pact-jvm

saurabh.goel
2021-10-15 09:22
we tried many things, like adding the cert to the jvm keystore and even the commands to ignore ssl. really crazy error. :slightly_smiling_face: so i decided to just cut our loses and not investigate any further. i am able to run from IDE and anyways these tests have to run from the build machine. so leaving this as a mistery for now.

mark.dathorne
2021-10-15 09:51
has joined #pact-jvm

franklin.lucena89
2021-10-15 12:24
Hi guys, I have a question, on my provider I have multiple controller class, so in my consumer I'm doing a pact test class for each controller and when I run the tests (on consumer side) the results get inside the same pact file (that's fine btw), but on my provider side, I wrote only one test class yet (for only one provider controller) and result of verification says that there's a lot of provider states missing, my question is, I need to write pact tests for al my provider controller into the same pact test class or I can do it separate like on my consumer?

haroldlearning93
2021-10-15 14:49
has joined #pact-jvm

srinagasai.krishnasan
2021-10-15 17:21
Hello guys, I am trying to use provider states. The way I want to implement is using `valueFromProviderState` in the response body. Now on the provider side, we are using pact provider gradle plugin. However I am having hard time understanding the `stateChangeUrl` and also how I can implement it. The following snippet is how I configured, any suggestions are encouraged... ``` serviceProviders { pithos { hasPactWith('aesop') { stateChange = { providerState, action -> if (action == 'setup') { return 2398423084L; } else { return 2398423084L; } false } } terminateProviderTask = killGretty port = grettyPort fromPactBroker{ // specify the tags we want to verify here // https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors/ selectors = latestTags('feature/consumer_contract_tests') providerTags = [gitBranch] providerVersion = { gitSha } if (gitBranch == 'master') { enablePending = true // enable pending pacts support } } } }```

brendan.j.donegan
2021-10-15 19:43
Sorry, coming back to this much later :slightly_smiling_face: It appears this happens with JUnit4. The 'solution' in the case I posted above was to switch to JUnit5

vsrungar95
2021-10-15 22:14
has joined #pact-jvm


jsoto128
2021-10-16 20:45
has joined #pact-jvm

fiszczu
2021-10-17 17:04
has joined #pact-jvm

brocheleau
2021-10-18 03:23
has joined #pact-jvm

bjorn.johansson
2021-10-18 11:08
Hi Trying to learn pact so I?m playing around with a dummy project. I?m using micronaut+kotlin and intellij. Found something that I find a bit odd. I have two tests on the consumer side. If I run all tests in the file it works like a charm. But if I just run one of them by clicking the little play button it fails because it complains that the other test where never executed. Is this a bug? Am I doing something wrong? Or is it suppose to work like this, if so can someone explain that a bit. Thanks

mike.geeves064
2021-10-18 13:35
Not familiar with the JVM side particularly, but my understanding would be that the @Pact annotations setup the mock provider, at that point you are saying you expect the mock to be called and how it should respond, similar to if you mock plain http requests and responses Because those get run regardless of which @Test function being called, it has setup both mocks but only one of them is used - so you get the failure because your "client" doesn't make calls to them all

franklin.lucena89
2021-10-18 18:34
Hey guys, I need to generate this object `[{"name":"name", "id":"axasfvf23424asc"}]` and I'm doing this ```PactDslJsonArray.arrayEachLike() .object() .like("name","name") .like("id","axasfvf23424asc") .closeObject();``` but when I run it, it throws me an error about object must contain a name `Caused by: java.lang.UnsupportedOperationException: use the object(String name) form` but if I use it with the name I get this object ```[{"name" : {"name":"name", "id":"axasfvf23424asc"}}]```

krishna.ramnk
2021-10-18 19:05
@uglyog I am trying to verify a pact from pactbroker and using the following sample kind of code but I keep getting error ```PactBroker(host = "http://pact-broker.abcd.co.uk", tags = {"tasks/007"}, scheme = "https",port = "443",         authentication = @PactBrokerAuth(username = "pact-broker", password = "hihellooaodoaodadoa")) public class CreateProviderPactVerification``` ```Error : At least one pact source must be present on the test class``` Dependencies used : ``` // contract testing testImplementation "org.junit.jupiter:junit-jupiter-api" testImplementation "au.com.dius:pact-jvm-consumer-junit5:4.0.10" testImplementation "org.mockito:mockito-junit-jupiter:2.22.0" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine" testImplementation "au.com.dius:pact-jvm-provider-junit5:4.0.10" testImplementation("au.com.dius.pact.provider:gradle:4.1.0") }```

matt.fellows
2021-10-18 19:43
That would be my guess too

uglyog
2021-10-18 21:50
remove `.object()`

andrerc
2021-10-18 22:11
has joined #pact-jvm

andrerc
2021-10-18 23:10
Hi ! I'm struggling to generate a Pact for the following json: ```{ "data": { "userData": { "phones": [ {"type": "MOBILE", "number": "1234"}, {"type": "LANDLINE", "number": "555"}, ] } } }``` I have tried many variations of the dsl (`eachLike`, `arrayLike`, `newJsonArrayMinLike`, `eachArrayLike`, `minArrayLike`) but none of then can generate the phones array info Sample code: ```builder .given("user has phones") .uponReceiving("request for phones") .willRespondWith() .status(200) .body(newJsonObject { newObject("data") { newObject("userData") { eachLike("phones", 1) { stringType("type", "MOBILE") stringType("number", "1234") } } } })``` The code above generates an empty object inside the array: ```{ "data": { "userData": { "phones": [ {} ] } } }```

andrerc
2021-10-18 23:25
Well, actually the object is outside the array :man-shrugging: ```"data": { "userData": { "number": "1234", "phones": [ {} ], "type": "MOBILE" } }```

uglyog
2021-10-18 23:27
This error `At least one pact source must be present on the test class` means it looked at all the annotations on your test class, and did not find one that is a pact source annotation.

uglyog
2021-10-18 23:27
Silly question, but your example is missing the `@` for the annotation

uglyog
2021-10-18 23:28
Also, you should not have to add the `gradle` library to your test classpath. It is also a different version `4.1` while the others are `4.0`. What that will do is update all the versions to `4.1`

andrerc
2021-10-18 23:29
FWIW I'm using kotlin

uglyog
2021-10-18 23:57
`eachLike` is a normal Java method that passes the array builder in to the closure. You need to call the methods on that, not on the receiver ```newJsonObject { newObject("data") { newObject("userData") { eachLike("phones", 1) { it.stringType("type", "MOBILE") it.stringType("number", "1234") } } } }```

krishna.ramnk
2021-10-19 05:07
@uglyog It was copy-paste issue here but the annotation had been added for Pactbroker :smile:

uglyog
2021-10-19 05:09
What class is CreateProviderPactVerification?

krishna.ramnk
2021-10-19 05:09
Yes thats what I couldnt understand.. It has Pact broker annotated and with all correct details but still it is unable to find the pact source. I have removed all PACT related stuff from Gradle though to make it easier

uglyog
2021-10-19 05:09
Is it an inner class, outer class, etc?

krishna.ramnk
2021-10-19 05:09
It is an outerclass

krishna.ramnk
2021-10-19 05:10
Regarding the versions , the gradle is throwing errors when I request latest versions for pact-jvm-juni5

uglyog
2021-10-19 05:10
You need to run with debug logging enabled and look at the logs

krishna.ramnk
2021-10-19 05:10
Yeah I tried debugging but couldnt find anything straightaway from debug logs

uglyog
2021-10-19 05:11
> the gradle is throwing errors when I request latest versions for pact-jvm-juni5 That means there is something wrong with your project

krishna.ramnk
2021-10-19 05:12
testImplementation "au.com.dius:pact-jvm-provider-junit5:4.0.10" - I mean only for this particular jar

krishna.ramnk
2021-10-19 05:13
I tried 4.1.+ and 4.1.0 but it says it is finding only old versions when debugged

uglyog
2021-10-19 05:14
`implementation 'au.com.dius.pact.provider:junit5:4.1.28'`

uglyog
2021-10-19 05:15
:point_up: the artefact name was changed

krishna.ramnk
2021-10-19 05:16
ahh okay , I shall try that straighaway and see if it resolves .. Thanks @uglyog

krishna.ramnk
2021-10-19 05:45
Great .. The change in versions fixed the issue @uglyog... But how do we generally know that these things have changed names etc ? .. Anyhow , thanks for swift response and resolution


krishna.ramnk
2021-10-19 06:03
:+1:

bjorn.johansson
2021-10-19 06:51
All right thanks. I?ll see if I can come up with a way to deal with it. Otherwise just something to be aware of I guess.

rodolfo.valenzuela
2021-10-19 07:43
has joined #pact-jvm

matt.fellows
2021-10-19 08:33
It must be possible to run a test without the associated "arrange" parts of the tests to fire.

mike.geeves064
2021-10-19 08:55
Out of interest, what's the "use case"? Ideally the tests should be fast enough that it doesn't matter too much running them all, or is the problem that e.g. you run tests, one or more fail and if you rerun failed from the ide it has the additional fail? I can see that could be quite annoying if it is the case :thinking_face:

bjorn.johansson
2021-10-19 09:25
When I write tests I just have the habit of only running the test that I?m working on. They are fast enough as you said, so running all of them is not a problem. I just need to rewire my brain a bit

v-ratngupta
2021-10-19 10:19
Can I skip a particular provider state at the time of pact verification execution? like in my pact file I have 10 interactions and I want to skip an interaction or a provider state.

mike.geeves064
2021-10-19 10:33
That's fair enough, I think I tend to do the same mostly :thinking_face:

mike.geeves064
2021-10-19 10:42
:thinking_face: I wonder if you could do something with dependency injection to only pull in those @Pact calls for the relevant tests? On the python side for example, the pact equivalent is generally part of the test function setup code itself, so only happens when you're actually calling that test function. I quite like them together for clarity I think. No clue the general best practice on the JVM side around this though

bjorn.johansson
2021-10-19 11:40
I think the solution I?m leaning towards is using `inner class` with `@Nested` annotation from junit5. I think that works a bit similar to what you described

bjorn.johansson
2021-10-19 11:41
If I run the test now only the code within that inner class will be executed. Running the parent classes still executes both tests

mike.geeves064
2021-10-19 11:47
Oh nice :slightly_smiling_face: Nested new around 2016 or so :open_mouth: I think I missed some updates :joy: Hadn't seen that before

andrerc
2021-10-19 12:13
Feeling dumb right now... hahahaha Thank you very much

bjorn.johansson
2021-10-19 13:14
yeah it?s a nice feature. :slightly_smiling_face: It?s part of junit5 which was release 2016-2017 sometime

krishna.ramnk
2021-10-19 19:19
@uglyog Currently I am facing issue with publishing the verification results back to the pactbroker

krishna.ramnk
2021-10-19 19:20
Gradle file ```pact { System.setProperty("pact.verifier.publishResults", "true");``` cmdline : `pactVerify -DpactPublishResults=true -Ppact.verifier.publishResults=true`

krishna.ramnk
2021-10-19 19:22
While running the pact verification class : Notices:     1) The pact at https://pact-abcd/....5 is being verified because the pact content belongs to the consumer version matching the following criterion:     * latest version tagged ?tasks /abcd(0.0.1-SNAPSHOT-7925a2e)     2) This pact is in pending state for this version of SquareHealth because a successful verification result for a version of provider with tag ?master? has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at https://docs.pact.io/go/pending

uglyog
2021-10-19 21:37
What do the logs say?

kamilyrb
2021-10-19 22:31
has joined #pact-jvm

krishna.ramnk
2021-10-20 02:34
The logs didnt throw any errors

krishna.ramnk
2021-10-20 02:34
about publishing results

franklin.lucena89
2021-10-20 03:27
Hey guys, I have an endpoint on my provider that is returning a ```new ResponseEntity(HttpStatus.NO_CONTENT)``` what kind of value can I use on consumer `PactDslWithProvider` object to set this value instead of a body?

matt.fellows
2021-10-20 03:28
you just don?t include a body at all

uglyog
2021-10-20 03:28
try `pactVerify -Dpact.verifier.publishResults=true`

krishna.ramnk
2021-10-20 06:08
org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation ?Task :-app-spring:pactVerify? started 2021-10-20T07:02:50.549+0100 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger]  2021-10-20T07:02:50.549+0100 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] *> Task :adapter-app-spring:pactVerify* UP-TO-DATE 2021-10-20T07:02:50.549+0100 [INFO] [org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter] Skipping task ?:adapter-app-spring:pactVerify? as it has no actions. 2021-10-20T07:02:50.549+0100 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation ?Task :dapter-app-spring:pactVerify? 2021-10-20T07:02:50.549+0100 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation ?Task :app-spring:pactVerify? completed 2021-10-20T07:02:50.549+0100 [INFO] [org.gradle.execution.plan.DefaultPlanExecutor] :adapter-app-spring:pactVerify (Thread[Execution worker for ?:?,5,main]) completed. Took 0.0 secs. 2021-10-20T07:02:50.549+0100 [DEBUG] [org.gradle.execution.plan.DefaultExecutionPlan] Node :-app-spring:pactVerify finished executing 2021-10-20T07:02:50.549+0100 [DEBUG] [org.gradle.execution.plan.DefaultExecutionPlan] Node :pactVerify completed, executed: true 2021-10-20T07:02:50.549+0100 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Execution worker for ?:?: released lock on :

krishna.ramnk
2021-10-20 06:12
When I tried same from IDE : *Task execution finished ?:app-spring:test --tests ?cont.ProviderPactVerification? -Dpact.verifier.publishResults=true*

krishna.ramnk
2021-10-20 06:13
Notices: 1) The pact at https://pact-broker.engineering.co.uk/pacts/provider//consumer/-adapter/pact-version/6389d5faf65a7596efd27b68f3324289b065c135 is being verified because the pact content belongs to the consumer version matching the following criterion: * latest version tagged ?92? (0.0.1-SNAPSHOT-7925a2e) 2) This pact is in pending state for this version of sabc because a successful verification result for a version of sabc with tag ?master? has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at https://docs.pact.io/go/pending [from Pact Broker https://pact-broker.engineering.co.uk/pacts/provide/metadata/c1tdW3RdPXRhc2tzJTJGSFVCLTkyJnNbXVtsXT10cnVlJnNbXVtjdl09NjUmcD10cnVl] Create Appointment returns a response which has status code 200 (OK) has a matching body (OK) BUILD SUCCESSFUL in 10s 9

krishna.ramnk
2021-10-20 06:14
But still the publish results back to Pactbroker is empty

krishna.ramnk
2021-10-20 06:14
@uglyog

uglyog
2021-10-20 10:21
If you are running the verification as unit tests, then that will not work. You also don't run pactVerify, that is for non-unit test verification



krishna.ramnk
2021-10-20 16:03
yes have already seen this and added it in gradle ```test { //Specify the folder where pacts need to be published - Contract Testing System.setProperty("pact.verifier.publishResults", "true") System.setProperty("pact.provider.version", "1.0.0") }```

krishna.ramnk
2021-10-20 16:05
yes have already seen this and added it in gradle ```test { //Specify the folder where pacts need to be published - Contract Testing System.setProperty("pact.verifier.publishResults", "true") System.setProperty("pact.provider.version", "1.0.0") }```

krishna.ramnk
2021-10-20 16:22
The only way it finally worked is by using ```@BeforeEach void before(PactVerificationContext context) throws Exception { System.setProperty("pact.verifier.publishResults", "true"); System.setProperty("pact.provider.version", "1.0");```

joel.whalen588
2021-10-20 20:27
has joined #pact-jvm


vasil.vasilev
2021-10-21 08:41
has joined #pact-jvm

ben.crinion
2021-10-21 11:09
has joined #pact-jvm

gayatree.eee
2021-10-21 11:44
Hi Team, is -D parameter value supported for urls attribute in @pactUrl. Whenever we are hard coding the url in @PactUrl, it is working fine but the same is not working when passed as runtime variable.

franklin.lucena89
2021-10-21 12:01
Hi guys, I'm having some issues testis a POST request on my consumer with the `PactProviderRule` if I execute more than 1 request on the same test class I get this error ```java.lang.AssertionError: Pact Test function failed with an exception, possibly due to ExpectedButNotReceived(expectedRequests=[ method: POST . . . Caused by: java.net.SocketException: Software caused connection abort: recv failed``` but if I set a 1 second sleep time to my failing test, everything go well, why is this behavior?

estephania.calvo
2021-10-21 19:27
has joined #pact-jvm

ahmetbcakici
2021-10-21 22:38
has joined #pact-jvm

abarcadabra
2021-10-22 12:30
has joined #pact-jvm

franklin.lucena89
2021-10-22 12:51
Hi guys, I'm having some issues on my consumer with this `.datetimeExpression("date", "today", "yyyy-MM-dd'T'HH:mm:ss.SSSS")` , whenever I create a new `PactDslJsonBody()` object, this expression set the date to this `"2000-01-31T09:00:00.0000"` and when run the test against the mock server I'm getting the current datetime, how can I set the date value?

harwin1494
2021-10-22 19:04
has joined #pact-jvm

anindita.ghosh
2021-10-22 23:26
has joined #pact-jvm

matias.waterloo
2021-10-23 23:12
Hi! I?m running provider tests on my pc (local copy ) and I?d like to disable pending pact (I want the tests to fail) but i can?t find a way to do it. I tried forcing `pactbroker.enablePending=false` and removing all the configs (afaik) to use the default. Any ideas? thanks

matias.waterloo
2021-10-23 23:30
to add more detail, I?m pulling pacts from the broker that haven?t been verified before. This is triggering the pending pact behavior and I?d like to disable it for this particular run on my machine

tjones
2021-10-25 00:59
Is there an easy way to specify multiple state strings for the same method using the JUnit5 pact wrapper? As in, I'd like to be able to say something like this: ``` @State("Some state string") @State("Also this state string") public void someSetup() { /* ... */ }```

rajnish.maurya
2021-10-25 06:47
has joined #pact-jvm

alanbos
2021-10-25 10:11
has joined #pact-jvm

kuzmanovid
2021-10-25 13:59
has joined #pact-jvm

j.malyjasiak
2021-10-25 14:24
has joined #pact-jvm

rtbhosale17
2021-10-25 14:25
has joined #pact-jvm

stefano.mantini
2021-10-25 14:31
has joined #pact-jvm

r.muthukumar136
2021-10-25 14:59
has joined #pact-jvm

franklin.lucena89
2021-10-25 17:42
Hi guys, I'm having some issues on my consumer with this `.datetimeExpression("date", "today", "yyyy-MM-dd'T'HH:mm:ss.SSSS")` , whenever I create a new `PactDslJsonBody()` object, this expression set the date to this `"2000-01-31T09:00:00.0000"` and when  run the test against the mock server I'm getting the current datetime, how can I set the date value? FYI: I also tried with `datetime, timestamp, date` @uglyog

gravis54
2021-10-25 21:46
has joined #pact-jvm

misha.antipenko
2021-10-25 21:57
has joined #pact-jvm

uglyog
2021-10-25 22:00
I'd be curious to see what that does. It might work

uglyog
2021-10-25 22:01
Those functions add a generator that uses the current system time.

franklin.lucena89
2021-10-25 23:44
yeah but the thing is when I create the @Pact(consumer = "myConsumer") method the time is set to some date time on 2000 year

tjones
2021-10-26 03:04
Sorry, I should have said: It doesn't compile. I'll get you the error

tjones
2021-10-26 03:04
```Duplicate annotation. The declaration of 'au.com.dius.pact.provider.junitsupport.State' does not have a valid java.lang.annotation.Repeatable annotation```


adomanski
2021-10-26 10:43
has joined #pact-jvm

kriegster108
2021-10-26 14:58
has joined #pact-jvm

franklin.lucena89
2021-10-26 16:12
Hey @uglyog, I'm having this issue `1.1) body: $.entitlements.0.endPeriodDate Expected 1635261624850 to match a datetime of 'yyyy-MM-dd'T'HH:mm:ss.SSSS': Unable to parse the date: 1635261624850` when I try to verify the pact between consumer/provider, on my consumer I'm setting datetime like this: `.datetime("startPeriodDate", "yyyy-MM-dd'T'HH:mm:ss.SSSS", date )` and the date value is ``` private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd'T'HH:MM:ss.SSSS"); String today = dateFormat.format(new Date()); Date date = dateFormat.parse(today);``` and on my provider I'm creating a mock object with the same datetime value

uglyog
2021-10-26 21:30
`1635261624850` is not a valid date value. I can't see how you are getting that value, but you need to find that out

adam.witko
2021-10-27 07:36
has joined #pact-jvm

alex.macpherson
2021-10-27 08:28
has joined #pact-jvm

alanbos
2021-10-27 09:42
Apologies this may seem like a rather basic question, but I haven't figured out a way to do it. I'm developing verification in my provider for some new contract tests. So I'm running my provider verification contract test against the contracts published by the specific consumer tagged with the branch on which on the consumer changes are being developed e.g. (assuming I have a maven profile VERIFY which filters out all but my provider contract test class) ```mvn -PVERIFY test -Dpactbroker.url=<pactBrokerUrl> -Dpactbroker.consumerversionselectors.tags=<consumerBranchName> -Dpactbroker.consumers=<consumerName>``` This all works as expected, the problem is that I'm finding it very difficult to spot the real pass/fail status of verification for the contracts because they're all treated as "Pending" so every state verification gets presented as a "green tick" in my IDE and I have to trawl through the output to check the status (which gets a bit tedious once the number of states grows). Is there any way to force a "Pending" state verification failure to be a hard fail in Junit test terms?

matt.fellows
2021-10-27 09:45
Probably best to turn pending off locally in that case, because it's not like the results go back to the broker

matt.fellows
2021-10-27 09:45
Perhaps that could be a feature request though - toggling how JUnit will treat a failing pending test?

alanbos
2021-10-27 09:46
Thanks @matt.fellows - how do I turn off pending locally?

matt.fellows
2021-10-27 09:47
Good question, I don't know with Java/maven but there should be a way!

alanbos
2021-10-27 09:48
I know :slightly_smiling_face: I've looked through the docs but can't see anything pending-related apart from `pactbroker.enablePending` but (a) that defaults to false anyway, and (b) it doesn't seem like quite the right thing.

alanbos
2021-10-27 09:49
Is there a way in pact-js?

matt.fellows
2021-10-27 09:49
Yes, it's a Boolean flag on the verifier

matt.fellows
2021-10-27 09:50
I know there was a bug recently where it wasn't being sent to the broker as false, and so the broker still treated them as pending

matt.fellows
2021-10-27 09:51
That may also be an issue in the maven verifier. Are you using JUnit, if so does https://docs.pact.io/implementation_guides/jvm/provider/junit5#pending-pact-support-version-410-and-later help?

matt.fellows
2021-10-27 09:51
(just guessing btw, I'm not that close to the Java impl)


alanbos
2021-10-27 09:56
(Yep I'm using Junit; have tried setting `-Dpactbroker.enablePending=false` just in case the documented default wasn't getting applied but it doesn't make any difference)


matt.fellows
2021-10-27 10:23
Just checking you're on the latest version?

matt.fellows
2021-10-27 10:24
Also, did the JUnit annotation help?

vuttithatkrongyot
2021-10-27 10:25
Hi team, I have a problem when using PactDslJsonBody with request/response that have too many fields (100++). Is there any solution to solve this pain? like generate Dsl from model FYI, i'm using pact http://au.com.dius.pact.consumer junit5 with springboot. Thanks

alanbos
2021-10-27 10:26
@matt.fellows alas it didn't - I tried explicitly setting enablePending=false both via the `@PactBroker` annotation and as an env variable passed with the command line, but neither helped.

alanbos
2021-10-27 10:34
@matt.fellows my pact dependencies version is 4.2.11 - I'll try 4.2.14 which seems to be the latest

alanbos
2021-10-27 11:04
Bingo - that looks like it (upreving) might have done the trick - thanks for your help!

matt.fellows
2021-10-27 11:14
Great!

matt.fellows
2021-10-27 11:14
When in doubt, update all the things :stuck_out_tongue:

yurich00
2021-10-27 18:10
has joined #pact-jvm

lincolnf
2021-10-27 23:30
has joined #pact-jvm

vuttithatkrongyot
2021-10-28 07:20
Any answer for my question? Thank you

lawrencemajmacdonald
2021-10-28 07:33
has joined #pact-jvm

matt.fellows
2021-10-28 07:40
What's the actual problem?

matt.fellows
2021-10-28 07:41
Is it just that 100 fields is time consuming or something else?

lawrencemajmacdonald
2021-10-28 07:48
Hi, I'm attempting to use the Groovy flavour of pact-jvm for consumer with pact-js for provider verification. Hence, my contracts need to use the V2 specification. I seem to be struggling with actually getting the contracts to output as V2 (following the pattern used https://docs.pact.io/implementation_guides/jvm/consumer/groovy/#generating-v3-spec-pact-files, but with V2 instead of V3). This still nets me a contract with pactSpecification: version: 3.0.0 in the metadata. As a follow-up, is there any documentation for using V2 spec with JVM, specifically for the available matchers? Or would I be better off moving my pact-js implementation over to the beta implementation to get the V3 spec compatibility?

uglyog
2021-10-28 08:12
`PactBuilder` takes the version as the parameter to the constructor

zsolt.vilagos
2021-10-28 10:00
has joined #pact-jvm

matias.waterloo
2021-10-28 15:28
any idea how handle this?

norway.martin
2021-10-28 15:59
@norway.martin has left the channel

matt.fellows
2021-10-28 21:04
I think there was a bug that was fixed in 4.2.14. which version are you on?

matias.waterloo
2021-10-28 22:28
4.1.23. is there any fix on 4.1.X?

matias.waterloo
2021-10-28 23:23
4.2.14 solved the issue! I?m not sure if I can upgrade that easily though

ramesh.dhanasekaran
2021-10-29 02:20
has joined #pact-jvm

ramesh.dhanasekaran
2021-10-29 02:32
Hi Pact Team, My name is Ramesh, I am fairly new to contract testing. We are trying to write a consumer test with `pact-jvm-consumer-junit5` We are able to create pacts and consumer tests for most of the methods, but when trying to create a test for POST with body, the mockServer returns `500 Internal Server Error` . I am not sure what i am doing wrong, can someone please help. Below is the is my code snippet for interaction and consumer test ``` @Pact(consumer = CONSUMER_Q3) public RequestResponsePact createFlowsRequestPact(PactDslWithProvider builder) { final Map<String, String> responseHeaders = singletonMap("Content-Type", CONTENT_TYPE_JSON);; final String pathSample = getSamplePath(PATH_FLOWS); final DslPart expectedResultBody = new PactDslJsonBody() .stringType("flowId") .asBody(); final DslPart requestBody = new PactDslJsonBody() .stringType("name","newFlow") .asBody(); return builder .uponReceiving(DESCRIPTION_FLOWS_POST) .pathFromProviderState(PATH_FLOWS, pathSample) .method(POST.getValue()) .headers("Content-Type", CONTENT_TYPE_JSON) .headerFromProviderState("Authorization", VALUE_TEMPLATE_AUTHORIZATION_TOKEN, getSampleAuthorizationToken()) .body(requestBody) .willRespondWith() .status(SC_OK) .headers(responseHeaders) .matchHeader(HEADER_TRACE_ID, EXPRESSION_TRACE_ID) .matchHeader(HEADER_SPAN_ID, EXPRESSION_TRACE_ID) .body(expectedResultBody) .toPact(); } @Test @PactTestFor(pactMethod = "createFlowsRequestPact", pactVersion = PactSpecVersion.V3) public void verifyCreateFlowsRequestPact(MockServer mockServer) { final Response response = Client.getInstance() .buildBasicRequestSpecification() .header("Authorization", getSampleAuthorizationToken()) .post(getFullSamplePath(mockServer, PATH_FLOWS)); assertEquals(SC_OK, response.getStatusCode()); }```

matt.fellows
2021-10-29 02:34
Check the log output / test output

matt.fellows
2021-10-29 02:34
500 means you aren?t sending a request to the pact server that matches, and the logs will tell you why

matt.fellows
2021-10-29 02:35
my guess is that you?re not sending the request to the Pact mock server, and instead it?s going to the real thing

matt.fellows
2021-10-29 02:36
i.e. `Client.getInstance()` is not using the url from `mockServer`

ramesh.dhanasekaran
2021-10-29 02:39
I can see from the logs Request URI: http://localhost:61292/api/v1/organizations/c1234e1c-abcd-1234-1234-1234ba12bb12/flows which is to the local host on some random port

matt.fellows
2021-10-29 02:50
the key insight is this: ```19:07:39.191 [Thread-4] DEBUG a.c.d.p.consumer.BaseJdkMockServer - Received request: method: POST path: /api/v1/organizations/c1234e1c-abcd-1234-1234-1234ba12bb12/flows query: {} headers: {Accept-encoding=[gzip,deflate], Accept=[*/*], Connection=[Keep-Alive], Host=[localhost:61292], User-agent=[Apache-HttpClient/4.5.3 (Java/1.8.0_302)], Authorization=[bearer 1234], Content-type=[application/json; charset=UTF-8], Content-length=[0]} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: EMPTY 19:07:39.192 [Thread-4] DEBUG a.c.d.p.c.matchers.RequestMatching - comparing to expected request: method: POST path: /api/v1/organizations/c1234e1c-abcd-1234-1234-1234ba12bb12/flows query: {} headers: {Authorization=[bearer 1234], Content-Type=[application/json; charset=UTF-8]} matchers: MatchingRules(rules={body=Category(name=body, matchingRules={$.name=MatchingRuleGroup(rules=[au.com.dius.pact.core.model.matchingrules.TypeMatcher@5154fef2], ruleLogic=AND)})}) generators: Generators(categories={PATH={=ProviderStateGenerator(expression=/api/v1/organizations/${organizationId}/flows, type=STRING)}, HEADER={Authorization=ProviderStateGenerator(expression=bearer ${authorizationToken}, type=STRING)}}) body: PRESENT({"name":"newFlow"}) 19:07:39.192 [Thread-4] DEBUG a.c.d.p.core.matchers.HeaderMatcher - Comparing header 'Authorization': 'bearer 1234' to 'bearer 1234' 19:07:39.192 [Thread-4] DEBUG a.c.d.p.core.matchers.HeaderMatcher - Comparing header 'Content-Type': 'application/json; charset=UTF-8' to 'application/json; charset=UTF-8' 19:07:39.192 [Thread-4] DEBUG a.c.d.p.core.matchers.HeaderMatcher - Comparing content type header: 'application/json; charset=UTF-8' to 'application/json; charset=UTF-8' 19:07:39.193 [Thread-4] DEBUG a.c.dius.pact.core.matchers.Matching - Found a matcher for application/json -> au.com.dius.pact.core.matchers.JsonBodyMatcher@6ad87174 19:07:39.194 [Thread-4] DEBUG a.c.d.p.c.matchers.RequestMatching - Request mismatch: [BodyMismatch(expected=null, actual=, mismatch=Expected empty body but received '[B@85f9da5', path=/, diff=null)]```

matt.fellows
2021-10-29 02:50
There should be a junit output file somewhere, if you open that up you?ll get a more readible error

matt.fellows
2021-10-29 02:51
it says that you send a POST request with an empty body, but you expected your code to send a body

ramesh.dhanasekaran
2021-10-29 02:59
yeah i see in the logs, but if you see my code snippet i am building the `RequestResponsePact` with the requestBody.

matt.fellows
2021-10-29 03:00
your code test says that your client *should* send a POST Body, but it?s not receiving one and hence the failure

matt.fellows
2021-10-29 03:01
i.e. `Client.getInstance()?` is sending a POST request with an empty body

ramesh.dhanasekaran
2021-10-29 03:03
oh ok, got it. I was not sending the body.

ramesh.dhanasekaran
2021-10-29 03:03
Thank you very much.

ramesh.dhanasekaran
2021-10-29 03:03
:slightly_smiling_face:

matt.fellows
2021-10-29 03:08
np

lawrencemajmacdonald
2021-10-29 06:22
In V2 spec groovy pact-jvm, how do I define a match for an int in the Groovy closure itself? I can see from https://github.com/pact-foundation/pact-jvm/blob/master/core/model/src/main/kotlin/au/com/dius/pact/core/model/matchingrules/MatchingRules.kt#L329 that toMap is trying to map, for example, `version integer(1)` from the Groovy PactBuilder withBody closure into `match: type` in the actual contract for specs below V3, but then it seems that `validateForVersion` is causing it to hard fail for specs below V3? As an example of what I'm hoping to achieve, when I have `id string("abc123")` in my `withBody` closure, the contract comes out with `$.body.caseId: {match: type}`, so it gets converted from the Matcher. I'm aware my contract won't contain `match: integer` or anything because that's for later specs, but I"m just trying to get my consumer test to output a `match: type` with an example value of an integer, not a string.

uglyog
2021-10-29 06:26
You can't use the number type matchers with V2, they won't work on the other side

uglyog
2021-10-29 06:26
You need to use the like matcher function

lawrencemajmacdonald
2021-10-29 06:32
I don't see a `like` Matcher function in the Groovy decompiled jar (v4.2.6). And if I try to use, for example, `version like(1)` in my withBody closure, it doesn't seem to recognise it (I end up with `version: null` and `like: 1` in my contract example response). Is there a file I can look at to see all of matcher functions available?

lawrencemajmacdonald
2021-10-29 06:32
~dont'~

uglyog
2021-10-29 06:36
Huh! You're correct, there is no like method. There should be one.

lawrencemajmacdonald
2021-10-29 06:36
So if my withBody looks something like this, what should `foo` be replaced with to achieve this? ```withBody { id string("abc123") version foo(1) anotherField regexp("A|B", "A") }``` As `string` gets converted to a type match, and I can use `regexp` to replicate spec V3+'s `or` Matcher, as shown. But I can't work out how to get it to parse an int into a type match

uglyog
2021-10-29 06:39
You can create your own method to do it. Look at `string()`, you need something the same but with a different parameter type

lawrencemajmacdonald
2021-10-29 06:54
Sorry to be a pain but I genuinely cannot find the definition of string() in GitHub. I can find the package and the javadocs, but not the file. Would you mind linking it when you get a moment please? EDIT: Nevermind, found it, was looking for Groovy code :facepalm: Thanks for all the assistance and quick answers!

christopher.mcewen
2021-10-29 12:14
has joined #pact-jvm

catalin.comarnescu
2021-10-29 12:31
has joined #pact-jvm

aubilla
2021-10-29 13:24
Just trying to do a sanity check here on using the Broker. I?m coding a Pact workshop at work and I started with the Provider. I tried running pactVerify (just for the kicks) and I?m getting a 401 Unauthorised from the Broker. Since there are no Consumers yet for this Provider, is this expected behaviour from the Broker? Do I have to ?register? the Provider on the Broker if no Consumers have published pacts for it yet? Credentials are OK and the error is the following: ```* Exception is: org.gradle.api.GradleScriptException: Failed to fetch pacts from pact broker https://pact-broker.mydomain.com/ at au.com.dius.pact.provider.gradle.PactPlugin.setupPactConsumersFromBroker(PactPlugin.groovy:108) at org.gradle.internal.metaobject.BeanDynamicObject$GroovyObjectAdapter.invokeOpaqueMethod(BeanDynamicObject.java:584) at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:511) at org.gradle.internal.metaobject.BeanDynamicObject.tryInvokeMethod(BeanDynamicObject.java:196) at org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:77) at au.com.dius.pact.provider.gradle.PactPlugin$_apply_closure1$_closure4.doCall(PactPlugin.groovy:44) at org.gradle.util.ClosureBackedAction.execute(ClosureBackedAction.java:71) at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:154) at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:105) at org.gradle.util.ConfigureUtil$WrappedConfigureAction.execute(ConfigureUtil.java:166) at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:100) at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction$1.run(DefaultCollectionCallbackActionDecorator.java:95) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:395) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:387) at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150) at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:84) at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction.execute(DefaultCollectionCallbackActionDecorator.java:92) at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:163) at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:198) at au.com.dius.pact.provider.gradle.PactPlugin$_apply_closure1.doCall(PactPlugin.groovy:43) at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator$BuildOperationEmittingClosure$1.lambda$run$0(DefaultListenerBuildOperationDecorator.java:181) at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication.reapply(DefaultUserCodeApplicationContext.java:86) at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator$BuildOperationEmittingClosure$1.run(DefaultListenerBuildOperationDecorator.java:178) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:395) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:387) at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150) at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:84) at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator$BuildOperationEmittingClosure.doCall(DefaultListenerBuildOperationDecorator.java:175) at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:41) at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25) at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42) at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:245) at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:157) at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58) at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:346) at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:249) at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:141) at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at com.sun.proxy.$Proxy39.afterEvaluate(Unknown Source) (OMITTED)```

kiran.rudrangi
2021-10-29 16:48
has joined #pact-jvm

matt.fellows
2021-10-29 23:45
Can you share the debug logs with any creds redacted?

matt.fellows
2021-10-29 23:46
401 is pretty clear though, is it the status code from the broker? Is it a self hosted one or Pactflow?

matt.fellows
2021-10-29 23:46
I seem recall it can fail if no pacts were found, but it's configurable

ahmetbcakici
2021-10-29 23:49
hey everyone! i am beginner about pact and contract testing and i have a problem that i could not solve for few days. i have a test class like that ```@ExtendWith(MockitoExtension::class, PactConsumerTestExt::class) class SellerBranchConsumerPactTest { @InjectMocks private lateinit var sellerBranchApiService: SellerBranchApiService @Mock private lateinit var sellerBranchApiClient: SellerBranchApiClient @Pact(consumer = "LahmacunBff", provider = "SellerBranchService") fun getRestaurantKitchens(builder: PactDslWithProvider): RequestResponsePact { val body = PactDslJsonArray.arrayMaxLike(1) .integerType("id", 1) .stringType("name", "Hamburger") return builder.given("kitchens here") .uponReceiving("get restaurant kitchens") .method("GET") .path("/branch/tags/kitchens") .willRespondWith() .status(200) .headers(headers()) .body(body) .toPact() } @Test @PactTestFor(pactMethod = "getRestaurantKitchens") fun getRestaurantKitchens() { val expected = listOf( KitchenDTO(1, "Hamburger") ) Mockito.`when`(sellerBranchApiClient.getKitchens()).thenReturn(expected) val kitchens = sellerBranchApiService.getKitchens() Assertions.assertEquals(expected, kitchens) } private fun headers(): Map<String, String> { val headers: MutableMap<String, String> = HashMap() headers["Content-Type"] = "application/json; charset=utf-8" return headers } }``` but when i run tests in the class i got error that ```au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: method: GET path: /branch/tags/kitchens query: {} headers: {} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING method: GET path: /branch/tags/kitchens query: {} headers: {} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING method: GET path: /branch/tags/kitchens query: {} headers: {} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING``` what is wrong, can you help me? i googled and saw some solutions but they did not help me for my case. *(my client is FeignClient)*

matt.fellows
2021-10-30 00:18
You need to send the request to the pact mock service

matt.fellows
2021-10-30 00:18
I assume you're sending to the real thing?


ahmetbcakici
2021-10-30 00:21
yes i was sending to real thing with mocking it :disappointed: i was just trying to implement same way here https://github.com/pact-foundation/pact-workshop-jvm-spring but i am not using restTemplate, my client is FeignClient and i was not sure how to implement mockServer without restTemplate. but i am trying again. tysm

ahmetbcakici
2021-10-30 00:31
there is no any example with feignClient, right?

matt.fellows
2021-10-30 00:32
I'm not sure, there probably is somewhere

matt.fellows
2021-10-30 00:32
I would find it hard to believe there's not a simple way to adjust the base URL it's sending requests to

matt.fellows
2021-10-30 00:33
You might need to make your Class configurable

matt.fellows
2021-10-30 00:33
There's probably a way to wire in the dependency too but I don't have the know how to tell you I'm afraid

ahmetbcakici
2021-10-30 00:41
i found https://github.com/thombergs/code-examples/tree/master/pact/pact-feign-consumer actually this is not bad too but your examples are really so clean and simple. but if i want to use it with FeignClient probably i should implement / use some extra things. i am appreciate for your help, thanks again :raised_hands:

aubilla
2021-11-01 09:26
It?s on a selfhosted broker. This is the first provider that has no Consumer yet. I?ll create a Consumer and check if the issue persists after a Pact has been pushed to the Broker.

jackbwheatley
2021-11-01 16:19
Hi :wave: what is the operation time out for pact verification, if anyone knows off the top of their head? `ProviderVerifier#runVerificationForConsumer`

jackbwheatley
2021-11-01 16:27
I guess it?s whatever the default timeout of `org.apache.http.impl.client.CloseableHttpClient` is. Will continue searching on my own

ahmed_syed
2021-11-01 20:46
has joined #pact-jvm

vuttithatkrongyot
2021-11-01 22:10
Yes just time consuming, any solution?

matt.fellows
2021-11-01 23:30
I?ve heard and seen cases of people writing wrapper scripts for JSON payloads that auto generate the DSL. It wouldn?t be that hard to do

matt.fellows
2021-11-01 23:30
somebody did do this here somewhere, i?ll see if I can find out hwho

somayajulaas
2021-11-02 00:38
has joined #pact-jvm

somayajulaas
2021-11-02 00:42
@All any possibilities here?


matt.fellows
2021-11-02 01:41
There should be some way to configure costumer version selectors also: https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors/

john
2021-11-02 03:32
has joined #pact-jvm

somayajulaas
2021-11-02 10:20
no that I know iff

somayajulaas
2021-11-02 10:20
off

somayajulaas
2021-11-02 10:20
i've tried multiple ways

somayajulaas
2021-11-02 10:21
<consumers> tag allows you to specify the consumers that you want but the provider name pulls all contracts that matches the provider name

rochitsen
2021-11-02 10:49
has joined #pact-jvm

aubilla
2021-11-02 13:04
Hi :wave: Besides https://docs.pact.io/implementation_guides/jvm/provider/junit/#verification-reports, are there any other reporting capabilities in Pact?

finta.pl
2021-11-02 14:43
has joined #pact-jvm

alessandro.borraccino
2021-11-02 17:04
has joined #pact-jvm

matt.fellows
2021-11-02 20:36
What are you after Abel?

matti.anusha
2021-11-03 02:58
has joined #pact-jvm

lawrencemajmacdonald
2021-11-03 04:20
Hi, is there a way to get a space in a header matcher in Groovy pact-jvm? I'm using spec V2, if that's relevant. Eg. ```willRespondWith( status: 201, headers: ['Content-Type': 'application/json; charset=utf-8'] )``` outputs a contract with ```"headers": { "Content-Type": "application/json;charset=utf-8" }``` which fails with my provider (Golang), as the http router package we use (`go-chi`) by default configures the header to include the space. I haven't been able to work out how to retain the space.

uglyog
2021-11-03 04:35
This is going to be platform/library specific. The space should not be required. It might be better to look at getting Go implementation to correctly handle the header format.

matt.fellows
2021-11-03 04:38
Perhaps you should consider using a matcher on the header

matt.fellows
2021-11-03 04:38
i.e. if the space isn?t a problem, then don?t make it one by specifying it to be an exact match

uglyog
2021-11-03 04:39
The underlying implementation should handle headers correctly. We should fix that.

aubilla
2021-11-03 09:12
Something like a view of all verification results for a given Provider version. Currently I see that verification results are grouped by Pact or Integration, which makes sense. I was hoping there was a view where I could see all the integrations that a certain Provider has (and the current verification status)

matt.fellows
2021-11-03 09:47
We'll be building these types of features (reporting) in Q1 next year but there may be some overlap with other things were currently doing. Will share with the team

aubilla
2021-11-03 10:27
Thank you very much!

ozgurerisir
2021-11-03 10:30
has joined #pact-jvm

francisco.moreno
2021-11-03 14:07
Hi, When defining the contract, is there any way to make all the fields of a class behave as a "like", so that I don't have to do it one at a time?

abubics
2021-11-03 22:13
Like is based on JSON shapes, not classes :) you can put like around a whole JSON object, and it will match on type for all fields (including nested objects)

jamesmlucas
2021-11-04 22:29
Hi -- is there a way using Spring/junit to verify a pact without using an @State annotation -- ie for a contract that has no state defined? We've been trying to figure out best practices with states to avoid having a 1:1 ratio of contracts to states, which has been the natural approach for our developers, and I thought one good way to do this might be to exclude `given` from the contract entirely when it's not relevant.

matt.fellows
2021-11-04 22:31
You don?t need to have states for all tests, and you can re-use them also if it makes sense

jamesmlucas
2021-11-04 22:37
Sure, makes sense. So I guess any mocks I would need can just go into a @BeforeEach method rather than `@State` -- thanks for the clarification!

vuttithatkrongyot
2021-11-05 06:14
That's will help me a lot, thanks. I hope you will find that guy :joy:

matt.fellows
2021-11-05 06:16
might have to search, I?m positive somebody asked in #general a while back.


dean.miley1
2021-11-05 11:40
has joined #pact-jvm

martha.nolan
2021-11-05 11:50
has joined #pact-jvm

franklin.lucena89
2021-11-05 14:06
Hey guys, question, on my provider I have couple of endpoint's that are returning a *ModelAndView* object, how can I test this out on my consumer side?

eniko_kollar
2021-11-05 16:46
has joined #pact-jvm

ashwin
2021-11-05 17:58
has joined #pact-jvm

ahmetbcakici
2021-11-07 04:48
hey everybody! i am trying to write a unit test on provider side but i got an error that `Failed to load ApplicationContext` do you have any idea? i really tried a lot of things, i did checked my app, take a look to example repositories but i could not solve it./ (my provider unit test codes and my pom xml will be in thread)

ahmetbcakici
2021-11-07 04:48
```package com.trendyol.instant.honeycombapi.contract import au.com.dius.pact.provider.junit5.HttpTestTarget import au.com.dius.pact.provider.junit5.PactVerificationContext import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider import au.com.dius.pact.provider.junitsupport.Provider import au.com.dius.pact.provider.junitsupport.State import au.com.dius.pact.provider.junitsupport.loader.PactBroker import org.apache.http.HttpRequest import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.TestTemplate import org.junit.jupiter.api.extension.ExtendWith import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.web.server.LocalServerPort import org.springframework.test.context.junit.jupiter.SpringExtension @Provider("HoneycombService") @PactBroker( host = "pact.x.com", port = "80" ) @ExtendWith(SpringExtension::class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class ProductPactProviderTest { @LocalServerPort var port = 0 @BeforeEach fun setUp(context: PactVerificationContext) { context.target = HttpTestTarget("localhost", port) } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun verifyPact(context: PactVerificationContext, request: HttpRequest) { context.verifyInteraction() } @State("products exist") fun getRestaurantDeliveryAreas() { } }``` my provider unit test

ahmetbcakici
2021-11-07 04:50
i am using this dependency: ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.2.9</version> </dependency>```

ahmetbcakici
2021-11-07 07:10
i noticed that it is related with ```@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)``` annotation. it is ok when i remove it but why this command occurs problem i do not understand. because all examples with the command, it should not be occur problem. and btw even i remove it i got an another error that connection refused localhost:{what port i gave no matter} :thinking_face: :disappointed:

ahmetbcakici
2021-11-07 21:45
when i just add annotation like that: ```@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT )``` i got an error: failed to load applicationcontext, error creating bean with name (some of my random class names) but when i specify my provider test class like that: ```@SpringBootTest( classes = [ProductPactProviderTest::class], webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT )``` actually my first problem is solved but this time error: `Request Failed - Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused`

ahmetbcakici
2021-11-07 21:45
i am writing exactly same code with pact sample workshop but i am using kotlin lang. maybe the problem source may be about kotlin.

uglyog
2021-11-07 22:19
Looks like your provider is not starting properly, or is not running on the correct port. You'll need ti check your logs and Spring configuration

ahmetbcakici
2021-11-07 22:29
thanks for answer! should i set my provider test class or my main springbootaplication class in SpringBootTest annotation classes attribute? because when i set it as my main springbootapplication class (and i think i should set this not my test class for my first question) i got error that with all logs you can see snippet above. but when i set it as my provider test class everything fine but there is no connection with i specified port. because there is no running applicaiton when i set my provider rest class i think?

ahmetbcakici
2021-11-07 22:32
```@Provider("HoneycombService") @PactBroker( host = "pact.x.com", port = "80" ) @SpringBootTest( classes = [ProductPactProviderTest::class], webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, properties = ["server.port=8080", "spring.main.web-application-type=none"] ) @ExtendWith(SpringExtension::class) class ProductPactProviderTest { @BeforeEach fun setTarget(context: PactVerificationContext) { context.target = HttpTestTarget("localhost", 8080) } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun pactVerificationTestTemplate(context: PactVerificationContext) { context.verifyInteraction() } @State("products exist") fun getRestaurantDeliveryAreas() { } }``` can you see any problem with this provider unit test? i think everything is okay, my port settings are okay too. but there is connection because of i am setting this class `ProductPactProviderTest` in SpringBooTest annotation.

ahmetbcakici
2021-11-07 22:33
i think the right way should be set to main springbootapplication class but as i said i am getting error creating bean with name blabla errors when i set it :disappointed:

uglyog
2021-11-07 23:00
`IllegalStateException: Failed to load ApplicationContext` means your Spring application context failed to start up correctly. If you look at the bottom of the stack trace, you can see `Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.couchbase.client.java.Collection' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}` and the one above it: `Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'areaRepositoryImpl' defined in file [/Users/ahmet.cakici/meal/honeycomb-api/target/classes/com/trendyol/instant/honeycombapi/infrastructure/repository/AreaRepositoryImpl.class]`

uglyog
2021-11-07 23:00
This has nothing to do with Pact, it is your Spring configuration that is not correct

ahmetbcakici
2021-11-07 23:14
you are right but my spring application or my another tests are running correctly. it is just happening when i try to run pact provider unit test. i think i am using SpringBootTest annotation not correctly but i am just making exactly same thing with https://github.com/pact-foundation/pact-workshop-jvm-spring/blob/main/provider/src/test/java/au/com/dius/pactworkshop/provider/ProductPactProviderTest.java. i will continue to search on it, thank you

abubics
2021-11-07 23:15
ModelAndView is a Spring concept, not an HTTP concept . . . look at what that endpoint returns from the outside to see what you can test :slightly_smiling_face:

ahmetbcakici
2021-11-08 01:44
i also faced with the problem https://github.com/pact-foundation/pact-jvm/issues/856, is there any news about that? should i comment on the issue? `java.lang.AssertionError:` `0 - Expected a response type of 'application/json' but the actual type was 'text/plain'` `1 - Expected a header 'Content-Type' but was missing` _i am not using vertx_

matt.fellows
2021-11-08 01:45
is your service actually returning a `content-type` header?

matt.fellows
2021-11-08 01:46
(I assume it?s not, but your consumer test _is_ expecting one with the value `application/json`)

ahmetbcakici
2021-11-08 01:49
actually i send a request to my provider service and response headers like that on postman. so it is returning?

ahmetbcakici
2021-11-08 01:50
and i am setting as headers on my consumer that: ```private fun headers(): Map<String, String> { val headers: MutableMap<String, String> = HashMap() headers["content-type"] = "application/json; charset=utf-8" return headers }```

matt.fellows
2021-11-08 02:12
That looks like it is

matt.fellows
2021-11-08 02:12
So that means there's probably something wrong work your pact test setup

matt.fellows
2021-11-08 02:13
It could be hitting the wrong endpoint, or have the wrong payload etc

matt.fellows
2021-11-08 02:13
Please share your debug logs, that will show the request/response details

d.philipp
2021-11-08 03:51
has joined #pact-jvm

ramesh.dhanasekaran
2021-11-08 03:58
Hello Guys, I am looking to create a consumer pact with some dynamic Id?s in the request body. I need a way to inject dynamic id for my pact test from provider to consumer.

ramesh.dhanasekaran
2021-11-08 03:58
here is my consumer ```@Pact(consumer = CONSUMER_Q3) public RequestResponsePact executeFlowPact(PactDslWithProvider builder) { final String pathSample = getSamplePathWithFlowId(PATH_FLOW_EXECUTE); String flowJson; final InputStream is = currentThread().getContextClassLoader().getResourceAsStream("scheduler_flow.json"); try { flowJson = IOUtils.toString(is, defaultCharset()); } catch (Exception e) { throw new RuntimeException("Irrecoverable error when trying to parse: scheduler_flow.json"); } return builder .given(STATE_ORGANIZATION_CREATED) .given(STATE_FLOW_EXECUTE) .uponReceiving(DESCRIPTION_FLOW_EXECUTE) .pathFromProviderState(PATH_FLOW_EXECUTE, pathSample) .method(POST.getValue()) .headers("Content-Type", CONTENT_TYPE_JSON, "X-SESSION-ID", SAMPLE_X_SESSION_ID, "Accept", ACCEPT_JSON) .headerFromProviderState("Authorization", VALUE_TEMPLATE_AUTHORIZATION_TOKEN, getSampleAuthorizationToken()) .body(flowJson) .willRespondWith() .status(SC_ACCEPTED) .toPact(); }```

ramesh.dhanasekaran
2021-11-08 03:59
and flow json is as a json file

ahmetbcakici
2021-11-08 04:39
thanks! there was problem in my test as you said, i fixed it

matt.fellows
2021-11-08 04:55
Thanks for looping back in Brad! How have you found it working in the intervening weeks/months? Is there any code that could be shared/extracted into a lib for others?

mail_4brad
2021-11-08 08:36
Sorry no update to date due to the work blockers as per the other thread. It?s a PoC enough to get folk at work on board. Not done in anger yet. If I was to make a prediction as to the first pain point, it would be nested/collections of objects.

franklin.lucena89
2021-11-08 10:43
It actually returning an html object, should I test it like a string object?

hamzah.saleem
2021-11-08 11:22
has joined #pact-jvm

francislainy.campos
2021-11-08 11:41
Hi, is it possible to assert an array of objects where the first item is always different to the others or not really? In our case we have stateHistory as the first object and then after that it?ll be always gradeHistory.

francislainy.campos
2021-11-08 11:42
```.eachLike("submissionHistory") .object("stateHistory") .stringType("state", "CREATED") .stringType("stateTimestamp", "2021-11-05T14:41:57.338Z") .stringType("actorUserId", "106990398552461082587") .closeObject() .object("gradeHistory") .numberType("maxPoints", 100) .numberType("pointsEarned", 100) .closeObject() .closeArray()```

francislainy.campos
2021-11-08 11:43
This is what I have but it?ll fail as it seems it?ll be looking for both stateHistory and gradeHistory on every item.

srividya.ece
2021-11-08 12:17
has joined #pact-jvm

markus.joschko
2021-11-08 13:13
has joined #pact-jvm

franklin.lucena89
2021-11-08 14:08
hey guys, I'm having an issue with one of my provider endpoint, turns out that this endpoint return an string, but by default the service responses have an application/json as content type, so if I do this ``` return builder .given("my state") .uponReceiving("receiving something") .path("/endpoint") .method("POST") .body(someBody) .matchHeader("Authorization", "Bearer\\s[\\d|a-f]{8}-([\\d|a-f]{4}-){3}[\\d|a-f]{12}", "Bearer somebearer") .willRespondWith() .status(200) .body("Response") .toPact();``` the verification throw me an error about expected content type is text/plain but actual was application/json. My question is, how can I set the proper content type to consumer test to fit with the actual one?

francislainy.campos
2021-11-08 14:39
Does sth like this help you?

francislainy.campos
2021-11-08 14:40
```Map<String, String> headers = new HashMap<>(); String path = "/v1/courses/421599667780/courseWork/425810690067/studentSubmissions/Cg4I_s2xyqIMEJOArqKyDA:turnIn"; @Pact(provider = PACT_PROVIDER, consumer = PACT_CONSUMER) public RequestResponsePact createPact(PactDslWithProvider builder) { headers.put("Content-Type", "application/json"); return builder .given("A request to turn in a student submission") .uponReceiving("A request to turn in a student submission") .path(path) .method("POST") .headers(headers) .willRespondWith() .status(200) .toPact();```

francislainy.campos
2021-11-08 14:41
The content type is set within the header map, so there you may be able to set sth like `headers.put("Content-Type", "text/plain");` for your case.

belugin.v
2021-11-08 17:16
has joined #pact-jvm

uglyog
2021-11-08 22:13
You can't use eachLike, because that will check that each item matches the example. Your only options are using an exact list (if you can control the data) or use the array contains matcher which will check that each type occurs at least once in the array.

abubics
2021-11-09 00:16
ReST is the sweet spot for Pact. I don't know if you really want to write an HTML scraping test for non-API endpoints like that.

abubics
2021-11-09 00:21
`arrayContaining` from V4 would help, but I don't think there's a way to ensure it's the first item vs the rest

abubics
2021-11-09 00:21
I'd suggest refactoring that element to a separate field, which would make the array homogeneous . . . but you might not have that liberty.

abubics
2021-11-09 00:22
worst case, you can fill the contract gap with unit testing, but then it won't won't be encoded in the contract.

will.griffiths
2021-11-09 05:25
has joined #pact-jvm


navilooz
2021-11-09 08:48
has joined #pact-jvm

belugin.v
2021-11-09 10:17
Hi guys, we?re migrating our Consumer 3.6.12 -> 4.2.x and encountering an issue with validating date: ```11:52:05.248 [HTTP-Dispatcher] WARN au.com.dius.pact.core.matchers.MatcherExecutor - Failed to parse {"chronology":{"calendarType":"iso8601","id":"ISO"},"dayOfMonth":19,"dayOfWeek":"TUESDAY","dayOfYear":292,"era":"CE","leapYear":false,"month":"OCTOBER","monthValue":10,"year":2021} with 'yyyy-MM-dd' using java.time.format.DateTimeFormatter. Exception was: Text '{"chronology":{"calendarType":"iso8601","id":"ISO"},"dayOfMonth"...' could not be parsed at index 0.``` Here?s the Pact body: ```return new PactDslJsonBody() .integerType("accountId", 111) .object("filter", filter) .minArrayLike("groupBy", 1, PactDslJsonRootValue.stringMatcher("query", "query")) .datetime("toDate", "yyyy-MM-dd", Instant.now()) .asBody();``` The dates are in the LocalDate format. What am I doing wrong? I tried `date`, `datetime`, `dateExpression`, `datetimeExpression` and none of it worked. Please help The test: ```@PactTestFor(pactMethod = "testMethod") void testGetQueryReportRows(MockServer mockServer) { TestObject reportCommand = TestObject.builder() .accountId(1111L) .groupBy(Collections.singleton("query")) .filter(new TestFilter()) .toDate(LocalDate.now()) .build(); ObjectMapper objectMapper = new ObjectMapper(); String stringEntity = objectMapper.writeValueAsString(reportCommand); StringEntity entity = new StringEntity(stringEntity); HttpResponse httpResponse = http://Request.Post(mockServer.getUrl() + PROVIDER_PATH) .addHeader(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8") .body(entity) .execute() .returnResponse(); ... }```

matt.fellows
2021-11-09 10:29
It looks like the value (according to the consumer test) should be an array of simple strings, but it looks like the first entry is actually a JSON object

matt.fellows
2021-11-09 10:30
I.e. your provider is returning a JSON object, not a date string

belugin.v
2021-11-09 10:34
The weird part is that with 3.6.12 this test is working just fine with `.date("toDate", "yyyy-MM-dd")`

belugin.v
2021-11-09 10:36
And nothing has changed except Pact consumer version

matt.fellows
2021-11-09 10:54
what does the interaction in the pact file look like on the consumer side? (just share the specific interaction)

matt.fellows
2021-11-09 10:54
and if you can please share what the provider actually responds to that endpoint, that will help

belugin.v
2021-11-09 11:00
By interaction you mean this? ```return builder .given("returns query report") .uponReceiving("Request via POST method") .path(PROVIDER_PATH) .method(HttpMethod.POST.name()) .body(body) .willRespondWith() .status(HttpStatus.SC_OK) .headers(headers) .body(expectedResults()) .toPact();```

belugin.v
2021-11-09 11:02
> and if you can please share what the provider actually responds to that endpoint, that will help (edited) well, the issue is it doesn?t get to respond, b/c the mock server does not accept the request due to the date validation issue

matt.fellows
2021-11-09 11:15
No, I mean the generated pact file please

matt.fellows
2021-11-09 11:16
oh, right - this is on the consumer side!

belugin.v
2021-11-09 11:18
Ah, it doesn?t get to generate one

matt.fellows
2021-11-09 11:18
this is out of my pay grade :wink:

matt.fellows
2021-11-09 11:18
yeah, exactly.

matt.fellows
2021-11-09 11:18
it _seems_ like `Instant.now()` is not a string, but an object (but I?d expect the typed interface to complain about that)

matt.fellows
2021-11-09 11:18
if you replace it with ?2021-01-01? or something, does it work?

belugin.v
2021-11-09 11:23
in datetime it accepts only Date or Instant as an example

belugin.v
2021-11-09 11:24
well, date as well



matt.fellows
2021-11-09 11:44
In any case, feel free to fork that repo to make a repro, and raise a bug - that?ll help get it fixed if there is one :thumbsup:

belugin.v
2021-11-09 11:57
Model has the date as LocalDate. I will do the fork thing and see what happens )

keith.hirst
2021-11-09 12:13
has joined #pact-jvm

belugin.v
2021-11-09 12:38
``` > PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed``` @matt.fellows is it something on my end?

matt.fellows
2021-11-09 12:57
ahhhh

matt.fellows
2021-11-09 12:57
probably?

matt.fellows
2021-11-09 12:59
where is it failing though? It?s not communicating to a broker or anything, do you have an artifactory or package proxy?

belugin.v
2021-11-09 13:01
This is on ./gradlew clean build

belugin.v
2021-11-09 13:02
it can?t pull dependencies

belugin.v
2021-11-09 13:03
```A problem occurred configuring root project 'spring-boot'. > Could not resolve all artifacts for configuration ':classpath'. > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.2.2.RELEASE. Required by: project : > org.springframework.boot:org.springframework.boot.gradle.plugin:2.2.2.RELEASE > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.2.2.RELEASE. > Could not parse POM https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-gradle-plugin/2.2.2.RELEASE/spring-boot-gradle-plugin-2.2.2.RELEASE.pom > Could not resolve org.springframework.boot:spring-boot-tools:2.2.2.RELEASE. > Could not resolve org.springframework.boot:spring-boot-tools:2.2.2.RELEASE. > Could not get resource 'https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-tools/2.2.2.RELEASE/spring-boot-tools-2.2.2.RELEASE.pom'. > Could not GET 'https://jcenter.bintray.com/org/springframework/boot/spring-boot-tools/2.2.2.RELEASE/spring-boot-tools-2.2.2.RELEASE.pom'. > PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed > Could not resolve au.com.dius.pact:provider:4.2.0. Required by:``` etc

belugin.v
2021-11-09 14:09
I think I fixed the issue by adjusting the ObjectMapper, thanks for your help @matt.fellows

rbo
2021-11-09 17:47
has joined #pact-jvm

aubilla
2021-11-09 18:20
:wave: Hi, I?m using the Gradle plugin for Provider verification but I can?t use snake casing to specify a provider name. It only takes camel cased and pascal cased for that block, otherwise fails. I?ve seen other people using the @Provider annotation with the JUnit 5 extension which does support it. My current block looks like this: ```pact { broker { pactBrokerUrl = 'https://myURL.com' pactBrokerUsername = 'username' pactBrokerPassword = 'password' } serviceProviders { PactWorkshopJvm { protocol = 'https' ...more stuff``` but it should be like this: ```pact { broker { pactBrokerUrl = 'https://myURL.com' pactBrokerUsername = 'username' pactBrokerPassword = 'password' } serviceProviders { pact-workshop-jvm { protocol = 'https' ...more stuff``` The error I get is the following: ```* What went wrong: A problem occurred evaluating root project 'pact-workshop-jvm'. > No signature of method: build_e7o4l33ujihjvdvg6lluiqb88.pact() is applicable for argument types: (build_e7o4l33ujihjvdvg6lluiqb88$_run_closure15) values: [build_e7o4l33ujihjvdvg6lluiqb88$_run_closure15@ee929e4] Possible solutions: wait(), wait(long), each(groovy.lang.Closure), any(), wait(long, int), print(java.lang.Object)```

uglyog
2021-11-09 22:04
Try putting qootes around the `pact-workshop-jvm`

francislainy.campos
2021-11-09 23:38
Hi, how do I handle a url that finishes with *`:`* such as this ?/v1/courses/421599667780/courseWork/425810690067/studentSubmissions/Cg4I_s2xyqIMEJOArqKyDA:turnIn?

francislainy.campos
2021-11-09 23:38
```package com.hmhco.viaductservice.pact.consumer; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; import au.com.dius.pact.core.model.RequestResponsePact; import au.com.dius.pact.core.model.annotations.Pact; import io.restassured.RestAssured; import io.restassured.response.Response; import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import java.util.HashMap; import java.util.Map; import static com.hmhco.viaductservice.config.Constants.PACT_CONSUMER; import static com.hmhco.viaductservice.config.Constants.PACT_PROVIDER; /** * As per https://developers.google.com/classroom/reference/rest * <p> * mvn -Dtest=com.hmhco.viaductservice.pact.consumer.*Test test */ @ExtendWith(PactConsumerTestExt.class) public class PactConsumerGcTurnInStudentSubmissionTest { Map<String, String> headers = new HashMap<>(); String path = "/v1/courses/421599667780/courseWork/425810690067/studentSubmissions/Cg4I_s2xyqIMEJOArqKyDA:turnIn"; @Pact(provider = PACT_PROVIDER, consumer = PACT_CONSUMER) public RequestResponsePact createPact(PactDslWithProvider builder) { headers.put("Content-Type", "application/json"); return builder .given("A request to turn in a student submission") .uponReceiving("A request to turn in a student submission") .path(path) .method("POST") .headers(headers) .willRespondWith() .status(200) .toPact(); } @Test @PactTestFor(providerName = PACT_PROVIDER, port = "8080") public void runTest() { //Mock url RestAssured.baseURI = "http://localhost:8080"; RequestSpecification rq = RestAssured .given() .headers(headers) .when(); Response response = rq .post(path); assert (response.getStatusCode() == 200); } }```

francislainy.campos
2021-11-09 23:39
Thank you.

uglyog
2021-11-09 23:46
Is the colon causing an issue?

harshaan.n.khan
2021-11-10 05:38
has joined #pact-jvm

francislainy.campos
2021-11-10 05:56
yeah, it won?t run with it

francislainy.campos
2021-11-10 05:57
If I remove it the contract is generated fine

uglyog
2021-11-10 05:58
What is the error?

francislainy.campos
2021-11-10 06:27
Assertion error

francislainy.campos
2021-11-10 06:30
Normally when we have `?` we use some of the query matchers and that solves for it, but with the `:` I can?t find one that would do.

francislainy.campos
2021-11-10 06:34
The full log

uglyog
2021-11-10 06:46
That's the stack trace, not the log. You'll need to look at the debug logs

francislainy.campos
2021-11-10 08:35
Not sure I know where logs would live.. Trying to find out.

francislainy.campos
2021-11-10 08:41
When I print the response I get this:

francislainy.campos
2021-11-10 08:42
```error -> Unexpected request : method: POST path: /v1/courses/421599667780/courseWork/425810690067/studentSubmissions/Cg4I_s2xyqIMEJOArqKyDA%3AturnIn query: {} headers: {Accept-encoding=[gzip,deflate], Accept=[*/*], Connection=[Keep-Alive], Host=[localhost:8080], User-agent=[Apache-HttpClient/4.5.13 (Java/11.0.7)], Content-type=[application/json], Content-length=[0]} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: EMPTY```

aubilla
2021-11-10 08:42
Thanks a million :thumbsup:

francislainy.campos
2021-11-10 08:51
It?s fixed now

francislainy.campos
2021-11-10 08:51
```//Mock url RestAssured.baseURI = "http://localhost:8080"; RequestSpecification rq = RestAssured .given() .urlEncodingEnabled(false) .headers(headers) .when();```

francislainy.campos
2021-11-10 08:52
Had to disable url encoding.

francislainy.campos
2021-11-10 08:52
Thank you for your time looking into this with me.

esparga
2021-11-10 14:32
has joined #pact-jvm

thales.areis
2021-11-10 19:33
has joined #pact-jvm

thales.areis
2021-11-10 19:37
Hello! I'm trying to write a pact to a PATCH endpoint and Im getting this error: ```Caused by: com.bees.suppliers.vendormanagementapptier.exceptions.RemoteServiceErrorException: org.springframework.web.client.ResourceAccessException: I/O error on PATCH request for "http://localhost:34067/74e39bd3-c438-494c-80a4-0c6f5eeda17d": Invalid HTTP method: PATCH; nested exception is java.net.ProtocolException: Invalid HTTP method: PATCH at com.bees.suppliers.vendormanagementapptier.exceptions.RemoteServiceErrorException.errorCallingExternalService(RemoteServiceErrorException.java:38) at com.bees.suppliers.vendormanagementapptier.clients.RestClient.patch(RestClient.java:82) at com.bees.suppliers.vendormanagementapptier.clients.VendorServiceClient.patchVendors(VendorServiceClient.java:85) ... 43 more Caused by: org.springframework.web.client.ResourceAccessException: I/O error on PATCH request for "http://localhost:34067/74e39bd3-c438-494c-80a4-0c6f5eeda17d": Invalid HTTP method: PATCH; nested exception is java.net.ProtocolException: Invalid HTTP method: PATCH at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:711) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:602) at com.bees.suppliers.vendormanagementapptier.clients.RestClient.exchange(RestClient.java:49) at com.bees.suppliers.vendormanagementapptier.clients.RestClient.patch(RestClient.java:80) ... 44 more Caused by: java.net.ProtocolException: Invalid HTTP method: PATCH at java.base/java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:487) at java.base/sun.net.www.protocol.http.HttpURLConnection.setRequestMethod(HttpURLConnection.java:570) at org.springframework.http.client.SimpleClientHttpRequestFactory.prepareConnection(SimpleClientHttpRequestFactory.java:217) at org.springframework.http.client.SimpleClientHttpRequestFactory.createRequest(SimpleClientHttpRequestFactory.java:146) at org.springframework.http.client.support.HttpAccessor.createRequest(HttpAccessor.java:124) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:772) ... 48 more```

thales.areis
2021-11-10 19:38
Does someone had some issue like that?

uglyog
2021-11-10 22:02
Ah! Of course! It would encode the colon.

uglyog
2021-11-10 23:09
Looks like Spring RestTemplate does not support PATCH

thales.areis
2021-11-11 00:56
Thanks for your answer... it makes me think about a configuration that we have outside the "test scope". I really appreciate your attention.

henk.koopman
2021-11-11 08:56
has joined #pact-jvm

lena.lindblad
2021-11-11 09:58
has joined #pact-jvm

radekkoubsky
2021-11-11 16:24
has joined #pact-jvm

aditya
2021-11-11 17:20
has joined #pact-jvm

aditya
2021-11-11 17:39
Howdy. I'm trying to write a provider test in kotlin using spring + junit5 + maven and for some reason can't get the pact test to actually run. I thought the pact tests should fail if a pact file is not found in the broker or the broker can't be communicated with. However, I'm not seeing any errors. Was curious if anyone knows of a good way to debug this. I've tried to enable debug logging for the pact package with no luck. My test is set up as follows: ```@ExtendWith(SpringExtension::class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [KaleidoscopeApplication::class]) @Provider("kaleidoscope") @PactBroker( host = "localhost", port = "9292", consumerVersionSelectors = [VersionSelector(tag = "local")] ) class PactSearchResultExportTest { /* setup stuff */ @BeforeEach fun setUp(context: PactVerificationContext) { context.target = HttpTestTarget("localhost", port) doReturn(getMockLighthouseCall(1L)).`when`(searchClient).countBusinesses(kotlinIsA(SearchBusinessRequest::class.java)) } @TestTemplate @ExtendWith(PactVerificationSpringProvider::class) fun verifyPact(context: PactVerificationContext) { context.verifyInteraction() } }```

claire
2021-11-11 17:55
has joined #pact-jvm

aditya
2021-11-11 21:04
Some additional information: ? The consumer test is able to write the pact to our broker running in our cloud environment ? The above test actually works perfectly when running locally and talking to our broker running in the cloud. ? The test gets skipped when jenkins attempts to run the test using maven. Jenkins is talking to the exact same broker in the cloud. ? If I put a bogus hostname and run locally using maven I see the same behavior I see on jenkins (test getting skipped) ? If I put a bogus hostname and run using an IDE like intellij I see the exception get logged thats preventing the test from running. ? We are using the latest stable version of the pact library - junit5spring (4.2.14) ? I've tried switching to use the url instead of host/port but that didn't make a difference. So if there were a way to tell the pact test to log the potential exception when running using maven I would be able to better debug the issue.

uglyog
2021-11-11 22:01
When the Pact framework can't connect to the broker, it fails the test setup with an assertion error. There is not much more we can do there. How the test setup failure is being reported via Maven seems to be the problem. Can you try using Gradle to see if you have the same issue?

aditya
2021-11-11 22:03
I literally just found the problem. So it looks like there is a bug with the version of the surefire plugin we were using that was masking the exception from pact. Upgrading from 3.0.0-M4 to 3.0.0-M5 of the surefire plugin fixed the problem and I now understand the issue on jenkins.

aditya
2021-11-11 22:03
Thank you for the response!

gentritmm
2021-11-12 08:35
has joined #pact-jvm

francislainy.campos
2021-11-12 08:57
Yeah, exactly

wilson.espina
2021-11-12 09:52
has joined #pact-jvm

francislainy.campos
2021-11-12 12:04
Hi, I?m a bit at loss with this failure here: ```No Pact files were found to verify Provider: GC Consumer: VIADUCT Source: Pact Broker http://null consumerVersionSelectors=[ConsumerVersionSelector(tag=master, latest=true, consumer=null, fallbackTag=null)]``` It happens when running my tests from jenkins and it says my pact broker is null but I have it set ```@PactBroker(url = BROKER_PACT_URL, authentication = @PactBrokerAuth(token = "${pactbroker.auth.token}")) ``` And our tests run okay when triggered from maven locally. I?m using ```<pact.version>4.2.13</pact.version>``` Our url is of the type: ```public static final String BROKER_PACT_URL = "https://my.pact.dius.com.au";``` Thank you.

francislainy.campos
2021-11-12 12:48
This is what we have on our jenkins file that triggers these tests: ```try { stage(name: 'Pact Verify Tests') { def version = version().minus("-SNAPSHOT") withCredentials([string(credentialsId: 'our_credentials', variable: 'pactFlowToken')]) { sh """ $mvnHome/bin/mvn -Dpactbroker.auth.token=$pactFlowToken -Dpactbroker.tags=${tag} -DtestEnvt=${testEnvt} -Dtest=com.hmhco.viaductservice.pact.provider.*Test \ -Dpact.verifier.publishResults=true -Dpact.provider.version=$version test """ } } }```

francislainy.campos
2021-11-12 13:02
Even calling the api directly within the broker annotation will still give me the pact broker null failure ```@PactBroker(url = "https://my.pact.dius.com.au/", authentication = @PactBrokerAuth(token = "${pactbroker.auth.token}"))```

mike.geeves064
2021-11-12 13:21
What tutorial/docs etc are you following? Have you tried with host= rather than url= ? As per https://github.com/pact-foundation/pact-workshop-jvm-spring/blob/step11/provider/src/test/java/au/com/dius/pactworkshop/provider/ProductPactProviderTest.java (not overly familiar with pact-jvm personally)

francislainy.campos
2021-11-12 13:22
Host prints the url but still won?t find the contract files.

francislainy.campos
2021-11-12 13:22
And it?s deprecated so I?m assuming url is the one to be used going forward.

francislainy.campos
2021-11-12 13:37
Tried using this now ```@PactBroker(url = "https://my.pact.dius.com.au/", authentication = @PactBrokerAuth(token = "${pactbroker.auth.token}"), consumerVersionSelectors = @VersionSelector(consumer = PACT_CONSUMER))``` But still, the same error as before. null url and null consumer.

francislainy.campos
2021-11-12 14:03
Updating to `<pact.version>4.2.14</pact.version>` displays the url but the tests are still not found

francislainy.campos
2021-11-12 15:25
Maybe there?s some time to allow for something to be discoverable? If I change the consumer/provider combination to one that already exists on the same broker that contract is found. However, if I create a brand new combination between some of the existing provider and consumer and publish the contract that way it won?t then be found. @matt.fellows @uglyog any idea maybe?

megan.twyver
2021-11-12 18:39
has joined #pact-jvm

francislainy.campos
2021-11-12 21:13
Yeah, I just run the tests from a jenkins instance for another project, which has its tests always passing, but now with these other consumer and provider names and then I got again the ?no tests found to verify.? There?s really something going on here, maybe with the pact flow instance or something..

francislainy.campos
2021-11-12 21:17
As we can see the contract does exist.

mike.geeves064
2021-11-12 21:20
:open_mouth: I wouldn't have thought the pact flow side could have an impact on finding them, but maybe if something changed in a newer version now being pulled in? Weekend in .au now so might be a while before someone else spots

francislainy.campos
2021-11-12 21:21
I don?t know.. Weird, yes, but maybe? And yes, no worries. Used to talk to the guys here asynchronously. So whenever they can reply it?s okay. :slightly_smiling_face:

francislainy.campos
2021-11-12 21:26
Tried now using our older free broker before pactflow but got the same error still.

uglyog
2021-11-13 01:47
Looks like it is trying to fetch a pact with `tags=master` but that Pact has no tags

uglyog
2021-11-13 01:49
I assume your jenkins CI build is adding that requirement

francislainy.campos
2021-11-13 06:29
And that was it!!

francislainy.campos
2021-11-13 06:29
Thank you so much! Spent the whole day on this yesterday but am glad it?s now fixed.

francislainy.campos
2021-11-13 06:29
Thanks very much!!

mischa.molhoek
2021-11-14 09:42
has joined #pact-jvm

69vron
2021-11-15 01:35
has joined #pact-jvm

james.sawle
2021-11-15 08:49
has joined #pact-jvm

pete.watts
2021-11-15 12:46
has joined #pact-jvm

joshua.badger
2021-11-15 17:10
has joined #pact-jvm

omarsaddaoui
2021-11-17 02:55
has joined #pact-jvm

mbyrne
2021-11-17 14:23
has joined #pact-jvm

johnny.nilsson83
2021-11-17 14:57
Hi, I might have searched the full content of Google after a tutorial or example of how to use the 4.3.x update of ```<groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>4.3.1</version>``` Is it yet to be written or have I just missed it?

uglyog
2021-11-17 22:03
Hmm, maybe I forgot to press the release button on Sonatype....

uglyog
2021-11-17 22:05
Oh, you're asking about a tutorial. What are you looking to do?

matthew.drill
2021-11-18 01:08
has joined #pact-jvm

james.halsall
2021-11-18 12:02
has joined #pact-jvm

chvram
2021-11-19 14:09
has joined #pact-jvm

chvram
2021-11-19 14:11
hello

chvram
2021-11-19 14:12
contract-testing using Java for https services,is there any option of setting insecure flag to true in 2.1.2 Pact-JVM version?

akhandalmani.malik
2021-11-19 14:17
has joined #pact-jvm

akhandalmani.malik
2021-11-19 14:17
Hi Team

johnny.nilsson83
2021-11-19 14:19
Getting started :slightly_smiling_face: I am building microservices with rest endpoints replying with json and I want to write pact-tests to make sure I dont break any clients when making changes in my producer. I have found a few guides for the V3 implementation, but none for the V4.

akhandalmani.malik
2021-11-19 14:30
Actually we are trying to hit the *actual provider* with mockclient contract json file. It was working till security was not introduced in the the *Actual provider* I am getting the below error PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target... in the below line public final Target target = new HttpTarget("https","myHostName",443); Any suggestions/input will be very much appreciated Version: pact-jvm-provider-junit_2.12 Please let me know for any more information to resolve this issue. Thank you, Malik

elias.frykholm
2021-11-19 15:17
has joined #pact-jvm

martin.carlin
2021-11-19 15:52
has joined #pact-jvm

paul.nardone
2021-11-19 16:12
has joined #pact-jvm

emily
2021-11-19 18:56
has joined #pact-jvm

matt.fellows
2021-11-19 21:55
Looks like you have a self signed certificate?

2021-11-19 21:55
Please see these instructions on running and accessing a Pact Broker over TLS https://docs.pact.io/pact_broker/advanced_topics/using-tls/

matt.fellows
2021-11-19 21:55
You'll need to add any certificates to yourv Java trust store

rholshausen
2021-11-19 23:53
has joined #pact-jvm

uglyog
2021-11-19 23:59
Oh, yeah, no documentation was been written for V4 yet. It's on the long list of things that need to be done.

uglyog
2021-11-20 00:01
That is a *very* old version. I don't think so.

matt.fellows
2021-11-20 01:19
Do you need to use the v4 implementation though? I?d just stick with v3 until v4 has been stabilised etc.

matt.fellows
2021-11-20 01:27
I?m assuming if you must use the v4 interface, there is no reason why the v3 tutorials/workshops won?t be useful, it?s just that a few bits of the API might be different

chvram
2021-11-20 11:29
Yes,we have added test.pem file to jdk/jre/security/cacerts

chvram
2021-11-20 11:30
Still we are getting the same error

chvram
2021-11-20 11:30
We are using pact jvm but not pact broker

akhandalmani.malik
2021-11-20 13:13
Thank you matt for the quick help. @matt.fellows Please find the details of How we are installing the certificate in the below: 1. I logged-in into the https Provider api using user credential in mozila firefox. 2. And from the same logged-in home page I downloaded the *test.pem* file. 3. Just copied test.pem file to <JAVA_HOME>/jer/lib/security 4. Executed the below command in the command prompt(admin mode) 5. "c:\Program Files\Java\jdk1.8.0_251\bin\keytool" -importcert -alias <ipAddressOfProviderApi> -keyStore cacerts -file "c:\Program Files\Java\jdk1.8.0_251\bin\public.crt" 6. got message with "Certificate was added to keystore" 7. But still we are getting different error *Request Failed - Certificate for <ipAddressOfProviderApi> doesn't match any of the subject alternative names: []*

pietrucha.bartosz
2021-11-20 13:47
has joined #pact-jvm

chvram
2021-11-20 17:52
Hi, Can you let me which version supports and sample implementation. Appreciate your quick response

uglyog
2021-11-21 01:05
What do you use to run the pact tests? Maven, Gradle. JUnit?

chvram
2021-11-21 05:14
Junit

chvram
2021-11-21 06:59
Actually we are trying to hit the *actual provider* with mockclient contract json file. It was working till security was not introduced in the the *Actual provider* I am getting the below error PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target... in the below line public final Target target = new HttpTarget("https","myHostName",443); Any suggestions/input will be very much appreciated Version: pact-jvm-provider-junit_2.12 Please let me know for any more information to resolve this issue. Thank you, Malik

chvram
2021-11-21 06:59
Appreciate your quick help

chvram
2021-11-21 07:00
Thank you matt for the quick help. @matt.fellows Please find the details of How we are installing the certificate in the below: 1. I logged-in into the https Provider api using user credential in mozila firefox. 2. And from the same logged-in home page I downloaded the *test.pem* file. 3. Just copied test.pem file to <JAVA_HOME>/jer/lib/security 4. Executed the below command in the command prompt(admin mode) 5. "c:\Program Files\Java\jdk1.8.0_251\bin\keytool" -importcert -alias <ipAddressOfProviderApi> -keyStore cacerts -file "c:\Program Files\Java\jdk1.8.0_251\bin\public.crt" 6. got message with "Certificate was added to keystore" 7. But still we are getting different error *Request Failed - Certificate for <ipAddressOfProviderApi> doesn't match any of the subject alternative names: []*

mastrobardo
2021-11-21 11:42
has joined #pact-jvm

fed
2021-11-22 04:20
has joined #pact-jvm

akhandalmani.malik
2021-11-22 05:25
Any update/suggestion?

matt.fellows
2021-11-22 06:18
are you putting the IP address in the provider verification? If so, you need to ensure the IP address is also a valid SAN on the certificate, otherwise it will fail validation

matt.fellows
2021-11-22 06:18
alternatively, use a hostname that?s specified in the SAN

akhandalmani.malik
2021-11-22 06:52
Thank you Matt for the quick response. Yes, we are putting IP address in the provider verfication. Like below public final Target target = new HttpTarget("https","138.3.96.89",443,true);//insecure=true How to ensure the IP address is a valid SAN? Any suggestion

matt.fellows
2021-11-22 07:09
That's a problem with your certificate

matt.fellows
2021-11-22 07:09
Whoever runs that server should create a certificate that includes the IP address

matt.fellows
2021-11-22 07:10
Alternatively, can you use a hostname for it that is included as a SAN on the cert?

tumunshaily
2021-11-22 07:54
has joined #pact-jvm

yunfeng.wang
2021-11-22 09:25
has joined #pact-jvm

yunfeng.wang
2021-11-22 09:27
Hi, Have pact maven plugin supported record-deployment/release now? https://docs.pact.io/pact_broker/recording_deployments_and_releases/

yunfeng.wang
2021-11-22 09:29
If not, what's the plan to support it?


yunfeng.wang
2021-11-22 09:53
could be. while my project based on maven, its easier to use maven plugin instead.

yunfeng.wang
2021-11-22 09:54
if use cli, means need to prepare all related parameters separately.

matt.fellows
2021-11-22 11:14
You could always shell out from Maven, right?

matt.fellows
2021-11-22 11:15
(to answer your question though, i?m not sure if it?s on the roadmap, you might need to check the issues to see if it?s been requested)

chvram
2021-11-22 11:39
hi Uglyog ,any suggestion from your side?


christos.litsas
2021-11-23 13:05
has joined #pact-jvm

chvram
2021-11-23 13:32
hi, we have upgraded Pact-JVM to 4.0.10 from 2.1.x still the Insecure Flag is not working for SSL certificate by pass /issue

chvram
2021-11-23 13:32
can any one show some light on this?

chvram
2021-11-23 13:32
appreciate your quick inputs on this

chvram
2021-11-23 13:42
we are using Junit

martin.carlin
2021-11-23 15:14
Hi, has anyone encounter these error messages? `Error: Could not read scala-pact pact from json` `Could not convert good response to Pact:` We haven?t updated any pact tests recently but started getting those messages in our CI build, any clues?

walter.psjr
2021-11-23 17:39
has joined #pact-jvm

chvram
2021-11-23 19:09
any clue on Insecurity Flag for Junit ,Pact-JVM..we have tried with 4.0.10..but didn't work

matt.fellows
2021-11-23 20:35
Did you upgrade the broker? I think I saw this recently and a fix went out into the scala lib

uglyog
2021-11-23 21:02
Can you let us know what you did, what you were expecting to happen, and what did happen. Also looking at debug logs may help

steveforwork2
2021-11-24 08:47
has joined #pact-jvm

akhandalmani.malik
2021-11-24 09:44
Thanks for the support @uglyog Actually We are trying to validate our pact contract json file with actual provider. It was working till https was not implemented from the actual provider. Once https implemented we are not able to validate our pact json file with actual provider. Getting following exception: *pkix path building failed sun.security.provider.certpath.suncertpathbuilderexception* For this error we installed certificate in our local java. Post installing the certificate we are getting below exception:*Certificate for <111.2.22.12> doesn't match any of the subject alternative names: []* it is throwing error in the following code snippet @TestTarget public final Target target = new HttpTarget("https","111.2.22.12",443); if the above details is not sufficient to trace the issue please let me know for more information and details.

akhandalmani.malik
2021-11-24 11:28
Please find the implementation how we are using pact-jvm

akhandalmani.malik
2021-11-24 11:30
PactUtil.java public class PactUtil { //providerName=dynamic value,url=https://111.1.11.11:443(Earlier it was only http and it was working, post actual provider implemented https we are not able to validate our pact json file with actuall provider) public String validatePactContractFile(String providerName, String url) { http://logger.info("Checking Pact contract json file against "+providerName+"PASSED URL>>>"+url); JUnitCore junit = new JUnitCore(); junit.addListener(new TextListener(System.out)); Result status = null; try { // The below code is to set the @Provider("dummy") at runtime value final http://au.com.dius.pact.provider.junit.Provider oldAnnotation = (http://au.com.dius.pact.provider.junit.Provider) PactProviderTest.class .getAnnotations()[1]; Annotation newAnnotation = new http://au.com.dius.pact.provider.junit.Provider() { @Override public String value() { // TODO Auto-generated method stub return providerName; } @Override public Class<? extends Annotation> annotationType() { return oldAnnotation.annotationType(); } }; Class<?> pkgInfo = Class.forName("com.poc.verifyer.PactProviderTest", true, PactUtil.class.getClassLoader()); Field annotationDataField = Class.class.getDeclaredField("annotationData"); annotationDataField.setAccessible(true); Object annotationData = annotationDataField.get(pkgInfo); Field annotationsField = annotationData.getClass().getDeclaredField("annotations"); annotationsField.setAccessible(true); Map<Class<? extends Annotation>, Annotation> annotations = (Map<Class<? extends Annotation>, Annotation>) annotationsField .get(annotationData); annotations.put(http://au.com.dius.pact.provider.junit.Provider.class, newAnnotation); // End of set the @Provider("dummy") at runtime value PactProviderTest.url = new URL(url); } catch (MalformedURLException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch(Exception e) { e.printStackTrace(); } try { status = junit.run(PactProviderTest.class); if (status.wasSuccessful()) return "PASS"; else { logger.error(status.getFailures().toString()); String f=status.getFailures().get(0).getMessage(); List<Failure> list=status.getFailures(); return "FAIL"; } } catch (Exception e) { e.printStackTrace(); return "FAIL"; } } @Retention(RetentionPolicy.RUNTIME) @interface Provider { String value(); } }

akhandalmani.malik
2021-11-24 11:31
package com.poc.verifyer; @RunWith(PactRunner.class) @Provider("dynamic_provider") @PactFolder("../pacts") public class PactProviderTest { public static URL url;//dynamic url @State("test GET") public void toGetTest() throws Exception { System.out.println("test GET"); } @TestTarget public final Target target = new HttpTarget(url); }

fredrik.ostling
2021-11-24 11:56
has joined #pact-jvm

fredrik.ostling
2021-11-24 12:05
Is there any documentation on how date expressions work? This is basically the only thing I find: https://pactflow.io/blog/dealing-with-relative-dates-in-contract-tests/ What else is possible to write as expression apart from ?today?? How would you write ?4 hours from now? for instance? And when I try it, for example with `.dateExpression("someDate", "today")`, it generates `"someDate": "2000-01-31"` in the pact. That seems weird.

martin.carlin
2021-11-24 14:11
Thanks for the hint Matt. @kyle.florence I?m not aware of any updates, should we upgrade the scala lib? Cc@gdfesta

jorge.nunez
2021-11-24 14:28
has joined #pact-jvm

nathan.deamer
2021-11-24 14:49
Hi all, I think I have a date encoding problem - looking for some pointers....... I have a provider rest API which takes a LocalDateTime object as a path variable: ```@PutMapping("/api/v1/{dateTime}") @ResponseStatus(HttpStatus.NO_CONTENT) public void setDateTime(@PathVariable @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime dateTime, @Valid @RequestBody SomeRequest someRequest)``` And I have written my consumer pact: ``` return builder .given("GIVEN") .uponReceiving("A request") .path("/api/v1/2021-12-25T00%3A00%3A00") .method("PUT") .willRespondWith() ...``` Which has registered in the broker like this: ```/api/v1/2021-12-25T00%3A00%3A00``` But when I run the provider tests, I am getting a 404. My theory is that the datetime 2021-12-25T00%3A00%3A00 isn't being decoded properly.

akhandalmani.malik
2021-11-24 15:11
Any suggestion?

kyle.florence
2021-11-24 15:54
Go for it

kyle.florence
2021-11-24 15:55
PS probably a question better suited for #pact-scala-itv

nathan.deamer
2021-11-24 17:05
User error.... I didn't have a body in my PUT :joy:. And think I used the pathProviderState incorrectly too (not in the above example)

asradhakrishnan
2021-11-24 17:20
has joined #pact-jvm

akhandalmani.malik
2021-11-25 04:33
@matt.fellows Please go through the entire implementation... we are using... and kindly help us on how to hit a actual provider with https authentication.

uglyog
2021-11-25 04:43
You need to use `HttpsTarget`, not `HttpTarget`

akhandalmani.malik
2021-11-25 05:29
Wow. Great Uglyog. Thanks Let me try this out.:+1:

edouard.lopez
2021-11-25 11:01
has joined #pact-jvm

edouard.lopez
2021-11-25 11:04
Hello, I'm publishing my provider result with the following command in CI: ``` ./gradlew pactverify \ -Ppact.verifier.publishResults=true \ -Dpact.provider.version=$(git rev-parse --short HEAD) \ -Dpact.provider.tag=$(git rev-parse --abbrev-ref HEAD)``` But still got an `unspecified` value in the matrix, what am I missing?

mark.dathorne
2021-11-25 12:29
Hi. I may be getting my wires crossed but I have a pact where I'm expecting the request (JSON) values to come back in the response but the pact is returning each field's pact example value (or, if excluded, a generated value).

edouard.lopez
2021-11-25 14:41
I got the following pacticipant URL, I don't get why the `unspecified` http://.../hal-browser/browser.html#/pacticipants/ms.brand/versions/unspecified

maxkitzing
2021-11-25 17:49
has joined #pact-jvm

uglyog
2021-11-25 22:08
Not sure why that is not working, but try with -P instead of -D

cristian.carrillo
2021-11-26 00:06
has joined #pact-jvm

edouard.lopez
2021-11-26 09:07
if I set a `project.version` in my gradle's task I get the value int the broker. However I'm not sure of the lifecycle of this value and if setting it in this task is the best solution

christoph.oswald
2021-11-26 09:53
has joined #pact-jvm

gjourdanweil
2021-11-26 14:39
has joined #pact-jvm

sean.pike
2021-11-26 14:48
has joined #pact-jvm

uglyog
2021-11-27 00:21
What you can do is us -P, which defines a Gradle property in the build, then refer to that property in the task

uglyog
2021-11-27 00:22
I.e., ```serviceProviders { "ms.brand" { // <- name provider you want to verify protocol = 'https' host = 'http://ms-brand-web.ingress.eu-west-3.int.manomano.com' port = 443 path = '/' insecure = true // allow SSL with a self-signed cert projectVersion = project.projectVersion fromPactBroker { selectors = latestTags() } } }``` and then -PprojectVersion=1.2.3.4

michael.bannister
2021-11-29 07:43
has joined #pact-jvm

mark.dathorne
2021-11-29 10:37
Wires uncrossed now. Thanks.

srividya.ece
2021-11-29 11:28
Hi..Based on question https://stackoverflow.com/questions/70120718 . Could someone provide an example how to read in JSON documents in Java and convert to the matching DSL. ? *Stack Overflow* *https://stackoverflow.com/questions/70120718* We have a requirement that we need have a pact standalone server and interactions (request/ expected response pairs) in a JSON files and store it in a directory and just add to consumer tests and

rjadams96
2021-11-29 18:47
has joined #pact-jvm

pavithz
2021-11-29 23:51
has joined #pact-jvm

mfellows_20211130
2021-11-30 06:57
has joined #pact-jvm

mfellows_20211130v2
2021-11-30 10:32
has joined #pact-jvm

mfellows_20211130v3
2021-11-30 10:57
has joined #pact-jvm

mfellows_20211130v4
2021-11-30 11:16
has joined #pact-jvm

agittcelik
2021-11-30 18:35
has joined #pact-jvm

agittcelik
2021-11-30 19:13
Hi all :slightly_smiling_face: We are trying to adopt Contract testing in our team consist of about 30 microservices. We got stuck on choosing which strategy is right at Provider Pact Test. We wanted to ask some questions to clarify which strategy is able to meet our requirements As https://docs.pact.io/getting_started/testing-scope/ suggest we analyzed scope of writing the Provider Pact Test and decided to follow setting up services that only mocking external services (?external services? stands for other internal microservices) which we are planning to do: ? creating an isolated testing environment that Database, message brokers etc. will be set up then cleaned up after execution of the test. Could you give any suggestion about isolation testing environment. Do you think that is it worth to make such effort to write the test with following scenario ?

alturil
2021-11-30 20:56
has joined #pact-jvm

matt.fellows
2021-11-30 22:25
> Could you give any suggestion about isolation testing environment. what we mean by this is that you should be able to create the conditions to test the provider locally (not in a dedicated test environment somewhere.

agittcelik
2021-12-01 06:49
As you mentioned we meant by ?a dedicated test environment somewhere?. It will be set up at K8S cluster that consists of its own database and external mocked services. After execution of the test, the environment will be cleaned up and will be set up every execution.

draper.joseph
2021-12-01 06:50
has joined #pact-jvm

abhay175
2021-12-01 07:35
has joined #pact-jvm

abhay175
2021-12-01 07:55
Hi there, I am writing provider test for a spring application. However I am getting 404 for the 2 endpoints that i am testing. How do I enable debug logging to see the request?

matt.fellows
2021-12-01 09:43
You can do that, but if you can do that why not just run it the way a Pact test is intended - in a local process that doesn?t need a dedicate environment?

joelgrimberg
2021-12-01 11:27
has joined #pact-jvm

reem.alashry
2021-12-01 12:09
has joined #pact-jvm

beshoy.ibrahim
2021-12-01 12:09
has joined #pact-jvm

omar.radi
2021-12-01 12:10
has joined #pact-jvm

mmudassar192
2021-12-01 12:11
has joined #pact-jvm

eric.seipold
2021-12-01 13:40
has joined #pact-jvm

apselsevier
2021-12-01 16:48
has joined #pact-jvm

jarmy
2021-12-01 18:01
you can add these to a `logback-test.xml` in your test resources directory: ``` <logger name="au.com.dius.pact.provider" level="debug"/> <logger name="io.pactfoundation.*" level="debug"/>```

ali.korayem
2021-12-01 18:55
has joined #pact-jvm

luiz.filipe.abrahao
2021-12-01 21:04
has joined #pact-jvm

srividya.ece
2021-12-02 09:32
Hi All pact-jvm-server.bat 29999 -b "brokerl url" throws unknow option

srividya.ece
2021-12-02 09:33
--help doesnot show the argument but the pact documentation has -b argument https://docs.pact.io/implementation_guides/jvm/pact-jvm-server

srividya.ece
2021-12-02 09:34
how to configure pact broker to the jvm server?

srividya.ece
2021-12-02 09:36
@uglyog @matt.fellows

luiz.filipe.abrahao
2021-12-02 11:00
Hi, I'm still getting `No HAL document found at path 'https://url/pacts/provider/provider/for-verification'` when there are no pacts for a provider to verify and I have configured the maven plugin to `<failIfNoPactsFound>false</failIfNoPactsFound>` when I run `mvn pact:verify` ```<plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.1.11</version> <configuration> <failIfNoPactsFound>false</failIfNoPactsFound> <serviceProviders> <serviceProvider> <pactBroker> <url>URL</url> <authentication> <scheme>bearer</scheme> <token>TOKEN</token> </authentication> </pactBroker> </serviceProvider> </serviceProviders> </configuration> </plugin>``` am I missing something? When I run my tests with the `@IgnoreNoPactsToVerify` it passes

matt.fellows
2021-12-02 11:01
That looks like a different error Filipe. I think the Ignore flag is just masking a different problem

matt.fellows
2021-12-02 11:01
not finding pacts is one thing, but ?No HAL document? tells me something is broken

matt.fellows
2021-12-02 11:02
Is your provider name actually `provider`? (it might be, just checking)

matt.fellows
2021-12-02 11:02
If you can enable some debug level logging, I?d like to take a look at the HTTP calls the verifier is making

matt.fellows
2021-12-02 11:03
and more importantly, what it?s getting back

matt.fellows
2021-12-02 11:03
that error can present itself if an incorrect broker URL is supplied, or if there is an intermediate proxy intercepting and responding with garbage (e.g. HTML) instnead of the expected `application/hal+json` response

mike.geeves064
2021-12-02 11:34
:thinking_face: where is the .bat, I can't see that in the current repo anyway?

luiz.filipe.abrahao
2021-12-02 12:41
Hi @matt.fellows. I get this exact same error if I remove the `@IgnoreNoPactsToVerify` annotation form my test class

luiz.filipe.abrahao
2021-12-02 12:41
That is why I thought they were related

matt.fellows
2021-12-02 13:11
yeah, I think that Ignore flag is just ignoring any error case

matt.fellows
2021-12-02 13:11
are you able to share the http level debug logs? (redacted where needed)

matt.fellows
2021-12-02 13:11
that will help us understand better

luiz.filipe.abrahao
2021-12-02 13:12
do I need to enable anything to get that? because I don't thing I get any http tracing when running it

matt.fellows
2021-12-02 13:19
That's a maven/Java log package thing.

matt.fellows
2021-12-02 13:19
Probably a flag like --verbose or --debug

matt.fellows
2021-12-02 13:19
Not pact specific, but the pact packages log at debug level so however you manage log level now you'd need to enable it

matt.fellows
2021-12-02 13:20
(I'm not a java guy, sorry, but I do have memories of slf4j etc and having to configure which log levels and which packages could log at what level also)

srividya.ece
2021-12-02 13:25
Which.bat file are you refferring to?

mike.geeves064
2021-12-02 13:35
You said you were running pact-jvm-server.bat The documentation there refers to the actual binary, pact-jvm-server


srividya.ece
2021-12-02 13:41
```pact-jvm-server-4.1.0.zip ``` contains the batch file

david.cummings
2021-12-02 14:13
has joined #pact-jvm

mike.geeves064
2021-12-02 14:14
So what happens when you try with -b ? The pact-jvm-server.bat script should call and pass any args to it that you have provided. Have you tried "enabling" debug to check what it is doing? ("set DEBUG=1" for example before calling it)

miccagiann
2021-12-02 14:17
has joined #pact-jvm

srividya.ece
2021-12-02 14:17
pact-jvm-server.bat 29999 -b https://example.pactflow.io/ DEBUG=1 Error: Unknown option -b Error: Unknown argument 'https://example.pactflow.io/' Error: Unknown argument 'DEBUG=1' Try --help for more information. Usage: pact-jvm-server [options] [port] port port to run on (defaults to 29999) --help prints this usage text -h, --host <value> host to bind to (defaults to localhost) -l, --mock-port-lower <value> lower bound to allocate mock ports (defaults to 20000) -u, --mock-port-upper <value> upper bound to allocate mock ports (defaults to 40000) -d, --daemon run as a daemon process --debug run with debug logging -v, --pact-version <value> pact version to generate for (2 or 3) -k, --keystore-path <value> Path to keystore -p, --keystore-password <value> Keystore password -s, --ssl-port <value> Ssl port the mock server should run on. lower and upper bounds are ignored

mike.geeves064
2021-12-02 14:18
> Usage: pact-jvm-server [options] [port]

mike.geeves064
2021-12-02 14:18
port at the end, options before

mike.geeves064
2021-12-02 14:18
and the DEBUG=1 I literally meant before running the bat: `set DEBUG=1`

mike.geeves064
2021-12-02 14:18
if you look in the bat file, it switches on echoing out if DEBUG is set right at the start

mike.geeves064
2021-12-02 14:21
may or may not help swapping round, I'm not on windows to try here, I see what you mean it doesn't give the -b as an option there though

miccagiann
2021-12-02 14:24
Hi all, not sure if this topic has been brought up before in this channel. The question is the following: Assuming that I have a wlp service that is very hard to stand-up standalone via the maven wlp liberty plugin so as to run integration tests on it, is it possible to use testcontainers in order to bring up the docker image that I am producing for this service and inside there execute the pact tests?

mike.geeves064
2021-12-02 14:27
oh wait

mike.geeves064
2021-12-02 14:27
that's a very old version, can you upgrade?

mike.geeves064
2021-12-02 14:27
If you look in the history for Server.scala, you can see the options for broker and token were only added 2020-08-26, you're using a version from 2020-05-20

mike.geeves064
2021-12-02 14:30
It is definitely in 4.1.29, I've never used pact-jvm-server before so I wouldn't be able to say differences going to the 4.2.x or 4.3.x releases

srividya.ece
2021-12-02 14:34
how can we upgrade. i coudnt find the latest reslease


mike.geeves064
2021-12-02 14:38
So however you installed from there

srividya.ece
2021-12-02 14:42
thankyou - now I entered the following in command line --> pact-jvm-server.bat -b https://test.pactflow.io/ 29999 starting unfiltered app at localhost on port 29999 press enter to stop server:

srividya.ece
2021-12-02 14:42
this mean pact broker is configured right?

mike.geeves064
2021-12-02 14:46
Looks like it should be, yes

srividya.ece
2021-12-02 15:01
It works now

srividya.ece
2021-12-02 15:04
When I send /create request mock server is created with port. And I performed consumer tests for 2 states out of total three states. Now when I execute /complete it throws 400 error saying not all requests verified

srividya.ece
2021-12-02 15:04
and pact file is not created

srividya.ece
2021-12-02 15:05
Pact file is created only when I execute all states in interactions

srividya.ece
2021-12-02 15:08
Is there any other way to execute generate pact file without performing consumer all states

srividya.ece
2021-12-02 15:23
HI pact-jvm-server /publish throws "error": "Got IO Exception while reading file. Failed to fetch the root HAL document" during pact file publish(located in target/pact). Could someone please tell the reason and fix for this

mike.geeves064
2021-12-02 15:33
I don't think it makes sense to not perform all of the consumer tests, because then you would be publishing a Pact to the broker which implies there is only e.g. one interaction for that consumer version

srividya.ece
2021-12-02 15:37
okay

srividya.ece
2021-12-02 15:37
{   "provider": {     "name": "bbc-news"   },   "consumer": {     "name": "weather-app"   },   "interactions": [     {       "description": "Get weather at Munich",       "request": {         "method": "GET",         "path": "/weather/munich"       },       "response": {         "status": 200,         "headers": {           "Content-Type": "application/json; charset=UTF-8"         },         "body": {           "Value": "10 degrees"         },         "matchingRules": {           "$.body.name": {             "match": "type"           },           "$.headers.Content-Type": {             "match": "regex",             "regex": "application/json;\\s?charset=(utf|UTF)-8"           }         }       },       "providerState": ""     },     {       "description": "Get weather at Vizag ",       "request": {         "method": "GET",         "path": "/weather/vizag"       },       "response": {         "status": 200,         "headers": {           "Content-Type": "application/json; charset=UTF-8"         },         "body": {           "Value": "30 degrees"         },         "matchingRules": {           "$.body.name": {             "match": "type"           },           "$.headers.Content-Type": {             "match": "regex",             "regex": "application/json;\\s?charset=(utf|UTF)-8"           }         }       },       "providerState": "Get Vizag weather"     },     {       "description": "Get weather at Antarctica ",       "request": {         "method": "GET",         "path": "/weather/antarctica"       },       "response": {         "status": 404,         "headers": {           "Content-Type": "application/json; charset=UTF-8"         },         "body": {           "Value": "No such data found"         },         "matchingRules": {           "$.body.name": {             "match": "type"           },           "$.headers.Content-Type": {             "match": "regex",             "regex": "application/json;\\s?charset=(utf|UTF)-8"           }         }       },       "providerState": "Get Antarctica weather"     }   ],   "metadata": {     "pactSpecification": {       "version": "2.0.0"     },     "pact-jvm": {       "version": "4.1.0"     }   } }

srividya.ece
2021-12-02 15:38
this is my example JSON for which i have sent / create request

srividya.ece
2021-12-02 15:39
it has three different states. if I need to send do all consumer request, what is the use of states here?

mike.geeves064
2021-12-02 15:43
because you need the provider to respond accordingly to the different requests?

mike.geeves064
2021-12-02 15:44
suggest as this is now onto something different from the argument issue, to start a new thread on this (I need to go anyway)

srividya.ece
2021-12-02 15:44
okay got it. Thank you very much for your time

mike.geeves064
2021-12-02 15:46
no problem :slightly_smiling_face:

matt.fellows
2021-12-02 22:16
Is this a consumer or provider test?

matt.fellows
2021-12-02 22:17
I don?t see that being an issue for a provider test, so long as you can easily control the provider states

matt.fellows
2021-12-02 22:18
Hi Srividya, please see the guide on creating a minimal reproducible example, when it comes to asking for help


matt.fellows
2021-12-02 22:19
In this case, that might be hard, but for anybody to help you debug an issue we?re going to need to know: ? What you are trying to do ? What software is being called ? What the command arguments/code looks like ? Logs that show the problem ? etc.

matt.fellows
2021-12-02 22:20
the likely answer to your above question, is that it?s trying to publish to an API that doesn?t have the correct response. It seems like it?s not talking to a proper pact broker to publish the contract here.

miccagiann
2021-12-02 22:28
I would say for consumer test... I know ideally you want your war or springboot service to be well coded and structured so as to be able to run consumer integration tests easily but sometimes with legacy code this is not so easy

matt.fellows
2021-12-03 00:42
I don?t know testcontainers and the JVM ecosystem well enough to advise. I?m assuming you don?t have unit testing capability of your API client then? I?m not sure how you would write a Pact test from the consumer side that requires a running server though - how would you write the pact test itself?

abubics
2021-12-03 01:14
:taco: for @mike.geeves064

abubics
2021-12-03 01:28
fwiw, I usually find that refactoring messy API calls all over the codebase into a single API client isn't too difficult. If that's the problem, it might be a relatively cheap fix, which also can help get on track to other refactors.

praveen.em
2021-12-03 07:40
has joined #pact-jvm

srividya.ece
2021-12-03 08:04
Okay thankyou for your suggention. will keep in mind and yes comming to the issue . I am able to solve it by providing token while configuring the pactbroker

srividya.ece
2021-12-03 08:19
Hi All, Is there a way that I can include pact standalone server (ex: pact-jvm-server) during creating consumer tests, ex: in PactProviderRule. Can I add the standalone mock server running on a cloud or different machine in the PactproviderRule something like ex: @Rule public PactProviderRule mockTestProvider = new PactProviderRule("test_provider", "localhost", 29999); If possible Could you please explaing how to achieve?

mike.geeves064
2021-12-03 08:36
:party_parrot:

srividya.ece
2021-12-03 10:22
Hi I am new to pact and looking for a example of pact consumer test using wiremock standalone server

ally.parker
2021-12-03 11:18
has joined #pact-jvm

rishabh.gaur
2021-12-03 11:43
has joined #pact-jvm

matt.fellows
2021-12-03 12:19
You wouldn?t use wiremock with Pact

matt.fellows
2021-12-03 12:19
Pact _is_ the mock

matt.fellows
2021-12-03 12:19
you would use Pact instead of wiremock

srividya.ece
2021-12-03 12:34
okay . can I use standalone server using PactProvider junit rule

srividya.ece
2021-12-03 12:34
?

srividya.ece
2021-12-03 12:35
can I configure the standalone server here in the below rule @Rule public PactProviderRule mockProvider = new PactProviderRule("test_provider", "localhost", 8080, this);

matt.fellows
2021-12-03 12:40
Ah, I?m not sure about the standalone server sorry!

matt.fellows
2021-12-03 12:40
Do you need to use it though? Why not use the one it spins up automatically for you?

srividya.ece
2021-12-03 12:41
Because we are planning to host it in a different machine ex in cloud

matt.fellows
2021-12-03 12:41
why?

matt.fellows
2021-12-03 12:41
Pact is a unit testing tool, when you run the unit tests why do you want the mock running in the cloud?

srividya.ece
2021-12-03 12:42
There are other teams who want to use also use the same server

srividya.ece
2021-12-03 12:42
to perform the tests

matt.fellows
2021-12-03 12:43
can you describe your use case a little more?

matt.fellows
2021-12-03 12:43
That sounds odd

srividya.ece
2021-12-03 12:46
My requirement is I need to use a standalone server and generate pact files. I tried the following used pact-jvm-server and generated pact file.But the problem here is I need to test each state with the mock and should be successful then only a pact file is generated. if I miss one state to test against mock provider then I get an mismatch error.

matt.fellows
2021-12-03 12:47
Yes, that?s the way Pact works

matt.fellows
2021-12-03 12:47
it?s not a stubbing tool, it?s a mocking tool (there is a stub server, but that accepts a generated pact file and acts like a stub)

matt.fellows
2021-12-03 12:48
Pact is a unit testing tool - it?s designed to test the correctness of your consumer API client

matt.fellows
2021-12-03 12:49
Sharing the mock server doesn?t make sense. The mock server?s purpose is to be a *mock* (not a stub) for the provider, specifically for the interactions required of a given consumer, to generate a contract unique to a consumer-provider pair

matt.fellows
2021-12-03 12:49
this is why sharing the mock server makes no sense - each consumer should have its own mock server specific to them

matt.fellows
2021-12-03 12:50
> My requirement is I want to know _why_ that?s the requirement. I think perhaps somebody is asking you to do it this way, and they are misinformed about how Pact works. I want to ensure you use it right, otherwise you won?t have much fun with it :slightly_smiling_face:

matt.fellows
2021-12-03 12:51
I have to run (late here) but can check-in next week

matt.fellows
2021-12-03 12:51
I?d highly recommend one of our tutorials or workshops (see howtolearn)

2021-12-03 12:51
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

rishabh.gaur
2021-12-03 14:00
Hi, can anyone please help me, how can I run provider contract tests on specific version of contract published by a consumer(lets say version - 0.0.1-SNAPSHOT). It is always picking the latest one, right now. I am using below versions:- ? ?http://au.com.dius.pact? version ?3.5.23? ? testImplementation(?au.com.dius:pact-jvm-provider-spring_2.12:3.5.24?) ? testImplementation(?au.com.dius:pact-jvm-provider-junit_2.12:3.5.24") ? testImplementation(?au.com.dius:pact-jvm-consumer-junit_2.11:3.5.24?)

william.wallace
2021-12-03 15:12
has joined #pact-jvm

batiushkov.nik
2021-12-03 15:48
has joined #pact-jvm

keith.mcgrath
2021-12-03 18:28
has joined #pact-jvm

rchandragupthara
2021-12-03 19:32
has joined #pact-jvm

vinicius.cosmi
2021-12-03 20:01
has joined #pact-jvm

matt.fellows
2021-12-03 21:06
What does your provider verification setup code look like?

ichatterjee
2021-12-03 21:27
has joined #pact-jvm

ben.watts
2021-12-03 23:48
has joined #pact-jvm

rishabh.gaur
2021-12-04 07:13
@matt.fellows ```@RunWith(SpringRestPactRunner.class) @SpringBootTest(webEnvironment = RANDOM_PORT) @Provider("producer_service") @Consumer("consumer_service1") @PactBroker(host = "localhost",port = "9292") public class ConsumerService1PactTests { @TestTarget public Target target = new SpringBootHttpTarget(); @State("Get order details") public void testGetConsumerTwo(){ ProducerService mock = Mockito.mock(ProducerService.class); Order order = new Order("customerId", 1000.0, 2); Mockito.when(mock.getOrderDetails("SomeId")) .thenReturn(order); } }```

matt.fellows
2021-12-04 07:52
Look at the docs for the pact broker annotation / properties

matt.fellows
2021-12-04 07:52
See also the ci/cd workshop for how we recommend setting up a verification strategy (howtolearn)

2021-12-04 07:52
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

imikhtyuk
2021-12-06 00:36
has joined #pact-jvm

norrischebl
2021-12-06 05:54
has joined #pact-jvm

smantini
2021-12-06 09:25
has joined #pact-jvm

gzinger
2021-12-06 11:19
has joined #pact-jvm

mahatmafatal
2021-12-06 13:50
has joined #pact-jvm

jacob.v.gardner
2021-12-06 14:59
has joined #pact-jvm

glebing2000
2021-12-07 07:28
has joined #pact-jvm

sergio.freire
2021-12-07 09:52
has joined #pact-jvm

sahoo.skumar
2021-12-07 10:55
has joined #pact-jvm

kingyang728
2021-12-07 15:58
has joined #pact-jvm

jesseaantebi
2021-12-07 19:36
has joined #pact-jvm

rsheikh
2021-12-07 22:34
has joined #pact-jvm

jorgwel
2021-12-08 01:22
has joined #pact-jvm

rahul.anwekar23
2021-12-08 04:19
has joined #pact-jvm

rishabh.gaur
2021-12-08 10:22
Hi All, I am getting ?No Pact files were found to verify? exception if I am setting enablePendingPacts = ?true? in pact broker configuration in provider tests. Please help how can we fix this. ```@PactBroker(host = "localhost",port = "9292", consumerVersionSelectors = {@VersionSelector(tag = "v2")}, enablePendingPacts = "true")``` I want the build to fail in case pact verification fails for provided tag

matt.fellows
2021-12-08 11:13
if `enablePendingPacts` is set to false, does it find any pacts? (it should, pending just determines if your build fails or not under certain conditions: see http://docs.pact.io/pending

matt.fellows
2021-12-08 11:14
It?s more likely that there are no pacts with tag `v2`

rishabh.gaur
2021-12-08 11:45
I think, by default enablePendingPacts is set to false only. When I am executing test, it is able to find the pact and execute the test. In above case build is passing and in pact broker verification is failing for v2 tag contract(as the contract mismatch).

matt.fellows
2021-12-08 11:52
> In above case build is passing and in pact broker verification is failing for v2 tag contract(as the contract mismatch). I?m confused, just before you said this: > Hi All, I am getting ?No Pact files were found to verify? which one is it?

matt.fellows
2021-12-08 11:53
if the build is passing, but the verification is failed, that is expected behaviour. Please read http://docs.pact.io/pending on how that behaviour works

matt.fellows
2021-12-08 11:53
if you want it to always fail if the provider can?t satisfy the contract, set it to false explicitly so you?re sure

rishabh.gaur
2021-12-08 11:57
```@PactBroker(host = "localhost",port = "9292", consumerVersionSelectors = {@VersionSelector(tag = "v2")}, enablePendingPacts = "false")```

rishabh.gaur
2021-12-08 11:57
```@PactBroker(host = "localhost",port = "9292", consumerVersionSelectors = {@VersionSelector(tag = "v2")}, enablePendingPacts = "true")```

rishabh.gaur
2021-12-08 11:58
@matt.fellows above are the two behaviors with enablePendingPacts true / false.

matt.fellows
2021-12-08 11:59
thanks, that sounds like a bug to me, or we?re missing something else

matt.fellows
2021-12-08 11:59
could you please enable debug logging (however you do that) so that we can see what the req/res looks like with your pact broker?

matt.fellows
2021-12-08 11:59
that will help us understand

rishabh.gaur
2021-12-08 12:07
how to enable pact debug logs?

matt.fellows
2021-12-08 12:08
how do you enable logging for your code now? I?m assuming it?s going to be a flag like `--debug` on your gradle build

matt.fellows
2021-12-08 12:09
It?s however you do that with Java :slightly_smiling_face:

matt.fellows
2021-12-08 12:29
Thank you, but sadly it doesn?t contain the DEBUG level logs for the Pact JVM package (or maybe it?s an apache http library), so I can?t see the requests to the broker

luanacosta05
2021-12-08 20:34
has joined #pact-jvm

saurabh.techiee
2021-12-09 09:41
has joined #pact-jvm

albertcabantog
2021-12-09 10:52
has joined #pact-jvm

david.vancouvering
2021-12-09 23:19
Hey. We upgraded our broker, and now our Java provider verification test does not appear to run. If we switch to the old version of the broker, it works fine. We are suspecting that when we try to pull from the new broker, it somehow doesn't find the contract, but it does so silently. Is there a way to enable more verbose output so we can see what's going on?

uglyog
2021-12-09 23:46
You need to enable debug logging. If you enable debug level for the following packages ```org.apache.http au.com.dius.pact``` you should see the HTTP requests being made to the broker

david.vancouvering
2021-12-10 00:04
OK thanks!

paul.scholes
2021-12-10 10:21
has joined #pact-jvm

chris.sloan
2021-12-10 10:48
has joined #pact-jvm

leon.york
2021-12-10 12:42
has joined #pact-jvm

kyle.craviotto
2021-12-10 16:40
has joined #pact-jvm

lorenz.schumann
2021-12-10 18:33
has joined #pact-jvm

rejeesh.g
2021-12-12 02:58
Hello I'm already using https://docs.pact.io/implementation_guides/jvm/provider/gradle/#allowing-just-the-changed-pact-specified-in-a-webhook-to-be-verified-406 and it is working fine for pact-jvm provider junit library. I am curious to know, if same is supported for pact-jvm provider junit5 library. I want to use pact.filter.pacturl with @AllowOverridePactUrl in the pact-jvm provider junit5. Also can you please let me know if it is a global feature to all pact-jvm provider library or is it specific to junit4.

luispires.m
2021-12-13 12:32
has joined #pact-jvm

fabio.rodrigues
2021-12-13 16:22
has joined #pact-jvm

uglyog
2021-12-13 22:13
It should be, JUnit 5 support is meant to be the same as JUnit 4

mbailey
2021-12-13 22:17
has joined #pact-jvm

mbailey
2021-12-13 22:19
Before I give up and start over with another tutorial, has anyone gotten this to work? https://github.com/pact-foundation/pact-workshop-jvm-spring

mbailey
2021-12-13 22:20
Failed on Step 2: `./gradlew consumer:test`

uglyog
2021-12-13 22:20
What error do you get?

mbailey
2021-12-13 22:22
404 on get by id

mbailey
2021-12-13 22:22
```org.springframework.web.client.HttpClientErrorException$NotFound: 404 Not Found: [ Request was not matched =======================```

mbailey
2021-12-13 22:23
Nothing should be running, right? This is just a unit test

mbailey
2021-12-13 22:24
Pulled fresh from the repo about 10 minutes ago. Haven?t changed anything.

uglyog
2021-12-13 22:24
I'll have to check it

mbailey
2021-12-13 22:28
Thanks! I need to get a prototype up by tomorrow. Do you know of any other good guides?

uglyog
2021-12-13 22:30
Are you looking specifically for Spring support?

mbailey
2021-12-13 22:31
Yes. I?d prefer Spock to JUnit, but atm just want to get a good example going. This one look(ed) good, and it?s referenced on the http://pact.io site but there must be others out there that work.

uglyog
2021-12-13 22:32
It does work, I wrote it and ran an workshop for it not that long ago

uglyog
2021-12-13 22:32
Are you following the examples while switching the git branches?

mbailey
2021-12-13 22:33
Aha!

mbailey
2021-12-13 22:33
I didn?t know about the branches

mbailey
2021-12-13 22:34
I bet that?s it, thank you

uglyog
2021-12-13 22:34
Each step has it's own branch

mbailey
2021-12-13 22:39
OK, I see how it works now. Thanks for your help! And for the guide, it looks very tidy.

mbailey
2021-12-13 22:39
If I get that far, do you happen to know of a Spock version?

uglyog
2021-12-13 22:55
There is no tutorial with Spock, but I have some examples of using Spock with Pact

mbailey
2021-12-13 23:25
Are they on GitHub?

mbailey
2021-12-13 23:25
This tutorial is a lot easier than the SCC ones I did yesterday btw

uglyog
2021-12-13 23:28
Not sure where they are, I will have to track them down.

mbailey
2021-12-14 00:11
Would appreciate it - thank you!

mbailey
2021-12-14 00:13
If you happen to know - regarding step 6: ```We expected this failure, because the product we are requesting does in fact exist! ``` And step 7: ```Our code already deals with missing users and sends a 404 response, however our test data fixture always has product ID 10 and 11 in our database.``` Where is this test fixture setup? I?m searching the entire project and I don?t see any references to inserting product 11, or mocking a response with product 11. I understand if you don?t have time - but I?m trying to understand the test setup, so if you know, great!

mbailey
2021-12-14 00:14
Nevermind, it?s in the repository, not sure why my search didn?t find it

mbailey
2021-12-14 00:51
These are probably the examples you were looking for: https://github.com/pact-foundation/pact-jvm/issues/1384 But please let me know if there?s anything newer/more integrated into Spock. Would make this an easier sell to my team

mbailey
2021-12-14 02:26
(Different) question about the tutorial/live setup: when I ran the tutorial, I had to run the consumer unit tests with gradle to generate the contract. When I set this up in my own projects, it seems to generate the contract when running through IntelliJ. Is there some special setup to make this happen? Or can I count on it? (except in the tutorial)

uglyog
2021-12-14 02:32
If the tests pass, it will always generate a Pact file. On CI, you want to have the Pact file published to a Pact Broker so they are shared

mbailey
2021-12-14 02:54
I just started over and ran it again to confirm for you: when I run `ProductConsumerPactTest` through the IntelliJ runner, I do not get a file at `consumer/build/pacts`. When I run `./gradlew consumer:test --tests *PactTest` (per the instructions) I get a file `FrontendApplication-ProductService.json`.

uglyog
2021-12-14 02:58
It could be in a different directory when run from IntelliJ, but it is largely academic. The Gradle build must generate the file, because that is what is run on CI

abubics
2021-12-14 03:31
Aw, I haven't used Spock in, like, 7 years :sob:

dkwak
2021-12-14 03:47
has joined #pact-jvm

rejeesh.g
2021-12-14 05:05
Thanks for confirming

haoran.lin
2021-12-14 05:27
has joined #pact-jvm

tom450
2021-12-14 08:06
has joined #pact-jvm

pajaree.tuampitak
2021-12-14 10:00
has joined #pact-jvm

nitins333
2021-12-14 10:03
has joined #pact-jvm

pajaree.tuampitak
2021-12-14 10:06
Greeting !! I?m facing the issue that matchingRules not getting published to pact broker. When run the test on local it able to generate pact file with matching rules result but if use this `sbt -mem 4096 payout-api/pactPublish` to run/publish pact file to PAct broker then it shown as a blank in Pact file ```"matchingRules": { "body": {}, "header": {} }``` Please help advice :slightly_smiling_face:

francislainy.campos
2021-12-14 12:09
Hi, I?m getting this error after updating pact to use version 4.3.1. I believe it may be a conflict between junit versions but not sure which one to use. Thank you. ```org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [org.apache.http.HttpRequest request] in method [void com.hmhco.viaductservice.pact.provider.PactProviderGcTest.pactTestTemplate(au.com.dius.pact.provider.junit5.PactVerificationContext,org.apache.http.HttpRequest)].```

francislainy.campos
2021-12-14 12:51
```@PactBroker(url = BROKER_PACT_URL, authentication = @PactBrokerAuth(token = "mytoken")) @VerificationReports(value = {"markdown"}, reportDir = "target/pacts") public class PactProviderGcTest { @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactTestTemplate(PactVerificationContext context, HttpRequest request) { request.addHeader("Authorization", "Bearer " + accessToken); context.verifyInteraction(); } @BeforeAll public static void setUp() throws JSONException { accessToken = getAccessToken(); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpsTestTarget(BASE_PACT_URL, 443, "/")); } @State("A request to retrieve google courses") void sampleState() { } }```

jaakko.tompuri
2021-12-14 13:10
has joined #pact-jvm

francislainy.campos
2021-12-14 14:16
PS: It works up to version 4.3.0 and it fails on the most recent 4.3.1 and 4.3.2 versions.

albert.moreno
2021-12-14 17:01
has joined #pact-jvm

philipchardwick
2021-12-14 17:53
Hey team, can I just check should pact-jvm be case sensitive or insensitive when choosing provider states to execute? It seems like the broker decapitalises the states when putting it in the `Given $(state), upon receiving ${interaction_name}` which can cause a bit of confusion (our state was capitalised and we had @IgnoreMissingStates, we'll probably remove that now wip pacts protects the provider build from new pacts with new states)

mbailey
2021-12-14 21:20
Sympathies. Using JUnit again feels like walking through mud.

mbailey
2021-12-14 21:25
Thanks! That?s correct, it puts it in `/target` instead of in `/build`

mbailey
2021-12-14 21:28
Hi, I have a question about a problem I?m having implementing the producer-side test in a SpringBoot application. My application fails to start up in the `@SpringBootTest` because of the exception: ```java.lang.IllegalArgumentException: Not enough variable values available to expand 'label'``` According to various web sources, this is caused by a `RestTemplate` issue. But I?m not using `RestTemplate` explicitly in the test, I assume this is something happening behind the scenes in the Pact test generation. Is there some configuration I need to provide for this? A search of the sample jvm project does not turn up any hits on the word ?label?

mbailey
2021-12-14 21:29
FYI there?s also no ?label? in my contract json

mbailey
2021-12-14 23:10
Issue resolved - I was calling Hashicorp Vault behind the scenes

mbailey
2021-12-14 23:11
Hello again - I?m having a problem getting my test to correctly show failure, and to publish to my broker. Snippets in thread. Help appreciated.

mbailey
2021-12-14 23:11
```2021-12-14 16:02:03,206 [b2697398-82bc-4c49-a0ce-3db0c9d08c28] [http-nio-auto-1-exec-3] DEBUG o.s.w.s.DispatcherServlet - Exiting from "ERROR" dispatch, status 401 returns a response which has status code 404 (FAILED) has a matching body (OK) Pending Failures: 1) Verifying a pact between productevaluator and productcatalog - Get product with sku productSKU 1.1) StatusMismatch: expected status of 404 but was 401``` After this, my 2 tests pass.

mbailey
2021-12-14 23:12
Maybe or maybe not related: this run and publish job runs successfully, but nothing shows up in the broker. This broker was able to accept producer failures from the test project. ```./gradlew -DpactPublishResults=true product-catalog-service:integTest --tests *Pact*Test``` Note the oddity that I?m running `integTest`, not `test`

mbailey
2021-12-14 23:13
The broker does not show success - it has a blank ?Verified? column

uglyog
2021-12-14 23:13
That failure is a pending failure because the broker is treating them as pending. See https://docs.pact.io/pact_broker/advanced_topics/pending_pacts/ for more information


uglyog
2021-12-14 23:15
The parameter to turn on publishing is `pact.verifier.publishResults`

uglyog
2021-12-14 23:17
Also, it needs to be set on the test JVM. The command line parameter won't do that.


mbailey
2021-12-14 23:18
Does that override the default behavior in that article? (which I?m not going to understand in 5 minutes). In other words, is this a normal parameter that you enable once your pact setup is all done, or is this something you?d use only for troubleshooting?

uglyog
2021-12-14 23:18
It is meant to be enabled in CI. You don't want a developer running a local build and then publishing that it is verified correctly.

mbailey
2021-12-14 23:20
Trying it in the `@TestPropertySource`

mbailey
2021-12-14 23:20
This must be why it?s working in the workshop project: ```test { useJUnitPlatform() if (System.getProperty('pactPublishResults') == 'true') { systemProperty 'pact.provider.version', getGitHash() systemProperty 'pact.provider.tag', getGitBranch() systemProperty 'pact.verifier.publishResults', 'true' } }```

mbailey
2021-12-14 23:21
OK, so I think I understand why the publish isn?t working (trying that now). Why is the 401 not causing a test failure? I?m guessing I will need to make the test actually fail to get unverified in the broker (attempting to demonstrate this)

mbailey
2021-12-14 23:22
```"pact.verifier.publishResults: true",``` in the TestPropertySource did not work. Trying the buildfile hack

uglyog
2021-12-14 23:26
I've never used `@TestPropertySource`, so I'm not sure what it does

uglyog
2021-12-14 23:27
The build is not failing because the failures are pending. Once you get the results published, ot will no longer be pending and will fail

mbailey
2021-12-14 23:28
TestPropertySource is how you send in properties to a SpringBootTest (per-test, rather than using a yml which affects all tests)

mbailey
2021-12-14 23:29
I tried the method from the workshop project and no luck: ```test { useJUnitPlatform() if (System.getProperty('pactPublishResults') == 'true') { systemProperty 'pact.provider.version', getGitHash() systemProperty 'pact.provider.tag', getGitBranch() systemProperty 'pact.verifier.publishResults', 'true' }```

mbailey
2021-12-14 23:30
In the workshop project, the test build appears to respond correctly to the command line parameter.

uglyog
2021-12-14 23:31
Ah, I see. It is using a property to enable the other properties. Ok, your original command was correct then. But you can try change ```if (System.getProperty('pactPublishResults') == 'true')```

uglyog
2021-12-14 23:31
To ```if (project.pactPublishResults == 'true')```

uglyog
2021-12-14 23:32
and then use `-PpactPublishResults=true`

uglyog
2021-12-14 23:32
But I don't understand why the first one was not working

uglyog
2021-12-14 23:33
Which workshop did you get this from?


mbailey
2021-12-14 23:34
Yours I think you said

uglyog
2021-12-14 23:37
Yeah, I was worried about that. I don't recall adding that config.

uglyog
2021-12-14 23:37
But then, that doesn't mean I didn't

mbailey
2021-12-14 23:38
Cross fingers

mbailey
2021-12-14 23:38
Crap

mbailey
2021-12-14 23:38
That didn?t work

uglyog
2021-12-14 23:38
Bummer

uglyog
2021-12-14 23:38
Can you enable debug logs? The easiest way is to add logback to the project

mbailey
2021-12-14 23:42
I think I might have found it

mbailey
2021-12-14 23:42
This test takes forever to run though. I was trying the MockMvc version but I couldn?t find the project on the http://pact.io site to import

mbailey
2021-12-14 23:46
I had ```test { useJUnitPlatform()``` I probably needed ```integTest { useJUnitPlatform()``` but still not working.

mbailey
2021-12-14 23:48
Thank god

mbailey
2021-12-14 23:49
? test with `System.getProperty('pactPublishResults'` didn?t work ? test with `project.pactPublishResults` didn?t work ? integTest with `System.getProperty('pactPublishResults'` didn?t work ? integTest with `project.pactPublishResults` WORKED!!!!

mbailey
2021-12-14 23:50
I wonder why System.getProperty works on the test project but not in real life

mbailey
2021-12-14 23:52
Is there an easy way to publish the results of previously-run tests in a gradle task without running the tests again? I only have about 5 minutes to demo this, and the test takes almost that long between spring boot startup and embedded database

uglyog
2021-12-14 23:58
Ah, yeah, the settings needs to be applied to the config the tests run as

mbailey
2021-12-14 23:59
Right

mbailey
2021-12-14 23:59
That was an obvious miss. But I wonder why the -D runs on the workshop but not on one of our microservices - -P worked there

uglyog
2021-12-14 23:59
There is no easy option to publish previous results. But it just a post request. If you capture the json, you can use curl

mbailey
2021-12-15 00:01
Is there a flag or option to output the json? Or do you have it handy?

mbailey
2021-12-15 00:02
I?m surprised no one has wanted that for doing as separate steps in a CI/CD pipeline. I was thinking of putting these tests in a separate profile, but I bet a lot of folks don?t

uglyog
2021-12-15 00:07
Nobody has asked for that. If you enable debug logs for the Apache http client, you will see the request logged

abubics
2021-12-15 00:33
oh yeah, I don't use Junit, I'm in Kotlin land :slightly_smiling_face: but Spock was so beautiful :pleading_face:

uglyog
2021-12-15 00:34
Can you try 4.3.2?

uglyog
2021-12-15 00:35
It will do a String comparison, which will be case sensitive

mbailey
2021-12-15 00:37
Does anyone know where the dependency for https://docs.pact.io/implementation_guides/jvm/provider/spring/ in the Pact documentation can be found? I?ve imported `au.com.dius.pact.provider:junit5:4.1.7` (one of the classes from that lib is mentioned in the document) but it doesn?t contain `RestPactRunner` and some of the other classes in the example.

mbailey
2021-12-15 00:38
It?s easy to convince developers to write tests when writing tests is fun.

mbailey
2021-12-15 00:40
I got back in the ?pending pacts? loop again. If I make it out of that I?ll try the logging. At this point, for the demo I may need to adapt your workshop to look like my service.

uglyog
2021-12-15 00:55
That is a JUnit 4 example, so it will be in `au.com.dius.pact.provider:junit`

mbailey
2021-12-15 00:56
Oh! OK, I can switch that and give it a try. Is there a reason MockMvc was deprecated in JUnit5?

uglyog
2021-12-15 00:57
It's not deprecated??

uglyog
2021-12-15 00:57
It's in the `au.com.dius.pact.provider:junit5spring` lib

mbailey
2021-12-15 01:19
By deprecated, I meant it?s in the junit 4 library but was dropped in the junit 5 library. I didn?t know about the junit5spring one. There?s a lot of documentation to go through!

mbailey
2021-12-15 01:29
Sorry to bother again. If I put *any* headers in the contract, the MockServer fails with a 500. Details in thread.

uglyog
2021-12-15 01:29
Yeah, we try to keep all the Spring libs separate so people who are not using Spring don't have to pull in all the Spring libs

mbailey
2021-12-15 01:30
Doing a pretty vanilla contract (derived from workshop sample): ```@Pact(consumer = "productevaluator", provider = "productcatalog") RequestResponsePact productDoesNotExist(PactDslWithProvider builder) { return builder.given("Product productSKU does not exist") .uponReceiving("Get product with sku productSKU") .method("GET") .path("/product-catalogv2/merchants/subscrip_test/products/productSKU/2019-05-01T00:00:00.000Z") .headers(requestHeaders()) .willRespondWith() .status(404) .toPact(); }```

mbailey
2021-12-15 01:30
If I add that `.headers` in the request, with anything in it, I get a 500 from MockServer.

mbailey
2021-12-15 01:30
```private Map<String, String> requestHeaders() { Map<String, String> headers = new HashMap<>(); headers.put("any", "any"); return headers; }```

mbailey
2021-12-15 01:32
Error: ```... Caused by: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Internal Server Error: [{ "error": "Unexpected request : \tmethod: GET\n\tpath: \/product-catalogv2\/merchants\/subscrip_test\/products\/productSKU\/2019-05-01T00:00:00.000Z\n\tquery: {}\n\theaders: {Accept-encoding=[gzip,de... (500 bytes)]```

mbailey
2021-12-15 01:32
I thought I might have bad syntax, but my fluent interface exactly mirrors https://docs.pact.io/implementation_guides/jvm/consumer/junit/ from the http://pact.io docs.

matt.fellows
2021-12-15 01:32
is your client code sending those headers?

matt.fellows
2021-12-15 01:33
It?s probably failing because your test says those headers _should_ be present, but aren?t being sent with the request

mbailey
2021-12-15 01:33
I?m not sure what you mean ?sending? - I deleted the consumer tests to make sure they weren?t the problem. It?s just the processing of the contract

matt.fellows
2021-12-15 01:33
If this is a JUnit test, the html report should have a human friendly explanation of this

mbailey
2021-12-15 01:34
```org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Internal Server Error: [{ "error": "Unexpected request : \tmethod: GET\n\tpath: \/product-catalogv2\/merchants\/subscrip_test\/products\/productSKU\/2019-05-01T00:00:00.000Z\n\tquery: {}\n\theaders: {Accept-encoding=[gzip,de... (500 bytes)]```

mbailey
2021-12-15 01:34
Same same

matt.fellows
2021-12-15 01:34
A pact test is a few parts: 1. The mock of the provider - this validates what you actually do (i.e. it?s a mock, not a stub) 2. Your API client must call that mock as defined. Any differences in what you do vs what you said you do is a failure (and will result in a 500 from the mock service)

mbailey
2021-12-15 01:34
I?m not sure what you mean by ?sent with the request? - I ignored the client tests so that I could make sure it was only the processing of the contract that was affected.

matt.fellows
2021-12-15 01:35
can you please share your test?

mbailey
2021-12-15 01:36
OK. I see what you?re saying?. But I?m not sure how it knows what the API client does when I have the tests using it ignored

mbailey
2021-12-15 01:36
Hmm code snippet does not work in this slack org

mbailey
2021-12-15 01:36
OK here it is sorry for the bulk: ```package com.squaretrade.productevaluator.pact; import au.com.dius.pact.consumer.MockServer; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; import au.com.dius.pact.core.model.RequestResponsePact; import au.com.dius.pact.core.model.annotations.Pact; import com.squaretrade.productcatalog.model.GenericProductV2; import org.junit.Ignore; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import static io.pactfoundation.consumer.dsl.LambdaDsl.newJsonArrayMinLike; import static io.pactfoundation.consumer.dsl.LambdaDsl.newJsonBody; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @ExtendWith(PactConsumerTestExt.class) public class ProductConsumerPactTest { @Pact(consumer = "productevaluator", provider = "productcatalog") RequestResponsePact getOneProduct(PactDslWithProvider builder) { return builder.given("Product productSKU exists") .uponReceiving("Get product with sku productSKU") .method("GET") .path("/product-catalogv2/merchants/subscrip_test/products/productSKU/2019-05-01T00:00:00.000Z") .willRespondWith() .status(200) .headers(headers()) .body(newJsonBody(object -> { object.stringType("merchantId", "subscrip_test"); object.stringType("productSku", "productSKU"); object.stringType("displayName", "A product to die for"); }).build()) .toPact(); } @Pact(consumer = "productevaluator", provider = "productcatalog") RequestResponsePact productDoesNotExist(PactDslWithProvider builder) { return builder.given("Product productSKU does not exist") .uponReceiving("Get product with sku productSKU") .method("GET") .path("/product-catalogv2/merchants/subscrip_test/products/productSKU/2019-05-01T00:00:00.000Z") .headers(requestHeaders()) .willRespondWith() .status(404) .toPact(); } @Ignore @Test @PactTestFor(pactMethod = "getOneProduct") void getProductBySku_whenSkuExists(MockServer mockServer) { GenericProductV2 expected = new GenericProductV2(); expected.setMerchantId("subscrip_test"); expected.setProductSku("productSKU"); expected.setDisplayName("A product to die for"); RestTemplate restTemplate = new RestTemplateBuilder() .rootUri(mockServer.getUrl()) .build(); GenericProductV2 product = new ProductService(restTemplate).getProduct("10"); assertEquals(expected, product); } @Ignore @Test @PactTestFor(pactMethod = "productDoesNotExist") void getProductBySku_whenSkuDoesNotExist(MockServer mockServer) { RestTemplate restTemplate = new RestTemplateBuilder() .rootUri(mockServer.getUrl()) .build(); HttpClientErrorException e = assertThrows(HttpClientErrorException.class, () -> new ProductService(restTemplate).getProduct("11")); assertEquals(404, e.getRawStatusCode()); } private Map<String, String> headers() { Map<String, String> headers = new HashMap<>(); headers.put("Content-Type", "application/json; charset=utf-8"); return headers; } private Map<String, String> requestHeaders() { Map<String, String> headers = new HashMap<>(); headers.put("any", "any"); // headers.put("Authorization", "Basic c3lzdGVtaW50ZWdyYXRpb250ZXN0OmZyZWVsMDBr"); return headers; } }```

matt.fellows
2021-12-15 01:36
That error says ?I recieved a GET request to /product-catalogv2/merchant?.? but I did not expect it

mbailey
2021-12-15 01:39
What I?m really trying to do here is generate the appropriate contract and send it through the broker to the provider. I?m not sending it anything, I?m just defining the contract - so I?m not sure what the ?received? a request means

mbailey
2021-12-15 01:45
I?m beginning to think that the unit tests are the mechanism that defines the contract (per our other discussion). Maybe you need the contract definition *and* the tests so that the runner, when running the tests, writes out the contract

mbailey
2021-12-15 01:46
Which would be a shame because, as I implied on the other thread, the tests just seem to be boilerplate.

mbailey
2021-12-15 01:47
All I want is a passing test, but I?m in this ?Pending pacts? hell where I can?t get a good build going.

matt.fellows
2021-12-15 01:48
yes, you still need to send the request to Pact. You can?t just specific your expectations (it?s a mock).

matt.fellows
2021-12-15 01:49
you could always generate the pact file itself programmatically, but I don?t think that would be ideal unless you use the bi-directional flow

matt.fellows
2021-12-15 01:49
Apologies, I have to run to another call

matt.fellows
2021-12-15 01:50
I think it best to start by doing it the ?right way? (even if it has some boilerplat/cumbersome) and then when you?ve got it down pat, can evolve your flow to better suit it

matt.fellows
2021-12-15 01:50
right now, you?re probably juggling a few too many new concepts _and_ trying to work against the default behaviour of the framework

mbailey
2021-12-15 01:59
Agreed. That?s why I hate building prototypes with a short deadline! I was really happy with the demo, so much easier than Spring Cloud Contract. But integrating it into a real application is a real challenge. Really I was trying to delete the tests just to isolate the problem down to the contract, not to reduce the boilerplate, but you?re right, it?s the client tests that were the problem. I?ve got it running now. I saw mention of the ?bi-directional flow? in a blog post about ?Pact is dead long live pact?. That was from March, I wasn?t expecting it to be a real thing - could you point me to some documentation?

mbailey
2021-12-15 02:00
Appreciate your help and @uglyog ?s, and go get your call! It?s getting late here I?ll try to revisit in the morning when I haven?t? been slogging against this for 6 hours.

mbailey
2021-12-15 02:03
I see that you posted about bi-directional contracts in another thread, so nevermind here. Thank you!

francislainy.campos
2021-12-15 02:38
It works up to version 4.3.0, but not for 4.3.1 or 4.3.2

uglyog
2021-12-15 02:39
Ah! It needs to use the version 5 Http client classes

uglyog
2021-12-15 02:40
`org.apache.hc.core5.http.HttpRequest`

francislainy.campos
2021-12-15 03:12
Changed it now but still getting the same error

francislainy.campos
2021-12-15 03:13
```import au.com.dius.pact.provider.junit5.HttpsTestTarget; import au.com.dius.pact.provider.junit5.PactVerificationContext; import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; import au.com.dius.pact.provider.junitsupport.Consumer; import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.State; import au.com.dius.pact.provider.junitsupport.VerificationReports; import au.com.dius.pact.provider.junitsupport.loader.PactBroker; import au.com.dius.pact.provider.junitsupport.loader.PactBrokerAuth; import au.com.dius.pact.provider.junitsupport.loader.PactFolder; import org.apache.hc.core5.http.HttpRequest; import org.json.JSONException; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith;```

francislainy.campos
2021-12-15 03:13
```<java.version>17</java.version> <jacoco-maven-plugin.version>0.8.7</jacoco-maven-plugin.version> <sonar.version>3.9.0.2155</sonar.version> <rest-assured.version>4.4.0</rest-assured.version> <json-schema-validator.version>4.4.0</json-schema-validator.version> <junit.jupiter.version>5.6.3</junit.jupiter.version> <pact.version>4.3.2</pact.version> <pact.plugin.version>4.0.10</pact.plugin.version> <maven.surefire.version>3.0.0-M5</maven.surefire.version> <http.client.version>4.5.13</http.client.version> <curl.logger.version>2.1.0</curl.logger.version> <springdoc.version>1.2.26</springdoc.version> <swagger.annotations.version>1.5.13</swagger.annotations.version> <nimbus.oauth2-oidc-sdk.version>9.19</nimbus.oauth2-oidc-sdk.version> <hmh-security-common.version>1.0.05</hmh-security-common.version> <hiberante-types.version>2.4.2</hiberante-types.version> <maven.compiler.source>17</maven.compiler.source> <maven.compiler.target>17</maven.compiler.target>```

uglyog
2021-12-15 03:27
You can't get the same error if you changed it, as it says `No ParameterResolver registered for parameter [org.apache.http.HttpRequest request]` which is the old HTTP class

francislainy.campos
2021-12-15 03:31
Sorry, yes, you?re right. I misread the logs. It?s a different issue now. I think I can fix that one. Thank you for your help.

matt.fellows
2021-12-15 03:33
You?re welcome!

matt.fellows
2021-12-15 03:33
I can send you a video on the feature also, or if you like, can do a demo with the team. Drop us a line at and I can share

matt.fellows
2021-12-15 03:34
I don?t like to recommend over slack without context, because it is in dev preview and want to make sure you?re setup for success before trying it

matt.fellows
2021-12-15 03:34
otherwise, another tool to be angry at :laughing:

francislainy.campos
2021-12-15 03:41
Actually, the new issue is also related to this change. I?ll need to update this method to retrieve the interaction and the base uri but I don?t see this field there.

uglyog
2021-12-15 03:44
You should get the base uri from the mock server. Or do you mean the path for the request?

francislainy.campos
2021-12-15 03:45
This should be the base url for the request as I?m later reconstructing the curl that triggered it to have it printed back to the terminal.

francislainy.campos
2021-12-15 03:46
```((HttpPost) request).getURI().toString();``` This would give us that before with the older version of pact and http.

uglyog
2021-12-15 03:53
So you want the full URL. `request.getPath()` will give you the path. But you should know the base URL, as that is the URL for your provider

francislainy.campos
2021-12-15 04:09
Thank you. Did some extra tweaks and it?s working again now.

francislainy.campos
2021-12-15 04:40
Is there anything else that changed I should know of or some docs to read about this update? I?m now blocked under another issue, getting a 403 when generating my contracts and before that I had sth different where I had to add ProviderType.Async as per https://github.com/pact-foundation/pact-jvm/issues/1047#issuecomment-601989810

francislainy.campos
2021-12-15 04:42
This is my contract. ```@ExtendWith(PactConsumerTestExt.class) class PactConsumerGcGetCourseWorksTest { Map<String, String> headers = new HashMap<>(); String sampleCourseId = "421599667780"; String sampleCourseWorkId = "425810690067"; String path = "/v1/courses/"+ sampleCourseId +"/courseWork"; @Pact(provider = PACT_PROVIDER, consumer = PACT_CONSUMER) public RequestResponsePact createPact(PactDslWithProvider builder) { headers.put("Content-Type", "application/json"); return builder .given("A request to retrieve a list of course works") .uponReceiving("A request to retrieve a list of course works") .path(path) .method("GET") .headers(headers) .willRespondWith() .status(200) .toPact(); } @Test @PactTestFor(providerType = ProviderType.ASYNCH, providerName = PACT_PROVIDER, port = "8080") void runTest() { //Mock url RestAssured.baseURI = "http://localhost:8080"; RequestSpecification rq = RestAssured .given() .headers(headers) .accept(ContentType.JSON) .contentType(ContentType.JSON) .when(); Response response = rq .get(path); assertEquals(200, response.getStatusCode()); } }```

francislainy.campos
2021-12-15 04:43
And my imports

francislainy.campos
2021-12-15 04:43
```import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; import au.com.dius.pact.consumer.junit5.ProviderType; import au.com.dius.pact.core.model.RequestResponsePact; import au.com.dius.pact.core.model.annotations.Pact; import io.restassured.RestAssured; import io.restassured.config.RestAssuredConfig; import io.restassured.http.ContentType; import io.restassured.response.Response; import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import java.util.HashMap; import java.util.Map; import static org.junit.jupiter.api.Assertions.assertEquals;```

uglyog
2021-12-15 04:43
Your test is not ASYNCH (message), that will cause the mock server to not be started

francislainy.campos
2021-12-15 04:44
Should I remove that? This will bring me back to the other error though.

uglyog
2021-12-15 04:45
Yes, remove that because you are not testing a single message

francislainy.campos
2021-12-15 04:45
`java.lang.UnsupportedOperationException: Method createPact does not conform required method signature 'public http://au.com.dius.pact.core.model.V4Pact xxx(PactBuilder builder)'`

francislainy.campos
2021-12-15 04:46
Back here now


francislainy.campos
2021-12-15 04:55
Perfect, thank you. This works.

himanshu
2021-12-15 06:16
has joined #pact-jvm

philipchardwick
2021-12-15 09:11
Cool :thumbsup: do you think the broker should output the state with the exact case in the UI or should the jvm library do a case insensitive string comparison? Because I feel like one of them should change - it'd be interesting to see if other implementations use a case sensitive comparison too

james.perepiczka
2021-12-15 10:15
I'm having trouble with running pactVerify using the gradle plugin and verifying against the broker, I have the configuration below ```pact { broker { pactBrokerUrl = System.getenv('PACT_BROKER_URL') pactBrokerUsername = System.getenv('PACT_BROKER_USERNAME') pactBrokerPassword = System.getenv('PACT_BROKER_PASSWORD') } publish { version = System.getenv("PACT_CONSUMER_VERSION"); String strlist = System.getenv("PACT_TAGS"); List<String> list = strlist != null ? Arrays.asList(strlist.split(",")) : []; tags = list } serviceProviders { provider1 { verificationType = 'ANNOTATED_METHOD' // providerVersion = { 'main' } // providerTags = { ['main'] } fromPactBroker { selectors = latestTags('main') //filters out the contracts only with these tags to verify against } } } }``` I have validated that the environment variables have been set but when I run pactVerify I get the error ```Parameter specified as non-null is null: method au.com.dius.pact.provider.gradle.GradleProviderInfo.hasPactsFromPactBrokerWithSelectors, parameter pactBrokerUrl``` Any ideas? If I publish the contracts using pactPublish then it uploads to the broker fine

diva.pant1
2021-12-15 14:21
has joined #pact-jvm

mbailey
2021-12-15 16:33
I?m likely to miss the response in my flood of email, but I?ll give it a try, Just want the video, not nearly far enough for a demo yet.

johnreilly100
2021-12-15 16:36
has joined #pact-jvm

johnreilly100
2021-12-15 16:39
Are branch properties implemented in Consumer Version Selectors in version 4.3 of the jvm client provider library. I cant find much documentation about the 4.3 release

mbailey
2021-12-15 16:40
@uglyog I imported `au.com.dius.pact.provider:junit5spring:4.1.7` and am still not able to compile the `RestPactRunner` sample. Is that the wrong library, or does it appear in a later version? If you?re around, please advise.

elliot.weiser
2021-12-15 19:06
has joined #pact-jvm

mbailey
2021-12-15 19:29
General question about the jvm pact implementation: when I run provider tests, I?m finding it very hard to diagnose test failures - output sent from the test through println does not appear on the console, and debug statements are not hit. How do people track down issues?

matt.fellows
2021-12-15 22:02
are you using JUnit?

matt.fellows
2021-12-15 22:02
there should be an HTML report that is really easy to read

matt.fellows
2021-12-15 22:09
no email coming shortly?

uglyog
2021-12-15 23:17
Sorry, we crossed wires there. `junit5spring` contains the MockMVC support for JUnit 5. `RestPactRunner` is for JUnit 4 tests and is in the `junit` lib

uglyog
2021-12-15 23:21
I think everything should be case-sensitive.

uglyog
2021-12-15 23:21
When you mention the broker decapitalises the states, this is not in the returned pact file, but in the UI?

mbailey
2021-12-15 23:59
Thanks, I?ll try that. I didn?t realize the MockMvc api would be so different between them! What is the equivalent of RestPactRunner in junit5spring, while I?ve got it.

uglyog
2021-12-16 00:03
With JUnit 5, there is no test runner. It works with the JUnit 5 extension model. There is no equivalent.

mbailey
2021-12-16 00:04
I got it, thanks!

mbailey
2021-12-16 00:04
Yes, JUnit

mbailey
2021-12-16 00:05
Is there a reason to think that output would go to the report that does not go to the console? That has not been my experience with non-generated tests in general

mbailey
2021-12-16 00:05
But that?s just a workaround - what I really need is to be able to debug. Maybe have access to a dummy test being generated by the pact annotation

mbailey
2021-12-16 00:07
Sounds like I need to do some reading. Not that I?ll probably ever use JUnit 5, except for prototyping like this.

matt.fellows
2021-12-16 00:09
I?m not sure, I?m not a java/jvm expert, I just know as a consumer that it can be sometimes hard to see amongst all of the other logging noise

matt.fellows
2021-12-16 00:10
and the html report that is generated is the most helpful I?ve experienced

sunit
2021-12-16 07:27
has joined #pact-jvm

francislainy.campos
2021-12-16 13:49
Have you perhaps tried to hardcode the broker url rather than retrieving it from system.env pactBrokerUrl = System.getenv(?PACT_BROKER_URL?) to see what happens?


francislainy.campos
2021-12-16 13:50
I hardcoded a method to do turn the requests into curl which you can verify visually or through postman or any other api client. Maybe it?d be useful to you.

francislainy.campos
2021-12-16 13:55
You can also log the failures to a .md file by adding this annotation to the top of your provider. ```@VerificationReports(value = {"markdown"}, reportDir = "target/pacts")```

francislainy.campos
2021-12-16 13:56
As in ```@VerificationReports(value = {"markdown"}, reportDir = "target/pacts") public class PactProviderGcTest {```

francislainy.campos
2021-12-16 13:57
This would make the failures a bit easier to read. The file will generate under the same autogenerated target folder for pacts.

felipe.simoes
2021-12-16 18:42
has joined #pact-jvm

ameadewi
2021-12-16 18:48
has joined #pact-jvm

mbailey
2021-12-16 21:27
ooooh thanks @francislainy.campos!

mbailey
2021-12-16 21:29
The curl I mean - would be nice to debug the tests but this might get you to what the test is producing quick and would allow you to debug the server.

francislainy.campos
2021-12-16 21:30
Yes, but the annotation is one line only so you can easily do both.

mbailey
2021-12-16 21:35
2 general questions which I?m hoping have pretty simple answers: 1. What is the difference between `au.com.dius.pact.provider:junit5` and `au.com.dius.pact.provider:junit5spring`? `junit5` appears to have Spring support?. Sorry if this is in the documentation somewhere, I?m reading the https://github.com/pact-foundation/pact-jvm and I?m not able to tease that out. 2. I?m reading the https://github.com/pact-foundation/pact-jvm/tree/master/provider/gradle and there?s a point I?m confused about: I was able to get tests up and running, including broker checks, by simply creating a unit test. What is the section defined by `Define the pacts between your consumers and providers` for? It seems to be explicitly defining contracts, but that?s already done through either the broker, or configuration within the provider unit test. Maybe this is for running provider tests against a deployed service?

mbailey
2021-12-16 21:36
Maybe I?m confused, but the annotation looks like it will just output Pact?s own known data in its own format. I was looking for the option to log debug information for particular issues to the output. The curl doesn?t tell you *how* the test produced the json, but it sounds like it serves the same purpose

francislainy.campos
2021-12-16 21:38
yes, the annotation is not for the request but for better viewing the pact error messages.

francislainy.campos
2021-12-16 21:38
The SO post with the curl method will give you the request and response.

matt.fellows
2021-12-16 21:38
Very cool!

matt.fellows
2021-12-16 21:39
:taco: for @francislainy.campos

francislainy.campos
2021-12-16 21:39
It would be nice to have sth like this out of the box.

francislainy.campos
2021-12-16 21:39
I?ll give the code away for free if you guys would add that in. :wink:

uglyog
2021-12-16 22:18
1. `junit5spring` contains classes to support MockMVC and WebFlux. 2. You don't need to use the Gradle plugin if you are using unit tests. The Gradle plugin is for verifying a full running application.

mbailey
2021-12-16 23:46
Thank you! If you recall, I wasn?t able to get MockMVC running with junit5spring, but maybe that?s because the class names of the helpers have changed.

songqing.gu
2021-12-17 00:37
if In case of an application with both consumer and provider roles, when Can-i-deploy end point gets called, what will happen in Broker's logic?

michael.scheepers
2021-12-17 08:11
has joined #pact-jvm

rishabh.gaur
2021-12-17 13:03
I am getting below error on trying to write pact test for post api at consumer end. Please help on this:- ```500 Internal Server Error: [{ "error": "Unexpected request : \tmethod: POST\n\tpath: \/create-person\/\n\tquery: {}\n\theaders: {Accept-encoding=[gzip,deflate], Accept=[application\/json, application\/*+json], Connection=[Keep-A... (521 bytes)] org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Internal Server Error: [{ "error": "Unexpected request : \tmethod: POST\n\tpath: \/create-person\/\n\tquery: {}\n\theaders: {Accept-encoding=[gzip,deflate], Accept=[application\/json, application\/*+json], Connection=[Keep-A... (521 bytes)] at app//org.springframework.web.client.HttpServerErrorException.create(HttpServerErrorException.java:100) at app//org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:186) at app//org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:125)``` *Pact test methods:-* ```@Pact(consumer = "consumer_service1_post", provider = "producer_service_post") RequestResponsePact createUserPact(PactDslWithProvider builder) { PactDslJsonBody body = new PactDslJsonBody() .integerType("id", 1) .stringType("firstName", "Jon") .stringType("lastName", "Snow") .stringType("emailId", ""); PactDslJsonBody reqBody = new PactDslJsonBody() .stringType("firstName", "Jon") .stringType("lastName", "Snow") .stringType("emailId", ""); Map<String,String> headers = new HashMap(); headers.put("Content-Type","application/json"); return builder .given("Create person") .uponReceiving("Create person") .path("/create-person/") .body(reqBody) .method(HttpMethod.POST.name()) .willRespondWith() .status(HttpStatus.CREATED.value()) .headers(headers) .body(body) .toPact(); } @Test @PactTestFor(pactMethod = "createUserPact") void createUserUnitTest(MockServer mockServer) { /** * Below unit test will run again above mock provider */ RestTemplate restTemplate = new RestTemplateBuilder() .rootUri(mockServer.getUrl()) .build(); Person person = new Person(null, "Jon", "Snow", ""); Person person1 = new ConsumerService(restTemplate).triggerCreatePersonApi(person); assertEquals(person1.getFirstName(), "Jon"); }``` Service class method:- ```public Person triggerCreatePersonApi(Person person) { HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type","application/json"); HttpEntity<Person> request = new HttpEntity<>(person, headers); return restTemplate.postForObject("/create-person/", request, Person.class); }```

yanis.benekaa
2021-12-17 16:05
has joined #pact-jvm

brentbarker9
2021-12-17 21:35
Hi, have a question - do we know how long the `4.1.x` branch of the pact-jvm will be maintained?

uglyog
2021-12-18 22:37
It will be maintained as long as JDK 8 is used

uglyog
2021-12-18 22:42
If you have a look at the standard output you will see the reason why the request did not match

kamoljan
2021-12-19 01:58
Hi! Is it right channel for Android (Kotlin) case?

akhandalmani.malik
2021-12-19 20:30
Hi Team, I am trying to validate the below contract json with actual provider. But actually ACTION array key value pair list data is not in the same order from the actual response. Some times "empId": "EMP744" will be at index 1 and "empId": "EMP755", at index 0. I mean acton order key value can be change. Any Idea how to ignore list order comparision with respect to order. { "provider":{"name":"my_provider"}, "consumer":{"name":"my_consumer"}, "interactions":[ { "description": "GET REQUEST", "request": {"method": "GET", "path":"path" },"response":{ "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "id": "E200", "name": "xzk", "address": "Asia", "action": [ { "empId": "EMP744", "name": "MyCode1", "address": "mexico", "desc": "emp744 details", "pin": "453" }, { "empId": "EMP755", "name": "MyCode2", "address": "california", "desc": "EMP755 details", "pin": "763" }, { "empId": "EMP766", "name": "MyCode3", "address": "atlanta", "desc": "emp766 details", "pin": "342" } ] }, "providerStates":[ { "name": "test GET" } ]} }], "metadata":{ "pact-specification": { "version": "3.0.0" }, "pact-jvm": { "version": "3.5.10" } } }

uglyog
2021-12-19 22:06
There are new matching rules in 4.1.x that allow matching ignoring the order. You probably need the `arrayContains` matcher

akhandalmani.malik
2021-12-20 03:23
thank you uglyog for the quick support. in contract json file we need to have *arrayContains* matcher. Where exactly this code need to be implemented.

akhandalmani.malik
2021-12-20 03:23
?

dilek
2021-12-20 12:42
has joined #pact-jvm

brentbarker9
2021-12-21 00:03
Perfect, thank you!

akhandalmani.malik
2021-12-21 05:33
Any code snippet @uglyog...


sadhana.0203
2021-12-21 07:55
has joined #pact-jvm

adrian.ernst.lgln
2021-12-21 08:36
has joined #pact-jvm

akhandalmani.malik
2021-12-21 08:55
Went through the mentioned link. It is basically for consumer. Actually we have contract json file as above. We want to validate it with actual provider. anything we need to implement in PactProviderTest. Or we need to change contract json file?

dalton.pinto
2021-12-21 09:53
has joined #pact-jvm

andrerc
2021-12-21 15:28
*Dealing with hardcoded null element in array* I know that Pact doesn't support optional fields, but I have a scenario that I'm struggling to deal with. The endpoint returns a list of events and the first one (Welcome) has most of the fields null. It seems that the `arrayContaining` would work for me, but its only available on 4.2.X onward and currently my project is on java8, so I can't upgrade to it. Is there any way to ignore the first element of my array ? Sample json: ```{ "events": [ { "date": "22/04/2018", "someField": "-", "eventType": "TRANSACTION", "productName": "credit card", "nomeTransacao": "purchase", "awards": "47", "exchangeRate": "1.2", "value": 177.37, "icon": "1234" }, { // This element of the array is always returned, so I can't change the provider state to not return it "date": null, "someField": null, "eventType": "WELCOME", "productName": "Welcome to our app", "nomeTransacao": null, "awards": null, "exchangeRate": null, "value": null, "icon": "5432" } ] }```

roman.rutkowski.87
2021-12-21 15:42
has joined #pact-jvm

andrerc
2021-12-21 20:13
When I say first I actually meant last

matt.fellows
2021-12-21 23:49
Is it a variable list of ?events? and then always one at the end, or is the list of events always 2 like above?

matt.fellows
2021-12-21 23:50
I think if it?s a variable length array with the one at the end, the current matching rules won?t support that use case

matt.fellows
2021-12-21 23:50
you could use provider states to limit the number of events that are returned, and in your consumer test, expect the second element of the array to have those `null`ed fields

roman.rutkowski.87
2021-12-22 20:17
*PACT not matching array key names containing dots* I have a problem with matching keys containing dots when a value is an array of objects. Consider an endpoint /groups/{name} which returns this simple structure: ```{ "name": "testGroup", "registered.members": [ { "id": "28d7175c1cea9866" }, { "id": "8125aa2750636b9f" }, { "id": "1f280c16f5ee0471" } ] }``` I am creating PACT in Java: ```builder.given("testGroup exists") .uponReceiving("returns testGroup object") .path("/groups/testGroup") .method("GET") .willRespondWith() .status(200) .body(new PactDslJsonBody() .stringType("group.name", "testGroup") .eachLike("registered.members") .stringType("id") .closeObject() .closeArray() ) .toPact();``` And when I test this pact on the provider I get the following error: ```1) Verifying a pact between example-consumer-jvm and example-pact-dots - returns testGroup object has a matching body 1.1) body: $ Expected ['registered.members']=[{"id":"string"}] but was missing { - "['registered.members']": [ + "group.name": "testGroup", + "registered.members": [ { - "id": "string" + "id": "cf93c25952aee094" + }, + { + "id": "8422982ec1da4118" + }, + { + "id": "80d6ac38552e7b90" } - ], - "group.name": "testGroup" + ] }``` Am I doing something wrong here by using "eachLike" in this case? It works fine when I remove the dot from the "reigistered.member" key. The generated PACT looks like this: ```{ "provider": { "name": "example-pact-dots" }, "consumer": { "name": "example-consumer-jvm" }, "interactions": [ { "description": "returns testGroup object", "request": { "method": "GET", "path": "/groups/testGroup" }, "response": { "status": 200, "headers": { "Content-Type": "application/json; charset=UTF-8" }, "body": { "group.name": "testGroup", "['registered.members']": [ { "id": "string" } ] }, "matchingRules": { "body": { "$['group.name']": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$['registered.members']": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$['registered.members'][*].id": { "matchers": [ { "match": "type" } ], "combine": "AND" } }, "header": { "Content-Type": { "matchers": [ { "match": "regex", "regex": "application/json(;\\s?charset=[\\w\\-]+)?" } ], "combine": "AND" } } }, "generators": { "body": { "$['registered.members'][*].id": { "type": "RandomString", "size": 20 } } } }, "providerStates": [ { "name": "testGroup exists" } ] } ], "metadata": { "pactSpecification": { "version": "3.0.0" }, "pact-jvm": { "version": "4.1.24" } } }``` When I manually edit the PACT file and change "['registered.members']" to "registered.members" in response body then the PACT test on provider passes. Is there something wrong with pact generation, or am I misusing the DSL builder?

maxwell.xandeco
2021-12-22 21:43
has joined #pact-jvm

akhandalmani.malik
2021-12-23 05:43
I am following this link https://github.com/pactflow/example-siren and prepared the json like below: { "provider":{"name":"my_provider"}, "consumer":{"name":"my_consumer"}, "interactions":[ { "description": "GET REQUEST", "request":   {"method": "GET", "path":"path" },"response":{                 "status": 200,                 "headers": {                     "Content-Type": "application/json"                 }, "body": {    "id": "E200", "name": "xzk", "address": "Asia", "action": *arrayContaining(* { "empId": "EMP744", "name": "MyCode1", "address": "mexico", "desc": "emp744 details", "pin": "453" }, { "empId": "EMP755", "name": "MyCode2", "address": "california", "desc": "EMP755 details", "pin": "763" }, { "empId": "EMP766", "name": "MyCode3", "address": "atlanta", "desc": "emp766 details", "pin": "342" } *)* }, "providerStates":[                 {                     "name": "test GET"                 }                 ]} }], "metadata":{         "pact-specification": {             "version": "3.0.0"         },         "pact-jvm": {             "version": "3.5.10"         }     } }  but getting below error: 1) initializationError(com.ofss.verifyer.PactProviderTest) groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object The current character read is 'a' with an int value of 97 Unable to determine the current character, it is not a string, number, array, or object line number 25 index number 663 "action": arrayContaining( ..........^

uglyog
2021-12-23 05:54
That is the Pact file. It has to be valid JSON, you can't just edit it like that. That is what the error is saying, it is not valid ```Unable to determine the current character, it is not a string, number, array, or object line number 25 index number 663 "action": arrayContaining(```

uglyog
2021-12-23 05:54
You need to use the arrayContaining funciton in the consumer test.


lixiaoyan68
2021-12-23 06:50
has joined #pact-jvm

sashaavramchik
2021-12-23 09:07
has joined #pact-jvm

jamie.manson
2021-12-23 10:51
has joined #pact-jvm

colin.ansah
2021-12-23 13:21
has joined #pact-jvm

bruno855
2021-12-23 17:47
has joined #pact-jvm

appgify
2021-12-23 20:41
has joined #pact-jvm

jason329
2021-12-23 22:12
has joined #pact-jvm

shaheen.d2
2021-12-24 07:55
has joined #pact-jvm

laura.koekenberg
2021-12-24 10:32
has joined #pact-jvm

craiganthonyrichards
2021-12-25 05:01
has joined #pact-jvm

mch
2021-12-28 12:54
has joined #pact-jvm

florian.becker_pact-s
2021-12-28 14:49
has joined #pact-jvm

oblique
2021-12-28 18:45
has joined #pact-jvm

smalladi
2021-12-28 19:22
has joined #pact-jvm

jordan.nazemi
2021-12-28 19:24
has joined #pact-jvm

gbhusari
2021-12-28 21:22
has joined #pact-jvm

pghosh
2021-12-28 21:23
has joined #pact-jvm

smalladi
2021-12-28 21:44
Hi Team, I am working on Pact testing for the first time . We are using Spring boot provider and consumer applications. Provider seems to be working fine but Consumer is not generating pacts . I followed below github link for reference https://github.com/pact-foundation/pact-workshop-jvm-spring/tree/step11/consumer Error I am facing is Method does not conform required method signature 'public http://au.com.dius.pact.core.model.V4Pact xxx(PactBuilder builder)' java.lang.UnsupportedOperationException: Method does not conform required method signature 'public http://au.com.dius.pact.core.model.V4Pact xxx(PactBuilder builder)' at http://au.com.dius.pact.consumer.junit5.PactConsumerTestExt.lookupPact(PactConsumerTestExt.kt:338) at http://au.com.dius.pact.consumer.junit5.PactConsumerTestExt.setupMockServer(PactConsumerTestExt.kt:230) at http://au.com.dius.pact.consumer.junit5.PactConsumerTestExt.beforeTestExecution(PactConsumerTestExt.kt:215) Could you please provide inputs


smalladi
2021-12-28 22:47
Thank you

smalladi
2021-12-28 22:48
testException = http://au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: http://au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: method: GET path: / query: {} headers: {} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING

uglyog
2021-12-28 22:50
Did your test make that request?

carlos.agullo
2021-12-29 08:46
has joined #pact-jvm

cyrus.devnomad
2021-12-29 14:15
has joined #pact-jvm

smalladi
2021-12-29 15:36
yes

smalladi
2021-12-29 22:27
http://au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: method: GET path: / query: {} headers: {} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING at app<//au.com>.dius.pact.consumer.junit.JUnitTestSupport.validateMockServerResult(JUnitTestSupport.kt:110) at app<//au.com>.dius.pact.consumer.junit5.PactConsumerTestExt.afterTestExecution(PactConsumerTestExt.kt:468) at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterTestExecutionCallbacks$9(TestMethodTestDescriptor.java:233) at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$13(TestMethodTestDescriptor.java:273) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

smalladi
2021-12-29 22:27
Could you suggest how to get rid of the exception

uglyog
2021-12-29 22:29
Can you provide your test code

akhandalmani.malik
2021-12-30 09:10
Hi *https://app.slack.com/team/U5FCZAAUU*, Is there any implementation for pact-jvm consumer test for this list order issue?

smalladi
2021-12-30 14:29
import http://au.com.dius.pact.core.model.PactSpecVersion; import http://au.com.dius.pact.core.model.RequestResponsePact; import http://au.com.dius.pact.core.model.annotations.Pact; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import http://au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import http://au.com.dius.pact.consumer.junit5.PactTestFor; import http://au.com.dius.pact.consumer.MockServer; import http://au.com.dius.pact.consumer.dsl.PactDslWithProvider; import java.util.HashMap; import java.util.Map; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static http://org.hamcrest.Matchers.is; @SpringBootTest @ExtendWith(PactConsumerTestExt.class) @PactTestFor(pactVersion = PactSpecVersion.V3) //@PactTestFor(providerName = "ArticlesProvider", port = "1234", pactVersion = PactSpecVersion.V3) public class ConsumerServicePactTest { @Autowired private ConsumerService consumerService; // @Pact(consumer = "GPCPayments") @Pact(consumer = "GPCPayments", provider = "Example API") public RequestResponsePact giftcards(PactDslWithProvider builder) { System.out.println("Inside giftCards"); return builder .given("card exists") .uponReceiving("get all info") .path("/giftcard/").method("GET") //.matchHeader("Authorization", "Bearer [a-zA-Z0-9=\\+/]+", "Bearer AAABd9yHUjI=") .willRespondWith() .status(200) //.headers(headers()) .body( "Welcome to Giftcards Consumer Service" ) .toPact(); } @Test @PactTestFor(pactMethod = "giftcards") void testGiftcards() { System.out.println("Inside testGiftcards"); consumerService.setBaseUrl("http://localhost:8181/payments"); String result = consumerService.getConsumer(); System.out.println("result"); //assertThat(products, hasSize(2)); assertThat(result, is(equalTo("Welcome to Giftcards!"))); } }

smalladi
2021-12-30 14:30
I am just trying to test a sample Rest API from provider which returns a string message

smalladi
2021-12-30 14:32
Provider Rest API is below

smalladi
2021-12-30 14:32
`@GetMapping("/giftcard/")` public String welcomeGiftcard() { giftCardActivationService.startGiftCard(); return "Welcome to Giftcards!" ; }

muirandy
2021-12-30 17:57
has joined #pact-jvm

smalladi
2021-12-30 18:55
Can i get any reference for provider and consumer spring boot applications using pact

smalladi
2021-12-30 19:24
Hi Above is resolved for me

smalladi
2021-12-30 19:24
facing new issue , below is the pact code snippet

smalladi
2021-12-30 19:24
`@SpringBootTest` `@ExtendWith(PactConsumerTestExt.class)` `@PactTestFor(pactVersion = PactSpecVersion.V3)` `public class ConsumerServicePactTest {` `@Autowired` `private ConsumerService consumerService;` `@Pact(consumer = Example" provider = "Example API")` `public RequestResponsePact giftcards(PactDslWithProvider builder) {` `System.out.println("Inside giftCards");` `return builder` `.given("card exists")` `.uponReceiving("get all info")` `.path("/giftcard/").method("GET")` `.willRespondWith()` `.status(200)` `.body(` `"Welcome to Giftcards!"` `)` `.toPact();` `}` `@Test` `@PactTestFor(pactMethod = "giftcards")` `void testGiftcards(MockServer mockServer) {` `String expected = "Welcome to Giftcards!";` `RestTemplate restTemplate = new RestTemplateBuilder()` `.rootUri(mockServer.getUrl())` `.build();` `String result = new ConsumerService(restTemplate).getConsumer();` `assertEquals(expected, result);` `}` `}`

smalladi
2021-12-30 19:29
`@Service` `@Slf4j` `public class ConsumerService {` `private final RestTemplate restTemplate;` `@Autowired` `public ConsumerService(RestTemplate restTemplate) {` `this.restTemplate = restTemplate;` `}` `public String getConsumer() {` `return restTemplate.exchange("http://localhost:8181/payments/giftcard/",` `HttpMethod.GET,` `null,` `String.class).getBody();` `}` `}`

smalladi
2021-12-30 19:30
I/O error on GET request for "http://localhost:8181/payments/giftcard/": Connect to localhost:8181 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8181 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8181/payments/giftcard/": Connect to localhost:8181 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8181 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect at app//org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785)

uglyog
2021-12-30 22:13
That has port 8181 hardcoded in the getConsumer() method. Nothing will be listening on the port.

smalladi
2022-01-03 15:36
I have a provider service running on 8181

brocheleau
2022-01-03 21:23
@brocheleau has left the channel


rejeesh.g
2022-01-04 12:45
I have an API micro-services application which consumes response from an another application and same application provides response to another application. In such case is it possible to have junit tests to create pact contracts for consumer and verify pact contracts by provider in the same application. if i add maven dependency of provider in the same pom file , i am getting error while running consumer contract tests such "java.lang.NosuchMethoderror: http://au.com.dius.pact.core.support.json.JsonValue$Object.<init>(Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;).

uglyog
2022-01-04 22:23
You need to make sure you are using the same version of the pact libraries. You are probably mixing versions.

david.vancouvering
2022-01-05 00:03
Hi. I am looking at the settings for the Maven plugin. I see an overview here, but I can't find any detailed documentation for all the commands and properties of this plugin. Is there something you all can point me to? Also, I looked at the CLI and it's a lot more complicated than the Maven plugin. Is the Maven plugin going to continue to be supported? Is it open sourced?


david.vancouvering
2022-01-05 00:15
sweet thanks!

david.vancouvering
2022-01-05 00:15
Do you all plan to continue enhancing/supporting it?

david.vancouvering
2022-01-05 00:16
Oh, wait, this is the maven plugin for the provider. I'm looking for the maven plugin for the consumer. Or are they the same?

uglyog
2022-01-05 00:22
There is only one Maven plugin. On the consumer side, you just use it to publish the Pact files

uglyog
2022-01-05 00:22
It will be supported for as long as people are using it

david.vancouvering
2022-01-05 00:23
Thanks. I had just found that out by looking at the source. The source also helps me understand what properties are required for the consumer versus the provider

rejeesh.g
2022-01-05 05:07
ok sure let me check and get back to you

hocautomation
2022-01-05 09:54
has joined #pact-jvm

hocautomation
2022-01-05 10:33
~Hi All, I have a few questions want to ask about Pact, hope you can clear and correct me before use Pact in the project.~ 1. ~Can I run consumer test and provider test in the endpoint (specific IP address) because the client just provider the API for us?~

hocautomation
2022-01-05 10:41
Hi All, I have a few questions want to ask about Pact, hope you can clear and correct me before using Pact in the project. 1. Can I run consumer test and provider test in the endpoint (specific IP address) or have to use Mock because the client just provider the API for us? 2. Is possible to put the test case in excel file then run it into pact test? (like I do with rest assured to make the request) Thank you.

matt.fellows
2022-01-05 10:45
1. No for consumer, Yes for provider 2. No, unless you built it yourself

matt.fellows
2022-01-05 10:46
Pact is a unit testing tool, not a functional testing tool and is really designed for developers / use in development. See the FAQs at http://docs.pact.io

rejeesh.g
2022-01-05 11:44
Thanks uglyog your suggestion on using same version pact libraries worked.

deepakdaga2007
2022-01-05 17:49
has joined #pact-jvm

smalladi
2022-01-05 22:40
@uglyog From my Provider I am facing a issue

smalladi
2022-01-05 22:40
Provider state change callback failed java.lang.AssertionError: Provider state change callback failed

smalladi
2022-01-05 22:40
Could you please suggest

uglyog
2022-01-05 22:44
Have a look at your debug logs, it will contain the reason why your provider state callback failed

smalladi
2022-01-05 22:59
Caused by: http://au.com.dius.pact.provider.junitsupport.MissingStateChangeMethod: Did not find a test class method annotated with @State("") for Interaction "" with Consumer "PaymentsConsumer"

uglyog
2022-01-05 23:01
:point_up: there is your issue

uglyog
2022-01-05 23:02
BTW, having a provider state as the empty string makes no sense. You should not include any provider state instead

uglyog
2022-01-05 23:02
Also, your interaction description is empty

tomas.hornak
2022-01-05 23:49
has joined #pact-jvm

smalladi
2022-01-05 23:54
```"interactions": [ { "description": "", "providerStates": [ { "name": "" } ],```

smalladi
2022-01-05 23:54
name should not be blank right ?


smalladi
2022-01-05 23:57
how to add a value to provider state ?

uglyog
2022-01-05 23:57
It is created using the `given` method in the consumer test

smalladi
2022-01-05 23:58
```uponReceiving``` method can be blank ?

uglyog
2022-01-05 23:59
No, it needs to be a descriptive name for the interaction

smalladi
2022-01-06 00:15
Thank you

smalladi
2022-01-06 00:18
I am trying to given sample string in given, uponreceiving methods

smalladi
2022-01-06 00:18
{"error":"Cannot change the content of the pact for PaymentsConsumer version 0.0.1-SNAPSHOT and provider PaymentsProvider, as race conditions

smalladi
2022-01-06 00:18
do i need to change name of provider and consumer ?

uglyog
2022-01-06 00:20
Were are you getting that error from? Maybe do a clean before running anything

smalladi
2022-01-06 00:23
ya i did clean

smalladi
2022-01-06 00:23
Consumer side i added given , uponreeviing as sample string

smalladi
2022-01-06 00:25
```return builder .given("creation of giftcard") .uponReceiving("welcome to giftcards") .path("/payments/giftcard/").method("GET") //.headers(headers) .willRespondWith() .status(200) //.headers(headers()) .body("Welcome to Giftcards!") .toPact();```

uglyog
2022-01-06 00:26
Ok, but were is that error come from. It does not look like a Pact-JVM error

smalladi
2022-01-06 00:28
on pact publish i am getting the error

uglyog
2022-01-06 00:29
Change the consumer version

smalladi
2022-01-06 00:30
where do i change it ? on the broker or in the pactTest?

uglyog
2022-01-06 00:31
When you publish the pact file, it is getting 0.0.1-SNAPSHOT from somewhere

smalladi
2022-01-06 00:40
I gave new Consumer name and tried publishing

smalladi
2022-01-06 00:40
when i run provider pact , it still says same error

smalladi
2022-01-06 00:40
http://au.com.dius.pact.provider.junitsupport.MissingStateChangeMethod: Did not find a test class method annotated with @State("creation of giftcard") for Interaction "welcome to giftcards" with Consumer "PaymentsConsumerPact"

smalladi
2022-01-06 00:40
this time its not null

uglyog
2022-01-06 00:41
Good. Now add that method

smalladi
2022-01-06 00:42
which method you are suggesting

smalladi
2022-01-06 00:42
@State method ?


smalladi
2022-01-06 00:56
Added

smalladi
2022-01-06 00:56
```@State("creation of giftcard") public void giftCard() { // Do what you need to set the correct state }```

smalladi
2022-01-06 00:57
Verifying a pact between PaymentsConsumerPact and PaymentsProviderPact - welcome to giftcards: has status code 200 1.1) status: expected status of 200 but was 201 1.2) body-content-type: Expected a response type of 'text/plain' but the actual type was 'application/json'

uglyog
2022-01-06 01:02
Your consumer test expected a status of 200 with a text body, but your provider actually returned a 201 with a JSON body

smalladi
2022-01-06 01:03
It worked finally

smalladi
2022-01-06 01:03
Thank you so much for your help

uglyog
2022-01-06 01:03
You are welcome

juan.cruz
2022-01-06 02:44
has joined #pact-jvm

marconota.mac
2022-01-06 10:30
has joined #pact-jvm

marconota.mac
2022-01-06 10:34
@marconota.mac has left the channel

marta.rey-benito
2022-01-06 15:56
has joined #pact-jvm

fr4ngus
2022-01-06 16:20
has joined #pact-jvm

akhandalmani.malik
2022-01-07 07:12
Hi uglyog, Could you please guide us how to handle unordered array in pact-jvm?

akhandalmani.malik
2022-01-07 07:15
https://github.com/pact-foundation/pact-jvm/issues/506 We are facing similar issue, Is this issue resolved? Any sample json contract file with ignoring array order will be very much helpful?

huhuang
2022-01-08 05:28
has joined #pact-jvm

frankfullstack
2022-01-09 20:33
has joined #pact-jvm

gkrawczyszyn
2022-01-10 06:51
has joined #pact-jvm

tom.kelly
2022-01-10 15:05
has joined #pact-jvm

dave.sorenson
2022-01-10 15:51
has joined #pact-jvm

smalladi
2022-01-10 19:36
@uglyog If there are multiple consumers and provider is same , how do we define it in the provider pact ?

smalladi
2022-01-10 19:36
@PactBroker( host="pactbroker", port="80", consumerVersionSelectors={ @Consumer1(tag = "dev"), @Consumer2(tag = "prod", latest = "false") } )

smalladi
2022-01-10 19:36
Please let me know ideal way

smalladi
2022-01-10 19:36
or do we need to maintain separate pacts for each consumer separately

uglyog
2022-01-10 22:08
You don't define it in the provider pact. You create a provider test that will verify each Pact file for each consumer for the provider. The PactBroker annotation will cause all pacts for the provider to be fetched, and verify each one

smalladi
2022-01-10 23:27
is there any code reference ? above description is little confusing . If i understand correctly , Provider should have pact for each Consumer ?

smalladi
2022-01-10 23:27
In provider pact i am using ```@Provider("PaymentsProviderPact") @Consumer("PaymentsConsumerPact")``` so should we have separate pacts for each consumer

uglyog
2022-01-10 23:31
Yes, there will be a separate Pact for each consumer

smalladi
2022-01-10 23:41
ok.Thank you

gianni.araco
2022-01-11 16:13
has joined #pact-jvm

franklin.lucena89
2022-01-11 16:24
Hello guys, I'm having some issues with this dependency ```<!-- https://mvnrepository.com/artifact/au.com.dius.pact.provider/spring --> <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.2.1</version> </dependency>``` when I try to run my provider test, maven always throw me an error about there is no test to execute

franklin.lucena89
2022-01-11 16:26
this are my class annotations ```@WebMvcTest @ExtendWith(SpringExtension.class) @Provider("provider") @Consumer("consumer") @PactBroker @ActiveProfiles("test") @IgnoreNoPactsToVerify``` and this is how I'm writing my test ```@State("some state") void someTest(){ when(something).thenReturn(otherThing); }```

anu.johar
2022-01-11 20:25
has joined #pact-jvm

uglyog
2022-01-11 22:25
This ```@State("some state") void someTest(){ when(something).thenReturn(otherThing); }``` is the state change handler, not the test. You need to have an actual test to run.

yann.danot
2022-01-12 10:15
has joined #pact-jvm

yann.danot
2022-01-12 10:23
Hello guys, first of all thanks for your work it's really great

yann.danot
2022-01-12 10:26
Recently I discovered Pact and I wanted to use it on my project. Unfortunately, I'm working with Kotlin as language and Ktor as embedded server, and I did not find any workshop on your github repository

yann.danot
2022-01-12 10:27
That's why I did it myself, I copied your Java with Spring workshop and adapted it


yann.danot
2022-01-12 10:27
Feel free to check it and maybe copy it into your workshop repository on github

roman.rutkowski.87
2022-01-12 10:30
I worked around this by changing `eachLike` to `eachKeyMappedToAnArrayLike`, but that's not an ideal solution. It generates correct body: ``` "body": { "group.name": "testGroup", "registered.members": [ { "id": "string" } ] },``` but the matcher cathces wildcard instead of actual node name `"registered.members"`: ``` "matchingRules": { "body": { "$['group.name']": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.*": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.*[*].id": { "matchers": [ { "match": "type" } ], "combine": "AND" } },``` Ideally I'd want to have a body as created by `eachKeyMappedToAnArrayLike` and matching rules as created in original post with `eachLike`. Is there a way to achieve this with pact-jvm?

matt.fellows
2022-01-12 11:07
amazing!

matt.fellows
2022-01-12 11:08
If we can get a second pair of eyes over it, i?m sure we could add this to our list of workshops to help people out

yousafn
2022-01-12 11:49
Awesome work buddy, kudos to you for sharing back with the community! Wish you success in the journey of Kotlin & Pact :slightly_smiling_face:

yann.danot
2022-01-12 12:05
Tell me what to do, I'd be glad to participate.

smalladi
2022-01-12 18:00
@uglyog I am trying to do a maven version for consumer and facing body missing exception

smalladi
2022-01-12 18:00
http://au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: method: GET path: /payments/giftcard/ query: {} headers: {} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING at http://au.com.dius.pact.consumer.junit.JUnitTestSupport.validateMockServerResult(JUnitTestSupport.kt:110) at http://au.com.dius.pact.consumer.junit5.PactConsumerTestExt.afterTestExecution(PactConsumerTestExt.kt:468) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterTestExecutionCallbacks$9

smalladi
2022-01-12 18:00
Could you please guide

hsanghavi
2022-01-13 00:57
has joined #pact-jvm

vejeta
2022-01-13 03:19
has joined #pact-jvm

tjones
2022-01-13 04:16
Thanks for the link! I can't see the code - is the project public?

yann.danot
2022-01-13 09:17
arf sorry, the project should be available for everyone. Let me check

yann.danot
2022-01-13 09:19
can you try again please ?

yousafn
2022-01-13 09:47
Public now buddy! Thank you!

sweeneyrichard2
2022-01-13 15:43
has joined #pact-jvm

thuvu.se
2022-01-14 05:51
has joined #pact-jvm

rahul.meher
2022-01-14 09:02
has joined #pact-jvm

tjones
2022-01-14 13:27
Wow, @yann.danot!! This is a lot of work, and from a quick glance, it looks really good! Thank you so much!

tjones
2022-01-14 13:27
Would be keen to get @abubics to have a look at it (if you have the time), but I think it's definitely worth moving to the pact-foundation workshop examples


gavin.campbell
2022-01-14 17:31
has joined #pact-jvm

davideliu
2022-01-14 17:52
has joined #pact-jvm

matthew.drill
2022-01-14 18:53
Hi. What is the best practice for writing tests for a provider endpoint that can accept multiple parameter combinations? Should I add all the interactions in one fragment?

tjones
2022-01-15 05:25
What do you mean by fragment?

pavlo.sprogis
2022-01-16 17:15
has joined #pact-jvm

jbrady
2022-01-16 21:54
has joined #pact-jvm

uglyog
2022-01-16 22:19
(fragment == set of interactions for one test) If there are lots of optional values, try create a test with the largest surface area and then one with all the smallest.

johnathan
2022-01-17 04:42
has joined #pact-jvm

yann.danot
2022-01-17 10:24
You're welcome guys ! It was a pleasure to do it.

abubics
2022-01-17 10:34
Yeah, I love it :slightly_smiling_face: I've only had a skim, my initial feedback is: ? Comprehensive & cohesive <3 ? There are some formatting inconsistencies in the readme & code ? I was surprised to see some Java code in there :stuck_out_tongue: and some less idiomatic kotlin snippets (e.g. functions that only return the value of an expression) ? Also surprised to see a ktor front-end talking to a ktor back-end. I might be a little worried of confusing people in the workshop, but maybe it has the opposite effect, maintaining consistency and less to learn.

yann.danot
2022-01-17 11:12
Thanks for the feedback, i'll fix the inconsistencies and the java code :stuck_out_tongue_winking_eye:

yann.danot
2022-01-17 11:12
Can you be more precise on these "less idiomatic kotlin snippets" ?

yann.danot
2022-01-17 11:13
And for the kotlin front-end, I just forked the java with spring workshop which is with a java frontend and java backend

abubics
2022-01-17 12:58
right, that makes sense :slightly_smiling_face: and it's going to be good for the docs to have more consistent examples between them (like this!)

abubics
2022-01-17 12:59
about to go to bed, but I can share a few more specific examples tomorrow :thumbsup:

yann.danot
2022-01-17 13:00
It should be better for formatting and java code issues by tomorrow. Thanks again for feedback and have a good night !

dimakos.neoklis
2022-01-17 15:04
has joined #pact-jvm

gueorgui
2022-01-17 16:43
has joined #pact-jvm

marcbetts
2022-01-17 22:35
has joined #pact-jvm

lambat.ishanya
2022-01-18 05:10
has joined #pact-jvm

lambat.ishanya
2022-01-18 05:46
@matt.fellows Hi Matt I am doing POC on writing Pact contract on CICD using Gitlab API alos I want a Spec validation along with pact So I was just asking is there any provision for spec validation in Pactflow along with using pact?

matt.fellows
2022-01-18 05:47
I?ve answered in your other thread Ishanya

lambat.ishanya
2022-01-18 05:48
i was asking that is there any feature provided by pactflow foe Schema validation



sprathi
2022-01-18 13:40
has joined #pact-jvm

emanuela.ceuta
2022-01-18 16:25
has joined #pact-jvm

chaugule.sandeep
2022-01-19 05:00
has joined #pact-jvm

ajay.kawde
2022-01-19 13:34
has joined #pact-jvm

ajay.kawde
2022-01-19 13:35
hi Folks

ajay.kawde
2022-01-19 13:36
can the pact verification be done without hosting provider service

ajay.kawde
2022-01-19 13:43
i am trying to run publish verification result stage in my gitlab pipeline

gjourdanweil
2022-01-19 19:39
You can verification against a provider started locally from unit tests. Exact steps will vary depending on your framework

matt.fellows
2022-01-19 20:23
Yes you would usually run the service locally and bit against a fixed test environment (one of the reasons pact exists is to reduce this reliance)

liam.chen
2022-01-19 21:19
has joined #pact-jvm

taylor.phillips01
2022-01-19 21:45
has joined #pact-jvm

abubics
2022-01-19 23:39
Yep, as mentioned in the other thread, this is the intended workflow :ok_hand:

sandeepa.kv
2022-01-20 06:46
has joined #pact-jvm

shane.dombowsky
2022-01-20 14:08
has joined #pact-jvm

jlbrown
2022-01-20 15:29
has joined #pact-jvm

gabriel.fatori
2022-01-20 18:36
has joined #pact-jvm

petersonbtah
2022-01-20 20:16
has joined #pact-jvm

petersonbtah
2022-01-20 20:29
Hello, just joined, I would like to make sure I am communicating properly...

petersonbtah
2022-01-20 20:50
Thanks for the response...

petersonbtah
2022-01-20 20:51
Hoping I might be able to get a little direction. I'm new to using pact but I have written a consumer side test to generate a contract.

petersonbtah
2022-01-20 21:00
I am now working on the provider side and am running into a few questions. I am no longer going to be using the consumer side, I just set it up to generate the contract so now I am all on the provider side. I have a couple questions but I'll start with this one: In my contract if I include the following in my interaction: "providerState": "it has a document", my state method defined as the following gets called properly: @State(value = "it has a document") public Map<String, String> hasDocState() { Map<String, String> valMap = new HashMap<String, String>(); valMap.put("customerId", "2"); valMap.put("docId", "imanagedbbob01!1627.1"); return(valMap); } However, if I instead include the following in my contract file, the state method does not get called: "providerStates": [ { "name":"it has a document" } ] I keep running across the providerStates syntax in multiple examples. So I am wonder if I might be using the wrong version of an artifact.

llast
2022-01-20 21:44
has joined #pact-jvm

matt.fellows
2022-01-20 23:27
IT would be helpful to know what versions of the libraries you are using on both side, as well as seeing your code setup (on both sides)

matt.fellows
2022-01-20 23:27
Also, if you can please use the code formatter to make it easier to read, that would be helpful to

devesh.mishra
2022-01-21 04:26
has joined #pact-jvm

devesh.mishra
2022-01-21 05:08
hey everyone, i have created a test case on the consumer side in *Bazel* project i have added the dependencies needed for test case but on running the test no pact file is generated, i think we have to add the corresponding plugin in the *Bazel* project in order to create the pact file after test run, is there any way we can add this plugin in Bazel project? ```<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <pact.rootDir>target/mypacts</pact.rootDir> </systemPropertyVariables> </configuration> ... </plugin>```

viveksingh.kiit
2022-01-21 09:29
has joined #pact-jvm

viveksingh.kiit
2022-01-21 09:58
@viveksingh.kiit has left the channel

james.demaine
2022-01-21 10:02
has joined #pact-jvm

michael.branders
2022-01-21 13:49
Is there an V4 Pact example available like this for V3: https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit5/src/test/java/au/com/dius/pact/consumer/junit5/AsyncMessageTest.java ? Is there a wat to make a builder.toPact() give a MassagePact V4? Seems there is only a V4Pact and no V4MessagePact

petersonbtah
2022-01-21 15:29
Matt, you mention "both sides", I am assuming you mean consumer and provider. Just to reiterate, I am no longer doing anything with the consumer. Strictly working with the provider. I set up a consumer to generate a contract but will no longer be using the consumer. My goal is to generate a set of contracts somehow (maybe manually) and use those contracts for a provider test only. I understand that goes against the grain of contract testing but that is my objective. Unless I am missing some foundational knowledge (which is very possible) I do not want a consumer involved in any way at this point. Here is my pom file information ``` <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.3.0</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.5.2</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.5.2</version> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-junit5</artifactId> <version>4.0.10</version> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit</artifactId> <version>4.0.10</version> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit5</artifactId> <version>4.0.10</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M5</version> <configuration> <useSystemClassLoader>false</useSystemClassLoader> <forkMode>never</forkMode> </configuration> </plugin> </plugins>``` Here is my java code for the provider verification side ```package testWorkContract; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.testng.annotations.Test; import au.com.dius.pact.provider.junit.loader.PactFolder; import au.com.dius.pact.core.model.Interaction; import au.com.dius.pact.core.model.Pact; import au.com.dius.pact.core.model.RequestResponseInteraction; import au.com.dius.pact.provider.junit.Provider; import au.com.dius.pact.provider.junit.State; import au.com.dius.pact.provider.junit.StateChangeAction; import au.com.dius.pact.provider.junit5.HttpsTestTarget; import au.com.dius.pact.provider.junit5.PactVerificationContext; import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; @Provider("work") @PactFolder("/temp/pacts") public class PactProviderTest { @BeforeAll static void providerSetup() { System.out.println("BEFORE ALL CALLED FOR PROVIDER SETUP*******************************************"); } @AfterAll static void providerTeardown() { System.out.println("AFTER ALL CALLED FOR PROVIDER TEARDOWN*******************************************"); } @BeforeEach void before(PactVerificationContext context, Pact pact, Interaction inter) { System.out.println("\n\nBEFORE EACH TEST ***"); context.setTarget(new HttpsTestTarget("localhost", 443, "/", true)); } @AfterEach void after(PactVerificationContext context, Pact pact, Interaction inter) { System.out.println("AFTER EACH TEST ***************"); } @State(value = "it has a document") public Map<String, String> hasDocState(Map<String, String> p_map) { Map<String, String> valMap = new HashMap<String, String>(); valMap.put("customerId", "2"); valMap.put("docId", "imanagedbbob01!1627.1"); return(valMap); } @State(value = "it has a document", action = StateChangeAction.TEARDOWN) public void hasDocStateTD() { System.out .println("HAS DOCUMENT STATE TEARDOWN CALLED ***"); } @State({ "document doesnt exist" }) public void docDoesntExistState() { System.out .println("DOCUMENT DOESNT EXIST STATE CALLED ***"); } @Test @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context, Pact pact, Interaction inter) { System.out.println("TEST *****************************************************************"); context.verifyInteraction(); } }``` And just for completeness, here is my contract ```{ "consumer": { "name": "consumer1" }, "provider": { "name": "work" }, "interactions": [ { "description": "a request to checkout document", "request": { "method": "POST", "path": "work/api/v2/customers/${customerId}/libraries/imanagedbbob01/documents/${docId}/checkout", "headers": { "Host": "localhost", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive", "X-Auth-Token": "XXXXXXXXXX", "Content-Type": "application/json" }, "body": { "appname" : "pdfDocs", "comments": "test.", "due_date": "2018-08-18T04:46:00Z" } }, "response": { "status": 200, "headers": { } }, "providerStates": [ { "name":"it has a document" } ] }, { "description": "a request to checkin document", "providerState": "it has a document", "request": { "method": "DELETE", "path": "work/api/v2/customers/${customerId}/libraries/imanagedbbob01/documents/${docId}/lock", "headers": { "Host": "localhost", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive", "X-Auth-Token": "XXXXXXX", "Content-Type": "application/json" } }, "response": { "status": 200, "headers": { } } } ], "metadata": { "pactSpecification": { "version": "2.0.0" } } }``` The second question I was going to ask involves injecting dynamic values in the "request" information before the interaction is verified. In my contract file as parth of the path I have a few fields defined as: $(customerId} and ${docId} From the documentation I am reading I am getting the impression that if your state method returns a map of those as keys and you provide values for them then they will be substituted before the interaction is ran. But that is not working either so I just have some basic misunderstanding of how this functionality works. Hopefully your still with me... Thanks

theferryatbuckland
2022-01-21 20:24
has joined #pact-jvm

matt.fellows
2022-01-21 21:19
The pact file looks wrong to me, which is why I was asking about your consumer test. Don't generate this by hand, that is not recommended

matt.fellows
2022-01-21 21:19
I can't see how it would work at this time

matt.fellows
2022-01-21 21:20
I think you're juggling too many things at once. Try making a very basic test that just makes a single get request with no parameter injection. Once that's working you can add in complexity

matt.fellows
2022-01-21 21:20
This will also make it easier to get help because your questions will be more targeted

petersonbtah
2022-01-21 23:19
I do have the basic test working. The provider code will process the contract, execute the calls against the provider, and pass the tests. I am now in the stage of adding complexity. So for your response of making a very basic test work, that is done. The pact file was generated by a consumer test. I do have a consumer test that runs and generates the contract file. So again, the basic of setup of having a consumer test run that generates a contract file and then having the provider side verify the contract, works. All basic aspects of the provider verification work. I just solved the issue of the provider state not being called if I specify it like: ``` "providerStates": [ { "name":"it has a document" } ]``` In the contract I changed: ``` "metadata": { "pactSpecification": { "version": "2.0.0" } }``` to be version 3 ``` "metadata": { "pactSpecification": { "version": "3.0.0" } }``` So at this point, the outstanding question is: Is it possible to have the contract file use something like this: ``` "path": "work/api/v2/customers/${customerId}/libraries/imanagedbbob01/documents/${docId}/checkout",``` where ${customerId} and ${docId} can be substituted with real data at the time the interaction is ran? I thought I was reading you could do that via the state method by doing something like: ``` @State(value = "it has a document") public Map<String, String> hasDocState(Map<String, String> p_map) { Map<String, String> valMap = new HashMap<String, String>(); valMap.put("customerId", "2"); valMap.put("docId", "imanagedbbob01!1627.1"); System.out.println("HAS DOCUMENT STATE CALLED*********************************************************"); return(valMap); }``` by returning a map of the keys and values that you want to substitute.

matt.fellows
2022-01-22 00:29
I'm confused though, it looks like you're modifying the pact file by hand. Are you saying you have generated this by code? I'm sceptical because you're talking about modifying metadata, and the paths don't look correct

matt.fellows
2022-01-22 00:31
You're correct in the provider state handlers that you can inject values, but you need to use the appropriate consumer side DSL methods to generate a correct pact file

david.kormushoff
2022-01-22 00:54
has joined #pact-jvm

petersonbtah
2022-01-22 02:06
I don't think I am making myself clear. The original pact file was in fact totally generated from a consumer side test. 100% as a result of the consumer test. I am now adding complexity to my test as I indicate below. Because of the nature of the data I am testing against I have to modify the contract. The data is constantly changing so if I generate a pact with a particular data set (for example an ID), it will be a different ID the next time I want to run the provider test. I do not want to rerun the consumer side to generate another pact file. I understand you might not agree with what I am trying to do and that it goes against the contract testing concept but I would like to be able to take a pact file that was generated some time in the past and run it against my provider. And in between the generation of the original pact file and when I want to run it now, all the data in the system has changed. I am not starting with a known data set. Therefore it would be impossible for me to know what is going to be in the data set when I run the provider test. I have no control over how the IDs of some of the data are generated, for sake of discussion, it is random. Therefore, when I run the provider test I will first need to find out the valid data in the system, then I would need to modify the pact file to include those random data values, then I can execute the contract test on the provider side. You are correct in that it looks like I have manually modified the pact file. That is because I am trying to figure out how to substitute the new data values in a previously generated pact. So for example, in my "path" you will see something like .../${customerId}/... When I original generated the pact file it actually looked like .../1/... But now the value could be 2, 22, xyz, 1233324azdlfjk,... So when I want to run the test I need to make that substitution in the pact file and then run the test. I am trying to find out if there is a mechanism to help with that substitution. I am going to stop because I am becoming too verbose and am going to lose you from boredom...

petersonbtah
2022-01-22 02:12
but I do sincerely appreciate your response

uglyog
2022-01-22 02:32
V4 pacts can have both message and HTTP interactions. There is no separate V4MessagePact

matt.fellows
2022-01-23 02:34
hahah

matt.fellows
2022-01-23 02:34
thanks for the detail

matt.fellows
2022-01-23 02:34
It makes sense

matt.fellows
2022-01-23 02:34
I?m just saying, editing it by hand gets complicated - this is an example of that

matt.fellows
2022-01-23 02:35
most people here won?t be able to tell you how to manually edit a Pact file with the correct serialisation of matching rules, generators etc. - they required detailed and advanced knowledge of how pact writes these out depending on versions of the pact specfiication etc.

matt.fellows
2022-01-23 02:35
It?s usually better to modify the consumer pact tests.

matt.fellows
2022-01-23 02:35
But let?s assume you want to modify by hand for now

matt.fellows
2022-01-23 02:37
The correct syntax for the feature you?re talking about is a `ProviderStateGenerator` in the v4 specification (ref: https://github.com/pact-foundation/pact-specification/tree/version-4#supported-generators)

matt.fellows
2022-01-23 02:38
They get stored in the `generators` attribute of a Request (ref: https://github.com/pact-foundation/pact-specification/tree/version-4#request)


matt.fellows
2022-01-23 02:46
Here is an example pact file that uses expressions: ```{ "consumer": { "name": "TransactionService" }, "interactions": [ { "description": "a request to get the account details", "providerStates": [ { "name": "Account Test001 exists", "params": { "accountRef": "Test001" } } ], "request": { "generators": { "query": { "$.accountNumber[0]": { "expression": "${accountNumber}", "type": "ProviderState" } } }, "headers": { "Accept": "application/hal+json" }, "matchingRules": { "header": {}, "query": { "$.accountNumber[0]": { "combine": "AND", "matchers": [ { "match": "type" } ] } } }, "method": "GET", "path": "/accounts/search/findOneByAccountNumberId", "query": { "accountNumber": [ "100" ] } }, "response": { "body": { "_links": { "account": { "href": "http://localhost:8080/accounts/100" }, "self": { "href": "http://localhost:8080/accounts/100" } }, "accountNumber": { "id": 100 }, "accountRef": "Test001", "createdDate": "2017-12-04T14:47:18.582Z", "id": 1, "lastModifiedDate": "2017-12-04T14:47:18.582Z", "name": "Test", "version": 0 }, "generators": { "body": { "$.accountNumber.id": { "expression": "${accountNumber}", "type": "ProviderState" } } }, "headers": { "Content-Type": "application/hal+json" }, "matchingRules": { "body": { "$._links.account.href": { "combine": "AND", "matchers": [ { "match": "regex", "regex": ".*(\\/accounts\\/\\d+)$" } ] }, "$._links.self.href": { "combine": "AND", "matchers": [ { "match": "regex", "regex": ".*(\\/accounts\\/\\d+)$" } ] }, "$.accountNumber.id": { "combine": "AND", "matchers": [ { "match": "type" } ] }, "$.accountRef": { "combine": "AND", "matchers": [ { "match": "type" } ] }, "$.createdDate": { "combine": "AND", "matchers": [ { "match": "timestamp", "timestamp": "yyyy-MM-dd'T'HH:mm:ss.SSSX" } ] }, "$.id": { "combine": "AND", "matchers": [ { "match": "integer" } ] }, "$.lastModifiedDate": { "combine": "AND", "matchers": [ { "match": "timestamp", "timestamp": "yyyy-MM-dd'T'HH:mm:ss.SSSX" } ] }, "$.name": { "combine": "AND", "matchers": [ { "match": "type" } ] }, "$.version": { "combine": "AND", "matchers": [ { "match": "integer" } ] } }, "header": {} }, "status": 200 } }, { "description": "a request to get the account details via POST", "providerStates": [ { "name": "Account Test001 exists", "params": { "accountRef": "Test001" } } ], "request": { "body": { "accountNumber": 100 }, "generators": { "body": { "$.accountNumber": { "expression": "${accountNumber}", "type": "ProviderState" } } }, "headers": { "Accept": "application/hal+json", "Content-Type": "application/json" }, "matchingRules": { "body": { "$.accountNumber": { "combine": "AND", "matchers": [ { "match": "type" } ] } }, "header": {} }, "method": "POST", "path": "/accounts/search/findOneByAccountNumberIdInBody" }, "response": { "body": { "_links": { "account": { "href": "http://localhost:8080/accounts/100" }, "self": { "href": "http://localhost:8080/accounts/100" } }, "accountNumber": { "id": 100 }, "accountRef": "Test001", "createdDate": "2017-12-04T14:47:18.582Z", "id": 1, "lastModifiedDate": "2017-12-04T14:47:18.582Z", "name": "Test", "version": 0 }, "generators": { "body": { "$.accountNumber.id": { "expression": "${accountNumber}", "type": "ProviderState" } } }, "headers": { "Content-Type": "application/hal+json" }, "matchingRules": { "body": { "$._links.account.href": { "combine": "AND", "matchers": [ { "match": "regex", "regex": ".*(\\/accounts\\/\\d+)$" } ] }, "$._links.self.href": { "combine": "AND", "matchers": [ { "match": "regex", "regex": ".*(\\/accounts\\/\\d+)$" } ] }, "$.accountNumber.id": { "combine": "AND", "matchers": [ { "match": "type" } ] }, "$.accountRef": { "combine": "AND", "matchers": [ { "match": "type" } ] }, "$.createdDate": { "combine": "AND", "matchers": [ { "match": "timestamp", "timestamp": "yyyy-MM-dd'T'HH:mm:ss.SSSX" } ] }, "$.id": { "combine": "AND", "matchers": [ { "match": "integer" } ] }, "$.lastModifiedDate": { "combine": "AND", "matchers": [ { "match": "timestamp", "timestamp": "yyyy-MM-dd'T'HH:mm:ss.SSSX" } ] }, "$.name": { "combine": "AND", "matchers": [ { "match": "type" } ] }, "$.version": { "combine": "AND", "matchers": [ { "match": "integer" } ] } }, "header": {} }, "status": 200 } }, { "description": "a request to get the plain data", "providerStates": [ { "name": "set id", "params": { "id": "42" } } ], "request": { "generators": { "path": { "expression": "/data/${id}", "type": "ProviderState" } }, "matchingRules": { "path": { "combine": "AND", "matchers": [ { "match": "type" } ] } }, "method": "GET", "path": "/data/42" }, "response": { "body": "data: testData, id: 42", "headers": { "Content-Type": "text/plain; charset=utf-8" }, "status": 200 } } ], "metadata": { "pact-js": { "version": "10.0.0-beta.54" }, "pactRust": { "ffi": "0.1.6", "mockserver": "0.8.7", "models": "0.2.7" }, "pactSpecification": { "version": "3.0.0" } }, "provider": { "name": "AccountService" } }```

matt.fellows
2022-01-23 02:46
This example uses them on the body, path and query of the request - hopefully that will help

matt.fellows
2022-01-23 02:51
> I keep running across the providerStates syntax in multiple examples. So I am wonder if I might be using the wrong version of an artifact. back to this. This is one of the reasons why editing it by hand is fraught with problems. If your consumer library and provider library use the same `major.minor.z` versions, they will know how to communicate via the contract. But editing it by hand without context of the serialisation formats, the version of the spec you?re generating and are able to verify will result in strange behaviour.

petersonbtah
2022-01-23 03:02
Thanks for the response. I will be back on this Monday. Appreciate your time. Although something is not make sense to me. Well, a lot things don't make sense to me, but that is a different issue... You mention multiple times about going back to the consumer side. Not sure what that could possibly have to do with my provider test given that I have no idea what data is available to my provider until I actually run the provider test. In fact, as part of my provider test I will be creating any data that is available in the system. It will be completely unknown from the consumer side because I might have ran the consumer side a month ago to generate the contract. So when I run the provider test I will create the individual database records the provider test will use. Therefore, the consumer side is irrelevant, right?

matt.fellows
2022-01-23 03:23
You?re welcome! > Therefore, the consumer side is irrelevant, right? no, the consumer side is responsible for testing the consumer _and_ creating the assertions for the provider side. This is where the generators are specified (generators are the general name for the feature you are wanting to use) > Not sure what that could possibly have to do with my provider test The provider tests are created by the consumer, so it?s very relevant. In fact, any tests not generated by the consumer, by very definition, won?t be a contract test

matt.fellows
2022-01-23 03:25
i.e. when you use https://docs.pact.io/implementation_guides/jvm/consumer/junit5#having-values-injected-from-provider-state-callbacks, it will serialise the correct matchers/generators into the pact file, so that when the provider test runs, it can inject the correct IDs/whatever into the test.

matt.fellows
2022-01-23 03:25
The consumer doesn?t need to know the correct ID anymore, which I think is what you want

matt.fellows
2022-01-23 03:29
So just in case I?m not clear. I?m not saying the consumer test and provider tests need to run together/in the same pipeline (that?s definitely not recommended). But more generally, the contract captures the intent of what a consumer needs of a provider. Sometimes these are exact values, but generally not. You can usually work around this with the use of provider states (see the docs on that). But in some cases, even provider states can?t help - this is the case with autogenerated IDs etc. So the feature you want (linked above) works around this with an expression language. The expressions still must be defined in the consumer test, even though the data is dynamically substituted later on in the provider test

petersonbtah
2022-01-23 03:45
THank you. I'll see where I can get with this. Appreciate it.

petersonbtah
2022-01-23 03:49
I think I am realizing I just don't really understand the fundamentals.

matt.fellows
2022-01-23 09:16
We have a few tutorials/workshops that might help

matt.fellows
2022-01-23 09:16
Howtolearn

2022-01-23 09:16
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

devesh.mishra
2022-01-24 05:38
hey @josh.rosenfeld, i have implemented the Consumer driven Contract Testing in my bazel project on consumer side my test cases are running fine but the issue is that no pact file is getting generated, if you have faced the issue how we resolved it? (https://pact-foundation.slack.com/archives/C9UN99H24/p1642741695047100)

michael.branders
2022-01-24 07:45
That i know. My Question realy is what in the V3 example needs to change so its a V4 example. I can't just change out Message with V4Pact can i? This just doesnt work: ```@ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "wg-sector-service", providerType = ProviderType.ASYNCH) class ParitairComiteChangedEventContractTest { public static final String PARITAIR_COMITE_ID = "01234567890123456789012345678901"; @Pact(consumer = "dimona-service") V4Pact paritairComiteChangedEventPact(MessagePactBuilder builder) { PactDslJsonBody body = new PactDslJsonBody(); body.stringMatcher("id", "^[a-zA-Z0-9]{32}$", PARITAIR_COMITE_ID); Map<String, Object> metadata = new HashMap<>(); metadata.put("Content-Type", "application/json"); return builder .expectsToReceive("valid ParitairComiteChangedEvent from wg-sector-service") .withMetadata(metadata) .withContent(body) .toPact(V4Pact.class); } @Test @PactTestFor(pactMethod = "paritairComiteChangedEventPact") void test(List<Message> messages) { assertThat(new String(messages.get(0).contentsAsBytes()), is("{\"id\":\"" + PARITAIR_COMITE_ID + "\"}")); } }```

michael.branders
2022-01-24 07:52
This works but then it is V3 and i want a V4 Pact: ```@ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "wg-sector-service", providerType = ProviderType.ASYNCH, pactVersion = PactSpecVersion.V3) class ParitairComiteChangedEventContractTest { public static final String PARITAIR_COMITE_ID = "01234567890123456789012345678901"; @Pact(consumer = "dimona-service") MessagePact paritairComiteChangedEventPact(MessagePactBuilder builder) { PactDslJsonBody body = new PactDslJsonBody(); body.stringMatcher("id", "^[a-zA-Z0-9]{32}$", PARITAIR_COMITE_ID); Map<String, Object> metadata = new HashMap<>(); metadata.put("Content-Type", "application/json"); return builder .expectsToReceive("valid ParitairComiteChangedEvent from wg-sector-service") .withMetadata(metadata) .withContent(body) .toPact(); } @Test @PactTestFor(pactMethod = "paritairComiteChangedEventPact") void test(List<Message> messages) { assertThat(new String(messages.get(0).contentsAsBytes()), is("{\"id\":\"" + PARITAIR_COMITE_ID + "\"}")); } }```

roman.rutkowski.87
2022-01-24 09:48
@roman.rutkowski.87 has left the channel

michael.branders
2022-01-24 10:50
@uglyog is there a way to generate a V4 pact with MessagePactBuilder. My rest pacts are V4 so i need these tests to be V4 as well or they dont merge and i get errors. It would be a shame to downgrade my rest pacts from V4 to V3 because my async test cant be V4.

michael.branders
2022-01-24 15:24
I found a solution

michael.branders
2022-01-24 15:24
```@ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "wg-sector-service", providerType = ProviderType.ASYNCH) class ParitairComiteChangedEventContractTest { public static final String PARITAIR_COMITE_ID = "01234567890123456789012345678901"; @Pact(consumer = "dimona-service") V4Pact paritairComiteChangedEventPact(PactBuilder builder) { PactDslJsonBody body = new PactDslJsonBody(); body.stringMatcher("id", "^[a-zA-Z0-9]{32}$", PARITAIR_COMITE_ID); Map<String, Object> metadata = new HashMap<>(); metadata.put("Content-Type", "application/json"); return builder.usingLegacyMessageDsl() .expectsToReceive("valid ParitairComiteChangedEvent from wg-sector-service") .withMetadata(metadata) .withContent(body) .toPact(); } @Test @PactTestFor(pactMethod = "paritairComiteChangedEventPact") void test(V4Pact pact) { V4Interaction.AsynchronousMessage message = (V4Interaction.AsynchronousMessage) pact.getInteractions() .stream().filter(i -> i instanceof V4Interaction.AsynchronousMessage).findFirst().get(); assertThat(message.getContents().getContents().valueAsString(), is("{\"id\":\"" + PARITAIR_COMITE_ID + "\"}")); } }```

uglyog
2022-01-24 21:51
Yes, that's the way to do it. I think you can also inject the messages if you don't want the whole pact class

petersonbtah
2022-01-24 23:04
Thanks Matt, I was able to piece together the functionality to inject the dynamic data into the path. And just to let you know, I have read post after post and article after article about contract testing. So I am not just throwing questions out there without doing due-diligence on my part. I have been in the development arena for a long time and feel like I just walked out of comp sci school when it comes to this... Anywho... So what are the thoughts on this scenario: A client creates a customer A client deletes a customer The response body from the create customer call includes the new customer id. Which for discussion sake is a random value and can not be known up front. The only time it is know is when the response body from the create call is look at. Now I want to write the contract test for the client delete. The client delete call has to include the customer id that was returned in the response body from the customer create call. So if I am following the previous messages, the client delete call in the contract can use a generator to update the call with a customer id. The problem is the customer ID is dynamic based on the customer create call. I suspect what you are going to respond with is something like: The delete can't rely on the response from the create. But what should happen is the test for the delete should rely on a generator that is populated in the provider state for the delete. The provider state for the delete should do what it needs to in order to create the customer. (I might have messed up some terms there...)

tom.tantisalidchai
2022-01-25 05:43
has joined #pact-jvm

michael.branders
2022-01-25 07:10
Ow yes that works as well thanks for that tip.

pavlo.sprogis
2022-01-25 13:19
hi all, does anyone know how to fix this error: ```WARN [13:31:46] [main] a.c.d.p.p.j.l.PactBrokerLoader Failed to instantiate the value resolver, using the default java.lang.IllegalAccessException: class au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader cannot access a member of class au.com.dius.pact.core.support.expressions.SystemPropertyResolver with modifiers "private" at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361) at java.base/jdk.internal.reflect.Reflection.ensureMemberAccess(Reflection.java:99) at java.base/java.lang.Class.newInstance(Class.java:579) at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.setupValueResolver(PactBrokerLoader.kt:168) at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:99) at au.com.dius.pact.provider.junit.PactRunner.initialize(PactRunner.kt:96) at au.com.dius.pact.provider.junit.PactRunner.getChildren(PactRunner.kt:151) at org.junit.runners.ParentRunner.getFilteredChildren(ParentRunner.java:534) at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:400) at org.junit.runners.model.RunnerBuilder.configureRunner(RunnerBuilder.java:81) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:72) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70) at org.junit.internal.requests.ClassRequest.createRunner(ClassRequest.java:28) at org.junit.internal.requests.MemoizingRequest.getRunner(MemoizingRequest.java:19) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:50) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)``` I want to run provider tests, pact broker is running on localhost java version ```java -version openjdk version "11.0.13" 2021-10-19 LTS OpenJDK Runtime Environment Zulu11.52+13-CA (build 11.0.13+8-LTS) OpenJDK 64-Bit Server VM Zulu11.52+13-CA (build 11.0.13+8-LTS, mixed mode)``` pact.provider: ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit</artifactId> <version>4.1.17</version> <scope>test</scope> </dependency>```

cedric.spengler
2022-01-25 15:08
has joined #pact-jvm

austin.reifsteck
2022-01-25 15:20
has joined #pact-jvm

pavlo.sprogis
2022-01-25 17:16
one more question: can somebody share good examples of custom test `Target` implementation https://docs.pact.io/implementation_guides/jvm/provider/junit/#custom-test-target ? We already using `akka-http-testkit` and `JUnitRouteTest` for backend testing and provided `HttpTarget` does not work in this case

hsd999
2022-01-25 19:06
has joined #pact-jvm

parasonbe
2022-01-25 20:31
has joined #pact-jvm

alex.diaz
2022-01-26 09:05
has joined #pact-jvm

kskowron
2022-01-26 11:30
has joined #pact-jvm

spencerm
2022-01-26 14:33
has joined #pact-jvm

cristiano.cunha
2022-01-26 14:55
has joined #pact-jvm

uglyog
2022-01-27 00:54
Can you check that you are not mixing different versions of the Pact libraries?

nish063
2022-01-27 02:42
has joined #pact-jvm

sandeepa.kv
2022-01-27 03:54
Looking for few inputs for the above query, any help here would be highly appreciated as this is a blocker at this point for us to continue with pact jvm on our Bazel project. As this maven plugin has some configurations inside, just wondering how this can be handled in Bazel projects.

uglyog
2022-01-27 03:58
If you use unit tests and the Pact CLI, you shouldn't need a Bazel plugin. I haven't seen any Bazel support, so there probably isn't any.

abubics
2022-01-27 04:05
Yarr, `maven-surefire-plugin` is also not used in Gradle builds, and we have no issues with Gradle. This is the first question I've ever seen in this Slack workspace about Bazel, so I suspect that either no one's using it here, or it works just fine so no one's had to ask :sweat_smile:

uglyog
2022-01-27 04:10
If the tests pass, the pact file will be generated. You just need to find out were that is.

devesh.mishra
2022-01-27 04:26
thanks for the update.

ingcmurcia
2022-01-27 04:41
has joined #pact-jvm

matt.fellows
2022-01-27 05:29
Presumably, with DEBUG level logging for the pact packages, you should be able to see where the pact file is written?

weijian.duan
2022-01-27 08:58
has joined #pact-jvm

weijian.duan
2022-01-27 10:00
#pact-jvm hello everyone, I followed this tutorial https://blog.testproject.io/2020/06/03/event-driven-architecture-how-to-perform-contract-testing-in-kafka-pubsub/, cloned the project (https://github.com/SrinivasanTarget/ContractTestingBoilerplate) and ran the test locally. The steps I did is: 1) run DateConsumerTest.java in data-consumer-kafka subproject, it passed and as a result it generated a dateConsumerKafka-dateProviderKafka.json pact file in target/pacts directory 2) I copy the file to date-producer-kafka/src/test/resources, intending to let producer-side test read the pact from local directory by using @PactFolder("src/test/resources") 3) I run DateProducerTest.java in date-producer-kafka subproject. But I was getting error message: ```org.junit.platform.commons.PreconditionViolationException: You must register at least one TestTemplateInvocationContextProvider that supports @TestTemplate method [void com.example.producer.pact.DateProducerTest.testTemplate(au.com.dius.pact.core.model.Pact,au.com.dius.pact.core.model.Interaction,au.com.dius.pact.provider.junit5.PactVerificationContext)] at org.junit.platform.commons.util.Preconditions.condition(Preconditions.java:296) at org.junit.platform.commons.util.Preconditions.notEmpty(Preconditions.java:146) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.validateProviders(TestTemplateTestDescriptor.java:122) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:98) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:42) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)``` I searched based on the message, it seems related to the using of @TestTemplate annotation instead of Pact framework. But what confused me is that in pact's documentation it indicates the using of @TestTemplate while doesn't mention anything related to "providing at least one TestTemplateInvocationContextProvider". Do you guys know what the problem here? Appreciate the help!

devesh.mishra
2022-01-27 10:06
hey i am adding, *<logger name="http://au.com.dius.pact.consumer" level="DEBUG"/>* in my *logback-test.xml in test resources directory* but it is not showing anything new in the logs, anythings else needs to be done?

weijian.duan
2022-01-27 10:19
and by the way I added this dependency in pom.xml of data-producer-kafka subproject ``` <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit5</artifactId> <version>4.0.10</version> </dependency>``` the source code from the tutorial doesn't have it, and without it the error message is different from above.

abraham.gonzalez93
2022-01-27 10:39
has joined #pact-jvm

pavlo.sprogis
2022-01-27 10:44
besides `http://au.com.dius.pact.provider` (mentioned above) I have also pact plugin ```<plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.1.17</version> <configuration> <pactBrokerUrl>${env.PACT_BROKER_URL}</pactBrokerUrl> <pactBrokerUsername>${env.PACT_BROKER_USERNAME}</pactBrokerUsername> <pactBrokerPassword>${env.PACT_BROKER_PASSWORD}</pactBrokerPassword> </configuration> </plugin>``` and that?s all

matt.fellows
2022-01-27 11:00
How are you actually running your tests - via Bazel? Are you sure they?re actually running? Can you run it directly via JUnit?

devesh.mishra
2022-01-27 11:38
yes test cases are running fine checked that.

devesh.mishra
2022-01-27 11:38
version that i am using - au.com.dius:pact-jvm-consumer-junit:4.0.10

devesh.mishra
2022-01-27 11:42
script --- > ```import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit.PactProviderRule; import au.com.dius.pact.consumer.junit.PactVerification; import au.com.dius.pact.core.model.RequestResponsePact; import au.com.dius.pact.core.model.annotations.Pact; import io.harness.CategoryTest; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; import java.util.HashMap; import java.util.Map; import static org.junit.Assert.assertEquals; @RunWith(MockitoJUnitRunner.class) public class PlatformPactTest { @Rule public PactProviderRule mockProvider = new PactProviderRule("Provider", this); @Pact(consumer = "Consumer") public RequestResponsePact createPactVersion(PactDslWithProvider builder) { Map<String, String> headers = new HashMap<>(); headers.put("Content-Type", "application/json"); return builder .given("version is 1.1") .uponReceiving("a request for the version") .path("/api/gateway-version-pact") .method("GET") .willRespondWith() .headers(headers) .status(200) // .body(new PactDslJsonBody() // .decimalType("system.properties.version", 1.1)) .body("{\"metaData\":null,\"resource\":{\"system.properties.version\":{\"string\":\"1.1\",\"chars\":\"1.1\",\"valueType\":\"STRING\"}},\"responseMessages\":null}") .toPact(); } // @Pact(consumer = "Consumer") public RequestResponsePact createPactInvalid(PactDslWithProvider builder) { System.setProperty("pact.rootDir", "target/Pact"); return builder .given("invalid property") .uponReceiving("a request with an invalid property") .path("/invalidurl") .method("GET") .willRespondWith() .status(500) .toPact(); } @Test @PactVerification(value = "Provider", fragment = "createPactVersion") public void runVersionTest() { String version = new PlatformPactURL(mockProvider.getUrl()).getVersion(); assertEquals("Expected version does not match", "{\"metaData\":null,\"resource\":{\"system.properties.version\":{\"string\":\"1.1\",\"chars\":\"1.1\",\"valueType\":\"STRING\"}},\"responseMessages\":null}", version); } // @Test @PactVerification(value = "Provider", fragment = "createPactInvalid") public void runInvalidTest() { String invalid = new PlatformPactURL(mockProvider.getUrl()).getInvalidProperty(); assertEquals("Expected invalid property response does not match", "", invalid); } }```

devesh.mishra
2022-01-27 12:15
```Execution output --> JUnit4 Test Runner .SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/private/var/tmp/_bazel_user/18eb72707fdh47/execroot/test_monorepo/bazel-out/darwin-fastbuild/bin/external/maven/v1/http/jfrogdev.dev.test/artifactory/test-maven/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/private/var/tmp/_bazel_user/18eb727d2d01f50d47/execroot/test_monorepo/bazel-out/darwin-fastbuild/bin/external/maven/v1/http/jfrogdev.dev.test/artifactory/test-maven/org/slf4j/slf4j-simple/1.7.0/slf4j-simple-1.7.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 11:59:44,735 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback-test.xml] at [jar:file:/private/var/tmp/_bazel_user/18eb727d2d0bea96ef507fd47/execroot/test_monorepo/bazel-out/darwin-fastbuild/bin/990-commons-test/libmodule.jar!/logback-test.xml] 11:59:44,736 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback-test.xml] occurs multiple times on the classpath. 11:59:44,736 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback-test.xml] occurs at [jar:file:/private/var/tmp/_bazel_user/18eb72f1bea9/execroot/test_monorepo/bazel-out/darwin-fastbuild/bin/80-commons/src/test/resources/libresources.jar!/logback-test.xml] 11:59:44,736 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback-test.xml] occurs at [jar:file:/private/var/tmp/_bazel_user/18eb727/execroot/test_monorepo/bazel-out/darwin-fastbuild/bin/990-commons-test/libmodule.jar!/logback-test.xml] 11:59:44,747 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@1eb5174b - URL [jar:file:/private/var/tmp/_bazel_user/18eb72d26ef507fd47/execroot/test_monorepo/bazel-out/darwin-fastbuild/bin/99-commons-test/libmodule.jar!/logback-test.xml] is not of type file 11:59:44,89 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set 11:59:44,89 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender] 11:59:44,93 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [stdout] 11:59:44,87 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property 11:59:44,92 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.http.wire] to WARN 11:59:44,92 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [de.bwaldvogel] to ERROR 11:59:44,21 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.mongodb.driver] to ERROR 11:59:44,21 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [io.netty] to ERROR [org.hibernate.validator] to ERROR SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] . Time: 1.907 OK (2 tests) BazelTestRunner exiting with a return value of 0 JVM shutdown hooks (if any) will run now. The JVM will exit once they complete. -- JVM shutdown starting at 2022-01-27 11:59:46 --```

tjones
2022-01-27 12:35
I don't know that tutorial. Have you tried the official pact-jvm examples?

weijian.duan
2022-01-27 13:26
This tutorial happens to demo how to test against Kafka message producing, which is what I am finding. But I think the usage is not much different from official example. It's just that error message got me confused.

weijian.duan
2022-01-27 14:05
@tjones if you mean this example https://docs.pactflow.io/docs/examples/kafka/java/provider, yeah it looks good but I don't want to involve setting up Pact Broker and CI. A simple case with pact file in local would be better.

petersonbtah
2022-01-27 14:18
@matt.fellows just wanted to see if I could get your input on my last post.

tjones
2022-01-27 14:51
I don't, I mean the pact-jvm examples

demna
2022-01-27 15:29
has joined #pact-jvm

mircea.ungureanu
2022-01-27 15:48
has joined #pact-jvm

nikhilwa84
2022-01-27 17:43
has joined #pact-jvm

bogdanm.rusu
2022-01-27 18:04
has joined #pact-jvm

matt.fellows
2022-01-27 21:11
I?m not seeing any pact tests running in there

cventcport
2022-01-27 22:29
has joined #pact-jvm

matt.fellows
2022-01-27 22:32
> So if I am following the previous messages, the client delete call in the contract can use a generator to update the call with a customer id. The problem is the customer ID is dynamic based on the customer create call. the key point here, is that Pact wants to test each interaction in isolation from any other. You explictly want to avoid coupling an interaction to another. Provider states are how you avoid this. > The delete can?t rely on the response from the create. But what should happen is the test for the delete should rely on a generator that is populated in the provider state for the delete. The provider state for the delete should do what it needs to in order to create the customer. (I might have messed up some terms there...) yes, that?s correct. So in your case you would have a test that is structured something like: ```Given a customer ID 1234 exists, a request to delete user 1234, should ?``` your provider could would have a provider state handler that receives ?customer ID 1234 exists? and sets up the data for that. If the ID is dynamic, that is where you can use the injection technique from above. In most cases, the provider is able to control this ID, and so you don?t need the injection bit

petersonbtah
2022-01-28 02:35
Thank you for the information

thanuxxxx
2022-01-28 02:42
Hello, I recently updated pact provider `junit5spring` from `4.1.16` to `4.2.0`, the problem is test hangs like 20s in certain tests. When I revert back my version to `4.1.16` or `4.1.19` it runs smoothly. Any idea why this is happening?

uglyog
2022-01-28 02:50
Are you able to provide any debug logs for those tests?

thanuxxxx
2022-01-28 03:11
```Version 4.2.0 ........ [from Pact Broker https://pact-broker/pacts/provider/oloservice/consumer/web-order-ahead/pact-version/540da9e1a305aaf41d08520682ef3e12c4c46754/metadata/c1tdW3RdPVBSLTI1OTQmc1tdW2xdPXRydWUmc1tdW2N2XT00Nzg1JnA9ZmFsc2U] Given Merchant exists a GET request for a customer's current orders with 47DBHCFNB0X85 [2022-01-27 21:57:51,576] [INFO] u= p= r= d= m= v= i= hm= hs= da= am= t= p= w= db= locale= GET http://localhost:8080/v1/merchants/47DBHCFNB0X85/customers/current/orders (Logbook) [2022-01-27 21:57:51,628] [INFO] u= p= r= d= m= v= i= hm= hs= da= am= t= p= w= db= locale= 200 GET http://localhost:8080/v1/merchants/47DBHCFNB0X85/customers/current/orders (Logbook) returns a response which has status code 200 (OK) has a matching body (OK) [2022-01-27 21:58:46,054] [WARN] u= p= r= d= m= v= i= hm= hs= da= am= t= p= w= db= locale= Not all of the 21 were verified. The following were missing: (DefaultTestResultAccumulator) [2022-01-27 21:58:46,054] [WARN] u= p= r= d= m= v= i= hm= hs= da= am= t= p= w= db= locale= a GET request for a customer's current orders with Contract-Test (DefaultTestResultAccumulator) ........ Version 4.1.19 ........ [from Pact Broker https://pact-broker.com/pacts/provider/oloservice/consumer/web-order-ahead/pact-version/540da9e1a305aaf41d08520682ef3e12c4c46754/metadata/c1tdW3RdPVBSLTI1OTQmc1tdW2xdPXRydWUmc1tdW2N2XT00Nzg1JnA9ZmFsc2U] Given Merchant exists a GET request for a customer's current orders with 47DBHCFNB0X85 [2022-01-27 22:07:25,516] [INFO] u= p= r= d= m= v= i= hm= hs= da= am= t= p= w= db= locale= GET http://localhost:8080/v1/merchants/47DBHCFNB0X85/customers/current/orders (Logbook) [2022-01-27 22:07:25,584] [INFO] u= p= r= d= m= v= i= hm= hs= da= am= t= p= w= db= locale= 200 GET http://localhost:8080/v1/merchants/47DBHCFNB0X85/customers/current/orders (Logbook) returns a response which has status code 200 (OK) has a matching body (OK) [2022-01-27 22:07:25,889] [WARN] u= p= r= d= m= v= i= hm= hs= da= am= t= p= w= db= locale= Not all of the 21 were verified. The following were missing: (DefaultTestResultAccumulator) [2022-01-27 22:07:25,889] [WARN] u= p= r= d= m= v= i= hm= hs= da= am= t= p= w= db= locale= a GET request for a customer's current orders with Contract-Test (DefaultTestResultAccumulator) [2022-01-27 22:07:25,889] [WARN] u= p= r= d= m= v= i= hm= hs= da= am= t= p= w= db= locale= a GET request for a full menu with 47DBHCFNB0X85 (DefaultTestResultAccumulator) [2022-01-27 22:07:25,889] [WARN] u= p= r= d= m= v= i= hm= hs= da= am= t= p= w= db= locale= a GET request for a full menu with Contract-Test (DefaultTestResultAccumulator)```

thanuxxxx
2022-01-28 03:12
There is no visible differences except version 4.2.0 takes almost a minute to pass the tests

thanuxxxx
2022-01-28 03:14
It doesn't randomly stop. It stops at exactly same tests every time

thanuxxxx
2022-01-28 03:17
I think it has to do something with the version, I tried from `4.1.16` to `4.1.19` there is no problem.

devesh.mishra
2022-01-28 04:05
in the execution output we see 2 test cases ran, these are on consumer side.

devesh.mishra
2022-01-28 04:06
the same script is executed in maven project it gets executed successfully and gives the pact file as well.

uglyog
2022-01-28 04:10
Can you try `4.2.19` ?

matt.fellows
2022-01-28 04:22
Sorry I?m not sure what you?re saying in the first part there. I can?t see any pact output in the log you shared above.

thanuxxxx
2022-01-28 04:29
I tried `4.3.0`

thanuxxxx
2022-01-28 04:29
Didn't solve the problem

uglyog
2022-01-28 04:33
No, `4.2.19` instead of `4.2.0`

thanuxxxx
2022-01-28 04:37
Nope, it didn't work

uglyog
2022-01-28 04:41
You will have to provide debug logs for us to help you

weijian.duan
2022-01-28 08:00
@uglyog Hi, may I ask is that true that we need to write more than one method with @Pact annotation in consumer's side to generate pact file?

weijian.duan
2022-01-28 08:04
I am asking because we use @TestTemplate in provider's side to test against pact file provided by consumer. Only when consumer define more than one rules does the using of @TestTemplate make sense.

jamesatroughton
2022-01-28 09:07
Hello everyone, I am using the mvn dependency `pact-jvm-consumer-junit5` version `4.0.10` which looks like it contains guava version 18 which is causing my dependency scanner to mark the image as non compliant. I can see that guava has been updated to a newer version in pact github but in maven I cant see a newer version of `pact-jvm-consumer-junit5` ?

matt.fellows
2022-01-28 09:30
I think the package names/structure changed when 4.1.x came out. I could be wrong, but the full list is here: https://docs.pact.io/implementation_guides/jvm/readme#supported-jdk-and-specification-versions

matt.fellows
2022-01-28 09:32
ah, the 4.0.x line is no longer actively maintained

mayuri.khemani
2022-01-28 09:43
has joined #pact-jvm

jamesatroughton
2022-01-28 09:58
Ah gotcha thanks @matt.fellows this seems to work for me now :raised_hands: ``` <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>4.3.4</version>```

sujith.nair2
2022-01-28 12:33
has joined #pact-jvm

juanma97perez
2022-01-28 12:35
@juanma97perez has left the channel

yann.danot
2022-01-28 13:08
Hi, Do we have any updates regarding the pact ktor workshop ?

rob
2022-01-28 16:36
has joined #pact-jvm

thanuxxxx
2022-01-28 17:49
You mean entire log?

radovan
2022-01-29 00:20
has joined #pact-jvm

uglyog
2022-01-29 00:35
No, you only need one method. Depends on how you setup your tests. Some people like to break them up.

weijian.duan
2022-01-29 07:20
@uglyog alright, but when I am running this test https://github.com/SrinivasanTarget/ContractTestingBoilerplate/blob/master/date-producer-kafka/src/test/java/com/example/producer/pact/DateProducerTest.java, it says `You must register at least one TestTemplateInvocationContextProvider...`, do you have a clue if it's not because of @Pact annotation, what could be the reason? (sorry I have been googling for quite a period but can't manage to find the reason)

devesh.mishra
2022-01-29 08:00
Provider Implementation getting bellow error when executing the test cases anything missing? Dependency in use - `au.com.dius.pact.provider:junit5:4.1.21` ```import au.com.dius.pact.provider.junit5.HttpTestTarget; import au.com.dius.pact.provider.junit5.HttpsTestTarget; import au.com.dius.pact.provider.junit5.PactVerificationContext; import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; import au.com.dius.pact.provider.junitsupport.Consumer; import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.State; import au.com.dius.pact.provider.junitsupport.loader.PactBroker; import au.com.dius.pact.provider.junitsupport.loader.VersionSelector; import au.com.dius.pact.provider.junitsupport.target.Target; import au.com.dius.pact.provider.junitsupport.target.TestTarget; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.runner.JUnitCore; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import junit.runner.Version; @RunWith(JUnit4.class) @Provider("Provider") @Consumer("Conseumer") @PactBroker( host = "localhost", port = "9292" ) public class pactProviderTest { @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @BeforeAll static void enablePublishingPact() { System.setProperty("pact.verifier.publishResults", "true"); } @BeforeEach void before(PactVerificationContext context) { int port = 9090; context.setTarget(new HttpsTestTarget("localhost", port)); } @State("version is 1.1") public void validVersion() { } @State("invalid property") public void invalidProperty() { } }``` ```on execution getting - JUnit4 Test Runner .E Time: 0.02 There was 1 failure: 1) initializationError(io.dummy.PactProviderTest) java.lang.Exception: No runnable methods at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:191) at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:128) at org.junit.runners.ParentRunner.validate(ParentRunner.java:416) at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84) at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65) at org.junit.runners.JUnit4.<init>(JUnit4.java:22) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104) at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33) at com.google.testing.junit.runner.internal.junit4.MemoizingRequest.createRunner(MemoizingRequest.java:48) at com.google.testing.junit.runner.internal.junit4.MemoizingRequest.getRunner(MemoizingRequest.java:34) at com.google.testing.junit.runner.junit4.JUnit4TestModelBuilder.get(JUnit4TestModelBuilder.java:49) at com.google.testing.junit.runner.junit4.JUnit4TestModelBuilder.get(JUnit4TestModelBuilder.java:27) at com.google.testing.junit.runner.util.MemoizingSupplier.get(MemoizingSupplier.java:44) at com.google.testing.junit.runner.junit4.JUnit4Runner.run(JUnit4Runner.java:93) at com.google.testing.junit.runner.BazelTestRunner.runTestsInSuite(BazelTestRunner.java:159) at com.google.testing.junit.runner.BazelTestRunner.main(BazelTestRunner.java:85) FAILURES!!! Tests run: 1, Failures: 1 BazelTestRunner exiting with a return value of 1 JVM shutdown hooks (if any) will run now. The JVM will exit once they complete. -- JVM shutdown starting at 2022-01-29 07:58:56 -- ================================================================================```

devesh.mishra
2022-01-29 15:16
it was resolved because of different versions, run was with Junit4 and test cases annotationsare in Junit5.

petersonbtah
2022-01-30 02:55
I'm thinking about this some more and still am missing something. Scenario 1: Interaction is for a customer delete. In the customer delete provider state I would go off and create the customer and get the ID, I can then use a generator on the customer delete to inject the customer ID which is what is used for the delete. - Got it. However, Scenario 2: interaction is for a customer create which results in a new customer id that was dynamically generated, lets say it is a random value and I have no way to calculate it, I have to rely on the response from the customer create. Now I want to clean up after myself and NOT leave the customer that was just creating laying around. So in my customer create provider state "teardown" I would like to write the code to delete the customer. But the problem is the customer id (which is what I want to use for the deleting the customer) doesn't exist anywhere. I think I am understanding from the conversation that I am out of luck for scenario 2, the customer id info isn't available and I can't clean up after my test.

matt.fellows
2022-01-30 05:37
You're spot on with scenario 1

matt.fellows
2022-01-30 05:37
Scenario 2 might be resolved by just wiping the database clean, or just leaving it around

matt.fellows
2022-01-30 05:37
Usually you can design such things so they don't actually collide

matt.fellows
2022-01-30 05:38
Again, this form of testing is designed for when you have unit test level control over things

matt.fellows
2022-01-30 05:38
Which usually includes being able to control IDs, but not always

uglyog
2022-01-30 22:05
That is a JUnit 5 error, not a Pact one. What version of JUnit 5 and JVM are you using?

petersonbtah
2022-01-31 02:54
Thanks.

matt.fellows
2022-01-31 02:58
Helpful?

matt.fellows
2022-01-31 02:59
I didn?t ask - what is the consequence of (in this case) the user in Scenario 2 not being cleaned up afterwards?

matt.fellows
2022-01-31 03:00
FWIW in my test fixtures, I would usually either wipe the entire database before each state transition, or have an explicit state that does that.

mongeyc
2022-01-31 14:03
has joined #pact-jvm

petersonbtah
2022-01-31 21:07
I view the consequence as not being able to leave the environment the way you found it. I am a firm believer that any test should bring its own data to the party and then clean up before leaving the party. For sake of discussion, if you have test environments that are difficult/flakey to setup, you might want to not rebuild the environment for every test. The environment will continue to get polluted as tests run. If you have multiple different tests running in the same environment then potentially there could be issues if the writers of the tests happen to choose the same name for things or for other unforeseen reasons. I just like the idea of cleaning up after myself...

petersonbtah
2022-01-31 21:08
If I had access to the create response I could write the code to cleanup.

mike.bernard
2022-01-31 21:14
has joined #pact-jvm

matt.fellows
2022-01-31 23:12
> For sake of discussion, if you have test environments that are difficult/flakey to setup, you might want to not rebuild the environment for every test. The environment will continue to get polluted as tests run. If you have multiple different tests running in the same environment then potentially there could be issues if the writers of the tests happen to choose the same name for things or for other unforeseen reasons. so, this statement leads me to believe you?re running against a fixed test environment - Pact is not designed for this use case, albeit it can be done

matt.fellows
2022-01-31 23:12
the test environment should be a local process, spun up for the single purpose of running Pact tests, not a fixed/shared test environment

matt.fellows
2022-01-31 23:12
the whole point of Pact is to avoid the use of such environments, because they are so problematic (and this problem is one of them)

tjoy
2022-02-01 02:06
has joined #pact-jvm

max.tilford
2022-02-01 03:17
has joined #pact-jvm

christoph.oswald
2022-02-01 09:55
Hi, I noticed, that in the documentation for branches (https://docs.pact.io/pact_broker/branches/#support) JVM support had status "TBC". If I read the release notes correctly, I believe branch support was implemented in releases: 4.3.4, 4.2.19, 4.1.33 (https://github.com/pact-foundation/pact-jvm/releases). Would be nice to have the documentation updated as well.

weijian.duan
2022-02-01 12:28
I am using JDK1.8. And for Junit 5 version, I am not sure what exactly you are asking. I have this two dependencies in my pom.xml: ```<groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit5</artifactId> <version>4.0.10</version> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.2.10</version>``` and when I run the test, the console is telling me it is using junit-platform-launcher-1.7.2.jar @uglyog

toanshukumar
2022-02-01 14:15
has joined #pact-jvm

juanquis419
2022-02-01 15:01
has joined #pact-jvm

praneethkumar
2022-02-01 16:17
Hi , Is there any Google Guice framework for Pact ?

matt.murray
2022-02-01 19:40
has joined #pact-jvm

uglyog
2022-02-01 21:45
You're mixing Pact-JVM versions, remove the 4.0.10 dependency. 4.2.10 won't work on JDK 8, you need to use 4.1.33

uglyog
2022-02-01 21:46
It's only partially implemented, there are still some issues to be completed

matt.fellows
2022-02-02 00:11
Not that I?m aware of

frederic.gendebien
2022-02-02 08:54
has joined #pact-jvm

dougie.robertson
2022-02-02 11:15
has joined #pact-jvm

weijian.duan
2022-02-02 13:36
@uglyog that works! thank you so much! may I ask how can I know whether versions of Pact and JVM compatible or not?

juan.avendano
2022-02-02 13:36
has joined #pact-jvm

ananda-kumar.irudhaya
2022-02-02 14:14
has joined #pact-jvm

uglyog
2022-02-02 21:57
The different Pact-JVM libraries should all have the same version number.

mike.key
2022-02-02 23:34
I?m getting a failure on a provider verification using GitHub Actions and ```au.com.dius.pact.provider:junit5:4.3.4``` I?m not getting much information as to the cause (no stacktrace or anything)?.this is what the verifier shows: ```Received test result 'Failed(results=[{exception=io.github.classgraph.ClassGraphException: Uncaught exception during scan, description=Request to provider method failed with an exception, ``` Any ideas what might be wrong? I can run this same test from my local system and it passes.

uglyog
2022-02-02 23:37
Looks like the classgraph scan is failing. Can you check the JVM version that is being run in the Github Action? Also, enabling debug level logs will provide more information.

mike.key
2022-02-02 23:40
```Java configuration: Distribution: adopt Version: 11.0.11+9 Path: /opt/hostedtoolcache/Java_Adopt_jdk/11.0.11-9/x64```

mike.key
2022-02-02 23:40
thats what is being installed

mike.key
2022-02-02 23:41
I have `http://au.com.dius.pact.provider: DEBUG` set, which shows me some output but nothing I could see that was useful to me at least?.

mike.key
2022-02-02 23:43
One interesting tidbit?..I saw responses you had on an OOM similar to this one?.so I tried setting `pact.verifier.classpathscan.verbose` to true and then my local test fails with the same error. If I disable that flag it passes.

mike.key
2022-02-02 23:43
In GHA it fails regardless

uglyog
2022-02-02 23:44
This `Request to provider method failed with an exception` normally means your method that was called failed with an exception. I don't understand why it is happening during the classgraph scan.

uglyog
2022-02-02 23:46
It might be hitting memory limits trying to scan a large code base. You can enable just the package to scan in the test target.

mike.key
2022-02-03 00:01
That fixed it?.thanks for the help!

petersonbtah
2022-02-03 03:10
Thank you for your help. Much appreciated.

weijian.duan
2022-02-03 03:24
I don't really get it. How about the compatibility conflict between Pact-JVM and JDK?


weijian.duan
2022-02-03 03:27
awesome! thank you

roman.rutkowski.87
2022-02-03 09:33
has joined #pact-jvm

ausachov
2022-02-03 13:15
has joined #pact-jvm

aaron.kibbie
2022-02-03 15:59
has joined #pact-jvm

williangldzn
2022-02-03 20:23
has joined #pact-jvm

james.perepiczka
2022-02-03 22:37
Hi all, I?m getting a failure when using Pact JVM. Whenever I set a request body for a POST request, I receive a 500 error. If I take out the request body then the contract gets generated and I get the desired status code (201). ```package com.company.org.consumer; import au.com.dius.pact.consumer.MockServer; import au.com.dius.pact.consumer.dsl.DslPart; import au.com.dius.pact.consumer.dsl.PactDslJsonBody; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; import au.com.dius.pact.core.model.RequestResponsePact; import au.com.dius.pact.core.model.annotations.Pact; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.impl.client.HttpClients; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import java.io.IOException; import static org.hamcrest.MatcherAssert.assertThat; import static http://org.hamcrest.Matchers.is; @SpringBootTest @ActiveProfiles("test") @ExtendWith(PactConsumerTestExt.class) class ConsumerTest { private static final String RELATIVE_PATH = "/rest/endpoint"; @Pact(provider = "provider1", consumer = "consumer1") public RequestResponsePact createPactWith201Response( PactDslWithProvider builder) { DslPart requestBody = new PactDslJsonBody() .stringType("environment"); return builder .uponReceiving("A request for creating a schedule") .body(requestBody) .path(RELATIVE_PATH) .method("POST") .willRespondWith() .status(201) .toPact(); } @Test @PactTestFor(providerName = "provider1", pactMethod = "createPactWith201Response") void runPactTestFor201Response(MockServer mockServer) throws IOException { HttpRequestBase requestBase = new HttpGet(mockServer.getUrl() + RELATIVE_PATH); var response = HttpClients.createDefault().execute(requestBase); assertThat(response.getStatusLine().getStatusCode(), is(201)); } } ```

james.perepiczka
2022-02-03 22:37
I've tried using a Json string instead of a DSL part body also and that hasnt worked either

uglyog
2022-02-03 23:04
Couple of issues I can see: ? You test is not testing anything. It is just starting a mock server and then making a request to it. ? Your test code is making a GET not a POST. The 500 response is because the mock server is matching the request against the configured Pact ? You test code is also not sending a body

james.perepiczka
2022-02-04 00:12
Thank you, cant believe I made such rookie mistakes. It would be nice if the 500 response returned an error to say it wasn't matching or something.

uglyog
2022-02-04 00:14
The body of the 500 response will have the error details in JSON format.

uglyog
2022-02-04 00:15
It should also be in the logs

ricardo.gonzaga
2022-02-04 09:35
has joined #pact-jvm

robin.jacques
2022-02-04 10:51
has joined #pact-jvm

joaomiguel.rocha
2022-02-04 17:40
has joined #pact-jvm

weijian.duan
2022-02-07 03:37
@uglyog hi, a small thing for this thread, do we have gradle dependency support for `http://au.com.dius.pact.consumer`. I can only see this in our doc https://docs.pact.io/implementation_guides/jvm/provider/gradle

jacek.sienniak
2022-02-07 08:45
has joined #pact-jvm

jamie.weatherby
2022-02-07 15:25
has joined #pact-jvm

joaobrandao.rodrigues
2022-02-07 16:30
has joined #pact-jvm

thanuxxxx
2022-02-07 19:48
@uglyog the one that takes almost a minute to finish the test is returning a list, all other tests are returning an object. There is no other error logs

extra
2022-02-07 21:31
has joined #pact-jvm

extra
2022-02-07 21:35
Hello! In this example https://docs.pact.io/implementation_guides/jvm/provider#an-example-of-running-provider-verification-with-junit we have this comment "// setup any provider state", how can I setup the provider state?? Thank you!

matt.fellows
2022-02-07 21:46
Are you using junit4 or 5?

matt.fellows
2022-02-07 21:47
That isn?t supposed to be a full example, from what I can see


matt.fellows
2022-02-07 21:47
see also the JVM workshop :point_down: (howtolearn)

2022-02-07 21:47
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

ajay.kawde
2022-02-08 05:45
Hi

ajay.kawde
2022-02-08 05:46
is there any way we can converta json string to pactdsljsonbody

ajay.kawde
2022-02-08 05:47
i want to automate the pact creation instead of writing lengthy code for each property of json response

matt.fellows
2022-02-08 05:48
I think it?s been tried before, have a search around the workspace. I think the general consensus is that it?s a bad idea, but a few people seem to want it and have written scripts to make it work

uglyog
2022-02-08 05:49
If you have a JSON string, why don't you just use it. Why do you need to pass it into the DSL?

matt.fellows
2022-02-08 05:52
In the past, people wanted to take the JSON and add matchers etc.

ajay.kawde
2022-02-08 05:54
for examples if i have 10 fields to verify through pact they can be string, int,boolean ,i dont want to write code for each property for its type and example i wanted to know if there is any simpler way i can automate this process

matt.fellows
2022-02-08 05:59
Is there an equivalent of a `like (String json)` that would accept a JSON string and convert all attributes to a like type matcher Ron? I know that gets used a lot in JS

matt.fellows
2022-02-08 05:59
that probably is what you?re asking for Ajay, am I right?

ajay.kawde
2022-02-08 06:00
yeah correct

uglyog
2022-02-08 06:10
No, nothing like that. Someone once mentioned they were going to create it, but I never saw it get done

elenatuzel
2022-02-08 08:27
has joined #pact-jvm

vadim
2022-02-08 09:19
has joined #pact-jvm

anna.khv
2022-02-08 12:19
has joined #pact-jvm

anna.khv
2022-02-08 12:22
Hello guys, I wonder is there any plans to add testng support in the nearest future? We use testng in Miro and it would be great not to reinvent the wheel and use your client)

dhospital
2022-02-08 16:15
has joined #pact-jvm

jcabrera
2022-02-08 18:26
has joined #pact-jvm

anna.khv
2022-02-08 20:22
Maybe @matt.fellows can help with it?

pavlo.sprogis
2022-02-08 21:33
hi guys, I have noticed that by default pact will record `Content-Type` header in generated pact json during consumer tests, e.g.: ```"headers": { "Content-Type": "application/json; charset=UTF-8" },``` even though I do not mention this header explicitly. Is it possible to configure pact to skip content-type header and do not record it in generated pact json? Or omit content-type during pact verification tests in provider? I?m using `http://au.com.dius.pact.consumer.junit5 4.2.17` for consumer tests and `http://au.com.dius.pact.provider.junit 4.1.17` for provider tests

uglyog
2022-02-09 00:52
The content type is needed because it needs to know how to match it (i.e. plain text vs JSON vs XML)

matt.fellows
2022-02-09 00:53
:wave: I don?t believe there are any plans, sorry. I?d suggest raising a request at http://pact.canny.io

matt.fellows
2022-02-09 00:53
(I don?t maintain Pact JVM, btw)

matt.fellows
2022-02-09 00:54
I?m sure the Pact JVM maintainers would be grateful for a PR that supports it, or if you were to create a separate project/repository that supports testng we could reference it somewhere?

extra
2022-02-09 07:07
Thank you for the answer, in fact I'm working with groovy and Spock. Finally I have this working with this example https://docs.pact.io/implementation_guides/jvm/provider#an-example-of-running-provider-verification-with-spock

extra
2022-02-09 07:09
The only think, is that it could be great if as we have this "consumer.stateChange" to initialize data, have another point to verify the data created, after the execution of the POST

extra
2022-02-09 07:11
Because I have, lets say 5 states, that generate 5 types of documents, it will be great to verify the 5 types of docs that are saved in a DB.

matt.fellows
2022-02-09 07:13
I?m not sure what you?re asking sorry. But Pact can definitely test as many scenarios as you want. Each of thos eshould be a different test

matt.fellows
2022-02-09 07:13
If the shape of the data is the same, but just different values, you might want to consider testing that in other ways

ardiel.fuentes
2022-02-09 07:14
has joined #pact-jvm


extra
2022-02-09 07:22
Yes, I know that the business should be tested in other type of tests, but in this case would be nice to verify "Does the provider do the right thing with the request?" within the same contract.

extra
2022-02-09 07:23
In provider test

matt.fellows
2022-02-09 07:40
Maybe if you could provide more detail on what you?re trying to do I could help? We?re talking abstracts here, if you could please describe the scenario in more detail and perhaps some code samples to illustrate, I could give more specific help

ruud.von.faber
2022-02-09 09:11
has joined #pact-jvm

pavlo.sprogis
2022-02-09 09:37
ok, thank you for the answer!

pavlo.sprogis
2022-02-09 09:44
why would somebody use testng in 2022:thinking_face: especially if you just starting contract tests from scratch

matt.fellows
2022-02-09 10:58
I haven?t written code in Java for a while, but I recall I did like test ng back in the day - what?s the problem with it these days? Just that JUnit is more popular?

extra
2022-02-09 11:09
The arrow is where all the interactions are exceuted, once executed it returns the control. Can I do any verification of the system after the execution of every interaction?

pavlo.sprogis
2022-02-09 11:14
yes, especially JUnit5, from my experience testng was popular mostly among selenium-UI-tests guys. I work at Booking, there are a lot of legacy projects, but even here most of java services are covered with junit5 tests. We have legacy e2e tests written with testng, one of the tasks is a migration to junit5

pavlo.sprogis
2022-02-09 11:18
// I?m might be wrong, because fortunately, I do not work with java tests all of my time, I prefer node.js frameworks and test runners.

christoph.oswald
2022-02-09 12:47
Hello, when reading the documentation https://docs.pact.io/implementation_guides/jvm/provider/junit/#tagging-the-provider-before-verification-results-are-published-401 I had difficulties finding out the differences between the properties ´`pact.provider.tag`´ and ´`pactbroker.providerTags`´. Could you explain the differences? Also I was wondering if there is an overview of system properties that are picked up the the pact-jvm implementation. For example I could not find any reference to the ´`pact.provider.name`´ besides https://github.com/pact-foundation/pact-jvm/issues/1160#issuecomment-657184770

agustin.gomes
2022-02-09 13:23
has joined #pact-jvm

pavlo.sprogis
2022-02-09 13:27
> if there is an overview of system properties that are picked up the the pact-jvm implementation I have found most of the properties related to provider in this readme https://github.com/pact-foundation/pact-jvm/tree/master/provider/gradle#project-properties

thijme.langelaar
2022-02-09 13:29
has joined #pact-jvm

dharmesh.kumar
2022-02-09 13:52
has joined #pact-jvm

athaper
2022-02-09 14:14
has joined #pact-jvm

svranyes
2022-02-09 20:16
has joined #pact-jvm

uglyog
2022-02-09 21:58
The problem is that any PR that introduces a new property probably won't be recorded anywhere. I'll add a task to audit all the system properties

uglyog
2022-02-09 22:03
`pact.provider.tag` is used when publishing the verification results, `pactbroker.providerTags` would probably be used when fetching pending pacts. See https://github.com/pact-foundation/pact-jvm/tree/master/provider/junit5#pending-pact-support-version-410-and-later

samuel.whittaker
2022-02-09 23:40
has joined #pact-jvm

ajay.kawde
2022-02-10 09:49
Hi guys

ajay.kawde
2022-02-10 09:50
does anyone know what is root marker $ in pact contract json file

ajay.kawde
2022-02-10 09:51
i am trying to write a pact for a integer property age

ajay.kawde
2022-02-10 09:51
i am writing pactdsljsonBody.integerType("age",1)

ajay.kawde
2022-02-10 09:52
pact is created

ajay.kawde
2022-02-10 09:53
but during validation in provider side i get path expression ".age" does not start with a root marker "$"

david.hvilava
2022-02-10 10:53
has joined #pact-jvm

carlos.ferrao
2022-02-10 15:46
has joined #pact-jvm

rios.martinivan
2022-02-10 20:18
has joined #pact-jvm

charles.kuo
2022-02-10 21:42
has joined #pact-jvm

uglyog
2022-02-10 21:52
Can you provide your test code?


sudhanshu.testing
2022-02-11 05:12
has joined #pact-jvm

alessandro.polidori
2022-02-11 15:02
has joined #pact-jvm

manel_ben_yahia
2022-02-11 15:18
hello i have a question about pact for some interaction

manel_ben_yahia
2022-02-11 15:18
i have one interaction which should respond with 200

manel_ben_yahia
2022-02-11 15:19
and another that should be responding with 400

manel_ben_yahia
2022-02-11 15:19
the difference is one value in some string attribute changes

manel_ben_yahia
2022-02-11 15:20
but i can't do exact Match with the matching rules even when i use stringValue

manel_ben_yahia
2022-02-11 15:20
it matches the interaction with 200

manel_ben_yahia
2022-02-11 15:20
how am i supposed to do that ?

manel_ben_yahia
2022-02-11 15:23
``` builder .given("get_some_endpoint") .uponReceiving("get endpoint 200") .path("/v1/endpoint") .method(HttpMethod.POST.name()) .body(bodyRequest()) .willRespondWith() .status(HttpStatus.OK.value()) .headers(Map.of("Content-Type", "application/json")) .body(response()) .uponReceiving("get get endpoint 400") .path("/v1/endpoint") .method(HttpMethod.POST.name()) .body(bodyBadRequest()) .willRespondWith() .status(HttpStatus.BAD_REQUEST.value())```

manel_ben_yahia
2022-02-11 15:25
```protected DslPart bodyRequest() { return newJsonBody((jsonBody) -> jsonBody .stringType("id", "78") .array("product", this::products) .stringType("type", "someType") .stringType("actual_code", "code") ).build(); }```

manel_ben_yahia
2022-02-11 15:26
```protected DslPart dlvBodyBadRequest() { return newJsonBody((jsonBody) -> jsonBody .stringType("id", "78") .array("product", this::products) .stringValue("type", "400Type") .stringType("actual_code", "code") ).build(); }```

manel_ben_yahia
2022-02-11 15:26
as you can see the only difference is when i send type = 400Type to API, it should give me 400 bad request response, but when generating contract it matches the first interaction

manel_ben_yahia
2022-02-11 15:45
Anyone ?

krisakins
2022-02-12 20:19
has joined #pact-jvm

ian.cervantez
2022-02-13 03:32
has joined #pact-jvm

yanis.benekaa
2022-02-13 15:06
@yanis.benekaa has left the channel

uglyog
2022-02-13 21:58
`.stringType("type", "someType")` in the first request will match any string, including `"400Type"`, so it will always return that response.

antonio.gamiz
2022-02-14 06:51
has joined #pact-jvm

ajay.kawde
2022-02-14 08:21
hi guys if a create a RequestReponseObject and want to use it to create pact contract json

ajay.kawde
2022-02-14 08:24
is it possible to do that

matt.fellows
2022-02-14 09:00
Hi Ajay! Can you please add a bit more detail to your question? Are you asking _how_ to write a pact test in Java or something else?

matt.fellows
2022-02-14 09:01
Just in case, here are some helpful getting started resources (examples/tutorials etc.) :point_down: (howtolearn)

2022-02-14 09:01
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

ajay.kawde
2022-02-14 11:06
i just want to create a pact json from RequestResponsePact object

ajay.kawde
2022-02-14 11:07
iknow how to do it inside a consumer test with @pact method

ajay.kawde
2022-02-14 11:07
but i want to automate the process and create pacts for multiple endpoints

matt.fellows
2022-02-14 11:45
What do you mean by automate the process?

ajay.kawde
2022-02-14 12:28
by automating i mean instead of writing test cases for each endpoint and creating pact i want to do it programmetically

matt.fellows
2022-02-14 12:30
And why do you want to do that?

matt.fellows
2022-02-14 12:31
Or perhaps asked alternatively, why do you think that's a good idea?

ajay.kawde
2022-02-14 12:32
i want to save time writing all these tests

ajay.kawde
2022-02-14 12:33
i have api endpoints and expexted response

matt.fellows
2022-02-14 12:33
But the tests _are_ the valuable thing. How will you ensure the contract is valid?

ajay.kawde
2022-02-14 12:33
i want to validate only provider site

ajay.kawde
2022-02-14 12:33
against the created pacts

matt.fellows
2022-02-14 12:35
But if the contract isn't valid, then those tests are also useless and you might as well use a different tool. How will you ensure the contract itself is valid if you skip writing the tests?

matt.fellows
2022-02-14 12:40
> i have api endpoints and expexted response > If you have these and don't want/need to consider what the consumer does, then you're probably better off using a number of other functional API testing tools. Probably unit testing on the provider side is all that is required. Pact is about ensuring each consumer's needs are taken into consideration. What you're suggesting (I think) removes the consumer from the equation

matt.fellows
2022-02-14 12:40
I'm trying to get you to convince me it's a good idea, basically :wink:


zish.gatrad
2022-02-14 16:01
has joined #pact-jvm

james.troughton
2022-02-14 16:08
has joined #pact-jvm

manuelam20
2022-02-15 00:41
has joined #pact-jvm

dchen
2022-02-15 08:03
has joined #pact-jvm

aristides.suarez
2022-02-15 08:14
has joined #pact-jvm

marcelino.garcia
2022-02-15 08:22
has joined #pact-jvm

varnika.singh
2022-02-15 09:11
has joined #pact-jvm

bernard
2022-02-15 16:22
has joined #pact-jvm

david.uzumaki
2022-02-15 16:33
has joined #pact-jvm

dennis.woditsch
2022-02-15 16:51
Hey, I have successfully implemented publish of pacts and verifications. Now I want to use the plugin for the verification as well. This is my plugin `<pact.plugin.version>4.3.5</pact.plugin.version>`on the consumer side ``` <plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>${pact.plugin.version}</version> <configuration> <pactBrokerUrl>${pact.broker.url}</pactBrokerUrl> <pactBrokerToken>${pact.broker.token}</pactBrokerToken> <projectVersion>${docker.imageversion}</projectVersion> <branchName>${git.branch}</branchName> </configuration> <executions> <execution> <id>publish-pacts</id> <phase>verify</phase> <goals> <goal>publish</goal> </goals> </execution> </executions> </plugin>``` My Plugin on Provider Side looks like following ```<plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <configuration> <pactBrokerUrl>https://xxx.pactflow.io</pactBrokerUrl> <pactBrokerToken>myToken</pactBrokerToken> <projectVersion>${docker.imageversion}</projectVersion> <serviceProviders> <serviceProvider> <name>myService</name> </serviceProvider> </serviceProviders> </configuration> </plugin>``` I'm getting `Execution default-cli of goal au.com.dius.pact.provider:maven:4.3.5:verify failed.` Using debug mode is not helping me much. What is minimal required to use the plugin for verifications? Is the `stateChangeUrl` always required? I want to use this plugin to basically start my verifications. Edit: and how could this look like if my service is consumer of *service* *X* and producer for *service* *Y* at the same time? So it has to publish pacts and also do verifications?

francislainy.campos
2022-02-15 16:54
Hi, is it possible to change (remove) the path set within a contract dynamically from the provider side?

francislainy.campos
2022-02-15 16:55
The reason I ask our localhost env doesn?t contain the same path as the other environments, not including some of the trails and going straight into the endpoint, such as http://localhost.com/jwt whereas our main endpoint would http://ourapi.com/something/else/jwt.

francislainy.campos
2022-02-15 16:56
And /something/else is hardcoded on the consumer side.

francislainy.campos
2022-02-15 17:20
Hi, just hoping on this question, I?m not using the maven plugin but Junit instead and added the @SpringBootTest annotation on top of my pact provider hoping that would start the local server. Is my assumption wrong and not possible to do pact on localhost unless you manually trigger your application to be running before the tests execute?

abhishekc.jh
2022-02-15 17:21
has joined #pact-jvm

nuno.frias
2022-02-15 19:28
has joined #pact-jvm

uglyog
2022-02-15 22:29
Yes, @SpringBootTest can start the application

faran
2022-02-15 22:31
has joined #pact-jvm

andy
2022-02-16 00:35
has joined #pact-jvm

fushinoryuu
2022-02-16 01:40
has joined #pact-jvm

francislainy.campos
2022-02-16 06:14
hmm, it won?t do it for us though?

francislainy.campos
2022-02-16 06:16
```@Provider(VIADUCT) @Consumer(ED_UI) @PactBroker(url = BROKER_PACT_URL, authentication = @PactBrokerAuth(token = myToken)) @VerificationReports(value = {"markdown"}, reportDir = "target/pacts") @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) public class PactProviderEdIT { @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactTestTemplate(PactVerificationContext context, HttpRequest request) { request.addHeader("Authorization", getAuthorizationToken()); logCurlFromPact(context, request, BASE_URI_ED); context.verifyInteraction(); } @BeforeAll public static void setUp() throws JSONException { } @AfterAll public static void cleanUp() throws JSONException { } @BeforeEach void before(PactVerificationContext context) { if (ENVT.equalsIgnoreCase("local")) { context.setTarget(new HttpTestTarget(PACT_BASE_URL_LOCAL, Integer.parseInt(PORT), "")); } else { context.setTarget(new HttpsTestTarget(BASE_PACT_URL_ED, 443, "")); } } @State("Teacher user can create linked assignment") void sampleState1() { } @State("Claims exist for JWT string requested") void sampleState2() { } }```


uglyog
2022-02-16 06:17
Looks like you are using `SpringBootTest.WebEnvironment.RANDOM_PORT`, but you are not providing the port to the test

francislainy.campos
2022-02-16 06:30
Nice! So I tried now with ```SpringBootTest.WebEnvironment.DEFINED_PORT``` and this works. So I guess that?s because the port is pre-defined and injected through ```if (ENVT.equalsIgnoreCase("local")) { context.setTarget(new HttpTestTarget(PACT_BASE_URL_LOCAL, Integer.parseInt(PORT), "")); } else { context.setTarget(new HttpsTestTarget(BASE_PACT_URL_ED, 443, "")); }```

abdelior
2022-02-16 08:48
has joined #pact-jvm

misterjkl
2022-02-16 13:12
has joined #pact-jvm

brian.azizi
2022-02-16 14:05
has joined #pact-jvm

richelle.raaphorst
2022-02-16 15:17
has joined #pact-jvm

ukrainian1991
2022-02-17 09:56
Hi, I try to use Pact broker consumerVersionSelectors in kotlin. Seems its not working ```@PactBroker( authentication= @PactBrokerAuth(username = "", password = ""), port="8080", consumerVersionSelectors={ @VersionSelector(latest = "true") } ) @TestInstance(TestInstance.Lifecycle.PER_CLASS) class PactCPEProviderTest {``` I take it from Docs https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors/ But compiler argues on VersionSelector with *An annotation can't be used as the annotations argument* Is it possible to solve it somehow?

ajay.kawde
2022-02-17 10:57
hi Guys

ajay.kawde
2022-02-17 10:58
i want to map a json [{},{}]

ajay.kawde
2022-02-17 10:59
[{"name": "ajay,}]

ajay.kawde
2022-02-17 11:05
[ {"name"::"ajay", "age": 26 }, {"name":"paul", age:28 } ]

ajay.kawde
2022-02-17 11:08
the above json i want to create a pact dsljson body , i am us new pactdslJsonBody().minarraylike(1, method('produces pactdslbody with json object with property name and age)).asBody but i am getting error as unsupppoerted format use minarrayLike(name ,size,pactDslPart)

ajay.kawde
2022-02-17 11:10
i want to pass the json object in minarraylike method without property name

ajay.kawde
2022-02-17 11:10
but not able to do it

ajay.kawde
2022-02-17 11:10
does anyone has any idea how to achieve it

pavlo.sprogis
2022-02-17 11:30
I just tried an example from the docs and it works fine: ```@Provider("my provider name") @PactBroker(host = "${PACT_BROKER_HOST}", authentication = @PactBrokerAuth(username = "${PACT_BROKER_USERNAME}", password = "${PACT_BROKER_PASSWORD}"), consumerVersionSelectors = { @VersionSelector(tag = "master"), @VersionSelector(tag = "dev"), @VersionSelector(tag = "production") } )```

pavlo.sprogis
2022-02-17 11:31
I?m using ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.1.17</version> <scope>test</scope> </dependency>```

pavlo.sprogis
2022-02-17 11:33
have you tried ```au.com.dius.pact.consumer.dsl.LambdaDsl.newJsonBody``` ?

pavlo.sprogis
2022-02-17 11:37
for example: ```newJsonBody(body -> { body.minArrayLike("users", 2, users -> { users.stringType("name"); users.integerType("age"); }); });```

pavlo.sprogis
2022-02-17 11:38
you can return this result from you method and use inside .body() with PactDslWithProvider builder

ukrainian1991
2022-02-17 11:45
Do you use kotlin?

pavlo.sprogis
2022-02-17 11:46
no, I use java 11 (zulu build)

ukrainian1991
2022-02-17 11:48
that's the reason, thanks for sharing

ukrainian1991
2022-02-17 11:49
```@PactBroker( authentication= PactBrokerAuth(username = "", password = ""), consumerVersionSelectors=[ VersionSelector(latest = "true") ] )```

ukrainian1991
2022-02-17 11:49
Seems it should looks like that in kotlin

ajay.kawde
2022-02-17 12:27
thanks for the answer

ajay.kawde
2022-02-17 12:28
but i am asking if i dont want to give property name "users"

ajay.kawde
2022-02-17 12:28
as it is just an array of json objects


pavlo.sprogis
2022-02-17 12:44
in the example above array of arrays is used, but it can be applied for array of objects as well

guillermo.aguirre
2022-02-17 20:06
has joined #pact-jvm

guillermo.aguirre
2022-02-17 20:12
Hello everyone. I'm attempting to create a body DSL closure to generate a contract. I am creating the closure using fields and an array. However, I would like the array to have matchers to uniquely match each index with a different object. `eachLike` only works when an array has the same object in each index. Here is an example JSON that needs to be matched : ```{ "version" : 1234, "data" : [ { "name" : "someName" }, { "name" : "anotherName", "id" : 131312} ] }``` As you see using an eachLike on data wouldn't work because of the extra `id` field. Does anyone know how I can achieve this? I've look at the documentation, but I can't seem to figure it out. Thanks!

matt.fellows
2022-02-17 20:46
I think there is another matcher called something like "array containing"

matt.fellows
2022-02-17 20:46
That might be better

guillermo.aguirre
2022-02-17 22:44
I tried using that but it doesn't populate the contract for the field in there

matt.fellows
2022-02-18 00:21
can you please elaborate?

abubics
2022-02-18 02:11
Yeah, I think there's a way to make the root object an array, it's probably just hard to find in the docs.

abubics
2022-02-18 02:12
As an aside, I'd recommend using objects (not arrays) as the root element in JSON responses, for extensibility. It's much easier to add new fields to an object (backwards-compatible change), than wrapping your root array in an object later (backwards-incompatible change).

abubics
2022-02-18 02:13
(This is probably part of the reason that it's less documented)

guillermo.aguirre
2022-02-18 14:45
Yes, when I use arrayContaining matcher in the `withBody` closure. ex: ```.withBody({ data arrayContaining({ name string() }, { name string() id integer() }) })```

guillermo.aguirre
2022-02-18 14:47
This generates my JSON contract but with the `data` key empty

guillermo.aguirre
2022-02-18 14:48
`data : {}`

guillermo.aguirre
2022-02-18 14:48
Instead of being populated

guillermo.aguirre
2022-02-18 14:49
If I use `eachLike` it will populate that field with correct fields/values array

guillermo.aguirre
2022-02-18 15:51
But I don't want to use this because of that second entry that is different

adamslack
2022-02-18 15:55
has joined #pact-jvm

darwin.cahyadi
2022-02-18 18:00
has joined #pact-jvm

matt.fellows
2022-02-18 23:58
I can?t really help in terms of how to write that test in java/groovy, but that sounds like a bug

matt.fellows
2022-02-18 23:59
it should definitely return an array with data in it. So either, the input to the matcher is incorrect or there is a bug in the framework

matt.fellows
2022-02-18 23:59
Hopefully somebody else can steer you with how to use that matcher in groovy

jkdihenkar
2022-02-19 10:50
@jkdihenkar has left the channel

rishi.speets
2022-02-19 14:43
has joined #pact-jvm

ybergstrom
2022-02-21 03:24
has joined #pact-jvm

gyuvaraj10
2022-02-21 08:03
has joined #pact-jvm

athissen
2022-02-21 08:09
has joined #pact-jvm

andrefcsousa
2022-02-21 10:19
has joined #pact-jvm

katharina.pavic
2022-02-21 12:37
has joined #pact-jvm

ipoe
2022-02-21 14:54
has joined #pact-jvm

jeroen.vandijk
2022-02-21 16:40
has joined #pact-jvm

ajay.kawde
2022-02-21 18:35
hi Guys


ajay.kawde
2022-02-21 18:39
i am using pactdslprovider

ajay.kawde
2022-02-21 18:39
pactdslwithProvider*


ondikumana
2022-02-21 22:13
has joined #pact-jvm

nithyag.ganesan
2022-02-22 10:01
has joined #pact-jvm

ntiwari
2022-02-22 11:48
has joined #pact-jvm

andrefcsousa
2022-02-22 14:11
Hello everyone

andrefcsousa
2022-02-22 14:12
I'm starting to adopt contract testing through Pact framework. I've noted that http://Pact.io contract tests run with JUnit. Our services use TestNG to run unit tests. Do you see any problems or conflicts on still using testNG to run our current unit test suite and use junit to run contract tests exclusively on the same service repository?

ajay.kawde
2022-02-23 05:46
Hey, I used new PactDslJsonArray().arrayMinlike(1, new PactDslJsonBody()) but i am getting array of array

phil.vint
2022-02-23 11:01
has joined #pact-jvm

phongthornk
2022-02-23 11:04
has joined #pact-jvm

lukasz
2022-02-23 14:55
has joined #pact-jvm

matt.fellows
2022-02-23 20:39
Conceptually no, unless there are some strange library conflicts

matt.fellows
2022-02-23 20:39
Have you just tried giving it a go?

andrefcsousa
2022-02-24 11:30
i'll try running my current suite of unit tests with TestNG and add a verificatiion contract just to check this

ezequiel.uhrig
2022-02-25 13:46
has joined #pact-jvm

emin.sahin
2022-02-26 13:53
has joined #pact-jvm

ihassin
2022-02-27 21:20
has joined #pact-jvm

yumiihuang
2022-02-28 09:55
has joined #pact-jvm

yousaf
2022-02-28 11:57
has joined #pact-jvm

gerry
2022-02-28 12:56
has joined #pact-jvm

andrefcsousa
2022-02-28 14:40
Hi

andrefcsousa
2022-02-28 14:40
how can i match an empty list through Pact DSL?

andrefcsousa
2022-02-28 14:41
Imagine i have this response from a provider: { "bets": [] }

andrefcsousa
2022-02-28 14:41
how can i match bets list as empty on the consumer side?

pavlo.sprogis
2022-02-28 15:05
something like this? ```newJsonBody(body - > { body.array("bets", array - > {}); }).build()```

agustina.bosso
2022-02-28 16:04
has joined #pact-jvm

andrefcsousa
2022-02-28 21:08
Hello

andrefcsousa
2022-02-28 21:09
i'm having trouble with Content-Type matching

andrefcsousa
2022-02-28 21:09
my service returns the following response headers: Response Headers Date: Mon, 28 Feb 2022 21:08:23 GMT Server: Cougar - 4.10.3 (Cougar 2 mode) Cache-Control: no-cache X-Authentication: MzI0 X-Application: FORCE_ELASTIC Content-Type: application/json;charset=utf-8 Content-Encoding: gzip

andrefcsousa
2022-02-28 21:09
i've created a consumer contract test which specifies that the response should have a Content-Type=application/json;charset=utf-8

andrefcsousa
2022-02-28 21:10
but when running provider tests i got: Failures: 0) Verifying a pact between pedo-bear-consumer and fixed-odds-bet-reporting - a search bets for that account returns a response which includes headers "Content-Type" with value "[application/json;charset=utf-8]" Expected 'application/xml;charset=utf-8' to match 'application/json;charset=utf-8' 1) Verifying a pact between pedo-bear-consumer and fixed-odds-bet-reporting - a search bets for that account returns a response which has a matching body Expected a response type of 'application/json' but the actual type was 'application/xml'

andrefcsousa
2022-02-28 21:10
if i request my service through postman i can see the application/json;charset=utf-8 contentType

andrefcsousa
2022-02-28 21:10
not xml

andrefcsousa
2022-02-28 21:10
can anybody help me with this?

andrefcsousa
2022-02-28 21:11
thanks

andrefcsousa
2022-02-28 21:12
Consumer Test: ```@Pact(consumer = "pedo-bear-consumer", provider = "fixed-odds-bet-reporting") public RequestResponsePact accountWithoutBets(PactDslWithProvider builder) { PactDslJsonBody betReport = new PactDslJsonBody().array("bets") .closeArray() .close() .asBody() .integerType("accountID", accountID) .stringType("currencyCode",currencyCode) .stringType("localeCode",localeCode) .numberType("numberOfMatches",numberOfMatches) .booleanType("moreAvailable",moreAvailable); Map<String, String> response_headers = new HashMap<String, String>(); response_headers.put("Content-Type", "application/json"); return builder .given("exists an account without bets") .uponReceiving("a search bets for that account") .path("/api/FixedOddsBetReporting/v1.0/searchBets") .method("GET") .matchQuery("sortDir","DESC","DESC") //.headerFromProviderState("X-Authentication","{$token}","MzI0") .willRespondWith() .status(200) .matchHeader("Content-Type","application/json;charset=utf-8") //.headers(response_headers) .body(betReport) .toPact(); }```

andrefcsousa
2022-02-28 21:12
On Provider: @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("127.0.0.1")); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context, HttpRequest request) { request.addHeader("X-Authentication", "MzI0"); request.addHeader("X-Application", "FORCE_ELASTIC"); //request.addHeader("Content-type","application/xml"); context.verifyInteraction(); }

andrefcsousa
2022-02-28 21:12
i've already tried some tricks but i'm not getting any success

andrefcsousa
2022-02-28 21:13
my dependencies on provider: ```<dependencies> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit5</artifactId> <version>4.0.10</version> </dependency> <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.2.7</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.8.6</version> </dependency> </dependencies>```

matt.fellows
2022-03-01 03:09
My guess is that your provider uses the `Accept` header to determine what content type to respond to. It looks like it?s missing, so perhaps it?s defaulting to XML?

matt.fellows
2022-03-01 03:09
what does your postman request look like?

matt.fellows
2022-03-01 03:14
Remember, what you put in your consumer contract is what is gonig to be replayed against your provider. So all it?s telling you is that given the request you defined, it _should_ respond with your assertions. Obviously, that?s not the case (so Pact is telling you your assumptions are wrong)

athaper
2022-03-01 03:57
Hey! I had question regarding pact junit If we?re writing producer code for pact verification is it mandate to spin up the server on localhost to validate the interactions or will it be possible to just call the resource methods to verify those interactions ?

uglyog
2022-03-01 04:03
Is this a spring boot app?

athaper
2022-03-01 04:05
its a dropwizard service

uglyog
2022-03-01 04:17
How would it know which resource method to call, and how to convert the HTTP values to parameters?

athaper
2022-03-01 04:29
Makes sense , I was just trying to verify one single endpoint in pact so didn?t think of it. That answers my question , thanks @uglyog

andrefcsousa
2022-03-01 09:24
Hi Matt. Actually i found that my cointainer (jetty) had a configuration that defines application/xml has the content type by default. I've changed to application/json and could do the verification with success.

deactivateduser320370
2022-03-01 11:41
has joined #pact-jvm

luke.bickell
2022-03-01 14:46
has joined #pact-jvm

james.williams
2022-03-01 16:29
has joined #pact-jvm

pavlo.sprogis
2022-03-01 21:51
hi all, is it possible to describe `stringOrNull` value using Lambda DSL? I just want to check that the field exists in response. I use `unorderedMinArray` and in some array items this field is a string, in other ones - null

matt.fellows
2022-03-01 21:56
No, sorry. Please see https://docs.pact.io/faq#why-is-there-no-support-for-specifying-optional-attributes as to why (sorry for short response, have to run!)

pavlo.sprogis
2022-03-01 22:04
thanks for the quick response!

qluck
2022-03-01 22:15
has joined #pact-jvm

tomknee1
2022-03-01 22:40
Hello, is it possible to set loose expectations on a range of status code like 2xx ? I stumbled across https://github.com/pact-foundation/pact-specification/issues/68 but it wasn't overly clear if this is possible now or not ?

uglyog
2022-03-01 23:02
This has been implemented as part of the V4 spec changes in v4.3.x. The DSL now has methods like `successStatus()` which will match all status codes from 200-299

tomknee1
2022-03-01 23:17
Perfect that's exactly what I needed. Thank you :)


uglyog
2022-03-01 23:23
PactProviderRuleMk2, that's old!

peter.pinda
2022-03-01 23:37
has joined #pact-jvm

matt.fellows
2022-03-01 23:50
ha ok I thought that it was, hence why I was like :man-shrugging:

rejeesh.g
2022-03-02 09:17
We are using provider tests to `JUnit5` using `au.com.dius.pact.provider:junit5:4.2.9`. For the async Message Pact we are getting following error:

rejeesh.g
2022-03-02 09:17
generates a message which Verification Failed - Failed to invoke provider method 'verifyMessageforOrder'

rejeesh.g
2022-03-02 09:19
I saw this issue was earlier raised by another team https://github.com/pact-foundation/pact-jvm/issues/1265. And the issue is still open. Can you help us fix this issue ASAP.

tomknee1
2022-03-02 12:00
Hello, I am trying to write a consumer test which basically makes a POST request to get a token back, this POST request has an `Authorization` header where the value is a JWT. For it to be accepted fine by the provider, it needs to not be expired etc. Is there any way I can handle this with matchers etc? I have this regex ```.matchHeader("Authorization", "^[A-Za-z0-9-_=]+\\.[A-Za-z0-9-_=]+\\.?[A-Za-z0-9-_.+/=]*\$")``` but not sure about the JWT expiry part and obviously how the jwt would be decoded from that regex?

omer.bilgin
2022-03-02 15:51
has joined #pact-jvm

me1295
2022-03-02 17:05
Hi folks. I'm experiencing an issue currently when trying to publish pacts via gradle. It looks like the request to the broker is dropping auth. If I try and publish to an existing broker that has no auth, it works but when publishing to our new auth?d broker, the request fails. I?m using pact-jvm version 4.2.20 which appears to have fixed some authentication issues but it doesn't appear so in my case. Has anybody else encountered this recently? Any info is appreciated.

me1295
2022-03-02 17:24
I'm using the standard Gradle `pactPublish` step like most folks

me1295
2022-03-02 17:24
```pact { publish { pactDirectory = "$rootDir/pacts" pactBrokerUrl = "https://url/sub-path/" pactBrokerUsername = "xxx" pactBrokerPassword = "xxx" } }```

me1295
2022-03-02 17:26
On inspecting the request it looks like the auth headers are dropped, resulting in a generic error - `http://au.com.dius.pact.core.pactbroker.InvalidNavigationRequest: Failed to fetch the root HAL document`

banolik
2022-03-02 18:35
has joined #pact-jvm

ancyaziz
2022-03-02 22:26
has joined #pact-jvm

timothyg
2022-03-02 23:40
has joined #pact-jvm

uglyog
2022-03-03 00:08
`Failed to invoke provider method 'verifyMessageforOrder'` means that the Pact framework tried to call your function and an exception was raised. A lot of the time it is because something is not correct in the function being called (like using a null variable). You need to look at your log output (set at debug level), and then look at the cause of the exception.

uglyog
2022-03-03 00:11
That won't work, because it won't be able to send a valid token. See https://docs.pact.io/implementation_guides/jvm/provider/junit5#modifying-the-requests-before-they-are-sent for a way to do this

uglyog
2022-03-03 00:16
Pact-JVM publishes some Pact files to an authenticated broker as part of it's release build, so it definitely works. There must be something else that is the problem.

abhay175
2022-03-03 00:35
Hi #pact-jvm , i am trying to write provider test for a spring rest controller. However the pact test are failing on http status code 404. It is expected to return 200. if i run with MockitoJunitRunner it works fine. Any idea how to troubleshoot this further or resolve it. Thanks in advance.

uglyog
2022-03-03 00:39
It probably means the paths from the Pact file are not being correctly mapped to your controller methods. There is an example project you can have a look at https://github.com/pactflow/example-provider-springboot/blob/master/src/test/java/com/example/springboot/ProductsPactTest.java

matt.fellows
2022-03-03 06:03
Can you please share any logs Andrew? Might need to set the log level to debug so we can see the req/res from the broker

matt.fellows
2022-03-03 06:05
It looks like you are running the pact broker on a context path - it?s possible that has been misconfigured. What happens is Pact JVM -> request to broker at the root (`/sub-path` in your case). It then sends back a HAL JSON response with links to follow. If the broker doesn?t know it?s running on that path, those links won?t have the prefix and will result in badness


abhay175
2022-03-03 06:12
@uglyog , i did verify the paths. they seem to match. i should mention that its not a springboot project as in the example. Here is my controller- @Controller @Path(?/healthCheck?) public class HealthCheckController{ @Autowired private HealthCheckservice healthCheckService; @GET @Path(?/?) public Response checkHealth( ??.. return Response.ok(); } Here is the pact Json { ?.. ?interactions?: [ { request: { method: GET path: ?/healthCheck? ?? } Please ignore the formatting and syntax.

tomknee1
2022-03-03 09:26
thanks

tomknee1
2022-03-03 09:28
this looks to be on the provider side though? what about consumer side? I was considering asking provider team to make a long lived jwt with expiry far away for testing or something

tomknee1
2022-03-03 09:33
i read something about following Postels laws in the pact docs? So I could make the request data on my consumer side (which has this jwt auth header) more strict by using example jwt that should always work in testing, or I guess if I keep using that match header on my side or something, then the provider side could do the modifying of the request before sent?? What would normally be preferred, or am I still confused here? Thanks

harihararaj.lk
2022-03-03 09:44
has joined #pact-jvm

matt.fellows
2022-03-03 10:52
Would the path then be `/healthCheck/` (with the trailing slash)?

matt.fellows
2022-03-03 10:52
in your pact test, you?re missing the trailing slash

matt.fellows
2022-03-03 10:52
the logs of your API should hopefully tell you want path it actually hit and you could check against registered ones

mircea.ungureanu
2022-03-03 11:40
@mircea.ungureanu has left the channel

tomknee1
2022-03-03 12:23
hi, is there any example of pact jvm v4 dsl versus v3 dsl, seems like a lot of v3 stuff (e.g. `builder.given()...`) no longer is applied in the same way in V4 ? looking for example for setting *consumer* side expectations

nathan.deamer
2022-03-03 12:46
```@Pact(consumer = CONSUMER_NAME) public V4Pact getOrderById(PactBuilder builder) { return builder .usingLegacyDsl() // Here .given("An order exists")``` I fell back to using the legacyDsl() but also would be interested in some example whether should use v4 for http pacts? Or is it more for the plugins?

tomknee1
2022-03-03 12:47
ye, i also saw that `useLegacyDsl` as well as specifying to explicitly use V3 spec, but would love to see a proper V4 DSL example :slightly_smiling_face:

toyamarinyon
2022-03-03 13:25
has joined #pact-jvm

david342
2022-03-03 13:26
has joined #pact-jvm

yesilmenadil
2022-03-03 16:14
has joined #pact-jvm

abhay175
2022-03-03 18:39
@matt.fellows@matt.fellows@matt.fellows, will pact mock the call to the controller or the service has to be running? the same test works fine with mockitorunner. i added the trailing slash but it didnt help.

dajaman1
2022-03-03 20:30
has joined #pact-jvm

matt.fellows
2022-03-03 21:42
the provider has to be running locally

matt.fellows
2022-03-03 21:42
mocking it out isn?t very helpful here as it wouldn?t prove anything

matt.fellows
2022-03-03 21:42
the point of a provider test is to confirm it can respond to the requests the consumer needs

uglyog
2022-03-03 22:07
The legacy V3 DSL can create V4 Pacts. Most of the functionality should be supported.

uglyog
2022-03-03 22:08
Some things that can't be done is things like have both a HTTP and message interaction in the same Pact file but with different tests.

waqif
2022-03-03 23:32
has joined #pact-jvm

dmitry.matveev
2022-03-03 23:44
has joined #pact-jvm

yousafn
2022-03-04 09:57
Our very own members of the pact community @muirandy has been kind enough to help with some Kafka pact recipes for our docs website https://docs.pact.io/recipes/kafka and also has a new supporting blog post out. Feel free to take a read https://muirandy.wordpress.com/2022/03/03/contract-testing-with-pact-kafka-and-schema-registry-part-2/ Thanks Andy!

reuben.tonna
2022-03-04 14:32
has joined #pact-jvm

reuben.tonna
2022-03-04 14:45
Hi. I'm on version 4.3.5 of pact libraries and am trying to define the following pact in my consumer using the LambdaDsl (in a java+spring boot project) ``` final DslPart body = newJsonBody(root -> { root.stringMatcher("callCount", "\\d+", "10"); root.unorderedMinArray("distribution", 0, item -> item.object(o -> { o.stringMatcher("id", "\\d+", "1"); o.stringMatcher("callCount", "\\d+", "10"); })); }).build(); return builder .usingLegacyMessageDsl() .given("non-empty-greeting-usage-statistics") .expectsToReceive("private.metrics.greeting.usage") .withContent(body) .toPact(V4Pact.class);``` My intent is to state that this consumer accepts message content of the general shape { callCount: x, distribution: [] } where distribution array can be empty, and if not empty the items must match the general structure { id: x, callCount: y }. The pact generates and is loaded in the broker. However when in my provider I return payloads such as: ```"{\"callCount\":\"0\",\"distribution\":[]}";``` It is failing with: ``` 1) private.metrics.greeting.usage: generates a message which has a matching body 1.1) body: $.distribution Expected [{"callCount":"10","id":"1"}] to match [] ignoring order of elements [ - { - "callCount": "10", - "id": "1" - } + ]``` Any thoughts what I am missing? Maybe my expectation that in one pact I can define both scenarios were the array have items matching the example, or have no items is incorrect. Thoughts?

reuben.tonna
2022-03-04 14:49
Re above, for reference here is the pact spec generated: ```{ "consumer": { "name": "Greeter Service" }, "interactions": [ { "_id": "f2a0ad127283680720dba3410ed3c8cc97d0c36b", "contents": { "content": { "callCount": "10", "distribution": [ { "callCount": "10", "id": "1" } ] }, "contentType": "application/json", "encoded": false }, "description": "private.metrics.greeting.usage", "key": "", "matchingRules": { "body": { "$.callCount": { "combine": "AND", "matchers": [ { "match": "regex", "regex": "\\d+" } ] }, "$.distribution": { "combine": "AND", "matchers": [ { "match": "ignore-order", "min": 0 } ] }, "$.distribution[0].callCount": { "combine": "AND", "matchers": [ { "match": "regex", "regex": "\\d+" } ] }, "$.distribution[0].id": { "combine": "AND", "matchers": [ { "match": "regex", "regex": "\\d+" } ] } } }, "metadata": { "contentType": "application/json" }, "pending": false, "providerStates": [ { "name": "non-empty-greeting-usage-statistics" } ], "type": "Asynchronous/Messages" } ], "metadata": { "pact-jvm": { "version": "4.3.5" }, "pactSpecification": { "version": "4.0" } }, "provider": { "name": "Greeting Usage Api" } }```

negrolyze
2022-03-04 15:34
has joined #pact-jvm

42amehmeto
2022-03-04 19:17
has joined #pact-jvm

abhay175
2022-03-04 20:14
ohh we dont have a dedicated dev environment for the provider i am working on. Moreover we were thinking to integrate the pact test in to our maven int pipeline. i did try using wire mock and it worked. but i wanted to avoid using that. Isnt the purpose of pact to just make sure the contract is correct. how does it matter if we mock it or not. we are still validating the response against pact

abhay175
2022-03-04 20:19
Isnt it supposed to work like an integration Test since we are using MockMvc.

rawatankit90
2022-03-04 22:33
has joined #pact-jvm

matt.fellows
2022-03-04 23:40
Yes, you need to test it with data and without data


harihararaj.lk
2022-03-05 13:22
Hi people, Is it possible to do pact testing with the use of pact files available on local if pact broker is not reachable or accessible or based on some configuration?

matt.fellows
2022-03-06 09:05
Yes, but how would you know if you're validating the correct pact?

matt.fellows
2022-03-06 09:06
Any logic in the broker would be hard to replicate locally, so just keep it in mind

matt.fellows
2022-03-06 09:06
You can verify files locally, on an http server or via a pact broker

uglyog
2022-03-06 22:21
The purpose of Pact is to verify that the provider service behaves according to the interactions in the Pact file. If you use a mock server, you are not testing anything.

harihararaj.lk
2022-03-07 05:24
@matt.fellows it is of the case when pact broker is not available for the local development environment ,but for the upper environments we have that pact broker setup. Is there any kind of configuration or switch to toggle between pact files or with pact broker setup, so that the build doesn't fail in case of any pact broker unavailability

matt.fellows
2022-03-07 06:00
Yes, there are annotations to read from a local pact file vs a broker

matt.fellows
2022-03-07 06:00
I?m not sure what you mean by ?local? vs ?upper?. You should have a single pact broker for _all_ environments, that?s how it?s supposed to be used

tom.daley
2022-03-07 09:09
has joined #pact-jvm

leon.brown
2022-03-07 09:26
has joined #pact-jvm

aurelia.rochat
2022-03-07 10:16
has joined #pact-jvm

misterjkl
2022-03-07 10:41
Hi, we are having dependency convergence issues when using pact maven dependencies. For example for this version of pact.provider: ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.2.20</version> <scope>test</scope> </dependency>``` We get the following errors when attempting a `mvn clean install`. Is this a known issue? is there some workaround? On some projects we?ve worked around it by excluding certain dependencies and including the excluded dependency. This seems quite cumbersome though and it seems that the convergence issues are internal to the pact dependency (e.g. below pact.provider has transient dependencies to 2 versions of org.jetbrains.annotations) and in fact I deferred from using the latest version of pact as the list of convergence errors was far longer than below when I tried it out. Any help much appreciated ```[WARNING] Dependency convergence error for org.jetbrains:annotations:15.0 paths to dependency are: +-our.group.id:contract-test-module:1.1-SNAPSHOT +-au.com.dius.pact.provider:junit5:4.2.20 +-au.com.dius.pact:provider:4.2.20 +-com.vladsch.flexmark:flexmark:0.62.2 +-com.vladsch.flexmark:flexmark-util-ast:0.62.2 +-org.jetbrains:annotations:15.0 and +-our.group.id:contract-test-module:1.1-SNAPSHOT +-au.com.dius.pact.provider:junit5:4.2.20 +-au.com.dius.pact:provider:4.2.20 +-com.vladsch.flexmark:flexmark:0.62.2 +-com.vladsch.flexmark:flexmark-util-builder:0.62.2 +-org.jetbrains:annotations:15.0 and +-our.group.id:contract-test-module:1.1-SNAPSHOT +-au.com.dius.pact.provider:junit5:4.2.20 +-au.com.dius.pact:provider:4.2.20 +-com.vladsch.flexmark:flexmark:0.62.2 +-com.vladsch.flexmark:flexmark-util-collection:0.62.2 +-org.jetbrains:annotations:15.0 and +-our.group.id:contract-test-module:1.1-SNAPSHOT +-au.com.dius.pact.provider:junit5:4.2.20 +-au.com.dius.pact:provider:4.2.20 +-com.vladsch.flexmark:flexmark:0.62.2 +-com.vladsch.flexmark:flexmark-util-data:0.62.2 +-org.jetbrains:annotations:15.0 and +-our.group.id:contract-test-module:1.1-SNAPSHOT +-au.com.dius.pact.provider:junit5:4.2.20 +-au.com.dius.pact:provider:4.2.20 +-com.vladsch.flexmark:flexmark:0.62.2 +-com.vladsch.flexmark:flexmark-util-dependency:0.62.2 +-org.jetbrains:annotations:15.0 and +-our.group.id:contract-test-module:1.1-SNAPSHOT +-au.com.dius.pact.provider:junit5:4.2.20 +-au.com.dius.pact:provider:4.2.20 +-com.vladsch.flexmark:flexmark:0.62.2 +-com.vladsch.flexmark:flexmark-util-format:0.62.2 +-org.jetbrains:annotations:15.0 and +-our.group.id:contract-test-module:1.1-SNAPSHOT +-au.com.dius.pact.provider:junit5:4.2.20 +-au.com.dius.pact:provider:4.2.20 +-com.vladsch.flexmark:flexmark:0.62.2 +-com.vladsch.flexmark:flexmark-util-html:0.62.2 +-org.jetbrains:annotations:15.0 and +-our.group.id:contract-test-module:1.1-SNAPSHOT +-au.com.dius.pact.provider:junit5:4.2.20 +-au.com.dius.pact:provider:4.2.20 +-com.vladsch.flexmark:flexmark:0.62.2 +-com.vladsch.flexmark:flexmark-util-misc:0.62.2 +-org.jetbrains:annotations:15.0 and +-our.group.id:contract-test-module:1.1-SNAPSHOT +-au.com.dius.pact.provider:junit5:4.2.20 +-au.com.dius.pact:provider:4.2.20 +-com.vladsch.flexmark:flexmark:0.62.2 +-com.vladsch.flexmark:flexmark-util-sequence:0.62.2 +-org.jetbrains:annotations:15.0 and +-our.group.id:contract-test-module:1.1-SNAPSHOT +-au.com.dius.pact.provider:junit5:4.2.20 +-au.com.dius.pact:provider:4.2.20 +-com.vladsch.flexmark:flexmark:0.62.2 +-com.vladsch.flexmark:flexmark-util-visitor:0.62.2 +-org.jetbrains:annotations:15.0 and +-our.group.id:contract-test-module:1.1-SNAPSHOT +-au.com.dius.pact.provider:junit5:4.2.20 +-au.com.dius.pact:provider:4.2.20 +-com.vladsch.flexmark:flexmark-ext-tables:0.62.2 +-com.vladsch.flexmark:flexmark-util:0.62.2 +-com.vladsch.flexmark:flexmark-util-options:0.62.2 +-org.jetbrains:annotations:15.0 and +-our.group.id:contract-test-module:1.1-SNAPSHOT +-au.com.dius.pact.provider:junit5:4.2.20 +-au.com.dius.pact:provider:4.2.20 +-com.vladsch.flexmark:flexmark-ext-tables:0.62.2 +-com.vladsch.flexmark:flexmark-util:0.62.2 +-org.jetbrains:annotations:15.0 and +-our.group.id:contract-test-module:1.1-SNAPSHOT +-au.com.dius.pact.provider:junit5:4.2.20 +-org.jetbrains.kotlin:kotlin-stdlib:1.3.72 +-org.jetbrains:annotations:13.0```

tomknee1
2022-03-07 11:29
hi are there any good tutorials on how to apply consumer versioning (branches) when publishing with pact (both/either via gradle ideally or pact cli) ?

nathan.deamer
2022-03-07 18:12
This is how I publish my consumer pacts: `pact-broker publish build/pacts --consumer-app-version=$(git rev-parse HEAD) --branch=$(git rev-parse --abbrev-ref HEAD)`

nathan.deamer
2022-03-07 18:14
If you want to use the gradle plugin something like this?. (Think this was in one of the pact JVM tutorials ```def getGitHash = { -> def stdout = new ByteArrayOutputStream() exec { commandLine 'git', 'rev-parse', 'HEAD' standardOutput = stdout } return stdout.toString().trim() } def getGitBranch = { -> def stdout = new ByteArrayOutputStream() exec { commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD' standardOutput = stdout } return stdout.toString().trim() } static def getOrDefault(env, defaultVal) { def val = System.getenv(env) if (val == null || val.isEmpty()) { val = defaultVal } return val } pact { broker { pactBrokerUrl = getOrDefault("PACT_BROKER_BASE_URL", null) pactBrokerToken = getOrDefault("PACT_BROKER_TOKEN", null) } publish { consumerVersion = getGitHash() consumerBranch = getGitBranch() //tags = [getGitBranch()] } }```

tomknee1
2022-03-07 18:14
thank you, thats actually what ive ended up doing too just this morning, glad my understanding was on the right track

rawatankit90
2022-03-07 20:05
Hello, I just want to understand how will the provider test will look like for a POST method. Any example, i want to validate that when the post method is called, a random id is generated in body along with status

kabhatiya
2022-03-08 00:51
has joined #pact-jvm

luis.garelli
2022-03-08 09:29
has joined #pact-jvm

andrevdrodrigues
2022-03-08 12:50
has joined #pact-jvm

andrevdrodrigues
2022-03-08 13:07
Hello @yousafn how are you? Im a little bit confused regarding the official support to avro, protobufs and grpc. Does Pactflow have an official support for these features? Can we consider this post as a solution for any case related to kafka? Thanks a lot.

tobias
2022-03-08 13:11
has joined #pact-jvm

tobias
2022-03-08 13:20
Hey there, given a bigger multi-module project with multiple consumers and providers, I?d like to have a simple way of tagging the pacticipants after a deploy (everything is deployed together a the same time). I currently have to hard code the list of known pacticipant names and loop over that list, performing something similar to the snippet below: ```for pacticpant in "${pacticipants}" do pact-cli broker create-version-tag --pacticipant="${pacticipant}" --version="${version}" --tag=${tag} done``` Is there a simpler way of tagging _every_ pacticipant in a Maven project or at least collecting the list of pacticipants?

nathan.deamer
2022-03-08 14:24
What do you use for the pacticipant names? Could you use the directory structure to get the names instead of hardcoding a list?

mutharaju.kk
2022-03-08 14:34
has joined #pact-jvm

yousafn
2022-03-08 14:40
Hey @andrevdrodrigues. @matt.fellows@matt.fellows@matt.fellows wrote a blog post last year about the use case and current progress of proto/avro/grpc support. https://pactflow.io/blog/the-case-for-contract-testing-protobufs-grpc-avro/ It's still high on the teams roadmap. See the open pactflow roadmap issue here https://github.com/pactflow/roadmap/issues/5 It depends on building the pact plug-in infrastructure which is tracked here. https://github.com/pactflow/roadmap/issues/33 Hope this helps a little bit provide some context to the background discussions and where we are now. Would love to get your feedback, thoughts, proposals, votes on the canny OSS feature board or if you'd like to help support. We always welcome any contributions :) Full disclosure - I'm super new to the world of avro/proto/grpc and Kafka so with regards to it applicable to _any_ use case, I would always as a tester err on the side of caution and say it depends on your particular use case. I'd love to hear if this works, or doesn't for you :v::skin-tone-4:

tobias
2022-03-08 14:45
That's not feasible: we have quite a monolith, which contains different unrelated services. A shared structure would not match the actual domain contexts. We're actually aiming at splitting that monolith, which is why Pacts shall help to increase confidence. I hoped for some tool to extract the pacticipants straight from the sources or rendered Pacts, just like the Maven plugin detects them.

gerry
2022-03-08 14:48
@gerry has left the channel

tobias
2022-03-08 14:51
... or the other way around: the Maven plugin might be used to add a tag. I didn't find such a feature, yet, so I'm thinking about a feature request.

will.robinson
2022-03-08 14:54
has joined #pact-jvm

nathan.deamer
2022-03-08 14:59
Does this help? I don?t use the maven plugin https://docs.pact.io/implementation_guides/jvm/provider/maven#plugin-properties `pact.consumer.tags`

andrevdrodrigues
2022-03-08 15:06
Ok, I got it. However, are there some prevision about the probable date to this plugins are availables?

fragonib
2022-03-08 16:22
has joined #pact-jvm

tobias
2022-03-08 16:59
I can try - now I'm asking myself, whether the "publish" can happen multiple times with the same version, so that we can have multiple tags (test and production stages). We'll see, thanks for your support!

tobias
2022-03-08 17:00
... also thinking about the scope here: publishing is for the consumer, but we also need to tag the provider names :thinking_face:

jason.wang
2022-03-08 19:05
has joined #pact-jvm

matt.fellows
2022-03-08 21:34
the `--tag` flag can be specified multiple times, if that?s what you?re asking?

matt.fellows
2022-03-08 21:38
You can see the columns that each feature is in, which should give you general ideas of timelines (Q1, Q2 etc.)

matt.fellows
2022-03-08 21:38
Protobufs is currently implemented as a plugin, however we need to add plugin support to all languages for that to be widely available

matt.fellows
2022-03-08 21:38
gRPC will be the next plugin

yousafn
2022-03-08 22:07
@uglyog

uglyog
2022-03-08 22:29
There are lots of example tests in the Pact-JVM repository. Just search that for Post

sam680
2022-03-09 05:12
has joined #pact-jvm

annette.reid
2022-03-09 07:43
has joined #pact-jvm

rejeesh.g
2022-03-09 13:25
Thanks ... found the root cause of this issue. Pact Provider Contract Test was expecting both Test Class as well as provider method to use public access specifier.

andrevdrodrigues
2022-03-09 15:39
Thank you @matt.fellows, but for avro is the same case? I didnt find this issue on roadmap.

tobias
2022-03-09 19:46
@matt.fellows I would need multiple `--pacticipant` flags, so that I wouldn't have to execute the command multiple times, but before doing so I'm still struggling to find an easy way of collecting all pacticipant names in my repo. Maybe I'll try to describe again and you can tell me whether I'm overcomplicating things or overlooked some detail: ? We have a Maven multi-module project (400 modules), where some modules are consumers C, and some modules are providers P. ? Some C and P have contracts to services outside of the multi-module project. ? Publishing C Pacts works, along with the global version of the complete multi-module project, using the Pact Maven plugin. ? Verifying for P works as well (via JUnit5 tests). ? Releasing/Deploying always deploys _every_ C and P at the same time (did I mention the monolith? :wink: ) for the whole project. ? After successful deployment, C and P have to be tagged with the deployed stage, and this is where I'm struggling. ? At that step, I know the deployed version and the stage, but I don't know all the names for C and P. I actually never know them at all, because everything is delegated to the Pact libraries/plugins. So, I'd wish for some kind of report or file, where all C and P are collected, maybe as outcome of the publishing and verification steps. I can certainly use the log output, but you certainly agree that this doesn't feel very reliable. To conclude: ? Am I missing some detail or do I have to tag the pacticipant version somewhere else? ? Is there a convenient tool to collect every pacticipant in a given rep?

tobias
2022-03-09 19:48
... and sorry for the wall of text, I just don't know how to describe the problem in a more concise way.

victor.lau
2022-03-09 20:46
has joined #pact-jvm

abhay175
2022-03-09 23:18
@uglyog , @matt.fellows@matt.fellows@matt.fellows@Matt (http://pactflow.io / pact-js / pact-go)@Matt (http://pactflow.io / pact-js / pact-go) , i resolved the 404 issue The problem was our app is based on both jersey and spring mvc. The path annotations on resources were of jersey which were not getting picked up by the runner i believe. After replacing it with spring annotations like @RequestMapping and @GetMapping, it worked fine. I am using MockMvcTarget. Is this not the right way to test?

matt.fellows
2022-03-10 00:19
Avro is not curently being worked on. Once the plugin framework is fully up and runninsg across the ecosystem, we may create an Avro plugin (or somebody else could)

matt.fellows
2022-03-10 00:19
Avro should be pretty easy, I would have thought

andrevdrodrigues
2022-03-10 10:11
hmmm, ok. Thanks.. I checked this thread: https://github.com/pact-foundation/pact-jvm/issues/603 I think that is the same case.

matt.fellows
2022-03-10 11:36
Yes. For clarity, we are creating a general plugin framework and rolling that out across the Pact ecosystem

matt.fellows
2022-03-10 11:36
This will enable anyone (including Pact maintainers) to create new plugins - such as gRPC, protobufs, Avro or <some new thing> support.

matt.fellows
2022-03-10 11:37
I?m assuming you?re a JVM user, you could potentially look at the protobufs plugin and replicate it for Avro

matt.fellows
2022-03-10 11:37
The gRPC plugin will be coming to JVM relatively soon. Do you need to interop with other languages, or is it all JVM for now?


sebastianman45
2022-03-10 15:10
has joined #pact-jvm

andrevdrodrigues
2022-03-10 16:37
Hey @matt.fellows, thanks for your response. We are thinking about that yet... However, our main stack is .Net. Probably Im on a thread in wrong channel rsrs :confused:

andrevdrodrigues
2022-03-10 16:39
This plugin won't be agnostic for any language?

kenneth.krause
2022-03-10 16:41
has joined #pact-jvm

tomknee1
2022-03-10 17:38
@uglyog sorry just to follow up on this, if the provider side (e.g. pact go) is stuck using v2 spec, is there anything i can do for this or am i forced to specify just one specific status code and i assume id be having to use v2 spec on consumer side (jvm) too?

uglyog
2022-03-10 20:59
No, sorry, the V2 implementations don't have anything like this

matt.fellows
2022-03-10 21:02
the plugin _is_ technology agnostic

matt.fellows
2022-03-10 21:03
write once and execute anywhere, but the main thing is that the plugin framework needs to be added to .NET

tomknee1
2022-03-10 21:14
ok thanks, what about v3 spec?

uglyog
2022-03-10 21:16
No, it was added in V4

uglyog
2022-03-10 21:17
But anything that supports V3 should also have V4 support

tomknee1
2022-03-10 21:18
hm ok, unfortunately the person helping me on pact go provider side is on m1 mac and having issues getting up and running with v3 spec so i think we might have to use v2 spec

tomknee1
2022-03-10 21:18
thanks for the info

bergner
2022-03-11 06:19
has joined #pact-jvm

gotax80534
2022-03-11 06:55
has joined #pact-jvm

mathias
2022-03-11 10:17
has joined #pact-jvm

jtcsek
2022-03-11 13:02
has joined #pact-jvm

andrevdrodrigues
2022-03-11 14:11
hmmm, right.

rawatankit90
2022-03-11 18:34
Hi , I am getting below error while running the provider test but the consumer test are successful and pact is published to pact broker. I am using Token mechanism

rawatankit90
2022-03-11 18:54
belos is log @uglyog

joachim005
2022-03-14 08:16
has joined #pact-jvm

alexstout009
2022-03-14 14:32
has joined #pact-jvm

paul.richards
2022-03-14 14:38
has joined #pact-jvm

akif.tahir
2022-03-14 15:00
has joined #pact-jvm

lramos
2022-03-14 16:29
has joined #pact-jvm

michael036
2022-03-14 18:31
has joined #pact-jvm

me1295
2022-03-14 18:36
Apologies for the delayed response on this one - Unfortunately I am still encountering this issue

me1295
2022-03-14 18:37
We did encounter several subpath issues that were resolved in the most recent version of the OSS Pact Broker instance - I don't believe the subpath is causing issues here, though

me1295
2022-03-14 18:39
We're using `pact-jvm` with `gradle` to build pacts and publish them..from the debugging I've performed, it looks like no matter we try, the `pactBrokerUsername` and `pactBrokerPassword` values are not being sent in the request to the broker

me1295
2022-03-14 18:39
The errors I am seeing are similar to an issue raised in the #pact-broker channel by David Van Couvering on Tues 8th March

me1295
2022-03-14 18:40
I've checked network logs and these requests do not have a basic auth'd user attached..however, if I try and publish pacts using a `pact-node` codebase or using the `pact-cli` directly - I can publish pacts with no issue

me1295
2022-03-14 19:05
I've tried multiple ways to get this working with Gradle and passing in system variables, etc - no option seems to persist the auth in the requests

lauren.coggin
2022-03-14 19:27
has joined #pact-jvm

mkanika1811
2022-03-15 09:22
has joined #pact-jvm

ian.pringle
2022-03-15 11:02
has joined #pact-jvm

ukrainian1991
2022-03-15 12:12
Hi, 4.1.34 trying to execute provider tests ```@PactDirectory("pact-files") @Provider("iPaaS_Stripe") @TestInstance(TestInstance.Lifecycle.PER_CLASS) class PactStripeProviderTest {``` as a result ```Did not find any PactSource annotations. At least one pact source must be set java.lang.UnsupportedOperationException: Did not find any PactSource annotations. At least one pact source must be set``` However, pact is present in pact-files folder. Do you know how to handle this?

karl.wagner
2022-03-15 12:25
has joined #pact-jvm

matt.fellows
2022-03-15 13:42
Check the annotation, I think there is another with the same name which is the correct one

ukrainian1991
2022-03-15 13:46
I tried PactFolder - result is the same. Moreover PactFolder is marked as deprecated

ukrainian1991
2022-03-15 13:47
Seems it works if I choose PactBroker, but I need to use PACT file from folder


ukrainian1991
2022-03-15 13:48
I use this doc

me1295
2022-03-15 16:15
@matt.fellows @uglyog - any ideas?

uglyog
2022-03-15 22:10
Try making your test class public

uglyog
2022-03-15 22:13
401 Unauthenticated response means your credentials are not correct. What Pact broker are you connecting to?

matt.fellows
2022-03-16 00:00
Sorry I?m not sure, I don?t know JVM/Pact JVM well enough to advise. Usually, verbose/debug logging will get you there though

matt.fellows
2022-03-16 02:23
Are you using Pactflow or the open source broker? Pactflow uses the token mechanism, but for the OSS it?s likely a username/password combination

rawatankit90
2022-03-16 03:23
my credentials are correct. I am using pactflow and using the read/write token. If i pass the token in the Java class it is getting accepted but if i do from mvn it is not getting accepted ```<pact.version>4.1.28</pact.version>``` below is my maven command mvn clean test -PproducerContractTestWithBroker \ -Dpact.broker.url="https://x.pactflow.io/" \ -Dpact.broker.token="xxxxxxx" \ -Dpact.verifier.publishResults=true

rawatankit90
2022-03-16 03:59
I solved it. i was not setting the token in systemPropertyVariables of surefire. By setting there, it worked

chaitasi.patel988
2022-03-16 04:04
has joined #pact-jvm

ukrainian1991
2022-03-16 07:26
It's kotlin. With public modifier behaviour is the same

jose.iglesias
2022-03-16 09:23
has joined #pact-jvm

alegab0710
2022-03-16 10:20
has joined #pact-jvm

serghei.pogodin
2022-03-16 12:31
has joined #pact-jvm

tobias
2022-03-16 12:43
where is the `pact-files` folder located? Maybe the base path is different?

ukrainian1991
2022-03-16 12:57
_pact-files_ is in the root folder of the project. And path works for Consumer tests, which generates this pact file

jeremy.vincent
2022-03-16 14:29
has joined #pact-jvm

1.g10squad
2022-03-16 16:01
has joined #pact-jvm

alistair.c.kung
2022-03-16 18:44
has joined #pact-jvm

adam.howard
2022-03-17 02:05
has joined #pact-jvm

jonatan.jaworski
2022-03-17 02:32
has joined #pact-jvm

kjayachandra2000
2022-03-17 06:32
Hey Team:wave:, I am trying to publish pact with version using gradle plugin. [au.com.dius.pact:4.1.34] below is the config ```pact { publish { pactDirectory = "$buildDir/pacts" pactBrokerUrl = 'https://pact.sample.com/' pactBrokerUsername = 'username' pactBrokerPassword = System.getenv("PACT_PASSWORD") version = System.getenv("COMMIT_HASH") } }``` with this config the project version is affected and changed to the version of `pact` I want to keep actual project version `1.0-SNAPSHOT` and pact consumer version to `COMMIT_HASH`,. Is it possible or am i missing something here? pact-broker version `2.94.0.0`

matt.fellows
2022-03-17 07:22
Looks like a question for #pact-jvm

lewis.greenway-jones
2022-03-17 08:52
has joined #pact-jvm

kjayachandra2000
2022-03-17 11:22
any help here :pray:

matt.fellows
2022-03-17 11:25
Oh, strange, I swear when I answered before it was in general. My apologies Jayachandra

matt.fellows
2022-03-17 11:27
https://docs.pact.io/implementation_guides/jvm/provider/gradle#verifying-pact-files-from-a-s3-bucket this seems to indicate it should be `consumerVersion` and not `version`.

pierre.gerard
2022-03-17 11:59
has joined #pact-jvm

kjayachandra2000
2022-03-17 13:50
thank you so much

kjayachandra2000
2022-03-17 13:50
it worked

pierre.gerard
2022-03-17 15:23
Hello All :pactflow-platypus-slack: ! I'm pretty new with pact and I'm looking for french speaking users to "build" a french pact community :slightly_smiling_face:

yousafn
2022-03-17 15:47
Hey Pierre, :pactflow-platypus-slack: This is very exciting! You may get a better response via #general, as only around half of our users are in this JVM channel. I like the ideal of regional Pact communities, especially under a think globally, act locally mantra. I'd love to think about how we could support you and others in getting this off the ground!

tobias
2022-03-17 21:20
I would expect that the `pact-files` folder would be found at the root of the classpath. So, in a Maven or Gradle project you should try to put the `pact-folder` at `<project-root>/src/test/resources/pact-folder/`.

uglyog
2022-03-17 22:13
the `@PactDirectory` annotation is used to set the output directory that the consumer tests write pacts to. `http://au.com.dius.pact.provider.junitsupport.loader.@PactFolder` is used to setup a loader to load Pacts from a directory.

viswanathan.sarma
2022-03-17 22:39
has joined #pact-jvm

j3rry.wan9
2022-03-17 22:55
Hi team, is `http://au.com.dius.pact.consumer` 4.3.5 affected by https://nvd.nist.gov/vuln/detail/CVE-2021-29425? It looks like we only bumped `commons-io` version for `provider` in https://github.com/pact-foundation/pact-jvm/pull/1464 but not `consumer`?

madhulika.mitra
2022-03-18 15:56
has joined #pact-jvm

rupam.saha
2022-03-21 09:26
has joined #pact-jvm

christian.jeppesen
2022-03-21 10:10
has joined #pact-jvm

anand.kannan
2022-03-21 10:10
has joined #pact-jvm

mikhail.yartsev
2022-03-21 10:10
has joined #pact-jvm

bblechman
2022-03-21 16:36
has joined #pact-jvm

jeffrey2011998
2022-03-22 09:22
has joined #pact-jvm

xavier.arque
2022-03-22 11:33
has joined #pact-jvm

aubrey
2022-03-22 14:32
has joined #pact-jvm

balazs
2022-03-22 15:51
has joined #pact-jvm

seasharp37
2022-03-22 22:17
has joined #pact-jvm

saritacutinha
2022-03-23 07:09
has joined #pact-jvm

rachelb
2022-03-23 10:16
has joined #pact-jvm

shaheen
2022-03-23 23:11
has joined #pact-jvm

athaper
2022-03-24 07:47
We?re getting this error on provider pact verification and are unable to figure out what is causing it , can someone help please? ```Exception in thread "Thread-58" java.lang.NoSuchMethodError: 'void org.apache.commons.codec.digest.DigestUtils.<init>(java.security.MessageDigest)' at au.com.dius.pact.core.support.Metrics.hostnameHash(Metrics.kt:151) at au.com.dius.pact.core.support.Metrics.sendMetrics$lambda-2(Metrics.kt:105) at java.base/java.lang.Thread.run(Thread.java:829)```

saurabh.goel
2022-03-24 10:16
Hey everyone, we have multiple consumers consuming the same message from provider. The provider verification test classes for all these consumers look absolutely same. the only difference is the @Consumer("consumerName") annotation. It is creating a lot of duplicate code. Is there a way i could declare multiple consumer annotations, or multiple consumers names in the same annotation or reuse the providerverification methods. I tried to re-use the methods by putting them all in a AbstractFile and extending my consumers from it. In this case I start getting the below error: `Unable to fetch provider method ...`

matt.fellows
2022-03-24 10:20
What happens if you remove the `@Consumer` annotation on the method - can you still select the correct consumers from the `@PactBroker` annotation?

saurabh.goel
2022-03-24 10:25
i have put the @Consumer annotation on the class , not on the method. let me share some code snippet below the child class for specific consumer ```@Consumer("consumerName") @Provider("providerName") public class VcOrderEventsMessagePV extends AbstractOrderChangeNotificationPV {``` the parent class containing providerverification methods for all consumers ```public class AbstractOrderChangeNotificationPV extends AbstractContractVerifierTest { @BeforeEach public void beforeEach(PactVerificationContext context) { LOG.debug("beforeEach({})", context); setMessageTestTarget(context); } @TestTemplate @ExtendWith(PactVerificationSpringProvider.class) public void testOrderChangeNotification(Pact pact, Interaction interaction, PactVerificationContext context) { if (context == null) { return; } context.verifyInteraction(); } @PactVerifyProvider(ProviderVerificationNames.RESTAURANT_CP_RECEIVED) public String restaurantPickupOrderReceived() { return getRestaurantCustomerPickupMessage(RECEIVED); }``` grandparent class containing the methods needed for setting up the system in the correct state ```@PactBroker @IgnoreNoPactsToVerify @AllowOverridePactUrl public abstract class AbstractContractVerifierTest extends AbstractOrderEventDrivenTest {```

saurabh.goel
2022-03-24 10:47
consumer is deprecated in pactbroker

matt.fellows
2022-03-24 11:00
I?m guessing it?s deprecated in favour of consumer version selectors

saurabh.goel
2022-03-24 11:14
yes

sentyaev
2022-03-24 12:36
has joined #pact-jvm

altan.demirkiran
2022-03-24 14:06
has joined #pact-jvm

jonathan.fortunati
2022-03-24 21:53
has joined #pact-jvm

uglyog
2022-03-24 23:53
Remove the `@Consumer` annotation as Matt said

simon.dicola
2022-03-25 10:25
has joined #pact-jvm

mrooschuz
2022-03-25 14:52
has joined #pact-jvm

ashok.pathak
2022-03-25 15:17
has joined #pact-jvm

rdanthuluri
2022-03-27 03:28
has joined #pact-jvm

saurabh.goel
2022-03-28 10:51
yeah after making the changes it is working correctly. so to summarize, if we need to add multiple consumers we can use consumerversionselector in pactbroker annotation. Thanks a lot :smile: :beers:

cudi.unal
2022-03-28 11:25
has joined #pact-jvm

ashraf.anwar.iw
2022-03-28 13:12
has joined #pact-jvm

b.costa
2022-03-28 13:15
has joined #pact-jvm

mark.hopper
2022-03-28 14:53
has joined #pact-jvm

ashraf.anwar
2022-03-28 15:08
has joined #pact-jvm

damianruizdev
2022-03-28 18:44
has joined #pact-jvm

mike.key
2022-03-29 02:46
I am getting an error when using ` ```u.com.dius.pact.provider:junit5spring:4.3.6``` library when talking to an on premise pact broker?any insight as to what I may be doing wrong? ```Caused by: au.com.dius.pact.core.pactbroker.RequestFailedException: Request to path '/' failed with response 406 at app//au.com.dius.pact.core.pactbroker.HalClient.handleHalResponse(HalClient.kt:326) at app//au.com.dius.pact.core.pactbroker.HalClient.access$handleHalResponse(HalClient.kt:150) at app//au.com.dius.pact.core.pactbroker.HalClient$getJson$1.invoke$lambda-0(HalClient.kt:301) at app//org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:202) at app//org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:143) at app//au.com.dius.pact.core.pactbroker.HalClient$getJson$1.invoke(HalClient.kt:300) at app//au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:39) at app//au.com.dius.pact.core.pactbroker.HalClient.getJson(HalClient.kt:295) at app//au.com.dius.pact.core.pactbroker.HalClient.fetch(HalClient.kt:259) at app//au.com.dius.pact.core.pactbroker.HalClient.fetch(HalClient.kt:254) at app//au.com.dius.pact.core.pactbroker.HalClient.navigate(HalClient.kt:236) ... 80 more```

uglyog
2022-03-29 02:54
406 means the content negotiation failed. It is not a normal response code, and is normally because the request has an invalid charset or language specified in an accept header.

uglyog
2022-03-29 02:55
Is there a proxy in front of your pact broker? Also, look at the debug level logs and you might see what accept headers were sent

matthew.churcher
2022-03-29 08:48
has joined #pact-jvm

ben.brugman
2022-03-29 14:32
has joined #pact-jvm

mike.key
2022-03-29 14:45
ugh, sorry for the post, I should have known where the issue was, thanks for the response!

hassan.shaikley
2022-03-29 16:14
has joined #pact-jvm

oakkub.1995
2022-03-30 07:10
has joined #pact-jvm

serghei.pogodin
2022-03-30 08:16
Hi, I'm using Pact JVM to generate my consumer contracts to further upload them to Pactflow. I'm facing an issue with wildcards usage in matchQuery method. When I'm using `matchQuery("myQueryParam", ".*")` it's generating a value which is not supported by Pactflow. Example of generated value: `"\u095D"` . Do you think this should be fixed in Pact JVM or Pactflow should be able to handle values like this?

serghei.pogodin
2022-03-30 08:18
FYI: I already found a way to continue with a more precise regex. But still would be nice to fix the issue

andrefcsousa
2022-03-30 14:22
Hello. I'm trying to implement contract testing between two services that communicate through a kafka stream. There is one consumer and one provider and the later publishes messages using protobuf message format. I'm trying to implement consumer contract tests on the consumer side which is a java service but i have doubts about how to do it with Pact. I'm trying to follow this example plugin for Pact: https://github.com/pact-foundation/pact-plugins/tree/main/examples/protobuf

andrefcsousa
2022-03-30 14:23
can anyone tell me the maven dependencies needed to use PactBuilder and V4Pact classes?

andrefcsousa
2022-03-30 14:24
on this example gradle is used to build but it's possible to use this example with maven?

hiqbal
2022-03-30 15:16
has joined #pact-jvm

sstenhouse
2022-03-30 15:16
has joined #pact-jvm

andrefcsousa
2022-03-30 16:45
From the instructions https://github.com/pact-foundation/pact-plugins/tree/main/plugins/protobuf i need to build the plugin and install with Gradle but it will be possible to use this plugin on a java service that uses maven as build tool? btw, the consumer service is Java 8

bmeyres
2022-03-30 17:37
has joined #pact-jvm

bmeyres
2022-03-30 17:44
Hi all Im trying to create a pact between two services where the request is content-type form-data. With some googling i've found this snippet: ```.withFileUpload("file", "some.json", "multipart/form-data", new byte[]{10,40,61,153,16})``` but what im struggling with is how to add non-file key:values pairs? a curl example would be: ```curl --location --request POST 'http://localhost:8888/v1/some/ep' \ --form 'data1="abc"' \ --form 'data2="def' \ \ --form 'fileData=@"/some/file_dir/some_file.gz"'``` Can anyone explain how i add `data1` and `data2` to my pact? Thanks a lot!

alejandro.velez
2022-03-30 18:42
has joined #pact-jvm

justin
2022-03-30 20:07
has joined #pact-jvm

uglyog
2022-03-30 21:07
If you don't provide an example value, it will generate a random one from the regex. Just provide an example as the third parameter

justin
2022-03-30 21:23
Is there a good way to make the consumer side generate v2 spec matchers? I'm generating a spec with (Kotlin, sorry for the weird syntax) ```val pact = ConsumerPactBuilder .consumer("Android") .pactSpecVersion(PactSpecVersion.V2) ... .willRespondWith() .status(200) .body( newJsonObject { this.`object`("data") { o -> o.integerType("created_at", 1648049202) } } )``` I was hoping that setting it to pact spec 2 it would generate (yeah, it's still not quite v2, but go supports the v3 doc, just not the v3 matchers) ``` "$.data.tokens[0].created_at": { "combine": "AND", "matchers": [ { "match": "type" } ] },``` but instead it's still generating te v3 matcher (which isn't yet supported in go, which is what our producer is written in) ``` "$.data.tokens[0].created_at": { "combine": "AND", "matchers": [ { "match": "integer" } ] },```

matt.fellows
2022-03-30 21:47
I don't think java 8 is supported for plugins but could be wrong.

uglyog
2022-03-30 22:02
Maven is definitely supported, but the version that provides plugin support requires JDK 11+

uglyog
2022-03-30 22:03
There was a PR that added support for adding other parts to the request. Let me try find it

uglyog
2022-03-30 22:07
Ah, yes. The format will be V2, but it does not filter or change the matchers.

bmeyres
2022-03-30 22:07
:+1: thankyou @uglyog

uglyog
2022-03-30 22:07
There is a beta version of Pact Go with V3 support


uglyog
2022-03-30 22:11
It contains an example test, which uses `addTextBody` to add other parts to the request

justin
2022-03-30 22:18
I tried running it but it has tons of additional dependencies and one of them was causing issues with our builds. Was hoping coming at it from the consumer side might be a little easier.

leo.adriano1994
2022-03-31 00:00
has joined #pact-jvm

abubics
2022-03-31 00:35
As an aside, the generated string for `.*` might be highlighting edge cases you hadn't thought about :slightly_smiling_face:

hitesh.patadia
2022-03-31 04:27
has joined #pact-jvm

andrefcsousa
2022-03-31 08:27
Bad news :disappointed: Nevertheless, do you have some suggestion how to implement contract testing on protobuf messages? There is another way for java 8 services?

matt.cockayne
2022-03-31 11:02
has joined #pact-jvm

andrefcsousa
2022-03-31 14:42
Any example message pact project of a consumer and provider for jvm that i can use?

jimmy
2022-03-31 15:39
has joined #pact-jvm


matt.fellows
2022-03-31 21:29
The Pactflow docs also has some message examples

bret.mcclory538
2022-04-01 01:10
has joined #pact-jvm

michael.d
2022-04-01 04:40
has joined #pact-jvm

yash.deole
2022-04-01 07:07
has joined #pact-jvm

alan.alie
2022-04-01 08:10
has joined #pact-jvm

jimmy
2022-04-01 08:11
@jimmy has left the channel

ricardo.cruz
2022-04-01 11:54
has joined #pact-jvm

lauren.corderoy
2022-04-01 12:24
has joined #pact-jvm

jiayao.xu
2022-04-01 12:24
has joined #pact-jvm

michael.branders
2022-04-01 13:12
Hey, I'm just working with the LambdaDSL and if i use a date it expects a java.util.Date and there is no option for a java.time.Localdate . Localdate has replaced Date in java 8 why did you design the new LambdaDSL without Localdate? Is it something that you will add in the lambdaDSL soon? We never use Date anymore in code and to convert Localdate to Date just for pacts, I'm not a fan for that.

bret.mcclory538
2022-04-01 14:36
@bret.mcclory538 has left the channel

shiva.velde0413
2022-04-01 14:44
has joined #pact-jvm

bmeyres
2022-04-01 17:18
@uglyog sorry for delayed response, this was exactly what i need thanks for the help!

uglyog
2022-04-03 22:53
> why did you design the new LambdaDSL without Localdate? I guess you are imagining that all the DSLs have been designed upfront, when actually they are from a sequence of PRs provided by different people over time. The original authors of that DSL did not need to use Localdate, so did not add support for it. If you can create a PR, when can get that merged pretty quickly.

npc1222
2022-04-04 04:37
has joined #pact-jvm

michael.branders
2022-04-04 06:24
Ok I'll look into doing that. You can transform Date and Localdate easy into eachother. Its just that we dont use Dates anyware anymore so it would be handy that the transformation is inside the Pactcode. Where can I create a PR?


athaper
2022-04-04 07:58
Hey We?re trying to write contract test where the API uses bearer token which expires after a short period If we input the bearer from consumer test then it might get expired when test runs on provider , is there any workaround for that ? somehow we could declare a variable or dummy value which then gets replaced by the newly generated bearer when provider verification tests run ?


shiva.velde0413
2022-04-04 11:32
hi everyone

shiva.velde0413
2022-04-04 11:32
i would need sample code repo for Messaging PACT

shiva.velde0413
2022-04-04 11:32
does anyone has any leads?

shiva.velde0413
2022-04-04 11:32
Please ping hee

shiva.velde0413
2022-04-04 11:32
here*'

matt.fellows
2022-04-04 11:45
I responded to your question yesterday Shiva, please check your original question

shiva.velde0413
2022-04-04 12:42
sure

shiva.velde0413
2022-04-04 12:45
Yes Matt

shiva.velde0413
2022-04-04 12:46
Actually i would need code repo /github link which contains PACT MQ Contract testing code

shiva.velde0413
2022-04-04 12:46
thank you

matt.fellows
2022-04-04 13:03
Howtoexamples


arthur
2022-04-04 14:28
has joined #pact-jvm

andrefcsousa
2022-04-04 15:20
I was reading this stack overflow topic about how message pact was initially done for kafka streams cases: https://stackoverflow.com/questions/44884316/how-to-implement-contract-testing-when-kafka-is-involved-in-microservice-archite

andrefcsousa
2022-04-04 15:20
can anybody give me the link for the jvm example?

andrefcsousa
2022-04-04 16:02
Also i still have doubts how pact works for messaging cases. On the provider side should i use a MessageTarget pointing to a real kafka topic?

yousafn
2022-04-04 16:41
Hey @andrefcsousa, we have some examples here for Kafka https://docs.pactflow.io/docs/examples#consumers for JS and Java https://docs.pactflow.io/docs/examples#providers for Java We also have a recipe for Kafka here https://docs.pact.io/recipes/kafka#schema-registry-json-provider Hope this helps indirectly answer your question

andrefcsousa
2022-04-04 18:21
Thanks @yousafn. Its correct to interpret that this object MessageAndMetadata will be used by Pact to compare the message defined by the consumer against the one produced by the provider?

andrefcsousa
2022-04-04 18:21
For instance, this method: @PactVerifyProvider("a product created event") public MessageAndMetadata productCreatedEvent() throws JsonProcessingException { ProductEvent product = new ProductEvent("id1", "product name", "product type", "v1", EventType.CREATED, 27.00); Message<String> message = new ProductMessageBuilder().withProduct(product).build(); return generateMessageAndMetadata(message); }

andrefcsousa
2022-04-04 18:22
This method won't write into a existing kafka topic right? it'll just create this MessageAndMetadata object for Pact to match?

abhay175
2022-04-04 19:36
Hi, Is there something similar to MockMvcTarget for testing Jersey resources. we have a spring-jersey application and not sure how to test it. if i change the resources to spring, the pact tests works ok however the endpoints are not reachable when the server is turned on.

jarmy
2022-04-04 21:05
Hello. We have a project that's using JDK 8 and trying to do a deploy build with `classpath 'au.com.dius.pact.provider:gradle:4.2.11'` in one of the build files and getting this error: ```13:33:09 A problem occurred evaluating project ':dsp-service'. 13:33:09 > java.lang.UnsupportedClassVersionError: au/com/dius/pact/provider/gradle/PactPlugin has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0``` Is there a specific version of the gradle plugin that supports JDK 8?

jarmy
2022-04-04 21:08
cc @srinagasai.krishnasan

matt.fellows
2022-04-05 01:08
Yeah I think the 4.1.x line supports JDK 8


agastiya.mohammad
2022-04-05 01:19
has joined #pact-jvm

paul.stapleton
2022-04-05 07:33
has joined #pact-jvm

iurisoares1012
2022-04-05 09:53
has joined #pact-jvm

gocool9996
2022-04-05 10:04
has joined #pact-jvm

jarmy
2022-04-05 16:04
Thanks Matt

simrat.sidhu
2022-04-05 16:07
has joined #pact-jvm

bmeyres
2022-04-05 17:34
@uglyog I've been having trouble playiing my test on the provider, it keeps failing with 422 error. I've noticed the pact body is stored in base64 on pactflow and in the pact JSON is there a reason for that and could that be causing the problem im seeing?

bmeyres
2022-04-05 17:34
Sorry not sure on etiquette as to whether i should of tagged you here or not...seemed relevant to the original thread

gabriel.brazao
2022-04-05 17:42
has joined #pact-jvm

jhonataok01
2022-04-05 17:43
has joined #pact-jvm

bmeyres
2022-04-05 17:49
Also, when i inspect the packet I only see about half of the body being sent via pact-verifier to my producer

andre.mariano
2022-04-05 19:10
has joined #pact-jvm

alex.zuliqiaer
2022-04-05 20:31
has joined #pact-jvm

lflores
2022-04-05 20:33
has joined #pact-jvm

keoma4
2022-04-05 21:17
has joined #pact-jvm

erick.belf
2022-04-05 21:46
has joined #pact-jvm

uglyog
2022-04-05 22:58
It is binary data, so it can't be stored in a JSON file without being encoded

uglyog
2022-04-05 22:58
What are you using to verify the provider?

bmeyres
2022-04-05 23:31
> What are you using to verify the provider? @uglyog Python's Pact Verifier cli tool

uglyog
2022-04-05 23:32
Ah! Yeah, that won't be able to handle binary payloads

bmeyres
2022-04-05 23:32
:slightly_smiling_face: do you know of tool that would? My services are not Java to Java so i cant use the maven plugin for the producer side

bmeyres
2022-04-05 23:33
out of curiosity why wont it handle the binary payloads? is it just not implemented there?

uglyog
2022-04-05 23:48
It is using the Ruby version underneath, which only supports text based bodies. But you can try using the standalone verifier https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier_cli-v0.9.8


bmeyres
2022-04-05 23:51
@uglyog that standalone verifier has support for it correct?

uglyog
2022-04-05 23:59
Yes, it should support it

prabhakar.thippa
2022-04-06 00:35
How do I write PACT contract for { 'idList": [5, 6] } where idList could vary in size I tried ```DslPart requestBody = LambdaDsl.newJsonBody((o) -> { o.array("idList", (arr)-> { arr.numberType(6); });``` This would work if I am passing only one value. If more than value need to be in the list then I have to add something like this... ```arr.numberType(6).numberType(7);``` How can this be made generalized (like minArrayLike) so that one or more could be passed and contract is still valid


prabhakar.thippa
2022-04-06 00:51
nope. When I use minArrayLike I get array of an array whereas i need just an array. Also each array is an jsonObj requiring key(name). In my case I just have list of values.

matt.fellows
2022-04-06 00:57
That doesn?t sound write to me

matt.fellows
2022-04-06 00:57
You should be able to add values to that, I?m sure

abubics
2022-04-06 01:06
I think `eachLike`, `minArrayLike` and `maxArrayLike` open a new object, so you can't use them for primitive types.

abubics
2022-04-06 01:06
`arr` in your example is the object for the `like`, not an array

prabhakar.thippa
2022-04-06 01:07
yes, that's the problem. I was just showing Matt that I can't just add values only.

abubics
2022-04-06 01:08
Yeah, it's just that calling it `arr` gives you misleading DSL expectations :slightly_smiling_face:

prabhakar.thippa
2022-04-06 01:08
I am looking for a generalized way to write contract for { 'idList": [5, 6] } where the list size could vary

abubics
2022-04-06 01:09
Off the top of my head, I have no idea what the Java DSL has for matching arrays by primitive type. (Using both Java and the old DSL also won't be helping discoverability, but that's a little beside the point.)

abubics
2022-04-06 01:10
I guess, from a higher philosophical level, do you have test cases where you really don't care about the values in that list (you might, just confirming)?

prabhakar.thippa
2022-04-06 01:26
I could do this ```o.minArrayLike("categoryIds", 1, PactDslJsonRootValue.numberType(7), 2);``` But this would pass [7,7] to provider. Is there a way to specify actual Ids that I would like to pass to provider.

abubics
2022-04-06 01:31
Your original example does that, I think? ```arr.numberType(6).numberType(7);```

abubics
2022-04-06 01:32
The separate question I thought you were asking was for something like `eachLike` that works with primitives instead of objects :thinking_face:



michaele
2022-04-06 03:40
has joined #pact-jvm

bmeyres
2022-04-06 06:08
I'm trying to publish pact using the maven plugin available. Reading these docs: https://docs.pact.io/implementation_guides/jvm/provider/maven#configured-as-jvm-system-properties But im unable to set the consumer version. Ive tried ```mvn pact:publish -Dpact.publish.consumer.version=0.2-SNAPSHOT export PACT_PUBLISH_CONSUMER_VERSION=0.2-SNAPSHOT``` Neither seem to work. Im getting the following error from the plugin when running `mvn pact:publish` ```Cannot change the content of the pact for Producer version 0.1-SNAPSHOT and provider Producer, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number``` Can anyone tell me how i can increment the consumer version of the pact?

bmeyres
2022-04-06 06:08
This worked! All seems good now :slightly_smiling_face:

uglyog
2022-04-06 06:13
Can you provide debug logs?

matt.fellows
2022-04-06 06:15
the issue is that you are publishing a contract over an existing _consumer version_

matt.fellows
2022-04-06 06:15
you are saying ?here is a new contract for version 0.2-SNAPSHOT of <consumer>?

matt.fellows
2022-04-06 06:16
this is bad, for the reasons shown in the error

matt.fellows
2022-04-06 06:16
you should ensure each time you run a build on new code, the version changes

matt.fellows
2022-04-06 06:17
if the contract is not expected to change (which usually means the code doesn?t change), the version sent to the broker doesn?t need to change either.


iurisoares1012
2022-04-06 09:37
.

gocool9996
2022-04-06 09:49
Hello Everyone , Good day ! I was wondering if someone have tested message queues with pact , I found https://github.com/pact-foundation/pact-jvm/tree/master/provider/junit#verifying-a-message-provider but if there is someone have any real time experience , I would like to connect to know a bit deep about the same , please leave a message :slightly_smiling_face: Thanks In advance :rocket:

matt.fellows
2022-04-06 10:14
Yes, it?s very common

matt.fellows
2022-04-06 10:14
you might like to see some of the example projects :point_down: (howtolearn)

2022-04-06 10:14
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

matt.fellows
2022-04-06 10:14
There is also a Kafka recipe on the docs site (http://docs.pact.io). The linked blog is quite good

gocool9996
2022-04-06 11:07
Thanks @matt.fellows, I will check this out :thank_you:

guillaume.camus
2022-04-06 12:47
has joined #pact-jvm

serghei.pogodin
2022-04-06 13:44
@uglyog but in this case Pactflow should handle all kind of characters randomly generated by Pact

serghei.pogodin
2022-04-06 13:45
Currently if I have a Pact containing "\u095D" Pactflow will not accept it and fail with 500 error I think

bmeyres
2022-04-06 16:50
@matt.fellows thanks for the explanation. Just so I understand you are saying the reason im seeing this error is because there has been no change on the contract between `0.1-SNAPSHOT` and `0.2-SNAPSHOT` ?

bmeyres
2022-04-06 16:56
```Each pact must be published with a unique consumer version number``` This is what i thought I was doing by giving a newer version

danielglazer123
2022-04-06 19:06
has joined #pact-jvm

ashish.goyal
2022-04-06 23:14
has joined #pact-jvm

matt.fellows
2022-04-07 01:15
I didn?t properly read your message, sorry Ben. Your question was how to bump the version, which I don?t know how to answer I?m afraid. According to https://docs.pact.io/implementation_guides/jvm/provider/maven#configured-as-jvm-system-properties that key looks correct, assuming `-D` sets the system property as expected. The env var looks https://docs.pact.io/implementation_guides/jvm/provider/maven#configured-as-environment-variables though (and is exported after the publish command so would have no effect) it should be `PACT_PUBLISH_CONSUMER_VERSION` it seems

bmeyres
2022-04-07 02:30
@matt.fellows No worries thanks for looking into it though. After a little more reading it looks like I can do what i want via the pact_broker-cli so im going to go that route I think

matt.fellows
2022-04-07 02:33
I generally would recommend the CLI also (we also have a docker image and standalone version of that. Search the docs for a link)

abubics
2022-04-07 04:31
I'm not so sure about that . . . query parameters don't actually support `.*`, because characters need to be encoded outside the acceptable list. I don't know if it's reasonable to expect `matchQuery` to encode things for you, or if that should be a distinct capability, or option to the method. :thinking_face:

uglyog
2022-04-07 04:47
Better to use `[a-zA-Z0-9]+`

serghei.pogodin
2022-04-07 07:11
@uglyog yes, that's similar to what I did. But if let's say query parameters are allowed to have other characters than alphanumeric, that can take much more time to define a regex.

serghei.pogodin
2022-04-07 07:14
Is it an option to have a method like `queryString` which will work like `stringType` in body? Let's say I'm interested only to say that there will be a query parameter with specific name and I'm not concerned what will be the format of it's value.

serghei.pogodin
2022-04-07 07:27
I tried using `query` method but getting `IndexOutOfBoundsException` . So I assume this method has different purpose. Could you please confirm?

uglyog
2022-04-07 07:33
Just give it any example value, it will use a matcher when required

serghei.pogodin
2022-04-07 07:58
Thanks for good suggestion!

pennellbeth
2022-04-07 08:04
has joined #pact-jvm

dominic.gara
2022-04-07 08:57
has joined #pact-jvm

ivan.cheung
2022-04-07 08:58
has joined #pact-jvm

omrieyal
2022-04-07 08:58
has joined #pact-jvm

drakulavich
2022-04-07 08:58
has joined #pact-jvm

jonoar22
2022-04-07 09:06
has joined #pact-jvm

josh.king
2022-04-07 09:06
has joined #pact-jvm

pitas01_lope
2022-04-07 09:35
has joined #pact-jvm

rarestomos
2022-04-07 09:40
has joined #pact-jvm

shuba.paripoornam
2022-04-07 09:59
has joined #pact-jvm

shivam.kumar
2022-04-07 11:00
has joined #pact-jvm

dgupta2
2022-04-07 13:26
has joined #pact-jvm

dgupta2
2022-04-07 13:34
Hey, i was wondering, is there any way by which i can hide tokens(be it authToken/APIToken) while a pact is generated, i can see that these sensitive values are visible in an interaction. Is it possible to hide these sensitive attributes?

matt.fellows
2022-04-07 13:37
you shouldn?t add real tokens to a pact file

matt.fellows
2022-04-07 13:38
At least not for anything real (like prod)


pankajarora512
2022-04-07 22:50
has joined #pact-jvm

aruncontacts
2022-04-07 22:54
has joined #pact-jvm

mira.kim
2022-04-07 23:59
has joined #pact-jvm

michael.branders
2022-04-08 08:40
How can you describe in DSL a map? ```@Getter @ToString @Builder(toBuilder = true) @Jacksonized @JsonIgnoreProperties(ignoreUnknown = true) public class ObjectDto { private final String id; private final Map<Locale, String> descriptions; }``` I need to get that map in DSL ```private DslPart objectDtoContract() { return newJsonBody((o)->{ o.stringMatcher("id", REGEX_ID, OBJECT_ID); o.array("description",(map)->{ ???? }); }).build(); }``` Dont realy find any examples on how to get a map in a DslPart

michael.branders
2022-04-08 09:22
Ow just had an otherone that i dont know how to do in DSL: ```@GetMapping(value = "/documents/{id}") Optional<Resource> fetchDocument(@PathVariable(value = "id", required = true) String documentId);``` How do i define a Resource. I have a client that gets a document by id and get a recource as response.

alphonse.bendt
2022-04-08 11:44
has joined #pact-jvm

wim.dupont
2022-04-08 11:49
has joined #pact-jvm

wilsonmar
2022-04-08 13:41
has joined #pact-jvm

henit.laxmicant
2022-04-08 14:19
has joined #pact-jvm

mateustalles
2022-04-08 17:35
has joined #pact-jvm

uglyog
2022-04-10 22:39
A map should be just an object in JSON. Check the JON output

abubics
2022-04-11 03:45
Yeah, best to think about it from a JSON perspective, rather than a JVM perspective :slightly_smiling_face:

athaper
2022-04-11 04:49
Hey guys , had a follow up question related to this I was checking the pactflow features here https://pactflow.io/features/ And saw that the feature to authenticate API using bearer token is a pactflow feature and not available in open source pact. does that mean authenticating API through bearer token is not possible in pact ?

michael.branders
2022-04-11 06:26
And what about my resource example? Thats nor realy a JSON object but a PDF

abubics
2022-04-11 08:40
Scrolling up, I'm not seeing any PDF examples :thinking_face: There are some multipart file upload examples around, but those kinds of requests tend not to be structured objects, only a file body, so the "given" can usually dictate whether the request succeeds or not.

abubics
2022-04-11 08:40
But if that's not what you mean, please link the post :pray:

bioflash1
2022-04-11 09:21
has joined #pact-jvm

bioflash1
2022-04-11 10:53
Hello everyone! We currently have the problem that we have different providers test classes (for on one contract) located in different modules and therefore in different jvm's when running the tests. Therefore the provider sdk has no way of knowing when all interactions of the contract were validated and therefore never ends up publishing to the pact broker. Is there any existing solution to go about this? (Repost from General chat)

francislainy.campos
2022-04-11 12:40
I think you should try and have one contract per provider.

stambolaolya
2022-04-11 13:20
has joined #pact-jvm

souravmalhotra007
2022-04-11 15:56
has joined #pact-jvm

akshay.nm92
2022-04-11 17:48
has joined #pact-jvm

luxfactaest
2022-04-11 18:25
has joined #pact-jvm

cameron.allan
2022-04-12 00:15
has joined #pact-jvm

songqing.gu
2022-04-12 00:30
Hello there! may I check vendor related information? who runs OSS, DiUS? who runs SaaS, Pactflow/SmartBear?

abubics
2022-04-12 00:38
I'm a bit confused about having test classes for provider verification :thinking_face: but I think that's just a vocabulary niggle.

abubics
2022-04-12 00:39
Interested in your module strategy, if the provider interface is genuinely fragmented into discrete modules, it implies that each one might be its own provider.

abubics
2022-04-12 00:42
If that's not what you want, can the base project be the entry & integration point for the modules instead? i.e. set up one Pact-provider-annotated class for verification, provide all the states there, and verify them centrally

abubics
2022-04-12 00:42
or, if not, I think each module would need a separate provider name, and verify in its own run

abubics
2022-04-12 00:43
or merge your per-module verifications together, but that's absolute dragon territory

uglyog
2022-04-12 01:21
Pact OSS is run by a group of maintainers from different organisations and some in their personal capacity. Some of the maintainers have been or are employed by Dius, but Dius does not run it. Pactflow SaaS is owned and run by Pactflow/Smartbear. Going forward, Smartbear will be taking over stewardship of the Pact OSS, but it will still be run by the maintainers.

songqing.gu
2022-04-12 02:00
Thanks for your quick response! what is the relationship between Pactflow and DiUS?


songqing.gu
2022-04-12 02:10
Great! :+1:

kendrickbong1996
2022-04-12 04:12
has joined #pact-jvm

timothy.osm
2022-04-12 05:16
has joined #pact-jvm

pact270
2022-04-12 08:53
has joined #pact-jvm

oytun
2022-04-12 13:12
has joined #pact-jvm

alessandrovermeulen
2022-04-12 14:00
has joined #pact-jvm

alessandrovermeulen
2022-04-12 14:03
Hi all, we have a custom test harness that I would like to embed the pact verification in. We have our own custom http client already configured, so I would like to be able to use the verification on a slightly different level. What would be the best way to plug in the verification of pacts with responses? (On the JVM)

lucka
2022-04-12 15:25
has joined #pact-jvm

damon_walker
2022-04-12 15:26
has joined #pact-jvm

nathan.deamer
2022-04-12 17:21
`pact.verifier.buildUrl` - Should I be able to see this in pactflow anywhere? I am using `id 'http://au.com.dius.pact' version '4.3.5'` gradle plugin. https://github.com/pact-foundation/pact-jvm/blob/master/provider/junit/README.md#setting-the-build-url-for-verification-results-4216432

nathan.deamer
2022-04-12 17:49
Or is it just used in webhooks?

anusha_matti
2022-04-12 18:24
has joined #pact-jvm

albert.pincevic
2022-04-12 21:48
has joined #pact-jvm

uglyog
2022-04-12 23:05
Depends on how embedded it is with your test framework. There is an Verifier class that does most of the work. Best to start with the Gradle or Maven tasks and see how they work.

uglyog
2022-04-12 23:07
If you use the HAL browser, you should see it in the JSON somewhere. It would defiantly be saved. But, yes, it is mainly used to pass in with the webhook call.

alessandrovermeulen
2022-04-13 07:16
Thanks. Do you have an entry point? I was looking at the JUNit tests but those pull up the server and run the tests as well

marcello.rigan335
2022-04-13 12:07
has joined #pact-jvm

koel.misra
2022-04-13 13:31
has joined #pact-jvm

johnmichael.bullen
2022-04-13 15:04
has joined #pact-jvm

james.perepiczka
2022-04-13 16:44
Hi, out of interest does the PactDslWithProvider `query` parameter url encode the variables it is sent? I have a service which sends a uri encoded value to another service `"from=2022-04-11T09%3A52%3A59%2B0100"` as a query parameter in the path. If I try and do a comparison using this value then it fails with an unexpected request error. However, if I wrap the query parameter in a uri decode statement then the request matches. When I send the http request, I just enter the value specified and thats enough to match. UPDATE: I've just found the `encodedQuery` param which has sorted out me having to encode the query, however the json I have generated does not have the encoded version

wng
2022-04-13 17:54
has joined #pact-jvm

connor.mcneil
2022-04-13 19:45
has joined #pact-jvm

henrry.salinas
2022-04-13 20:10
has joined #pact-jvm

uglyog
2022-04-13 22:43
When you say generated JSON, do you mean in the Pact file?

uglyog
2022-04-13 22:45
The JUnit test support is a bit more complex, as it integrates with the JUnit lifecycle.



danielflieger
2022-04-14 06:37
has joined #pact-jvm

james.perepiczka
2022-04-14 07:23
Yes

james.perepiczka
2022-04-14 07:24
The output is ```"query": { "from": [ "2022-04-11T09:52:59+0100" ] }```

james.perepiczka
2022-04-14 07:24
Instead of ```"query": { "from": [ "2022-04-11T09%3A52%3A59%2B0100" ] }```

elyas.najafizada
2022-04-14 11:01
has joined #pact-jvm

pavlo.sprogis
2022-04-14 13:55
hi guys, I want to try using Pactflow, I have updated provider tests configuration (host, scheme and token) but now test fails with the following errors: ```ERROR [15:45:47] [main] a.c.d.p.c.p.HalClient Failed to fetch the root HAL document javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131) ...``` is there a way to fix this (on my laptop and during CI build) ?

yousafn
2022-04-14 14:42
Hey, Have you specified a custom trust store?



pavlo.sprogis
2022-04-14 14:46
ok, thank you, I also found this article https://confluence.atlassian.com/kb/unable-to-connect-to-ssl-services-due-to-pkix-path-building-failed-error-779355358.html it looks like overkill to me, I do not have any custom trust store. I had something similar with RestAssured and it was possible to fix with 1 config line ```useRelaxedHTTPSValidation``` ok, I should read those links, maybe it is not such an overhead as it looks like

tasaki
2022-04-14 14:46
has joined #pact-jvm


pavlo.sprogis
2022-04-14 14:47
wow, that?s what I want, thank you!:)

yousafn
2022-04-14 14:48
always read the manual :sweat_smile: don't worry I go blind too

yousafn
2022-04-14 14:49
also it's not the easiest to find, proactively working on making it easier, open to ideas. Best of luck on your Pact journey

pavlo.sprogis
2022-04-14 14:49
I see that the documents are about provider tests, but I get this error when pact is trying to connect to pactflow instance

pavlo.sprogis
2022-04-14 14:50
so if I use my own PactBroker deployed in our local network (http) - no errors

pavlo.sprogis
2022-04-14 14:50
if I switch to pactflow (https) - I get the error about ?Failed to fetch the root HAL document?

lucka
2022-04-14 17:17
I got that error only in conjunction with missing or bad credentials from http://pactflow.io side. You are sending the token right?

pavlo.sprogis
2022-04-14 19:52
yes, env variable is set and I use it in the test: ```authentication = @PactBrokerAuth(token = "${PACT_BROKER_TOKEN}"``` but PACT_BROKER_HOST was wrong - my local pact broker instead of pactflow, now it works, thanks for help!

yousafn
2022-04-14 20:27
Excellent @pavlo.sprogis, glad you are rocking now and thanks for the support @lucka ! :raised_hands: mental note made for dx improvements!

pennellbeth
2022-04-18 01:36
@pennellbeth has left the channel

jithinjacob2011
2022-04-18 02:43
has joined #pact-jvm

uglyog
2022-04-18 03:39
It will be stored unencoded in the Pact file. The reason is that most HTTP clients will encode the query parameters, so if it is stored encoded in the Pact file it will end up being double encoded when used

francislainy.campos
2022-04-18 06:42
Hi, is it possible to inject dynamic ids for parts of the body rather than only the path or query from provider state such as in here https://pactflow.io/blog/injecting-values-from-provider-states/? Thank you.

justin
2022-04-18 15:10
Yes, You should be able to use something like this. ```bodyObject.valueFromProviderState("fieldNAme", "providerStateFieldName", "exampleValue")```

francislainy.campos
2022-04-18 15:11
Thanks. So do we then lose the matchers for the types?

justin
2022-04-18 15:12
I think so. I suspect because you're matching the actual value it was assumed you don't need to care about the type.

francislainy.campos
2022-04-18 15:13
hmm..

francislainy.campos
2022-04-18 15:13
okay, thanks. I?m off today but will give it a go tomorrow.

bkapadia
2022-04-18 17:25
has joined #pact-jvm

lewiscowles
2022-04-18 19:10
has joined #pact-jvm

florent
2022-04-19 16:02
has joined #pact-jvm

testingterrasoft
2022-04-19 19:19
has joined #pact-jvm

olivia.c
2022-04-19 23:27
has joined #pact-jvm

aurelia.rochat
2022-04-20 13:53
Hello, I a Java project using pact junit5 4.2.11, and I have *encoding issues*. When generating a Pact, the response body is read from a json file containing accented characters (é, è, ü, etc) When the pact is generated, those characters are replaced with their unicode encoding. Then on the producer side, when running the test, the pact verification fails due to those encoded characters. Do you know why the pact can?t just be written with the unicode characters ? I found nothing helpful when searching on Internet, but I?m surely not the only person with accented characters in the pact payload. Thanks in advance for your help :pray:

testingterrasoft
2022-04-20 14:30
@testingterrasoft has left the channel

ysuei.ygui
2022-04-20 20:42
has joined #pact-jvm

ysuei.ygui
2022-04-20 20:45
Hello, new to Pact. Was wondering if we can use pact to test pagination?

uglyog
2022-04-20 22:48
Are you able to provide your test code, pact file and any logs? Can you check what charset is being used, and whether that charset is configured with the content type header?

uglyog
2022-04-20 22:49
I would use 3 tests for that, one for the first page, one for the last page, and one for a middle page.

ysuei.ygui
2022-04-21 01:22
Is there a way to auto generate those content in the contract and can test each page at will, or it is over kill. (for example, testing navigating to page 25, then back to page 23 and verify the content for page 23 is the same). Thanks

uglyog
2022-04-21 01:24
I wouldn't test every page, it is not worth it.

ysuei.ygui
2022-04-21 01:30
ah .. thanks for the idea

abubics
2022-04-21 02:28
also, Pact isn't targeting behaviour (i.e. navigation between pages), use it for testing that the API responds with the correct page when it's requested. Page 23 shouldn't affect page 25 :sunglasses:

ysuei.ygui
2022-04-21 02:41
Thanks :smiley:

dennis.woditsch
2022-04-21 12:23
Hey :wave::skin-tone-2: Unfortunately I did not found any information about my current problem. So we have successfully integrated PACT between two (asynchronous) services. Basically all the pieces are tight together, last part I was working on was integrating web hooks whenever a contract changed that `required` verification. To come to the question: We saw that PACT verified several versions - especially from PR's which actually might not exist anymore at this time. I think it would make most sense to just verify against deployed versions of a service right? Basically latest master/main would be fine + all versions deployed on environments (recorded deployments). Is there some configuration available? Here is my current (provider) test setup ```@Provider("goto-conference-service") @PactBroker @SpringBootTest @Import(KafkaConsumerConfiguration.class) @AutoConfigureMockMvc @AllowOverridePactUrl public class ConferenceEventsContractTests extends TestcontainersIntegrationTests { @Autowired private MockMvc mockMvc; @Autowired private ObjectMapper objectMapper; @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(Pact pact, Interaction interaction, PactVerificationContext context) { context.verifyInteraction(); } @BeforeAll static void beforeAll(){ PactBrokerDefaults.initFallbackTokenIfMissing(); PactBrokerDefaults.initFallbackUrlIfMissing(); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new MessageTestTarget()); } @PactVerifyProvider("valid conference created event") public String verifyConferenceCreatedEvent() throws Exception { ConferenceEvent createdEvent = getEventByCreateTrigger(event -> "ConferenceCreated".equals(event.getEventName())); return objectMapper.writeValueAsString(createdEvent); } // some more not relevant pieces of code }```

lucka
2022-04-21 12:57
I think you may have forgotten to make use of `consumerVersionSelectors` property of the PactBroker annotation. You basically skipped the "Gold" step of Pact Nirvana I think: https://docs.pact.io/pact_nirvana/step_5 Without the consumerVersionSelector, your provider verifies all latest PACTs it finds

aurelia.rochat
2022-04-21 12:58
Sure, here is the test code : ```@ExtendWith(PactConsumerTestExt.class) @SpringBootTest public class ProductWithAccentPactTest { @Autowired private ObjectMapper objectMapper; @Pact(provider = "one-catalog_product_with_accents", consumer = "product-display") public RequestResponsePact createPact(PactDslWithProvider builder) { return builder.given("an hybrid product") .uponReceiving("a request for product 100001789") .path("/one-catalog/public/v1/catalog-items") .query( "ids=100001090&warehouseId=1&ongoingOfferDate=2022-04-19T00:00&fields=(id, product)&activeOffersOnly=true") .method("GET") .willRespondWith() .status(200) .body(jsonAsString("/pact/product-with-accents.json")) .headers(Map.of("content-type", "application/json")) .toPact(); } @PactTestFor(providerName = "one-catalog_product_with_accents") @Test void validatePact(MockServer mockServer) throws IOException { // when var actual = oneCatalogClient(mockServer.getUrl()).findOneCatalogItems( ProductFilter.builder().uids(List.of(100001090l)).build(), OfferFilter.builder() .storeType(http://StoreType.ONLINE) .warehouseId(1) .ongoingOfferDate(LocalDateTime.of(2022, 4, 19, 0, 0, 0)) .build(), "(id, product)"); // then var expected = objectMapper.readValue( ResourceReader.readResource("pact/product-with-accents.json"), OneCatalogItem[].class); assertThat(actual).hasSize(1).first().usingRecursiveComparison().isEqualTo( Arrays.stream(expected).findFirst().get()); } private String jsonAsString(String path) { return removeWhiteSpaces(IOUtils.toString( this.getClass().getResourceAsStream(path), StandardCharsets.UTF_8)); } private String removeWhiteSpaces(String input) { return input.replaceAll("\r", "").replaceAll("\n", "").replaceAll("\t", ""); } private RestOneCatalogClient oneCatalogClient(String uri) { return new RestOneCatalogClient(URI.create(uri), new RestTemplateBuilder()); } @SpringBootConfiguration public static class TestContext { @Bean public ObjectMapper objectMapper() { return new ObjectMapper() .registerModule(new Jdk8Module()) .registerModule(new JavaTimeModule()) .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .setSerializationInclusion(JsonInclude.Include.NON_EMPTY); } } }```

lucka
2022-04-21 12:59
However, if all pacts are verified even though your cicd is triggered by the webhook, I suppose something else (or additionall) is off. The Webhook ships the direct pact URL to verify and the provider should ONLY verify the pact from that URL and not all of them. Did you pass the ` ```-Dpact.filter.pacturl=${PACT_FILTER_URL} \ -Dpact.filter.consumers=${PACT_FILTER_CONSUMER} \``` args to the maven/gradle/... command?

aurelia.rochat
2022-04-21 13:00
And here is an extract of the generated pact with encoded characters : ```{ "consumer": { "name": "product-display" }, "interactions": [ { "description": "a request for product 100001789", "providerStates": [ { "name": "an hybrid product" } ], "request": { "method": "GET", "path": "/one-catalog/public/v1/catalog-items", "query": { "activeOffersOnly": [ "true" ], "fields": [ "(id, product)" ], "ids": [ "100001090" ], "ongoingOfferDate": [ "2022-04-19T00:00" ], "warehouseId": [ "1" ] } }, "response": { "body": [ { "id": 100001090, "product": { "brand": "Jura-Sel", "categoryBreadcrumbs": [ { "categoryId": "3850252", "categoryName": { "de": "Salzige Lebensmittel", "en": "Salty Groceries", "fr": "Epicerie sal\u00E9e", "it": "Alimenti salati" }, "level": 2, "slug": { "de": "salzige-lebensmittel", "en": "salty-groceries", "fr": "epicerie-salee", "it": "alimenti-salati" } }, { "categoryId": "3860189", "categoryName": { "de": "Gew\u00FCrze & Saucen", "en": "Spices & Sauces", "fr": "Condiments & Sauces", "it": "Spezie e salse" }, "level": 3, "slug": { "de": "gewurze-saucen", "en": "spices-sauces", "fr": "condiments-sauces", "it": "spezie-e-salse" } }, { "categoryId": "3860200", "categoryName": { "de": "Salz, Pfeffer & W\u00FCrze", "en": "Spices, Salt & Pepper", "fr": "Sels, Poivres & Assaisonnements", "it": "Sale, pepe e condimenti" }, "level": 4, "slug": { "de": "salz-pfeffer-wurze", "en": "spices-salt-pepper", "fr": "sels-poivres-assaisonnements", "it": "sale-pepe-e-condimenti" } } ],```

dennis.woditsch
2022-04-21 13:01
I didnt know about the pact nirvana let me check that, thanks. To your suggestion - yes I'm doing that and that got me confused as well. Here is my pipeline step ```stage('verify') { steps { script { def config = readYaml file: 'pact.yaml' def verificationCommand = config.VERIFICATION_COMMAND if (!verificationCommand?.trim()) { error("Please configure a pact 'VERIFICATION_COMMAND'") } verificationCommand = verificationCommand + " -Dpact.filter.consumers=${consumer} -Dpact.filter.pacturl=${pactUrl}" echo "pact provider verification command = ${verificationCommand}" mavenBuilder 'test', customParams: verificationCommand } } }```

dennis.woditsch
2022-04-21 13:03
both `${consumer}` and `${pactUrl}` are from the web hook

lucka
2022-04-21 13:06
Do you find the PACT URL appears in the maven build logs?

lucka
2022-04-21 13:06
For me there is such a log entry: ```[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 >> "GET /pacts/provider/fake-product-api/consumer/some-consumer/pact-version/441f7e998d167ca75aa0a93653e7ce093808f79f/metadata/Y3ZuPWZkODQ0YzImY3Z0W109bWFpbiZ3PXRydWU HTTP/1.1[\r][\n]"```

lucka
2022-04-21 13:08
and that URL is identical with the webhook one

dennis.woditsch
2022-04-21 13:09
Looks like that when pactflow triggered my jenkins job it seams I got all the required data ```pact provider verification command = -Dtest=ConferenceEventsContractTests -Dpact.filter.consumers=goto-provisioning-service -Dpact.filter.pacturl=https://xxx.pactflow.io/pacts/provider/goto-conference-service/consumer/goto-provisioning-service/pact-version/865103be9f0e9eedd7b29ccdf8339e2d4f0e7458/metadata/Y3ZuPTEuMS4yLVBSLTI4NC1iNWM0MjdmJnc9dHJ1ZQ```

lucka
2022-04-21 13:11
So far so good. And if you turn on DEBUG logging of `org.apache.hc` you should see outgoing traffic to that URL, do you?

lucka
2022-04-21 13:12
Something like this basically:

dennis.woditsch
2022-04-21 13:16
that will take some time to test that

aurelia.rochat
2022-04-21 13:25
While debugging I can see that until this line https://github.com/pact-foundation/pact-jvm/blob/4712d32575856d4fc5796ded5685caeca232b62e/core/model/src/main/kotlin/au/com/dius/pact/core/model/PactWriter.kt#L66 the characters look fine. Therefore I guess something happens in the Json.prettyPrint() function, but I can?t debug inside.

dennis.woditsch
2022-04-21 13:43
Currently I'm not able to log that properly :face_with_rolling_eyes: But from my understanding in reading this here https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors we actually want to exactly use that kind of version selector as described as following > `deployed`: if the key is specified, can only be set to `true`. Returns the pacts for all versions of the consumer that are currently deployed to any environment. Use of this selector requires that the deployment of the consumer application is recorded in the Pact Broker using the `pact-broker record-deployment` CLI. As of October 2021, this is not yet supported in all Pact client libraries. I checked the code and it seems like this is still not supported https://github.com/pact-foundation/pact-jvm/blob/master/provider/src/main/java/au/com/dius/pact/provider/junitsupport/loader/VersionSelector.java

edouard.lopez
2022-04-21 14:18
I'm not clear how I should return a BAD_REQUEST response using state. Do you have example to share?

lio.lunesu
2022-04-21 17:17
Hi! Will the latest pact-jvm release 4.1.35 be pushed to the Maven Central repo?

lucka
2022-04-21 19:53
I think you should put the provider application in such a state so that your productive code is reacting with 400

uglyog
2022-04-21 23:06
Ok, can you raise a GH issue for this?

uglyog
2022-04-21 23:09
Let me check...

uglyog
2022-04-21 23:13
Ok, released it. Should be available in the next few hours

abubics
2022-04-22 02:22
Pretty much yeah. A useful example would depend on where you cut your provider for verification.

abubics
2022-04-22 02:23
At a high level, your state handler is meant to affect what the provider responds with.

abubics
2022-04-22 02:24
In my architectures, I usually let the presentation & use case layers run normally (to exercise just enough of the application code), and the state handler stubs the input for use cases.

giuseppe.torchia
2022-04-22 08:25
has joined #pact-jvm

thadamski
2022-04-22 14:00
has joined #pact-jvm

druiz
2022-04-22 15:02
has joined #pact-jvm

tord.brokvist
2022-04-22 15:08
has joined #pact-jvm

lio.lunesu
2022-04-22 16:20
Got it! Much appreciated!

gnanasekar69
2022-04-22 17:23
has joined #pact-jvm

himanshu.1046
2022-04-24 18:25
has joined #pact-jvm

marcello.rigan335
2022-04-25 08:11
Hello, im new to Pact and i want to know if there is an easy way to overcome protected endpoints as the Provider. Endpoint expects an Bearer Token.

yousafn
2022-04-25 09:04
Hi, yes you can, This is covered in our workshop, would recommend you run though it https://github.com/pact-foundation/pact-workshop-jvm-spring

chris196
2022-04-25 09:51
has joined #pact-jvm

marcello.rigan335
2022-04-25 10:07
Hey i already saw this example, sadly it doesnt work for me. Maybe i have the wrong dependency versions i dont know. Just to clarify i need to modify the request before sending it. my Code looks like this ```@SpringBootTest(classes = { X.class }, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @Provider("ProviderX") @Consumer("ConsumerX") @PactFolder("src/test/resources/pacts") @ExtendWith(SpringExtension.class) public class XProviderTest { @BeforeEach void before(PactVerificationContext context) throws MalformedURLException { String myProviderUrl = ""; context.setTarget(HttpTestTarget.fromUrl(new URL(myProviderUrl))); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context, HttpRequest request) { replaceAuthHeader(request); context.verifyInteraction(); } private void replaceAuthHeader(HttpRequest request) { if (request.containsHeader("authorization")) { String header = "Bearer " + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm").format(new Date()); request.removeHeaders("authorization"); request.addHeader("authorization", header); } }``` i need to change the replaceAuthHeader method later for our rules for a valid Bearer Token. but i get an error while running the test. org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [org.apache.http.HttpRequest arg1] in method [void pactVerificationTestTemplate(http://au.com.dius.pact.provider.junit5.PactVerificationContext,org.apache.http.HttpRequest)].

yousafn
2022-04-25 10:15
Hmm that looks the same as our example, I note your constructing your url with port, which is fine, your auth header isn't capitalised? Is that correct. What versions of the pact provider lib are you using? (And what version Java?) thx


marcello.rigan335
2022-04-25 10:16
yes it isnt capitalised. Im using java version 11 and provider version 4.3.6

yousafn
2022-04-25 10:18
Cheers, are you able to talk the time to create a reproduction, possibly from that example repo? That's probably where I would start as we have a working example, upgrade it and see it it breaks (fyi not checked what version it is running atm) Otherwise some more familiar with the Java offerings will help out :+1:

marcello.rigan335
2022-04-25 10:21
Ok, thanks!

yousafn
2022-04-25 10:27
Just in case you haven't seen these docs, if you have its useful reference ( for me especially, if I need to update things later :) ) https://docs.pact.io/implementation_guides/jvm/provider/junit5spring https://docs.pact.io/implementation_guides/jvm/provider/junit5#modifying-the-requests-before-they-are-sent

manu.vereecken
2022-04-25 11:06
has joined #pact-jvm

maltechristian.neuman
2022-04-25 11:52
has joined #pact-jvm

manu.vereecken
2022-04-25 12:17
Hello! I have two tests on my provider side, of which one runs green and the other fails with a "header missing" message. The expected headers are both the same in the .json pact file, same on pactflow, same when I try them on the real swagger ui. How can I best debug to find the cause? Thanks in advance :pray:

manu.vereecken
2022-04-25 12:17
Tests & failure message:

manu.vereecken
2022-04-25 12:18
The tests themselves:

yousafn
2022-04-25 12:28
doesn't look like your provider response is working for the second test, no content type and body is null

yousafn
2022-04-25 12:29
also looks like you are returning a personDto, same for both, but you expect `persons`? should it be array of the person object.

manu.vereecken
2022-04-25 12:36
The failing one returns a Page<PersonDto> Page = org.springframework.data.domain.Page

yousafn
2022-04-25 12:37
ahh my apologies Manu :thumbsup:

manu.vereecken
2022-04-25 12:55
Indeed it seems the body is null and therefore the content type is missing

manu.vereecken
2022-04-25 13:50
Green now - mocking the Page was a bit complicated. Thanks for the help @yousafn :slightly_smiling_face:

yousafn
2022-04-25 14:02
wahey :raised_hands:

prashanth.ramadass
2022-04-25 14:04
has joined #pact-jvm

janarthanan.rajendras
2022-04-25 22:35
has joined #pact-jvm

shreyas.gowda
2022-04-26 02:14
has joined #pact-jvm


marxjo
2022-04-26 07:09
has joined #pact-jvm

andrew.fraser
2022-04-26 07:19
has joined #pact-jvm

lei.shi
2022-04-26 07:46
has joined #pact-jvm

akash.sharma5253
2022-04-26 11:50
has joined #pact-jvm

prabhakar.thippa
2022-04-26 18:33
how to write contract for an API having html content as response. I can verify response header content type is text/html. But does it even make sense to verify the body contains html content, if so how do I write contract in a more general way (may be I would have to check <html and /html> tags exist)

matt.fellows
2022-04-26 21:48
You can check it, but we don't have matches for HTML so you'd need to check the exact contents

uglyog
2022-04-26 23:07
You can use the content type matcher. It will check that the body contains a valid HTML header

matt.fellows
2022-04-27 00:40
for clarity, are you suggesting to just match the content type (header) but ignore the body? (I?d not want to match on an HTTML body with exact contents)

matt.fellows
2022-04-27 00:40
we don?t support regex or anything on non-JSON bodies do we Ron?

uglyog
2022-04-27 00:44
No, Pact-JVM supports the content type matcher, which will check the header (the first 20 bytes) of the *body*. Not the content type header.

matt.fellows
2022-04-27 01:14
ohh, cool

matt.fellows
2022-04-27 01:14
is there a similar matcher in Rust?


uglyog
2022-04-27 01:16
It is the same matcher that is used for binary payloads

kannan.jai
2022-04-27 07:49
has joined #pact-jvm

uladzislau_danilchyk
2022-04-27 09:40
Hi everyone! I have an issue regarding creating expected response in groovy. I can't write field/attribute in expected response starting from capitalized letter, e.g. `PORequired`. It just doesn't build the pact test. Does anyone can help me with that? Issue on github will be created soon.


c.giannakopoulos
2022-04-27 10:47
has joined #pact-jvm

fragonib
2022-04-27 11:32
Hi there, Thank you for this great software. Very useful. I want to know if this is by design in PACT-JVM? or a BUG ? You are running a PROVIDER Contract Test that gets the contract to validate from PactBroker ? The PACT framework parses contract coming from defined PactBroker ? This particular contract has this header `Content-Type: multipart/related; type=\"application/json\"; boundary=myBoundary` ? When parsing contracts quotes disappear on PACT Request Model ? But when it serializes the Request Model this is the generated header `Content-Type: multipart/related; type=application/json; boundary=myBoundary`

fragonib
2022-04-27 11:36
The involved code is: ```au.com.dius.pact.core.model.HeaderParser``` ```private fun hvToString(headerValue: HeaderValue): String { return if (headerValue.params.isEmpty()) { headerValue.value.trim() } else { headerValue.value.trim() + ";" + headerValue.params.joinToString(";") { it.name + "=" + it.value } } }```

fragonib
2022-04-27 11:37
This serialization code it isn´t dealing with quotes

sebastian.spiess
2022-04-27 11:43
has joined #pact-jvm

oury.diallo
2022-04-27 13:46
has joined #pact-jvm

marcello.rigan335
2022-04-27 14:59
Hey there, im using ``` @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); }``` to execute my provider test locally. Im using Provider Version 4.36, Junit 5. I wanted to try it out in a gitlab build, but the test wasnt executed. Is that a pipeline issue or am i missing something. +

jean.paiva42
2022-04-27 18:58
has joined #pact-jvm

alex.zuliqiaer
2022-04-27 20:27
hello everyone, i am new to pact and im following the getting started tutorial posted on github and i keep getting this exception when trying to execute the pact tests

alex.zuliqiaer
2022-04-27 20:27
```java.lang.NoSuchMethodError: 'void au.com.dius.pact.core.support.expressions.ExpressionParser.<init>(java.lang.String, java.lang.String, int, kotlin.jvm.internal.DefaultConstructorMarker)' at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.<init>(PactConsumerTestExt.kt:72) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.junit.platform.commons.util.ReflectionUtils.newInstance(ReflectionUtils.java:550) at org.junit.platform.commons.util.ReflectionUtils.newInstance(ReflectionUtils.java:525) at org.junit.jupiter.engine.extension.MutableExtensionRegistry.registerExtension(MutableExtensionRegistry.java:145) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:274) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) at org.junit.jupiter.engine.extension.MutableExtensionRegistry.createRegistryFrom(MutableExtensionRegistry.java:103) at org.junit.jupiter.engine.descriptor.ExtensionUtils.populateNewExtensionRegistryFromExtendWithAnnotation(ExtensionUtils.java:74) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.prepare(ClassBasedTestDescriptor.java:145) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.prepare(ClassBasedTestDescriptor.java:80) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at com.sun.proxy.$Proxy2.stop(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:132) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:413) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) at java.base/java.lang.Thread.run(Thread.java:829)```

alex.zuliqiaer
2022-04-27 20:28
i am using ```testImplementation('au.com.dius.pact.consumer:junit5:4.3.6')```

yousafn
2022-04-27 20:39
Which tutorial buddy? Could you provide the link? Assume you are using it out the box? What version Java are you running?


yousafn
2022-04-27 20:41
What was the difference in output between your local run and your gitlab and are you executing the same steps. Could you help by providing more details about your pipeline setup.

yousafn
2022-04-27 20:43
Have you updated the dependencies yourself?


alex.zuliqiaer
2022-04-27 20:44
yes i did, since i see thats the newest master release

alex.zuliqiaer
2022-04-27 20:44
btw 4.1.7 is working for me

yousafn
2022-04-27 20:44
The message suggests there is no such method,

yousafn
2022-04-27 20:46
So that code isn't compatible, and would need to be updated as such. We would need to update through the steps, happy for you to raise an issue on the gh repo, will be taking a look through all our workshops over the next week or so, so will pick this up. We need to update through all the steps as well. If you find the correct code for the version update, would be grateful if you want to contribute back :v::skin-tone-4:

yousafn
2022-04-27 20:47
Changelog would probably be my port of reference, they will be on the docs site and in the pact-jvm repo :v::skin-tone-4:

alex.zuliqiaer
2022-04-27 20:50
surething, thank you for the information , i see the the exp was generated from `ExpressionParser` that a class exists in 4.0.9 jvm-support package and i assume its compatibility with 4.3.x is causing the issue.

alex.zuliqiaer
2022-04-27 20:50
i tried upgrading jvm-support to 4.0.10 and it didnt work either.

yousafn
2022-04-27 21:16
I would probably say if you are new to Pact, don't both upgrading anything, and just work your way through the examples, especially as each step will take you into a new git branch, you would lose the upgrade changes you have previously done. Once you get familiar you can get stuck into the Pact codebase, if thats your bag, sounds like you are an eagle eye in the docs.

yousafn
2022-04-27 21:17
Also curious to know how you found the workshop and Pact if you don't mind sharing :slightly_smiling_face:

alex.zuliqiaer
2022-04-27 21:19
gotcha,

alex.zuliqiaer
2022-04-27 21:19
i was exploring contract testing and i came across a relatively old article/tutorial posted on Baeldung : https://www.baeldung.com/pact-junit-consumer-driven-contracts lol

yousafn
2022-04-27 21:29
I like that article, short and snappy! I tend to yammer on in my posts. If you fancy some further resources https://docs.pactflow.io/docs/examples#demos (you can sort the table by language if you want to find all the Java ones) Our Pactflow University https://docs.pactflow.io/docs/workshops and some external courses from Testing Automation University and Udemy https://docs.pact.io/implementation_guides/workshops#courses I'm looking to pull together a list of all the many blogs and posts I've seen about Pact in the wild, as there is some gold content out there, and it saves me having to write a load :sweat_smile:

alex.zuliqiaer
2022-04-27 22:03
sweet, thanks for sharing these resources !

uglyog
2022-04-27 23:00
Can you raise an issue for this?

abubics
2022-04-28 02:27
Probably want a code sample to go along with that :thinking_face: I know Groovy well, but haven't used it for Pact in a looong time

christoffer.vig
2022-04-28 06:09
has joined #pact-jvm


fragonib
2022-04-28 06:12
From https://www.w3.org/Protocols/rfc1341/4_Content-Type.html I guess quoting has different rules for each header. So rebuilding them after parsing removal can be tricky

uladzislau_danilchyk
2022-04-28 08:14
@abubics, you just need to add field with first capitalized letter to expected response and that's it:) Event Intelliji IDEA will talk you that something is wrong..

marcello.rigan335
2022-04-28 09:15
I renamed the ProviderTestClass to IT temporarily so it would get executed in the Integrationtest Job. I still have to adapt the pipeline for this. This was purely for test reasons because the pactbroker credentials are coming from gitlab and i wanted to assure that everything works fine.

marcello.rigan335
2022-04-28 09:16
671110 [INFO] Running at.X.X.X.X.MintProviderIT https://gitlab.willhaben.at/willhaben/tribe/ljt/p2p-payment/-/jobs/415760#L1851671745 [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.634 s - in at.X.X.X.X.MintProviderIT

marcello.rigan335
2022-04-28 09:16
it doesnt execute the method

andrea.sangiorgio
2022-04-28 13:01
has joined #pact-jvm

jason.mcinerney
2022-04-28 19:14
has joined #pact-jvm

psnyder
2022-04-28 19:22
has joined #pact-jvm

dominique.cote
2022-04-29 01:17
has joined #pact-jvm

laura.walsh
2022-04-29 13:40
has joined #pact-jvm

mailtoadnan.ahmed
2022-04-30 08:56
has joined #pact-jvm

prasanna.mallisetty
2022-04-30 12:11
has joined #pact-jvm

v-ratngupta
2022-05-01 04:20
Hi Folks

v-ratngupta
2022-05-01 04:22
do we have any solution for grpc protocol. Like I wanted to pact contract test stuff with grpc application or grpc api:thinking_face:

v-ratngupta
2022-05-01 04:57
Or any example for grpc +pact integration kindly let me know

uglyog
2022-05-01 05:00
Check in #protobufs channel.

uglyog
2022-05-02 00:23
Your build pipeline may not be setup to run JUnit 5 tests

pavlo.sprogis
2022-05-02 08:56
hi guys, which version of `http://au.com.dius.pact.provider.junit` supports `pact.provider.branch` system property? Now I?m using 4.1.17 and it ignores `pact.provider.branch` value

pavlo.sprogis
2022-05-02 15:17
ok, I have found the solution: update from 4.1.17 to 4.1.33 fixes this issue with branch name

marcelo.jaeggi
2022-05-02 16:26
has joined #pact-jvm

jaswanth.ooty
2022-05-03 00:26
has joined #pact-jvm

james.weng
2022-05-03 05:13
has joined #pact-jvm

jochen.kraushaar
2022-05-03 09:16
has joined #pact-jvm

jochen.kraushaar
2022-05-03 09:31
Hi guys, I have a question concerning the migration from V3 to V4 spec. Our http interaction returns a json response. So my code looks like: ```builder.expectsToReceive("get entity", "core/interaction/http") .with(Map.of("response.contents", Map.of( "pact:content-type", "application/json", "body", body ))).toPact()``` *What is the proper way to configure additional matching rules and generators for the response?* `JsonContentMatcher` seems to only set the body. I may set the rules using `"response.matchingRules.rules(body)"` , but setting the generators using `"response.generators.categories(BODY)"` fails. Thanks!

pavlo.sprogis
2022-05-03 09:39
hi everyone, could somebody help me with pact-jvm system properties question? Here is the list of all properties https://docs.pact.io/implementation_guides/jvm/docs/system-properties, what would be the ENV variable name for, let?s say, `pact.provider.branch` system property? `pact_provider_branch` does not work

anurag.soni1984
2022-05-03 10:58
has joined #pact-jvm

stephen.taylor
2022-05-03 14:26
has joined #pact-jvm

conrad
2022-05-03 18:41
has joined #pact-jvm

lucka
2022-05-04 09:24
Hi everyone, I noticed a strange behaviour when using regex matchers using the 4.3.5 JVM DSL. When using Regex then PACT is generating random values that are compliant to my Regex, but.. they are random. This leads to the issue that the broker is unable to cache my PACTs and when re-running the consumer PR pipeline on the same commit than before, it looks like I get a merge conflict in the broker (due to the random generated "discountPrice"). Is this a bug? If not, we should certainly extend the Javadoc of all regex matchers for the JVM module to clearly point out that this does generate Randoms, because the javadoc at the moment does not state this :) The reason why we retry the consumer PR pipeline on the identical PACT version is this: When a changed PACT is not yet ready to merge because the provider doesn't support it yet, my PR is blocked for merging. As soon as the provider has built the changes and published his verification results, I as the consumer, have to rerun my PR pipeline on consumer side. I don't want to have the necessity to push a dummy commit though.

lucka
2022-05-04 09:29
Apart from that, generating random values when using regex matchers seems to contradict the PACT rule of thumb, to not use randoms. For us it seems like, that we have to discourage the usage of Regex matchers in general now, because every PACT using regex matchers is appearing as a new PACT in pactflow for every commit I suppose, even though nothing really changed syntactically?

lucka
2022-05-04 09:32
I mean generating a random is fine to have "something" in the PACT that conforms to the Regex. But the output of the randomizer has to be consistently identical when recreating the PACT and this is not the case (i see that locally)

lucka
2022-05-04 09:34
Here's my output when running twice:

matt.fellows
2022-05-04 09:37
Most matchers have the ability to specify an example to accompany them, thus removing any randomness.

matt.fellows
2022-05-04 09:37
Check if there is a method overloaded

matt.fellows
2022-05-04 09:37
You're right though, I would discourage random values

lucka
2022-05-04 09:41
Hi Matt! Thanks for quick response. Indeed there is a method overload to provide our own. But I believe this is an easy trap and its going to be quite hard to understand the reason of these merge issues, or, it works and causes unwanted side effect behaviour. Since this method is in now we cannot remove it, but may I suggest / contribute a javadoc change on the method level to indicate the randomness explicitly with reference to pact Docs?

lucka
2022-05-04 09:47
I'd even think about a Randomizer algorithm that generates consistent randoms, so that when run twice, the output is identical. I'll note it on my list.

marxjo
2022-05-04 09:49
Hi Matt, thanks for your response. My question would be if there is a use case for regex matcher to generate an example? Maybe it would be an option to simply remove that functionality and let the user supply a sensible example?

matt.fellows
2022-05-04 09:52
All good points. There may well be but I've not encountered one before. @uglyog might have some use cases for it that would explain its existence

rholshausen
2022-05-04 20:48
Can you set the version to V4 and use the existing DSL classes, the new builder class is a bit basic. It will be improved in time, but for now you don't need to use it unless you want to use a plugin.

prabhakar.thippa
2022-05-05 00:25
When running provider tests is there any way to enable more user friendly output (like showing description of 'uponReceiving' in contract). For now all I can see is something like this.... ContractVerificationTest.pactVerificationTestTemplate(PactVerificationContext)[1] PASSED

rholshausen
2022-05-05 00:28
Where are you seeing this? In the test report, console output or in your IDE?

rholshausen
2022-05-05 00:31
It's historical. Earlier versions people wanted to use random values in their tests. It has been replaced with generators, which generate the random value at runtime and not persist it in the Pact file

prabhakar.thippa
2022-05-05 00:47
in console output. Is there a test report?

rholshausen
2022-05-05 00:48
Yes, there would be a JUnit test report generated

qamarlonalmeida
2022-05-05 05:24
has joined #pact-jvm

jochen.kraushaar
2022-05-05 07:30
Thanks! I will use `usingLegacyDsl()` . We don't need any V4 features, yet.

ben.pilgrim
2022-05-05 10:19
has joined #pact-jvm

ben.pilgrim
2022-05-05 10:21
Is it possible to publish pacts to a broker using `au.com.dius.pact.consumer:junit5` without `au.com.dius.pact.provider:maven`?

lredpath
2022-05-05 11:21
has joined #pact-jvm

alex834
2022-05-05 11:26
has joined #pact-jvm

nachogonzalez
2022-05-05 15:51
has joined #pact-jvm

matt.fellows
2022-05-05 17:47
I'd just suggest using our CLI tools (search http://docs.pact.io for this)

mounaouar
2022-05-05 18:00
has joined #pact-jvm

joanna.schloss
2022-05-06 04:45
has joined #pact-jvm

frank.kilcommins
2022-05-06 04:46
has joined #pact-jvm

douglas.clark
2022-05-06 04:46
has joined #pact-jvm

aaron.m.williams24
2022-05-06 07:50
has joined #pact-jvm

2022-05-06 07:55
This message was deleted.


matt.fellows
2022-05-06 08:07
Perhaps it?s not in the specific version you have?


joanna.janiec
2022-05-06 08:14
has joined #pact-jvm

aaron.m.williams24
2022-05-06 08:17
Ahh! Nice find. Let me have a look at that version.

aaron.m.williams24
2022-05-06 08:49
Well it?s interesting I have the latest https://mvnrepository.com/artifact/au.com.dius/pact-jvm-consumer/4.0.10 of everything lol

aaron.m.williams24
2022-05-06 08:50
``` public final fun toPact(): au.com.dius.pact.core.model.messaging.MessagePact { /* compiled code */ } public final fun withContent(body: au.com.dius.pact.consumer.dsl.DslPart): au.com.dius.pact.consumer.MessagePactBuilder { /* compiled code */ } public final fun withMetadata(metadata: kotlin.collections.Map<kotlin.String, kotlin.Any>): au.com.dius.pact.consumer.MessagePactBuilder { /* compiled code */ }```

matt.fellows
2022-05-06 08:56
I don't think it's in the 4.0.x line, as per the image above you'll need the 4.1.x, 4.2.x or 4.3.x line

aaron.m.williams24
2022-05-06 08:59
The latest on maven is 4.0.10 :confused:

uglyog
2022-05-06 09:00
The jar file name was changed


aaron.m.williams24
2022-05-06 09:04
Yeah thanks, I noticed! ```<!-- https://mvnrepository.com/artifact/au.com.dius.pact/consumer --> <dependency> <groupId>au.com.dius.pact</groupId> <artifactId>consumer</artifactId> <version>4.4.0-beta.2</version> </dependency>```

matt.fellows
2022-05-06 09:04
I'll make a note to update the examples that use the 4.0.x version now

aaron.m.williams24
2022-05-06 09:05
Yeah I did fork an example but didn?t noticed the DSL was 2 years out of date :smile:

matt.fellows
2022-05-06 09:10
Sorry for the confusion!

nicholas.simons
2022-05-06 11:02
has joined #pact-jvm

matias.cardenas
2022-05-06 13:44
has joined #pact-jvm

akash.srivastava.1911
2022-05-08 09:38
has joined #pact-jvm

gustavs.slutins
2022-05-09 11:51
has joined #pact-jvm

yhiamdan
2022-05-09 13:51
has joined #pact-jvm

thomas.cederholm
2022-05-09 14:48
has joined #pact-jvm

thomas.cederholm
2022-05-09 14:59
Hi, I have an issue when my consumer has triggered my Github Action towards the provider, to verify the pact. The webhook contains a payload that contains the "${pactBroker.pactUrl}" that has been resolved in the Pact Broker. The issue is that is does not contain the `pb:latest-provider-pacts` entry, and the test fails. The Pact Broker version is `2.98.0` and the junit5 lib (`au.com.dius.pact.provider:junit5`) is version `4.3.6` . I would very much like some assistance as to where I should investigate...

thomas.cederholm
2022-05-09 15:00
The test error is: ```au.com.dius.pact.core.pactbroker.InvalidHalResponse: Link 'pb:latest-provider-pacts' was not found in the response, only the following links where found: [self, pb:consumer, pb:consumer-version, pb:consumer-versions, pb:provider, pb:pact-version, pb:latest-pact-version, pb:all-pact-versions, pb:latest-untagged-pact-version, pb:latest-tagged-pact-version, pb:previous-distinct, pb:diff-previous-distinct, pb:diff, pb:pact-webhooks, pb:consumer-webhooks, pb:tag-prod-version, pb:tag-version, pb:publish-verification-results, pb:latest-verification-results, pb:triggered-webhooks, pb:matrix-for-consumer-version, curies]. URL: 'https://[...]/pacts/provider/{provider}/consumer/{consumer}/pact-version/6694147efd97f837b4bd892d11cc074d77b50a90/metadata/Y3ZuPWUwM2UyMjc0Mzc1ZTRhYWZkY2QyYjU4OWIyMDkzYTNkYWQ0ZjdmMzQmdz10cnVl', LINK: 'pb:latest-provider-pacts'``` _(Link has been abbreviated)_

thomas.cederholm
2022-05-09 15:02
The sysProps supplied to the test are: ```<pactbroker.url>${env.PACT_URL}</pactbroker.url> <pact.provider.version>${env.GITHUB_SHA}</pact.provider.version> <pact.provider.branch>${env.GITHUB_BRANCH}</pact.provider.branch> <pact.provider.tag>${env.GITHUB_BRANCH}</pact.provider.tag>``` The PACT_URL is taken from the webhook body.

rakesh.arrepu
2022-05-09 15:22
has joined #pact-jvm

abhinavsharma333
2022-05-09 17:44
has joined #pact-jvm

orbit
2022-05-09 17:58
has joined #pact-jvm

andrefcsousa
2022-05-09 18:38
Hello, i'm using maven's pact plugin to verify contract tests on provider side

andrefcsousa
2022-05-09 18:39
Although they're failing the commands builds with success as you can below: 1.8) body: $ Expected numberOfMatches=0 but was missing { - "accountId": 324, - "bets": [ - - ], - "currencyCode": "GBP", - "localeCode": "en", - "moreAvailable": false, - "numberOfMatches": 0 + "faultcode": "Client", + "faultstring": "DSC-0015", + "detail": { + "trace": "", + "message": "Credentials supplied were invalid" + } } [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.945 s [INFO] Finished at: 2022-05-09T19:35:57+01:00 [INFO] ------------------------------------------------------------------------

andrefcsousa
2022-05-09 18:40
1. how can i prevent this? i want this command to fail when the contract is not verified by Pact

andrefcsousa
2022-05-09 18:40
2. its possible to generate a report like a surefire report with the verification results?

andrefcsousa
2022-05-09 20:03
3. i've written a junit test to verify the contract. how could be the maven command to run such test?


andrefcsousa
2022-05-09 20:53
i can run from IDE the state but cant run them with pact:verify maven plugin because i didn't implemented a state url

andrefcsousa
2022-05-09 20:53
how can i run my junit test with maven surefire? using mvn surefire:test -D=MyClass is not working


andrefcsousa
2022-05-09 21:06
My class: ```package com.ppb.platform.sb.fbr.contract; import au.com.dius.pact.provider.junit.Consumer; import au.com.dius.pact.provider.junit.Provider; import au.com.dius.pact.provider.junit.State; import au.com.dius.pact.provider.junit.StateChangeAction; import au.com.dius.pact.provider.junit.loader.PactBroker; import au.com.dius.pact.provider.junit5.HttpTestTarget; import au.com.dius.pact.provider.junit5.PactVerificationContext; import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; import org.apache.http.HttpRequest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; @Consumer("pedo-bear-consumer") @Provider("fixed-odds-bet-reporting") @PactBroker(host = "ie1-fbrpp01-pact.qa.betfair", port = "8282") public class SearchBetsContractTests { @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("127.0.0.1")); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context, HttpRequest request) { request.addHeader("X-Authentication", "MzI0"); request.addHeader("X-Application", "FORCE_ELASTIC"); context.verifyInteraction(); } @State(value = "exists an account without bets", action = StateChangeAction.SETUP) public void noBets() { System.out.println("Hello state"); } }```

andrefcsousa
2022-05-09 21:06
my pom: ```<?xml version="1.0" encoding="UTF-8"?> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>integration-tests</artifactId> <groupId>com.ppb.platform.sb.fbr</groupId> <version>1.3-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>fbr-contract-tests</artifactId> <dependencies> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit5</artifactId> <version>4.0.10</version> </dependency> <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.2.7</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.8.6</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> <configuration> <skipTests>false</skipTests> <useSystemClassLoader>false</useSystemClassLoader> </configuration> <executions> <execution> <id>pact-test</id> <goals> <goal>test</goal> </goals> <configuration> <systemPropertyVariables> <pact.verifier.publishResults>true</pact.verifier.publishResults> </systemPropertyVariables> <includes> <include>**/*Tests.java</include> </includes> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <configuration> <systemPropertyVariables> <pact.verifier.publishResults>true</pact.verifier.publishResults> </systemPropertyVariables> </configuration> </plugin> <plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.1.11</version> <configuration> <serviceProviders> <serviceProvider> <name>fixed-odds-bet-reporting</name> <pactBroker> <url>http://ie1-fbrpp-pact.qa.betfair</url> <!-- <tags> <tag> master</tag> </tags> --> </pactBroker> </serviceProvider> </serviceProviders> <reports> <report>console</report> <report>json</report> <report>markdown</report> </reports> </configuration> </plugin> </plugins> </build> </project>```

andrefcsousa
2022-05-09 21:07
i've tried mvn surefire:test@pact-test but no tests were executed

matt.fellows
2022-05-09 21:15
Is that all the output you get? My suspicion is that pending pacts is enabled by default and you might need to disable it


andrefcsousa
2022-05-09 21:31
hi @matt.fellows please see my last questions. my problem is how to run a junit5 provider test throught a mvn command .

andrefcsousa
2022-05-09 21:32
from the run button on IDE is ok


rholshausen
2022-05-10 03:14
This may be a bug, can you raise an issue with that


eric.barrow
2022-05-10 03:50
has joined #pact-jvm

agarwal.akash333
2022-05-10 04:21
Hi. I?m using `au.com.dius.pact.consumer:junit:4.2.20` on an android client and I keep running into a `java.lang.AssertionError: expected:<200> but was:<500>` error. It?s unclear to me what?s causing the problem. I?ve found a https://github.com/pact-foundation/pact-jvm/issues/40 that was opened in the past which is marked as resolved but probably isn?t.

agarwal.akash333
2022-05-10 04:22
Also worth mentioning that the only thing different for this endpoint is the path and the expected response body. Everything else (request and response headers, state, response status code) is the same between this one and other pacts that we have currently.

matt.fellows
2022-05-10 04:29
Check the logs. A `500` means the mock server likely got the wrong request it was expecting

matt.fellows
2022-05-10 04:29
It should produce a junit report with the details

agarwal.akash333
2022-05-10 04:37
Thanks for the reply Matt. The only *relevant* logs that I keep receiving (for similar 500 issues in the past as well) are: ```java.lang.AssertionError: Pact Test function failed with an exception, possibly due to Mismatches(mismatches=[UnexpectedRequest(request= method: GET path: /api/participants/00000000-0000-0000-0000-000000000012/notifications query: {} headers: {Accept-encoding=[gzip], Connection=[Keep-Alive], Host=[localhost:1234], User-agent=[okhttp/4.7.2], Authorization=[Bearer blah]} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: EMPTY)]) at au.com.dius.pact.consumer.junit.JUnitTestSupport.validateMockServerResult(JUnitTestSupport.kt:79) at au.com.dius.pact.consumer.junit.BaseProviderRule.validateResult(BaseProviderRule.java:207) at au.com.dius.pact.consumer.junit.BaseProviderRule$1.evaluate(BaseProviderRule.java:106) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:121) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.AssertionError: expected:<200> but was:<500> at org.junit.Assert.fail(Assert.java:89) at org.junit.Assert.failNotEquals(Assert.java:835) at org.junit.Assert.assertEquals(Assert.java:647) at org.junit.Assert.assertEquals(Assert.java:633) at ai.a2i2.conductor.sdk.pacts.ParticipantsPacts.validateParticipantServicePact(ParticipantsPacts.java:196) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at au.com.dius.pact.consumer.junit.BaseProviderRule.lambda$runPactTest$2(BaseProviderRule.java:192) at au.com.dius.pact.consumer.BaseMockServer.runAndWritePact(MockHttpServer.kt:135) at au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest(ConsumerPactRunner.kt:32) at au.com.dius.pact.consumer.junit.BaseProviderRule.runPactTest(BaseProviderRule.java:190) at au.com.dius.pact.consumer.junit.BaseProviderRule$1.evaluate(BaseProviderRule.java:105) ... 42 more``` I?m not sure how to decipher these further.

agarwal.akash333
2022-05-10 04:41
Ah, please disregard. The path ID parameter was different in the pact definition and the unit test performing the request. I wonder if there?s a better way instead of requiring to hardcode those IDs?

matt.fellows
2022-05-10 04:59
there should be a junit report

agarwal.akash333
2022-05-10 04:59
Yep, those logs are same between stdout and junit report

matt.fellows
2022-05-10 04:59
but the error above also shows the problem, which I think you?ve also figured out!

agarwal.akash333
2022-05-10 05:00
Yeah! The error text wasn?t immediately clear. Thanks again :slightly_smiling_face:

matt.fellows
2022-05-10 05:00
> Ah, please disregard. The path ID parameter was different in the pact definition and the unit test performing the request. I wonder if there?s a better way instead of requiring to hardcode those IDs? On the consumer side you can use matchers, but because it?s a unit test you should be able to control these things. The provider must know about them though (or you can use the provider state generators to swap them out at test time)

agarwal.akash333
2022-05-10 05:55
Hi again. I?ve got another query. We?ve got a key `blah` of type array inside an array of objects in the response body on an API like so: ```[ { "id": "10bc2494-610c-4606-b169-0c33014757e9", "blah": [ "testing 123", "Testing, testing, 123..." ], "type": "GENERIC" } ]``` While I can use: ```DslPart dslPart = PactDslJsonArray.arrayEachLike() .array("blah") // Undocumented at https://docs.pact.io/implementation_guides/jvm/consumer/junit#building-json-bodies-with-pactdsljsonbody-dsl .closeArray() .closeObject()``` to validate the key `blah` to be an array, *I can?t seem to find a way to restrict the elements of the array to be of type String. Is this possible using the DSL?* I?m using `au.com.dius.pact.consumer:junit:4.2.20`.

rholshausen
2022-05-10 06:51
use `eachLike` that takes a `PactDslJsonRootValue` parameter

rholshausen
2022-05-10 06:53
i.e. ``eachLike(PactDslJsonRootValue.stringType("example string value"))``

agarwal.akash333
2022-05-10 06:55
Thanks! I ended up using `.array("blah").stringType("testing 123").closeArray()`, which luckily works too.

agarwal.akash333
2022-05-10 07:27
Forgot to mention, here?s the source (different from what the library I?m using): https://docs.pact.io/implementation_guides/jvm/consumer

thomas.cederholm
2022-05-10 08:01
@rholshausen Would there be an issue with missing annotations perhaps? ```@Provider("name-of-provider") @PactBroker @IgnoreNoPactsToVerify class X ...```

francislainy.campos
2022-05-10 08:10
Hi, we?re using pact version 4.0.7 for one of our projects and when trying to authorise with the broker it complains about it. I think it may perhaps be something to do with some error on the syntax on how we?re trying to send these credentials over to pactflow? We have this: ```<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <systemPropertyVariables> <pact.provider.version>${project.version}</pact.provider.version> <pact.verifier.publishResults>true</pact.verifier.publishResults> <pactbroker.host>http://my.pactflow.io</pactbroker.host> </systemPropertyVariables> </configuration> </plugin>``` And then ```@RunWith(PactRunner.class) @PactBroker(host = "http://my.pact.dius.com.au", consumers = { "${pact.filter.consumers:NONE}" }, tags = { "${pact.consumer.tags:latest}" }, authentication = @PactBrokerAuth(token = "myToken"))``` @uglyog I see you helped someone before with a similar error but on gradle? https://github.com/pact-foundation/pact-jvm/issues/902#issuecomment-506959822 Thank you.

thomas.cederholm
2022-05-10 08:10
I tried adding consumerVersionSelectors, but that still end up with same error. It gets to the end of `http://au.com.dius.pact.core.pactbroker.PactBrokerClient#fetchConsumersWithSelectors` where it calls `fetchConsumersWithTag` which breaks because of missing link.

matt.fellows
2022-05-10 08:17
I?m not familiar with the `:NONE` or `:latest` syntax - is that a Pact thing or a spring or something else thing? is that a default value?

matt.fellows
2022-05-10 08:18
See if you can get a debug level output. If you see that your variables aren?t being substituted (i.e. you should see `$` or something else in the logs) then you know the problem is in the interpolation

francislainy.campos
2022-05-10 08:19
Thanks Matt. I?m not sure how to get better logs out of this though? Would it be printed somewhere?

francislainy.campos
2022-05-10 08:24
I tried this now ```@RunWith(PactRunner.class) @PactBroker(host = "http://my.pactflow.io", consumers = "myConsumer", authentication = @PactBrokerAuth(token = "myToken"))```

francislainy.campos
2022-05-10 08:24
(The address was still pointing to the australian domain.

francislainy.campos
2022-05-10 08:24
However, I now see another error.

francislainy.campos
2022-05-10 08:40
I think this may be to do with the other helper classes. I?ll investigate it.

francislainy.campos
2022-05-10 08:40
Or try to get them to update to a newer version. :wink:

oprisor.cata24
2022-05-10 09:42
has joined #pact-jvm


jonathan.rice
2022-05-10 10:50
has joined #pact-jvm

matt.fellows
2022-05-10 11:37
The issue is that you?re putting the dynamic value `PACT_URL` (the path to the _contract that needs to be verified_) in a property that needs the base URL of a Pact Broker to dynamically discover pacts: `<pactbroker.url>${env.PACT_URL}</pactbroker.url>` . It can?t find the correct relation to navigate to, because the request is not sent to the correct starting point.

matt.fellows
2022-05-10 11:38
The maven command is then makinsg a call to `PACT_URL` with any configured selectors to discover pacts to verify. But this is not what you want.

matt.fellows
2022-05-10 11:39
What you want, I think, is `pactSource`. I?m not sure how to configure this behaviour dynamically, but I believe it to be the source of the issue

thomas.cederholm
2022-05-10 11:44
@matt.fellows Oh thank you for assisting! :pray: I do indeed use this the way you state; I took the inspiration from https://docs.pact.io/pact_broker/webhooks/template_library#github---trigger-build which says to do like this. Obviously I am missing out on something more.. :disappointed:

thomas.cederholm
2022-05-10 11:45
So, I want to find a way to use this url not as a baseUrl but instead as a PactSource.

matt.fellows
2022-05-10 11:46
exactly.

matt.fellows
2022-05-10 11:46
I don?t know how to do that with maven which tends to be quite declarative. I?m hoping/guessing there is a system property way of doing it

matt.fellows
2022-05-10 11:48
`pact.filter.pacturl` from https://docs.pact.io/implementation_guides/jvm/docs/system-properties seems helpful. Hopefully it flows through to Maven

matt.fellows
2022-05-10 11:48
> Overrides the URL to use to fetch the Pacts to verify. This should be used when a webhook from the Pact broker has triggered the build.

thomas.cederholm
2022-05-10 11:48
As long as it is fetched from a sysProp, I got it covered.

thomas.cederholm
2022-05-10 11:49
Sincere thanks, Matt!

matt.fellows
2022-05-10 11:49
disclaimer: I?m just guessing on the properties, but worth a shot!

thomas.cederholm
2022-05-10 11:49
It is the best I got so far :trophy:

andrefcsousa
2022-05-10 12:50
many thanks i needed to add the junit5 engine dependency

guillermo.aguirre
2022-05-10 13:11
Hello, Is there a way to use `eachLike` with string values inside? It seems that I can only figure out how to add key pair string values to this array. I would like to achieve this : `["elem1", "elem2"]` instead of `["key" : "value".. etc]`


guillermo.aguirre
2022-05-10 13:31
Thank you

vijayasaratha.v
2022-05-10 14:28
has joined #pact-jvm

radhika.madala
2022-05-10 18:10
has joined #pact-jvm

rejeesh.g
2022-05-10 18:55
https://github.com/pact-foundation/pact-jvm/pull/1552 is failing during checks. Can you please look into the issue.

rejeesh.g
2022-05-10 19:01
I am still seeing vulnerabilities in maven repository https://mvnrepository.com/artifact/au.com.dius.pact.provider/spring/4.3.4 even though it is rectified in https://github.com/pact-foundation/pact-jvm/blob/v4.3.x/provider/spring/build.gradle. Could you please help in fixing this.

oscar.lopez
2022-05-10 20:39
has joined #pact-jvm

agarwal.akash333
2022-05-10 23:49
Is there a tool/parser that can help convert a JSON to `PactDslJsonBody`?

johnathan.pestano
2022-05-11 00:43
has joined #pact-jvm

rejeesh.g
2022-05-11 07:12
Thanks Ronald Holshausen for fixing this and merging it to the branch.

milda.abromaviciute
2022-05-11 12:47
has joined #pact-jvm

alegab0710
2022-05-11 12:48
Hi all in the group! I have a a bit of problem with setting up pact for a project we are trying at our company. I have a project in intellij running spring boot with pact and it holds both client service and also a provider class responding to https call with a reply. Here is the pickle.. Im running the component im due to test, deployed in a docker container running on wsl on my machine (our company doesnt allow docker on windows... I have sorted the ssl problem by now) So the client class in intellij is sending a https call via the component in the container and back to the provider class in intellij and back to a responseEntity in my client. This works fine via the commandLineRunner in main and the regular SpringBootTest assertEquals (expected, actual). HOWEVER. If i set up a similar test in pact test having the pact test method send a https request via the client class and so forth i get the : http://au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: method: POST path: /callNextTicket/v1 query: {} headers: {} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING Im suspecting that this has to do with pacts mockserver kicking in. But is there any way around this without having to set up mock versions of all my services etc. deploying the pact project in the container causes a whole set of other problems.. Any thoughts?

matiasleandronunez
2022-05-11 13:22
has joined #pact-jvm

croudet
2022-05-11 14:07
has joined #pact-jvm

alex.bonstrom
2022-05-11 16:19
has joined #pact-jvm

cody.sims
2022-05-11 16:45
has joined #pact-jvm

harii.ravii
2022-05-11 22:02
has joined #pact-jvm

josh.kilazoglou
2022-05-12 04:17
has joined #pact-jvm

poojakunder1997
2022-05-12 07:25
has joined #pact-jvm

pekka.kiviniemi
2022-05-12 10:46
has joined #pact-jvm

sophie.bosse2
2022-05-12 12:45
has joined #pact-jvm

gustavs.slutins
2022-05-12 13:09
Hi, has anyone encountered this error for the provider verification test before? `java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/antlr/v4/runtime/CharStreams`

gustavs.slutins
2022-05-12 13:10
```java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/antlr/v4/runtime/CharStreams at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:44) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.resolvePactSources(PactJUnit5VerificationProvider.kt:83) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:44) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:103) at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:271) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:107) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:42) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53) Caused by: java.lang.NoClassDefFoundError: org/antlr/v4/runtime/CharStreams at au.com.dius.pact.core.support.Version.parse(Version.java:78) at au.com.dius.pact.core.model.DefaultPactReader.pactFromJson(PactReader.kt:219) at au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:214) at au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:210) at au.com.dius.pact.provider.junitsupport.loader.PactFolderLoader.load(PactFolderLoader.kt:54) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$pactSources$1$pacts$1.invoke(PactJUnit5VerificationProvider.kt:83) at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:39) ... 55 more Caused by: java.lang.ClassNotFoundException: org.antlr.v4.runtime.CharStreams at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 62 more```

matt.fellows
2022-05-12 13:53
Usually you would isolate the specific scenario you're testing and not send actual requests to services, except for the interaction you're focussed on. You definitely don't send requests to the real provider - they should go to the mock server. This is the error you're seeing - the mock server expected requests but didn't get them

dimitris.schizas
2022-05-12 16:04
has joined #pact-jvm

j.shankarnath
2022-05-12 16:37
has joined #pact-jvm

yesh.veera
2022-05-12 17:35
has joined #pact-jvm

fabio.been
2022-05-12 18:04
has joined #pact-jvm

b.1.alpha
2022-05-12 18:50
Hi all I am trying to do the CI/CD workshop with a colleague. The java-provider has a failing test in github actions that is not the auth in step 2. I think its broken can someone verify with me? https://docs.pactflow.io/docs/workshops/ci-cd/set-up-ci/configure-consumer-and-provider-pipelines

aliboztemir
2022-05-12 19:47
has joined #pact-jvm

james.weng
2022-05-12 23:52
Do we have examples on how to do pact on json rpc and also grpc on jvm systems liike kotlin

rholshausen
2022-05-13 01:51
For grpc, see the #protobufs channel

james.weng
2022-05-13 01:52
thanks. anything for json rpc?

rholshausen
2022-05-13 01:52
I haven't seen any examples

james.weng
2022-05-13 01:52
so not advisable to use PACT for that?

rholshausen
2022-05-13 01:53
You could try it, I assume it is just using HTTP so you could use Pact

rholshausen
2022-05-13 01:57
Does your project use antlr?

rholshausen
2022-05-13 01:58
Pact-JVM needs antlr 4.7.2

matt.fellows
2022-05-13 03:31
JSON RPC is just JSON payloads right over HTTP? If so, it should work just fine with Pact

matt.fellows
2022-05-13 03:31
P.S. `s/PACT/Pact` :wink:

james.weng
2022-05-13 04:28
yes should be http. let me give it a try

gustavs.slutins
2022-05-13 06:15
I think there is some dependency conflict with that in my project.

alegab0710
2022-05-13 08:26
But is it possible at all to send a request to the real provider? Could i send a request to the real provider via a mock server?. If not, I think we have proven that pact will not be suitable for our purposes.

gustavs.slutins
2022-05-13 08:54
Resolved with help of https://dzone.com/articles/solving-dependency-conflicts-in-maven. One of the dependencies in the project was using it as a transitive dependency with an older version.

luis.garcia
2022-05-13 09:06
has joined #pact-jvm

matt.fellows
2022-05-13 09:11
No, it's not how it works. Perhaps there's a misunderstanding of what Pact does. Why can't you run them as isolated unit tests instead of integrated using docker etc?

alegab0710
2022-05-13 09:38
Yea I knew that it wasnt the conventional way of using Pact but I wanted to test if it could be used in this way anyway. So, the company I work for own this component that mappes and forwards GET requests from two services that we dont provide. So it looks like this: [Service A ]->SOAP GET -> [My Component] -> SOAP GET [Service B] After that a reply is sent back from Service B -> via my component that translates the msg format and forwards it to Service A. We dont provide or control either Service A nor B. So we have mocked both those services in our intelliJ project. What we want is to test the integration of *our component* without mixing with it. To be able to test it in a safe enviroment we have deployed our component in a container. I think If we need to mock also the component itself the Pact framwork will not be suitable for our specific needs. Althout pact seems really great for its intended puropses

alegab0710
2022-05-13 13:32
So is your verdict that i should not use Pact for this kind of testing? :slightly_smiling_face:

matt.fellows
2022-05-13 14:05
I'm not quite understanding why you can't do isolated testing. I get the general scenario but pact will give you the integration confidence without running them in an integrated way

alegab0710
2022-05-13 14:16
I feel like the alternative would be to mock also our component?. Simular jUnit tests are already on the components unit tests. I think in general it would create too many layers of mocking for our liking and we would like to test the actual integration of the component with mocked services around it. But its possible that i missunderstood the details of how Pact works in the end.

andreas.wiig
2022-05-13 14:18
has joined #pact-jvm

gustavs.slutins
2022-05-13 14:22
Hey. I'm wondering if there is a quicker way to create the consumer pact matchers. We have some huge responses of 200+ keys. How would one go about writing tests in such cases? Doesn't seem reasonable to write them by hand. We created a library to convert java DTOs into pactDslPart matchers, but it seems like its going against the whole idea of contract testing. Some of the DTOs are generated from Swagger spec. Any ideas appreciated.

ocalderin14
2022-05-13 15:20
has joined #pact-jvm

ocalderin14
2022-05-13 15:23
Hi, was the type timestamp removed from PactDslJsonArray?

ocalderin14
2022-05-13 15:24
I need to use that type but I can't find it


b.1.alpha
2022-05-13 15:32
^^Failing

b.1.alpha
2022-05-13 15:34
Anyone own this?

b.1.alpha
2022-05-13 15:38
Do you consider this part of pact-jvm?

josh.king
2022-05-13 15:43
I'm trying to use @ignorenopactstoverify for provider tests using junit. If there's no PACT for the provider recorded in the broker, I realise that the context will be null but even if I try to handle the exception I can't get the test to pass. Are there any examples for the use of @ignorenopactstoverify ?


yousafn
2022-05-13 15:59
but it looks like from the results, it could be a bit more prominent

yousafn
2022-05-13 16:00
This issue looks like it might be worth a view buddy, if you are getting into the feature. Not hugely familiar with pact-jvm at the moment so finding my feet https://github.com/pact-foundation/pact-jvm/issues/1448

jyoti.yennam
2022-05-13 17:28
has joined #pact-jvm

rberger
2022-05-13 21:06
has joined #pact-jvm

matt.fellows
2022-05-14 23:26
It's not part of Pact JVM but we can look Monday.

matt.fellows
2022-05-14 23:26
The build looks green at the moment, is this related to its use in the workshop?

jsb0545
2022-05-15 18:55
has joined #pact-jvm

matt.fellows
2022-05-16 01:29
That error says it can?t find a provider with that name - was the consumer test updated with the different provider name?

abubics
2022-05-16 01:55
My focusing questions for this are usually: ? Are all the fields always relevant? ? Could you compose chunks of related fields together, to DRY out the interaction declaration?

matt.fellows
2022-05-16 03:51
You don?t mock your own component in a Pact test, just the other collaborators. The idea is to isolate the communication between the two systems you?d like to contract test. In your case, you would mock `Service B` when writing a consumer Pact test from `My Component` to service B. The mock would be provided by Pact, so it can create a contract for Service B to later check. When `Service B` is verified by Pact, it would stub out any other external dependencies. `Service A` would do similar, except the provider would be your component. When `My Component` verifies its consumer contract with `Service A`, you would stub our your provider(s) - in this case, `Service B` .


leon.luu2
2022-05-16 06:43
has joined #pact-jvm

samikshaphulzele
2022-05-16 09:53
has joined #pact-jvm

samikshaphulzele
2022-05-16 09:54
Hi Everyone

samikshaphulzele
2022-05-16 09:55
I am trying to do contract testing with Kafka which support schema registry avro

samikshaphulzele
2022-05-16 09:55
I was reading about pact but didn't find an example of pact with avro schema registry

samikshaphulzele
2022-05-16 09:57
Do pact support avro schema registry , i am little confused can someone help me out with this?

josh.king
2022-05-16 12:18
Thanks. Very useful. I think the case I'm looking is bit different as it's when there is no integration recorded for the provider in the broker but I could be wrong. Still working through everything.

rholshausen
2022-05-16 23:32
Yes, it does support it. You need to use a content type of `application/vnd.schemaregistry.v1+json`. I don't know of any examples, maybe @yousafn might know of some

yousafn
2022-05-16 23:56
Hey hey, here is an example by Andy Muir, I won't tag him as its late https://docs.pact.io/recipes/kafka#magic-bytes for Kafka w/schema registry

yousafn
2022-05-16 23:56
We wrote a set of blog posts to accompany, I will have to find the link

rholshausen
2022-05-17 00:23
Wow, that's awesome!

yousafn
2022-05-17 00:27
https://muirandy.wordpress.com/2022/02/18/contract-testing-with-pact-kafka-and-schema-registry-part-1/ https://muirandy.wordpress.com/2022/03/03/contract-testing-with-pact-kafka-and-schema-registry-part-2/ sorry if it doesn't help Samiksha as you are using avro, I can't tell myself how suitable it would be, as I am only familiar with gRPC through our demos, and this is a new world

yousafn
2022-05-17 00:28
I :heart: `pactman`

shiva.idc
2022-05-17 00:33
has joined #pact-jvm

agarwal.akash333
2022-05-17 00:53
Hi all. Does https://docs.pact.io/implementation_guides/jvm/consumer#usage supersede https://docs.pact.io/implementation_guides/jvm/consumer/junit? Edit - More specifically, the new https://docs.pact.io/implementation_guides/jvm/consumer#why-a-new-dsl-implementation supposedly does supersede pact-jvm-consumer-junit if I understood the docs correctly. if it does, I can?t find a maven repository for io.pactfoundation.

rholshausen
2022-05-17 01:07
These are different things, one provides support for using JUnit to write Pact tests, the other for building JSON payloads in Java.

rholshausen
2022-05-17 01:07
If you write JUnit Pact tests using JSON payloads in Java, you need both

agarwal.akash333
2022-05-17 01:09
Thanks for the prompt reply. How come we need both when pact-jvm-consumer-unit ships with a DSL too? E.g.: ```import au.com.dius.pact.consumer.dsl.DslPart; import au.com.dius.pact.consumer.dsl.PactDslJsonArray; import au.com.dius.pact.consumer.dsl.PactDslJsonBody; import au.com.dius.pact.consumer.dsl.PactDslWithProvider;```

rholshausen
2022-05-17 01:10
That is the older support which does not use lambda functions. But it works.

agarwal.akash333
2022-05-17 01:11
Right, thanks for clarifying that.. how exactly does one get their hands on the new Lamba DSL?

rholshausen
2022-05-17 01:12
If you included the Pact JUnit jar, it will be available on your classpath (transitive dependency)

rholshausen
2022-05-17 01:12
If you have dependency issues, then also include the consumer jar

agarwal.akash333
2022-05-17 01:12
Is this available only after 4.3.x? I?ve already got `testImplementation 'au.com.dius.pact.consumer:junit:4.2.20'`

rholshausen
2022-05-17 01:13
No, it has been available for a long time

agarwal.akash333
2022-05-17 01:14
Weird, because:

rholshausen
2022-05-17 01:15
Ah! the examples are wrong. The package is `http://au.com.dius.pact.consumer.dsl`

agarwal.akash333
2022-05-17 01:15
Ah, the docs need updating. ```au.com.dius.pact.consumer.dsl.LambdaDsl.newJsonArray;``` works

agarwal.akash333
2022-05-17 01:19
I reckon it?d be really helpful to clarify on the jUnit page(s) that the older DSL is deprecated in favour of the lambda DSL. I didn?t look into the new DSL?s page (which looks much more clean) until we started running into issues :sob:

rholshausen
2022-05-17 01:23
It's not deprecated, the newer one just wraps the older one and allows the use of lambda functions

agarwal.akash333
2022-05-17 01:24
@rholshausen just a little more context for the reason why I am looking to switch to the Lamda DSL docs ? it?s because as pointed out in the docs, the junit4 DSL seems to be buggy (I?m on version `4.2.20`). We?ve got 2 different similar requests like: ```DslPart requestOneResponseBodyDslPart = PactDslJsonArray .arrayEachLike() .uuid("id", UUID.randomUUID()) .datetime("startTime", INSTANT_FORMAT_STRING) // More keys here .closeObject(); DslPart requestTwoResponseBodyDslPart = PactDslJsonArray .arrayEachLike() .uuid("id", UUID.randomUUID()) .datetime("scheduledStartTime", INSTANT_FORMAT_STRING) .closeObject();``` Both of them generate random UUIDs and the default datetime string adhering to the format like: `"2000-02-01T00:00:00.000000Z"` in the pact JSON file. The problem is that `requestOneResponseBodyDslPart`?s provider verification is expecting exact value matches for both the `.uuid` and `.datetime` fields, which is _*really*_ odd, considering we?ve used PactDslJsonArray before too.

agarwal.akash333
2022-05-17 01:26
Right. I?m yet to try the new DSL, I wonder if that?d fix my issue, although nothing seems wrong at the Pact generation side. Perhaps it?s the provider?

rholshausen
2022-05-17 01:30
Switching to lambda based DSL will not resolve your problems, as it all uses the same implementation. You need to work out the correct values to use in your tests.

agarwal.akash333
2022-05-17 01:35
Actually, I just spotted that the pact being generated for `requestOneResponseBodyDslPart` doesn?t include *any* `generators` and `matchingRules` for that request :thinking_face:

agarwal.akash333
2022-05-17 01:52
Looking closer, at least one of our requests that works fine doesn?t have a generator for all the fields, despite all the fields in that request?s body being `.stringType` :thinking_face:

rholshausen
2022-05-17 02:03
How are the DSL parts used (ie. ``requestOneResponseBodyDslPart``)

agarwal.akash333
2022-05-17 02:16
Like so: ```return builder .given("MY STATE") .uponReceiving("a request to get all of a participant's recommendations") .path(String.format("/api/participants/%s/recommendations", DEFAULT_PARTICIPANT_ID)) .method("GET") .headers(REQUEST_HEADERS_WITH_AUTH) .willRespondWith() .status(200) .headers(RESPONSE_HEADERS_FOR_VALIDATION) .body(getRecommendationsPactDslJsonBody.toString()) .toPact();```

rholshausen
2022-05-17 02:17
Don't do this: `getRecommendationsPactDslJsonBody.toString()`, it converts it to pure JSON and you loose all the matchers and generators. Just remove the `toString()` call

agarwal.akash333
2022-05-17 02:24
Jeez, thanks heaps!

ocalderin14
2022-05-17 10:18
Hi guys, I have this contract ```.body(PactDslJsonArray.arrayMinLike(1) .stringType("transactionHash") .stringType("originWallet") .stringType("destinationWallet") .decimalType("amount", 1.0) .datetime("creationDate") .stringType("method") .stringType("status") .decimalType("fee") ).toPact();``` when I execute my consumer tests they are passing, but then when I'm running my provider tests I'm getting this error: body: $.0.creationDate Expected 1652738400000 to match a datetime of 'yyyy-MM-dd'T'HH:mm:ss': Unable to parse the date: 1652738400000

ocalderin14
2022-05-17 10:19
does anybody have any idea about this?

fabio.rodrigues
2022-05-17 10:41
it's the format of the date. a datetime should be in that format and it's not

fabio.rodrigues
2022-05-17 10:44
the dateformat it's expect it's something like this: 2022-05-16, 23:00:00

ocalderin14
2022-05-17 10:44
yes, the provider is returning a timestamp for the field creationDate and I'm using datetime("creationDate") in PactDslJsonArray, but it is not working

fabio.rodrigues
2022-05-17 10:44
if it's a timestamp it is a int

fabio.rodrigues
2022-05-17 10:44
not a datetime

fabio.rodrigues
2022-05-17 10:44
also that timestamp is in what nanoseconds?

ocalderin14
2022-05-17 10:45
let me try with an int

ocalderin14
2022-05-17 10:47
but I think it should fail because this field is declared as a Date in the Dto

fabio.rodrigues
2022-05-17 10:48
the thing is that a timestamp is a number (number of units of time since a specific instant)

fabio.rodrigues
2022-05-17 10:48
and a date requires localization and other concepts

fabio.rodrigues
2022-05-17 10:48
what does the provider gives

fabio.rodrigues
2022-05-17 10:48
a timestamp or a datetime string with correct localization ?

ocalderin14
2022-05-17 10:51
a datetime string with correct localization

fabio.rodrigues
2022-05-17 10:51
then your provider has a bug

fabio.rodrigues
2022-05-17 10:52
because it's sending a timestamp

fabio.rodrigues
2022-05-17 10:52
on that field

fabio.rodrigues
2022-05-17 10:52
or you have a wrong expectation

ocalderin14
2022-05-17 11:02
I think I have a wrong expectation because the field is a Date, when I check in the database it is also stored as a Date, but then when I receive the response it looks like they are transforming this Date to a timestamp and that is what I'm receiving

fabio.rodrigues
2022-05-17 11:03
then contract testing is doing it's job on dealing with expectations

fabio.rodrigues
2022-05-17 11:03
:slightly_smiling_face:

joseph.joyce
2022-05-17 12:15
has joined #pact-jvm

ben.pilgrim
2022-05-17 13:07
Is there an issue/timeline for adding providerVersionBranches support for for-verification lookups?

vasanth.s
2022-05-17 13:36
has joined #pact-jvm

sri.kasturi
2022-05-17 14:21
has joined #pact-jvm

r.muthukumar136
2022-05-17 21:58
Hi Team

r.muthukumar136
2022-05-17 21:58
Issue: In the provider end, pact tests is failing with below error:- Request to provider failed with an exception: ?/? is not allowed in an identifier in path expression ?$.data[0].relationships.user/shippingAddress.data.id? at index 28 (http://au.com.dius.pact.core.model.InvalidPathExpression) My Request (POST): ?relationships?: { ?user/shippingAddress?: { ?data?: { ?id?: ?12345?, ?type?: ?user/shipping-address? } } We are using junit5spring version 4.3.7. Is this a known issue in the pact ? Is there any way to fix this issue? Thanks.

carlosh.carmo2
2022-05-17 22:43
has joined #pact-jvm

rholshausen
2022-05-17 23:25
Can you raise an issue for this? It is a bug

james.weng
2022-05-18 06:10
hi , im trying to connect my provider with pactflow using the example https://docs.pactflow.io/ (java/junit5) @Provider("<Your provider name here>") @PactBroker(host = "<YOUR_BROKER>.http://pactflow.io", scheme = "https", authentication = @PactBrokerAuth(scheme = "bearer", username = "<TOKEN>", password = "")) but it keeps prompting cannot resolve method 'scheme' am i missing some import in the lib?

james.weng
2022-05-18 06:17
works when i change it to ```@PactBroker(host = "http://airwallex.pactflow.io", scheme = "https", authentication = @PactBrokerAuth( token = "xxxxx-xxxxx"))``` Is this how i should do it @matt.fellows?

matt.fellows
2022-05-18 06:24
looks like maybe the API has changed to not require the ?scheme?

matt.fellows
2022-05-18 06:24
nice work!

james.weng
2022-05-18 06:25
yea i think so. it seem to be have been removed

gchursov
2022-05-18 09:43
has joined #pact-jvm

gchursov
2022-05-18 09:46
@rholshausen hey, where I can create a defect for that? Could you share the link?

berk.safranbolulu
2022-05-18 10:18
has joined #pact-jvm


thomas.cederholm
2022-05-18 11:19
If I have two Pact test classes (1 test per state) that run, as soon as I added `@PactFilter` annotation, with the exact string of the state, then both tests fail to find pacts. Without the annotation it breaks because a test only contains one state. Do I have to have all states in each test file together with the `@PactFilter` ?

larshoogma
2022-05-18 11:34
has joined #pact-jvm

anja.gruss
2022-05-18 12:03
anyone encounter "Error parsing json" when uploading the OAS to the broker? happens both for yml and json file, the file is created by springdoc-openapi and generates a 3.0.1 openapi version file which seems valid to my ide

matt.fellows
2022-05-18 12:10
hello!

matt.fellows
2022-05-18 12:11
how are you uploading the OAS - are you able to share?

anja.gruss
2022-05-18 12:11
currently in a meeting, will get back to you in a moment, sorry

malvika0810
2022-05-18 12:17
has joined #pact-jvm

anja.gruss
2022-05-18 13:15
I am using a bash script, based on this example (https://docs.pactflow.io/docs/bi-directional-contract-testing/contracts/oas/#publishing-the-provider-contract--results-to-pactflow) currently it's a yml file, ```OAS=$(cat ${CI_BUILDS_DIR}/${CI_PROJECT_PATH}/target/openApi/openapi.yml | base64 -w0)```

anja.gruss
2022-05-18 13:16
curl: ```curl \ -X PUT \ -H "Authorization: Bearer ${PACT_BROKER_TOKEN}" \ -H "Content-Type: application/json" \ "${PACT_BROKER_BASE_URL}/contracts/provider/${PACTICIPANT}/version/${CI_COMMIT_SHORT_SHA}" \ -d '{ "content": "'$OAS'", "contractType": "oas", "contentType": "application/yaml", "verificationResults": { "success": '$SUCCESS', "content": '$REPORT', "contentType": "text/plain", "verifier": "verifier" } }'``` the output of the curl: ==> Uploading OAS to Pactflow https://git.eu.365farmnet.com/anja.gruss/pacttest-service-be/-/jobs/729801#L196 % Total % Received % Xferd Average Speed Time Time Time Current https://git.eu.365farmnet.com/anja.gruss/pacttest-service-be/-/jobs/729801#L197 Dload Upload Total Spent Left Speed https://git.eu.365farmnet.com/anja.gruss/pacttest-service-be/-/jobs/729801#L198100 13839 100 6973 100 6866 4849 4774 0:00:01 0:00:01 --:--:-- 9617 https://git.eu.365farmnet.com/anja.gruss/pacttest-service-be/-/jobs/729801#L199{"error":"Error parsing JSON - Error parsing JSON

matt.fellows
2022-05-18 13:24
interesting. Is it a really big file by any chance?

matt.fellows
2022-05-18 13:26
is `$REPORT` a string or a a primitive? I think it would need escaping also if it?s a string (update: definitely needs quoting if a string, see below)

matt.fellows
2022-05-18 13:27
you may want to out the new beta CLI for this - https://pact-foundation.slack.com/archives/CLS16AVEE/p1652436428503859

matt.fellows
2022-05-18 13:27
(it?s the usual CLI, with a feature flag enabled to publish provider contracts)

matt.fellows
2022-05-18 13:28
FYI this is how I managed to get an invalid JSON locally using your code above as a basis: ```export REPORT="aoeuaeou" export SUCCESS=true echo '{ "content": "'$OAS'", "contractType": "oas", "contentType": "application/yaml", "verificationResults": { "success": '$SUCCESS', "content": '$REPORT', "contentType": "text/plain", "verifier": "verifier" } }' | jq . parse error: Invalid numeric literal at line 1, column 137```

anja.gruss
2022-05-18 13:36
it's super small

anja.gruss
2022-05-18 13:37
report was a string (with some whitespace)

nishant.shah
2022-05-18 13:38
has joined #pact-jvm

anja.gruss
2022-05-18 13:39
and result stays the same when I switch report to a simple string

matt.fellows
2022-05-18 13:40
Ok cool, I think you just need to add double quotes around REPORT then

anja.gruss
2022-05-18 13:42
in the curl command?

anja.gruss
2022-05-18 13:42
what exactly is this report anyway?^^

anja.gruss
2022-05-18 13:44
quotes worked wonders, thanks @matt.fellows

anja.gruss
2022-05-18 13:46
When I have the sample up and running with the bidirectional, I will get back to you regarding the new CLI thingy

rholshausen
2022-05-18 23:03
Do the interactions in the Pact file require both provider states?

thomas.cederholm
2022-05-19 06:24
I figured out that if I add ```@PactBroker(url = "https://the-url/" , consumerVersionSelectors = {@VersionSelector(consumer = "one-consumer")} )``` in the first test, and ```@PactBroker(url = "https://the-url/" , consumerVersionSelectors = {@VersionSelector(consumer = "the-other-consumer")} )``` in the other test, they pass. I will hard-code this for now, until I find a good way to tag the consumers.



vorashil.farzaliyev
2022-05-19 10:59
has joined #pact-jvm

ruben.perezg
2022-05-19 11:11
Hi there :slightly_smiling_face: I was looking into the https://docs.pact.io/pact_broker/branches#support, trying to see if the JVM libraries already supported branches, environments, pending pacts, WIP pacts... and I though they didn't. But also I saw some comments in this channel and the https://docs.pact.io/implementation_guides/jvm/changelog of the JVM section, and it looks like at least some of those things are already implemented. Could you help me understand what is the current state of the JVM ecosystem regarding those new features, or where I can find documentation to understand it? Thank you :slightly_smiling_face:

jlcrazzy
2022-05-19 13:38
has joined #pact-jvm

galveznairon
2022-05-19 13:40
has joined #pact-jvm

sunny.cheung
2022-05-19 20:43
has joined #pact-jvm

rholshausen
2022-05-20 02:44
PR for branches has just been merged :smile: There is no central document describing these features, they will be spread between the various components that are supported, i.e. Maven, Gradle, JUnit etc.

chantalnitz
2022-05-20 07:22
has joined #pact-jvm

chantalnitz
2022-05-20 07:27
Hi All, I am trying to generate a contract for the following json response. This is just a snippet of the json. `[` { "type":"Component1", "content":{ "title":"Title 1" } }, { "type":"Component2", "content":{ "price":"£505.15", "subtitle":"Test subtitle", "title":"Test title" } } ]

chantalnitz
2022-05-20 07:28
This is my kotlin code so far: ```private fun responseBody2(): DslPart? { return PactDslJsonArray.arrayEachLike() .`object`("type") .`object`("content") .stringType("title", "Search Results") .closeObject() .closeObject() .`object`("type2") .`object`("content") .stringType("price", "$500") .stringType("subTitle", "") .stringType("title", "") .closeObject() .closeObject() }```

chantalnitz
2022-05-20 07:29
This is a snippet from the generated contract: ```"body": [ { "type2": { "content": { "subTitle": "", "price": "$500", "title": "" } }, "type": { "content": { "title": "Search Results" } } } ]```

abubics
2022-05-20 07:30
As an aside: it's easier to read and write if you use the Java 8 lambda syntax, even in Kotlin :slightly_smiling_face:

chantalnitz
2022-05-20 07:30
I have 2 problems here. 1. I cannot repeat objects with the same name "type". They get overwritten.

abubics
2022-05-20 07:32
Yeah, that's not how `arrayEachLike` works. It takes a single object for a number of repetitions, not a heterogeneous set of objects.

chantalnitz
2022-05-20 07:32
2. How do I add a value for the "type" property in the DSL code, for example: "type":"Component1"

abubics
2022-05-20 07:32
If you look closely, this is an array with one big object inside, not two.

chantalnitz
2022-05-20 07:33
Thanks for the responses. Please advise me on the correct way of doing this

abubics
2022-05-20 07:34
What interaction are you trying to describe? Because that will influence what goes into your requests/responses :slightly_smiling_face:

abubics
2022-05-20 07:35
i.e., do you really need multiple objects with different fields present, or could that be split to more specific interactions?

abubics
2022-05-20 07:36
In general, the `eachLike` functions in Pact are for testing lists of objects with the same shape.

chantalnitz
2022-05-20 07:37
So, I will have multiple type objects within the response array object, each with their unique properties, and I will need to validate that each of them and their properties exist

abubics
2022-05-20 07:46
that's definitely one way to do it, and probably the way I'd suggest if you need that kind of reasoning power

abubics
2022-05-20 07:48
other ways include using the `arrayContaining` function (from v4), but that gives you a different intent profile

chantalnitz
2022-05-20 07:52
Would you mind getting me started with a code snippet please. I can't use v4 at the moment, so I will need to stick with the previous option you mentioned

abubics
2022-05-20 07:58
You could definitely start with what you've got, but with only one `object(...)` in each interaction.

robert
2022-05-20 08:47
has joined #pact-jvm

baris.kucuk.atilim
2022-05-20 09:47
has joined #pact-jvm

chantalnitz
2022-05-20 10:48
Thanks for your guidance. I finally made some progress but still not using the lambda syntax. Might convert it once I get the contract right

rajnavakoti
2022-05-20 12:42
has joined #pact-jvm

mlund
2022-05-20 21:04
has joined #pact-jvm

pavi.dealwis
2022-05-21 03:28
has joined #pact-jvm

endika2
2022-05-21 10:52
has joined #pact-jvm

6eo2ge
2022-05-22 13:17
has joined #pact-jvm

eugene.baranovsky
2022-05-22 23:25
has joined #pact-jvm

harris
2022-05-23 03:04
has joined #pact-jvm

abhiattipra
2022-05-23 06:04
has joined #pact-jvm

max.bruns
2022-05-23 07:13
has joined #pact-jvm

ben.pilgrim
2022-05-23 08:22
Any chance of getting a new release cut?

edouard.lopez
2022-05-23 10:04
With message queue, is it mandatory to have a match between `@PactVerifyProvider(?)` value and the consumer `expectsToReceive(?)` one. I was using Pact only for REST until now and, to my understanding, I never had to use that. Why this difference?

matt.fellows
2022-05-23 10:19
Because with HTTP, you have paths and verbs and things - so the verifier can just issue a request to `GET /foo/bar`

matt.fellows
2022-05-23 10:19
With messages, it needs a way to know how to get the producer to produce a message of a particular type

matt.fellows
2022-05-23 10:19
there is no universal way to do that

hello560
2022-05-23 12:23
has joined #pact-jvm

ruben.perezg
2022-05-23 14:34
I guess I asked just in time :laughing: What I tried to find out was if the JVM ecosystem was ready for those new features/first-class-citizen. The documentation about the Pact Broker is "easier" in a way to see from the version all those new things are available. For the JVM is not that easy from what I'm seeing. What I tried to know was if the JVM ecosystem was ready for the "new flow" (new webhook event, pending pacts, branches and environments, WIP pacts...), or if we should still implement the https://docs.pact.io/pact_broker/advanced_topics/pending_pacts#without-the-pending-pacts-feature-enabled" of using the older webhook event, using tags for environment and branches... and so on

ruben.perezg
2022-05-23 14:35
but I guess the "JVM ecosystem" is so big that there's no easy answer for that question, so I will try to check the component repositories to find it out :slightly_smiling_face:

venky.hodigere
2022-05-23 14:54
has joined #pact-jvm

andrefcsousa
2022-05-23 16:12
Hello everyone. Imagine i have two classes (Class A and Class B) that have the same configuration for @Consumer, @Provider and @PactBroker tags. E.g: @Consumer("X") @Provider("Y) @PactBroker("Z") Now i have on that Pact Broker "Z", 3 interactions defined by the consumer, but two interactions have provider state definitions that are implemented on Class A to create state, the remaining one is implemented on Class B

andrefcsousa
2022-05-23 16:13
when i run provider verification tests, it's seems Pact is trying to find @StateMethods for each interaction on each class, therefore executing 3 tests per class. I want that Pact only runs the two interaction for Class A and the other one for B

andrefcsousa
2022-05-23 16:13
this is possible to surpass without creating for example a new provider name?

prerit.jain
2022-05-23 16:27
has joined #pact-jvm

evan
2022-05-23 16:48
has joined #pact-jvm

manuel.porto
2022-05-23 17:56
has joined #pact-jvm

rholshausen
2022-05-23 21:59
I think everything is supported except for environments

ruben.perezg
2022-05-24 07:56
Thank you! :slightly_smiling_face:

abhishek.lamba
2022-05-24 09:25
has joined #pact-jvm

stefan.friese
2022-05-24 09:32
has joined #pact-jvm

edouard.lopez
2022-05-24 09:33
Thanks

bharath.shetty
2022-05-24 09:33
has joined #pact-jvm

ben.pilgrim
2022-05-24 09:58
@rholshausen

tomknee1
2022-05-24 13:21
hello, does anyone have recommendations for expression to use for an email address in pattern matching? regex for email is usually very hard and not recommended, but `valueFromProviderState` seems to require an expression and example for my email address value, any recommendations here please?

rivanitskiy
2022-05-24 14:23
has joined #pact-jvm

carlosh.carmo2
2022-05-24 18:31
Hello team! I have a question: is the gRPC support (pact-jvm) only for Pact Flow? Thanks

marti92
2022-05-24 21:40
has joined #pact-jvm

matt.fellows
2022-05-24 22:20
no, it is an OSS feature so will be / is available to all

rholshausen
2022-05-25 00:04
The expression is for building the test value, not matching the value. You can just use `${email}` and then set the email attribute in the provider state data that is returned.

rholshausen
2022-05-25 00:04
I think even just `email` will work

yasarenver
2022-05-25 05:22
has joined #pact-jvm

qingyuliu
2022-05-25 06:42
Hi team, I would like to implement a message contract using kafka. A provider will send a message to a kafka topic and a consumer will read the message from the kafka topic. Could you provide some related doc or example for my reference? Thanks!


tomknee1
2022-05-25 06:59
ok thanks

brian.quinn
2022-05-25 08:53
has joined #pact-jvm

jarekrzdbk
2022-05-25 12:45
has joined #pact-jvm

shaun.mendham
2022-05-25 16:32
has joined #pact-jvm

plourded
2022-05-25 19:43
has joined #pact-jvm

qingyuliu
2022-05-26 05:16
Hi *https://app.slack.com/team/UB7B75EE4*, could you provide some provider side example for me? Thanks!


qingyuliu
2022-05-26 05:22
Thanks!

emirhan.emmez
2022-05-26 06:31
has joined #pact-jvm

emirhan.emmez
2022-05-26 06:41
Hi all, is there any good doc for android contract testing? It can be repo also, thank you

matt.fellows
2022-05-26 07:31
Hi Emirhan, Android shouldn?t be any different to any other Java/Kotlin/JVM project

matt.fellows
2022-05-26 07:32
My understanding is you can still do unit testing in Android, in which case there?s no difference

emirhan.emmez
2022-05-26 07:35
when i wrote the same code I'm giving "test environments were not found" error

matt.fellows
2022-05-26 07:35
Can you please share the actual error? That doesn?t sound like an error from Pact

shaun.mendham
2022-05-26 08:07
Hi all, This looks to be an already discussed topic, but struggling to find a conclusive answer to a question we have. Effectively we have a microservice which interacts both via HTTP and Kafka with other microservices, we are looking to PACT test both of these interaction types. Is it currently not possible to define multiple provider types against the same provider name? (E.g. we would need to define a two providers `service-name` and `service-name-kafka`) What I am seeing currently with a single provider name across two test classes, is that all contracts for the provider are run against both types of which the opposite type contracts fail.

shaun.mendham
2022-05-26 08:08
It looks by this: https://pact.canny.io/feature-requests/p/support-multiple-protocols-of-pact-for-the-same-application That the feature is planned, is this the best place to track the progress? In the meantime is the recommended solution to have multiple providers defined, one for each contract type?

emirhan.emmez
2022-05-26 09:00
OK, I fixed. That was a silly mistake :slightly_smiling_face:

yousafn
2022-05-26 11:36
Hi, I believe your use case is solved in v4 pact-specification https://github.com/pact-foundation/pact-specification/tree/version-4 This is from the latest OSS changelog https://pactflow.io/blog/changelog-oss-may-2022/ > Pact specification V4 is https://github.com/pact-foundation/pact-specification/tree/version-4! We worked hard on listening to the community, after the release of v3, 5 years ago. We consolidation many of the requests people made about things that haven?t worked quite properly. One of the biggest changes is consolidation the file format to allow for HTTP and message interactions with a single file. > ? :video_camera: See an AMA from 2021 where Ron Holshausen took us through ?https://www.youtube.com/watch?v=u7LzZ6Fm1Ok?? > ? :orange_book: Read the V4 spec RFC for a full list of changes: https://github.com/pact-foundation/pact-specification/issues/71 > ? :rocket: Implementations in https://github.com/pact-foundation/pact-reference/blob/master/rust/README.md core and https://github.com/pact-foundation/pact-jvm#supported-jdk-and-specification-versions has been completed > :earth_africa: All our Pact specifications are open-source and you can see them all https://github.com/pact-foundation/pact-specification#index

yasir27uk
2022-05-26 17:56
has joined #pact-jvm

yousafn
2022-05-26 18:28
Hey @praveen.em , spot on, I?ve replied

abubics
2022-05-27 04:31
On the Kotlin + lambda syntax, my tests tend to look something like this, with help from many extension functions: ```val pact = buildPact(given = "several amendments") { uponReceiving("a request to begin reindexing amendments").run { method("POST").path("/admin/amendments/reindex").authHeader() }.willRespondWith().run { status(201) jsonBody { uuid("transactionId", ConsistentUUID) zonedDateTime("startDate") numberType("pending", 300) numberType("successes", 0) numberType("failures", 0) numberType("total", 300) } } } val response = pact { startAmendmentsReindex() }```

abubics
2022-05-27 04:34
extension helpers like these: ```fun pactBuilder() = ConsumerPactBuilder .consumer("redacted-consumer") .hasPactWith("redacted-api") fun buildPact( builder: PactDslWithProvider.() -> PactDslResponse ): RequestResponsePact = pactBuilder().builder().toPact() fun buildPact( given: String, builder: PactDslWithState.() -> PactDslResponse ): RequestResponsePact = pactBuilder().given(given).builder().toPact() operator fun <R> BasePact.invoke(auth: Boolean = true, createCall: AdminClient.() -> Call<R>): R? { println() val result: PactVerificationResult = runConsumerTest( this, MockProviderConfig.createDefault(), object : PactTestRun<Response<R>> { override fun run(mockServer: MockServer, context: PactTestExecutionContext?): Response<R> { val client = buildClient<AdminClient>(mockServer.getUrl(), auth) return client.createCall().execute() } } ) println("testPact result: $result") return ((result as? Ok)?.result as? Response<R>?)?.body() } infix fun PactDslResponse.jsonBody(bodyBuilder: LambdaDslJsonBody.() -> Unit): PactDslResponse = body(LambdaDsl.newJsonBody(bodyBuilder).build()) fun PactDslResponse.jsonArray(times: Int = 1, body: LambdaDslObject.() -> Unit): PactDslResponse = body(newJsonArray { repeat(times) { newObject(body).build() } })``` etc

lcs2019022
2022-05-27 05:27
has joined #pact-jvm

kannan.jai
2022-05-27 08:01
Hello, have anyone tried passing the port number for the mock server as a command line argument when running consumer tests? Tried it but failing, may be I am missing something. Any thoughts? Thanks. ```@PactTestFor(providerName = "test-provider", port = "${pact.server.port}")``` We would be setting the same port in one of our config yml file hence we would like to either set it via command line or read and pass it to our yml config similar to using @AutoConfigureWiremockPort which exposes the port via ${wiremock.server.port}

wieslaw.bondyra
2022-05-27 08:09
has joined #pact-jvm

aurelia.rochat
2022-05-27 09:05
Hello, I?m checking the branches feature, and according to this page : https://docs.pact.io/pact_broker/branches#support it has not beed included in pact-jvm yet. Does anyone know if it?s planned to be included soon ?

yousafn
2022-05-27 09:14
Hey @aurelia.rochat, I believe there are 4 elements from a list we have tracking. I am planning on getting this list expanded for all languages and on the site as well. We would greatly appreciate anyones assistance in being able to get these over the line, and I will be doing a shout about it in our next OSS post due to go out next week 1. Publish pacts with branch (consumer) a. JVM i. https://github.com/pact-foundation/pact-jvm/issues/1453 2. Publish verification results with branch (provider) a. JVM i. https://github.com/pact-foundation/pact-jvm/issues/1454 3. Consumer version branch selector (provider) a. JVM i. https://github.com/pact-foundation/pact-jvm/issues/1465 1. Can be bypassed with raw JSON: https://github.com/pact-foundation/pact-jvm/pull/1471 4. Consumer version environment selectors (provider) a. JVM i. https://github.com/pact-foundation/pact-jvm/issues/1407


wieslaw.bondyra
2022-05-27 11:05
Hello, I am trying to test POST request with multipart but I have got error likr this java: cannot access org.json.JSONObject class file for org.json.JSONObject not found I am using au.com.dius.pact.consumer:junit5:4.2.21 version. My Pact and test is here: ``` @Pact(consumer = CONSUMER_NAME, provider = PROVIDER_NAME) public RequestResponsePact createPactForWiesaTest(PactDslWithProvider pactDslWithProvider) { MultipartEntityBuilder multipart2 = MultipartEntityBuilder.create() .setMode(HttpMultipartMode.BROWSER_COMPATIBLE) .setContentType(ContentType.APPLICATION_FORM_URLENCODED) .addBinaryBody("file", "1,2,3".getBytes(), ContentType.create("text/csv"), "data.csv") .addTextBody("textPart", "sample text"); PactDslResponse builder = pactDslWithProvider .given("Check buildId") .uponReceiving("Request to get wiesa buildId") .path("/wiesabuild") .body(multipart2) .method("POST") .willRespondWith() .status(HttpStatus.OK.getCode()) .body("is OK", MediaType.TEXT_PLAIN); return builder.toPact(); } @Test @PactTestFor(providerName = "WiesaMultipartService", pactMethod = "createPactForWiesaTest") void testWiesaMultipartService(MockServer mockServer) throws MalformedURLException { String url = mockServer.getUrl(); String response; MultipartEntityBuilder multipart2 = MultipartEntityBuilder.create() .setMode(HttpMultipartMode.STRICT) .setContentType(ContentType.APPLICATION_FORM_URLENCODED) .addBinaryBody("file", "1,2,3".getBytes(), ContentType.create("text/csv"), "data.csv") .addTextBody("textPart", "sample text"); try (RxHttpClient rxHttpClient = RxHttpClient.create(new URL(url))) { response = rxHttpClient.toBlocking().retrieve( http://HttpRequest.POST("/wiesabuild", multipart2) .contentType(APPLICATION_FORM_URLENCODED) .accept(APPLICATION_FORM_URLENCODED), String.class ); assertThat(response).as("body should be with simple is OK statement").isEqualToIgnoringWhitespace("is OK"); } }``` What might be wrong in this example?

yousafn
2022-05-27 11:06
I would advise raising a new GitHub issue and linking to that one, it is difficult to track against closed issues. I assume based on this comment this original issue was resolved for the OP https://github.com/pact-foundation/pact-jvm/issues/768#issuecomment-603974680 and yours is only in the case of adding the additional `HttpRequest` param.

fragonib
2022-05-27 11:38
That?s it. I guess the issue it?s very close. So I created a new issue https://github.com/pact-foundation/pact-jvm/issues/1564

yousafn
2022-05-27 11:44
Fab thanks! With so many closed issues ranging back to 2013, they often won't get looked at so raising fresh issues is always advised. I might look at getting some kind of bot that can comment on closed issues that receive a reply, and guide the user to create a new issue or jump on slack. Would help us understand if there is possibly good or bad information in the issues that we need to surface or correct. Sorry I can't immediately help with your problem

wieslaw.bondyra
2022-05-27 11:54
Seems that adding _testImplementation_("org.json:json:20190722") in my project fixes issue. Why it is required? Should not it be in pact.consumer dependency?

aurelia.rochat
2022-05-27 12:10
Hey @yousafn, thanks for the answer.

rafaelcebulla
2022-05-27 15:20
has joined #pact-jvm

fragonib
2022-05-27 16:13
No problem. All the necessary context it?s on the conversation of the linked issue, I guess. So you already have all the info its needed. It?s only just an extra non-working particular case.

orbit.mjs
2022-05-27 17:45
has joined #pact-jvm

msparks
2022-05-27 19:56
has joined #pact-jvm

agarwal.akash333
2022-05-30 01:21
Hi. Is there a way to force a build failure when a pact verification while using a broker like http://pactflow.io fails? I?ve tried using the following on my test class but it doesn?t help: ```@PactBroker( enablePendingPacts = "false" )``` We?re using `"au.com.dius.pact.provider:junit5spring:4.2.4"`.

agarwal.akash333
2022-05-30 01:31
Also worth noting that the default seems to be false already for that property, and yet, if I understand the https://docs.pact.io/pact_broker/advanced_topics/pending_pacts correctly, the behaviour seems to be `true`.

shaun.mendham
2022-05-30 08:48
How does this work on the provider side, our scenario is such that we have multiple consumers asserting different interaction types against a single provider. e.g. we have: ? Provider with both REST endpoints and a Kafka producer. ? Consumer A which consumes the REST endpoints. ? Consumer B which consumes the Kafka messages. I?m struggling to find anything in the documentation as to how a Provider PACT test file or files should look for this case. I have created an demo project here: https://github.com/shaunmendham/pact-demo/tree/main Where when running the provider PACT tests, each test file satisfies one of the pacts but not the other. Is there a way to filter which pacts are applied to which test file based on interaction type? Or should this be handled in another way? Thanks in advance.

falvarez
2022-05-30 14:17
has joined #pact-jvm

shaun.mendham
2022-05-30 14:54
We have since experimented with a custom `InteractionFilter` to filter by interaction type. Still with one test file per interaction type, but filtering to only those supported by the test file. Does this sounds like a reasonable approach?

yousafn
2022-05-30 18:06
Hey man, thanks SO much for the example repo, that is absolutely invaluable. just tagging @uglyog , so when he has time he can cast his eyes over, as he is the man!

shaun.mendham
2022-05-30 22:03
Perfect, thank you. I?ve just added my implementation of the interaction filter to that project, see https://github.com/shaunmendham/pact-demo/pull/1 :slightly_smiling_face:

agarwal.akash333
2022-05-31 04:47
Any ideas on this?

matt.fellows
2022-05-31 05:21
I can?t say for sure, but have you tried updating to the latest version?

ruslan.ponomarev
2022-05-31 06:28
has joined #pact-jvm

rholshausen
2022-05-31 07:04
How are you running the verification test? Normally a test failure will result in a verification failure being published to Pactflow and then the build will fail.

alexander.maiburg
2022-05-31 07:31
has joined #pact-jvm

agarwal.akash333
2022-05-31 08:18
Thanks guys. And sorry, I missed the notifications for these earlier! The current version is simply ran by `./gradlew test`. I was running into a different error when trying to upgrade to `4.3.8`, but after resolving that?pacts aren?t PENDING by default and looks like everything is working as expected! :tada:

matt.fellows
2022-05-31 08:19
:raised_hands:

shivam.kumar
2022-05-31 10:41
Hey, We are trying to update the request uri path in our provider contract test using below snippet. But we are getting an `org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter` exception. Can someone please help us on fixing it? If there is recommendation to use another approach, Can you please share? ```@TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun pactVerificationTestTemplate(context: PactVerificationContext, requestBuilder: org.apache.hc.core5.http.HttpRequest) { var newUri = sanitiseUrl(requestBuilder.uri.toString()) requestBuilder.setUri(URI(newUri)) context.verifyInteraction() }``` Dependencies used: `http://au.com.dius.pact.consumer.junit5` , `'org.apache.httpcomponents.core5', name: 'httpcore5', version: '5.1.3'`

thomas.cederholm
2022-05-31 11:36
From what I know, the `@PactFilter` should sort this out..

thomas.cederholm
2022-05-31 11:37
I have a similar issue; my provider is deployed in two flavors; different APIs for each flavor. I need two consumers, one per API, but it should be doable with one provider. I have yet to make it work fully; the consumers can-i-deploy still seems to fail for me.

edouard.lopez
2022-05-31 14:28
@edouard.lopez has left the channel

aherbst
2022-05-31 17:31
has joined #pact-jvm

rholshausen
2022-05-31 23:17
What version of Pact-JVM are you using?

rholshausen
2022-06-01 00:40
I would create two different consumer names (and keep the same provider), one for each transport. Then you can have two different pact files to test the different interactions.

agarwal.akash333
2022-06-01 01:25
Hi. We have a micro-services architecture on one of our projects. We?re using the following packages in the same micro-service which is a client to another micro-service and a server for other clients: ```"au.com.dius.pact.provider:junit5spring:4.3.8" "au.com.dius.pact.consumer:junit5:4.3.8" // tried this with junit 4 as well.``` Because of this, running either tests now keep failing: ```... at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)``` We think it?s because of including those packages together, despite running different classes for 1) generating the consumer tests. 2) running provider verifications. Any ideas for if this is indeed supported?

rholshausen
2022-06-01 01:28
Can you provide the full stack trace, or at least the cause message?


agarwal.akash333
2022-06-01 01:34
Sorry, didn?t think that stacktrace would be helpful, since it?s all under a java thread, but I suppose it might be helpful for you :slightly_smiling_face:

rholshausen
2022-06-01 01:35
That looks like a Java compiler error, ```> Task :micro-service:compileJava compiler message file broken: key=compiler.misc.msg.bug arguments=11.0.2, {1}, {2}, {3}, {4}, {5}, {6}, {7} java.lang.NullPointerException at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitApply(Flow.java:1235)``` What version of Java are you using?

agarwal.akash333
2022-06-01 01:35
Java 11

rholshausen
2022-06-01 01:35
Which distribution?

agarwal.akash333
2022-06-01 01:36
```openjdk 11.0.2 2019-01-15 OpenJDK Runtime Environment 18.9 (build 11.0.2+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)```

rholshausen
2022-06-01 01:38
Maybe try upgrading your Java version, that error is not a Pact-JVM error

agarwal.akash333
2022-06-01 02:07
Ah bummer, thanks! That fixed it :slightly_smiling_face:

agarwal.akash333
2022-06-01 02:07
Weird that this happened however, since we use Java 11 everywhere! Even on our android consumer.

shaun.mendham
2022-06-01 07:51
@rholshausen, I?ve clarified something in the demo repo that may not initially have been clear. In our actual scenario the two consumers are from different projects and so would already have a different consumer name and generate an individual contract against the provider. Additionally I would hope to keep the same consumer name for multiple interaction types if this was the case to keep the dependencies between services clear, for example not having two nodes for a single service in the pact flow network graph.

rholshausen
2022-06-01 08:02
With V4 Pact files, you can have both a HTTP and message queue interaction in the same file.

vipul.pachauri
2022-06-01 08:02
has joined #pact-jvm

komal.sharma1
2022-06-01 08:02
has joined #pact-jvm

rholshausen
2022-06-01 08:04
But you have different consumers. I think adding the `@Consumer` annotation to each provider test and it will only run the verification for that consumer

shaun.mendham
2022-06-01 08:08
Our issue is on the provider side where if a single or multiple consumers have different interaction types across the contracts (within a single or across multiple). We needed a way to specify which contracts should be verified against which test file Message or rest? I?ve just tried adding `@Consumer` Which looks like it?s working :thumbsup: I guess this issue would come back if we ever had a single consumer asserting multiple interaction types against the same provider. Where we would then need something like the filter. Or alternatively multiple provider names.

shaun.mendham
2022-06-01 08:13
In this more general case, is the above interaction filter a reasonable solution?

shaun.mendham
2022-06-01 08:13
Thank you for your time looking at this one :slightly_smiling_face:

thomas.cederholm
2022-06-01 08:32
Do I need to construct a pact (v4) using builders..? I got my expected body (json) as a string.

shaun.mendham
2022-06-01 08:58
`@Consumer` works for the demo use case, however with the annotation only accepting a single consumer name. This would mean needing to duplicate the provider test files, or add additional boilerplate per consumer, rather than adding a new consumer string which might have been an acceptable overhead :thinking_face: Our real scenario is something like: ? Provider A (Kafka and REST) ? Consumer B consumes Kafka of Provider A ? Consumer C consumes REST of Provider A ? Consumer D consumes REST of Provider A ? Consumer E consumes REST of Provider A ? ?

matt.fellows
2022-06-01 10:37
It doesn?t appear that you can inject those properties there. Can you not use the standard approach here: https://docs.pact.io/implementation_guides/jvm/consumer/junit5#injecting-the-mock-server-into-the-test

kannan.jai
2022-06-01 10:38
Thanks, unfortunately this won't work for as we load the properties file well before this where we use the pact mock server URL too.

matt.fellows
2022-06-01 10:39
can you override the API client URL at runtime?

kannan.jai
2022-06-01 10:41
Good question, need to check this.

matt.fellows
2022-06-01 10:45
That?s how most people do it. This allows you to run multiple consumer tests in parallel. If you share the same point, you have to run them in serial

matt.fellows
2022-06-01 10:45
It also is configless then

chris169
2022-06-01 11:53
has joined #pact-jvm

shivam.kumar
2022-06-01 14:26
I was able to resolve the issue by using `org.apache.http.HttpRequest` library, but there is no option to update the api path with this class. Do we have any suggestions or is it even possible to update the api path in provider contract verification step?

m.shi
2022-06-01 19:07
has joined #pact-jvm

rholshausen
2022-06-01 21:54
Why do you want to change the path?

asa.anudeep4
2022-06-02 04:33
has joined #pact-jvm

qingyuliu
2022-06-02 06:21
Hi team, is there anyway to directly convert a Java object to PactDslJsonBody?

diede
2022-06-02 10:01
has joined #pact-jvm

mateusz.zaborowski
2022-06-02 17:54
has joined #pact-jvm

rchord23
2022-06-05 19:30
has joined #pact-jvm

divya.parameswaran
2022-06-05 20:16
has joined #pact-jvm

qingyuliu
2022-06-06 04:52
Hi team, could anyone give some clue why this exception "Failed to invoke provider method 'creatPact' (java.lang.RuntimeException)" happened? Thanks!

rholshausen
2022-06-06 05:02
The `creatPact` method was called, but it threw an exception. You need to look at the exception thrown, and at the `creatPact` method (this won't be a Pact method)

qingyuliu
2022-06-06 05:05
The test passed but there is a pending failure: Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true'). I tested it locally, but I didn't see any exception thrown during the runtime, how could I get the detail about the error?

rholshausen
2022-06-06 05:54
The easiest way would be to add a try/catch to the `creatPact` method and print out the exception stack trace.

rholshausen
2022-06-06 05:55
You can also try setting the `pact.showStacktrace` JVM system property to `true`

ben.pilgrim
2022-06-06 08:36
Good catch. My bad.

alexey.shchukin
2022-06-06 11:46
has joined #pact-jvm

afang
2022-06-06 22:17
has joined #pact-jvm

pratish.mp
2022-06-07 00:58
has joined #pact-jvm

ruben.perezg
2022-06-07 14:21
Hi :slightly_smiling_face: I'm trying to use `consumerVersionSelectors` from the `PactBroker` annotation on my provider application, and I have a doubt. Looking into the https://github.com/pact-foundation/pact-jvm/blob/ac6a0eae0b18183f6f453eafddb89b90741ace42/provider/src/main/java/au/com/dius/pact/provider/junitsupport/loader/VersionSelector.java#L19, it only allows you to select tags, not branches or environments. I think what I would need is to get the latest from the main branch (`master`) and the latest from production. My question is, even if I'm using `branches` and `environments`, should I also add tags from my consumer for both branches and environments?

ben.pilgrim
2022-06-07 16:05
You can use branches with the `pactbroker.consumerversionselectors.rawjson` system property, but not the annotation

ben.pilgrim
2022-06-07 16:05
eg: ```<pactbroker.consumerversionselectors.rawjson>[{ "mainBranch": true },{ "deployedOrReleased": true }]</pactbroker.consumerversionselectors.rawjson>```

dasarih
2022-06-08 00:20
has joined #pact-jvm

benjamhawk
2022-06-08 02:37
has joined #pact-jvm

ruben.perezg
2022-06-08 06:37
Thank you Ben :slightly_smiling_face: After reading your message, I found this issue explaining the workaround you proposed: https://github.com/pact-foundation/pact-jvm/pull/1471

ruben.perezg
2022-06-08 06:41
I will try it :slightly_smiling_face:

sclaros
2022-06-08 13:07
has joined #pact-jvm

daniel.tjondro
2022-06-08 15:25
has joined #pact-jvm

slacksync
2022-06-08 17:21
has joined #pact-jvm

sandro
2022-06-08 18:26
has joined #pact-jvm

hazem
2022-06-08 23:14
has joined #pact-jvm

edouard.lopez
2022-06-09 13:27
has joined #pact-jvm

leonardo.lanni
2022-06-09 14:51
has joined #pact-jvm

jcamilovasquezm
2022-06-10 02:47
has joined #pact-jvm

markrkell
2022-06-10 08:13
has joined #pact-jvm

eva-maria.schaller
2022-06-10 08:24
has joined #pact-jvm

michel.kaporin
2022-06-10 14:43
has joined #pact-jvm

pooja.sharma4099
2022-06-11 08:39
has joined #pact-jvm

srinivas.vaddi
2022-06-11 16:31
has joined #pact-jvm

igor.sharfman
2022-06-12 11:25
has joined #pact-jvm

rejeesh.g
2022-06-13 08:03
What is Pact Publish mvn command for Maven Pact library 4.1.33/4.2.19/4.3.4? Looks like it needs this https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/doc/views/index/publish-contracts.markdown. Pact Maven Plugin configuration is <plugin> <groupId>http://au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.2.19</version> <configuration> <pactBrokerUrl>${pact.broker.url}</pactBrokerUrl> <pactBrokerToken>${pact.pactbroker.token}</pactBrokerToken> <latest>true</latest> <projectVersion>${pact.consumer.version}</projectVersion> <tags>${pact.tag}</tags> </configuration> </plugin> Currently mvn command I am using is "mvn pact:publish -Dpact.consumer.version=<Git Commit> -Dpact.tags=feature-XXX _Dpact.broker.url=<http://pactbrokerurl:1234> -Dpact.broker.token=${token}. But i am getting error such as [Error] Response from Pact Broker was not in JSON format: http://au.com.dius.pact.core.json.JsonException: Invalid JSON (1:2), found unexpected character 'U' Failed - Request to path 'https://pactbrokerurl/contracts/publish' failed with response 'HTTP/1.1 401 Unauthorized' But the same mvn command works fine with plugin version au.com.dius.pact.provider:maven:4.2.9. Currently I am not enabling branches. *Could you please share what is the mvn command for publish pacts when using version au.com.dius.pact.provider:maven:4.2.19 ?*

chituru.chinwah
2022-06-13 08:48
has joined #pact-jvm

cchinwah1
2022-06-13 09:45
has joined #pact-jvm

matt.fellows
2022-06-13 10:32
Hi Rajeesh, a 401 indicates the authentication was incorrect. Are you should you have the correct details?

rejeesh.g
2022-06-13 10:48
The same mvn command is working fine for plugin version au.com.dius.pact.provider:maven:4.2.9 but we are getting error for *au.com.dius.pact.provider:maven:4.2.19.* We are using Pactflow version 1.17.2. Do we need to enable any environment variables setup for "all-in-one" pact publish endpoint?

julian.alvarezv
2022-06-13 17:10
has joined #pact-jvm

julian.alvarezv
2022-06-13 17:15
Hi all, thanks in advance for the help! I am trying to debug a test that is failing and don't manage to print the request that the mock is receiving, I really feel like the issue is related to this. What I have tried is to set this property to true but no suceed: pact.showFullDiff .. any ideas? Thanks!

uglyog
2022-06-14 07:16
If you have DEBUG level logging enabled, you will see all the requests the mock server receives

malukenho.dev
2022-06-14 14:33
has joined #pact-jvm

vikki.read
2022-06-14 18:58
has joined #pact-jvm

omer.khalil
2022-06-14 19:33
has joined #pact-jvm

rxiao
2022-06-15 04:29
has joined #pact-jvm

james.demaine373
2022-06-15 10:22
has joined #pact-jvm

dmoll
2022-06-15 21:10
has joined #pact-jvm

kurt3402
2022-06-16 04:29
has joined #pact-jvm

kyo.tang
2022-06-16 06:03
has joined #pact-jvm

prasadsolanki
2022-06-16 10:58
has joined #pact-jvm

mairtin.conneely
2022-06-16 12:02
has joined #pact-jvm

laura.kennedy
2022-06-16 14:32
has joined #pact-jvm

qingyuliu
2022-06-16 17:09
Hi team, after adding a test configuration, I got the error msg: *The following methods annotated with @Pact were not executed during the test:xxxx* Any idea how to solve this problem? Thanks!

rholshausen
2022-06-16 23:21
Your tests are mis-configured. There is a Pact setup method that was never called. If it was intentional, just comment out the `@Pact` annotation on that method, otherwise you need to work out why it was not called.

gaurav.bajpai
2022-06-17 03:41
has joined #pact-jvm

salmanjamali
2022-06-17 06:49
has joined #pact-jvm

alansimonalie
2022-06-17 12:57
has joined #pact-jvm

ben.a.hubbard
2022-06-17 13:47
has joined #pact-jvm

lafriakh.rachid
2022-06-18 14:24
has joined #pact-jvm

courtney.lum
2022-06-20 04:02
has joined #pact-jvm

woojos
2022-06-20 09:58
has joined #pact-jvm

abdou.ahzab
2022-06-20 10:08
has joined #pact-jvm

paul.simms
2022-06-20 14:08
Hi all, I have a couple of questions regarding the verification stage using Java and JUnit5. 1. I am having trouble with setting @IgnoreNoPactsToVerify in the test file (or -DfailIfNoPactsFound=false in the mvn command). With no consumer the test is still failing (context is being set to null). 2. I want to run the verify step against a given environment using the specified 'tag' (we still haven't moved across to environments / deployments). This tag though depends on which CI job is running (ie which environment is being deployed to). Thus I want to pass in the consumer version at run time - and cannot thus set it up in the PACTBroker consumerVersionSelectors annotation. Is there a way this can be passed in maven similar to setting -Dpact.verifier.publishResults=true ? So I can run as part of the mvn command from gitlab CI? Thanks

dstekanov.tech
2022-06-20 15:28
has joined #pact-jvm

francislainy.campos
2022-06-20 20:51
Hi, do we have any samples for java contracts using graphql apis? The samples I?ve found so far are all Javascript.

rholshausen
2022-06-21 03:11
You can use `pactbroker.consumerversionselectors.rawjson`

rholshausen
2022-06-21 03:12
Just beware that you need to set it in your test JVM, passing it on the command line won't work

rohit.thadhani
2022-06-21 04:39
has joined #pact-jvm

francislainy.campos
2022-06-21 11:56
I think it?s simpler than I thought and it works by just treating the query as a simple string and anything else as their respective objects.

gaurav.bajpai
2022-06-21 19:26
Hi Guys, I am trying to do a POC, writing pact test for services consuming and publishing AVRO messages to kafka, I have searched similar discussion that have already happened on this channel, I found this https://docs.pact.io/recipes/kafka#magic-bytes created for json/json schema registry messages, does pact support AVRO or its still a work in process at this point? cc @matt.fellows @yousafn @muirandy

gaurav.bajpai
2022-06-21 19:38
@samikshaphulzele were you able to create pact for AVRO consumers and publishers, the link above clearly state below in Gotchas cc @yousafn @rholshausen @muirandy

jvieira
2022-06-21 22:28
has joined #pact-jvm

matt.fellows
2022-06-22 00:40
Avro not supported at this stage

matt.fellows
2022-06-22 00:43
It could be supported (in Java) via created an Avro plugin, I believe

matt.fellows
2022-06-22 00:43
@uglyog might have some suggestions on authoring a plugin if you are so inclined


qingyuliu
2022-06-22 10:29
Hi team, is there any document which introduces how message level contract work in pact? For example, I saw a blog mentioned that "Pact will *pretend* to be a message queue and get the message provider to send it a message." How does pact pretend to be a message queue?

matt.fellows
2022-06-22 13:02
This video maybe: https://youtu.be/IetyhDr48RI?t=485 Also the how it works section of http://docs.pact.io

qingyuliu
2022-06-22 13:23
Hi Matt, could you provide some doc about Pact message level contract? Like what message broker you're using.

marcus.james
2022-06-22 15:28
has joined #pact-jvm

jonas.pena
2022-06-22 15:50
has joined #pact-jvm

abudi.hijazi.01
2022-06-22 16:44
has joined #pact-jvm

vaddisrinivas170497
2022-06-22 18:57
has joined #pact-jvm

jvieira
2022-06-22 19:35
Hello, I hope this message finds you well. I observing a weird behaviour and I am not sure what I doing wrong. I am using ```testImplementation('au.com.dius.pact:consumer:4.3.9') testImplementation('au.com.dius.pact.consumer:junit:4.3.9'``` And creating two interactions for the same consumer and provider (one POST and other PUT). I am setting the same response header for both of the interactions but the second interaction, the `response.headers` are being generated different from what I am setting it. I am setting `responseHeaders.put("Content-Type", "application/json; charset=utf-8");` . The first interaction, the header is `"Content-Type": "application/json; charset=utf-8",` but in the second it is `"Content-Type": "application/json;charset=utf-8"` the difference being that the second there is no space after the `;` . I added another header just for testing and in the second interaction it added an `=` at the end. Basically, I want that the space in `"application/json; charset=utf-8"` is not removed in second interaction. Do you what can I do to achieve this? I am not sure if I am doing something wrong or is some kind of bug. (code and image in the thread)

jvieira
2022-06-22 19:35
This is the code that generates the contract file ```@Pact(consumer = "config-api", provider = "file-service") public RequestResponsePact createFileFragment(PactDslWithProvider builder) { Map<String, String> requestHeaders = createRequestHeaders(); Map<String, String> responseHeaders = createResponseHeaders(); PactDslJsonBody requestBody = new PactDslJsonBody() .uuid("clientId", "2454ad95-0352-4494-9a40-6afb333959e4"); PactDslJsonBody responseBody = new PactDslJsonBody() .uuid("clientId", "2454ad95-0352-4494-9a40-6afb333959e4"); return builder .given("a file does not exists") .uponReceiving("create file") .method("POST").headers(requestHeaders).body(requestBody) .matchPath("/files") .willRespondWith() .status(201).headers(responseHeaders).body(responseBody) .toPact(); } @Pact(consumer = "config-api", provider = "file-service") public RequestResponsePact updateFileFragment(PactDslWithProvider builder) { Map<String, String> requestHeaders = createRequestHeaders(); Map<String, String> responseHeaders = createResponseHeaders(); PactDslJsonBody requestBody = new PactDslJsonBody() .uuid("clientId", "2454ad95-0352-4494-9a40-6afb333959e4"); PactDslJsonBody responseBody = new PactDslJsonBody() .uuid("clientId", "2454ad95-0352-4494-9a40-6afb333959e4"); String uuidRegex = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"; return builder.given("a file exists"). uponReceiving("update the file") .method("PUT").headers(requestHeaders).body(requestBody) .matchPath("/files/" + uuidRegex) .willRespondWith() .status(200).headers(responseHeaders).body(responseBody) .toPact(); } private Map<String, String> createResponseHeaders() { Map<String, String> responseHeaders = new HashMap<>(); responseHeaders.put("Content-Type", "application/json; charset=utf-8"); responseHeaders.put("X-Type", "test1; test2"); return responseHeaders; } private Map<String, String> createRequestHeaders() { Map<String, String> requestHeaders = new HashMap<>(); requestHeaders.put("Content-Type", "application/json"); return requestHeaders; }```

jvieira
2022-06-22 19:36
and this is the contract file

jvieira
2022-06-22 19:36
notice the `response.headers` difference in the second interaction (removes the spaces, and added an `=`)

jvieira
2022-06-22 19:37
I removed POST from the test and left only the PUT and then it generates it correctly. It seems to happen in the second interaction (have not tried with more than 2)

matt.fellows
2022-06-22 21:38
The document above explains this. We don't actually use any message broker in the test, we only deal with the messages that pass between systems. This requires you to abstract your code on both sides to separate the protocol handling bit from the message generating/handling bita

matt.fellows
2022-06-22 21:39
This way we can work with any message broker (and other useful scenarios) without having to support every one explicitly

tjones
2022-06-23 00:57
I can't help with your question, but I can tell you that both those headers should be treated the same - see https://httpwg.org/specs/rfc7231.html#media.type

jvieira
2022-06-23 01:54
Interesting @tjones. I thought about that, but was not sure. My question is because I am getting this error on the provider verification `Expected header "Content-Type" to equal "application/json;charset=utf-8", but was "application/json; charset=utf-8"` . My provider is running on node with the `"@pact-foundation/pact": "^9.17.3"` . I thought the problem was in the consumer, but seems to be in the provider as it should(?) consider both values the same.

matt.fellows
2022-06-23 02:34
My guess is that you are generating a pact file with version `3` as the specification, but Pact JS core (the version you linked) only supports 2. I?m not sure if you downcast the consumer test to explicitly produce a v2 pact if that will fix it

matt.fellows
2022-06-23 02:34
I believe in V3, the way headers are managed differs slightly, so this could be the cause

matt.fellows
2022-06-23 02:35
If that doesn?t solve it, I?d add a regex matcher for the header. This way, the space can be made to be irrelevant

tjones
2022-06-23 02:38
If that error is coming from pact, it is definitely a bug.

tjones
2022-06-23 02:38
The http headers are well defined, and those two examples are defined to be equivalent

tjones
2022-06-23 02:39
Matt's suggestion of the regex matcher would be a good workaround in the meantime

jvieira
2022-06-23 02:50
@matt.fellows, it was `V3` but changed the consumer generation to `V2` and it generated the same thing as before, where the second interaction had a different header value without the space .

jvieira
2022-06-23 02:52
I will try the regex matcher. Thank you very much for the help and the suggestion :fistbump:

jvieira
2022-06-23 02:52
Where should I open an issue? in https://github.com/pact-foundation/pact-js repo?

tjones
2022-06-23 03:02
Whichever pact framework is throwing the error

tjones
2022-06-23 03:03
Pact js will just believe what you tell it about the header - I would guess that both your test and your client code are actually generating those two headers

matt.fellows
2022-06-23 03:09
So for clarity, the pact file looks to have the correct assertions in it now (one with and another without the additional space)

matt.fellows
2022-06-23 03:10
The ruby verifier I think will check those values verbatim (i.e. it will look at the space or lack thereof and check). So your provider should align with this if you want it to exact match

matt.fellows
2022-06-23 03:10
what behaviour are you now seeing with the new pact file?

jvieira
2022-06-23 03:11
It should have the two with spaces, as it is being set the same way. The same function sets the headers for the two interactions, but when it generates the contract file, one has no spaces

matt.fellows
2022-06-23 03:12
ah, I see

matt.fellows
2022-06-23 03:12
that is not a bug in Pact JS then. That sounds like a bug in Pact JVM

matt.fellows
2022-06-23 03:12
or a feature, as Tim suggested, it might be looking at what your client actually sends

tjones
2022-06-23 03:13
Is the client actually sending different things?

matt.fellows
2022-06-23 03:13
that would be good to know

tjones
2022-06-23 03:13
I think the client must be sending a different thing

matt.fellows
2022-06-23 03:13
@uglyog any ideas as to how that could be? Do the headers that were in the test get updated with what the client actually sends?

jvieira
2022-06-23 03:14
just to clarify @tjones, when you say client, you say the provider method being tested?

jvieira
2022-06-23 03:16
The thing is related to having two interactions. If I leave only the PUT (that has no space now) it generates the contract the way it was suppose to (with the space)

jvieira
2022-06-23 03:17
But If I leave the two, the second interaction always generates without the space, even having the same method on the definition.

uglyog
2022-06-23 03:17
Pact-JVM and Pact-Rust will parse those headers as per the RFC and compare the various parts. Spaces will be ignored unless they are in places that are important.

uglyog
2022-06-23 03:19
As to why it is occurring, that will need to be investigated, but it is a deficiency in the Ruby engine to compare them as strings. I agree it is not worth the effort and a regex can solve it

tjones
2022-06-23 03:24
No, I mean the consumer method being tested. The pact file is only written if the test passes and the consumer sends what you set up in the expectation. I'm guessing, but maybe the consumer is sending one without space and one with and maybe that's what is written in the pact. But I have no idea

tjones
2022-06-23 03:24
I think Ron?s point is solid- just put in a regex and forget (although it would be good to track the bug regardless)

jvieira
2022-06-23 03:32
I don?t think that the method is one without space and other with, as if leave only the method that has no space (and comment out the other) it generates as expected (with spaces). I will use your regex matcher recommendation and will create the issues in the respective projects. Thank you so much for the help and for maintaining this amazing framework :heart:. I am a pact advocate at the company that I work for

adam.anderson
2022-06-23 03:46
has joined #pact-jvm

yegorisa
2022-06-23 03:47
has joined #pact-jvm

tjones
2022-06-23 04:21
You're welcome! I'm no longer a maintainer, just here to help (the others totally are still maintainers, though)

swapnil.jagdale
2022-06-23 05:19
has joined #pact-jvm

mark.mcmurray
2022-06-23 08:33
has joined #pact-jvm

jacek.maciag
2022-06-23 09:15
has joined #pact-jvm

robert.strehli
2022-06-23 10:15
Hey, I hope I didn't over read it somewhere, but is there a possibility to annotate one provider test with 2 or multiple consumers? The use case is I have a provider with several consumers, two of them have the exactly same contract, because they are using the endpoints in the exact same way. Currently I have to create 2 identically provider tests classes with the only difference that in one class I have `@Conumser("consumer1")`` and in the other `@Consumer("consumer2")` . Is there another way?

vaddisrinivas170497
2022-06-23 16:07
hi lil new here, I have created a pact using the junit5 library. How can I publish it to local pact broker? is there a way to do that without using the cli?


b.1.alpha
2022-06-23 23:17
Hi I am working with a java service team, that wants to know if they can run the verify step with mvn test, instead of bringing up the entire service in localhost

b.1.alpha
2022-06-23 23:18
is it mandatory to bring up the real service localhost for the provider verify step

b.1.alpha
2022-06-23 23:20
`mvn clean test -PproducerContractTestWithBroker -Dusername=$username -Dpassword=$password -DapiKey=$key -Dpact.broker.url="https://test.pactflow.io/" -Dpact.broker.token=$token -Dci.props.git.hash.short="0" -Dci.props.git.branch.name=$branchname -Dpact.verifier.publishResults=true`

b.1.alpha
2022-06-23 23:25
that is the reason they wanted to use the pact maven plugin instead of the CLI

b.1.alpha
2022-06-23 23:25
Can you help straighten us around? Thanks in advance!

uglyog
2022-06-23 23:29
If you are using unit tests, you don't need to start the app, you can just test the things you need to in the unit test


b.1.alpha
2022-06-23 23:57
ahh okay great information thank you @uglyog In this case, can we still use the cli?s pact-provider-verifier? Is seems like in that case we should use `mvn clean test -options` as below right?

b.1.alpha
2022-06-23 23:58
I didnt see any examples of this in the docs, just that we need to start a localhost

uglyog
2022-06-24 00:06
You need to use one of the other. If you use the cli verifier, you need to have your app running. If you use unit tests, the tests will run the verification.

qingyuliu
2022-06-24 03:16
Hi team, how to perform an exact match for message pact, like: now it seems like pact will only verify the type of the field rather than the exact value. ```PactDslJsonBody body = new PactDslJsonBody(); body.stringType("name", "almost-anything");```

uglyog
2022-06-24 03:19
Use `stringValue`

qingyuliu
2022-06-24 03:19
Thanks!

sandor.arpa
2022-06-24 09:30
has joined #pact-jvm

sandor.arpa
2022-06-24 10:06
Good morning (evening, afternoon) :wave: We're on pact v3. I've got an issue with NumberTypeMatcher where the matcher does not recognise a negative number as Integer. The part of generated contract file (from MessageBuilder) that fails: ```$.event_details.net_amount=MatchingRuleGroup(rules=[NumberTypeMatcher(numberType=INTEGER)]``` The error I get: `BodyMismatch(expected=-8000, actual=-8000, mismatch=Expected -8000 (JsonPrimitive) to be an integer`

sandor.arpa
2022-06-24 10:06
(Yes, tried to search the documentation first)

matt.fellows
2022-06-24 10:12
As discussed in the other channel, could you please provide the additional details requested?

sandor.arpa
2022-06-24 10:14
I just need to format the files. Won't be a sec

sandor.arpa
2022-06-24 10:20
the generated contract file: ```au.com.dius.pact.model.v3.messaging.MessagePact([ au.com.dius.pact.model.v3.messaging.Message(a dispute lost event, [], PRESENT( { "event_type": "DISPUTE_LOST", "service_id": "service-id", "resource_type": "dispute", "event_details": { "gateway_account_id": "a-gateway-account-id", "amount": 6500, "fee": 1500, "net_amount": -8000 }, "live": true, "timestamp": "2022-01-19T07:59:20.000000Z", "resource_external_id": "payment-external-id", "parent_resource_external_id": "external-id" } ), MatchingRules(rules= { body=Category(name=body, matchingRules= { $.event_type=MatchingRuleGroup(rules= [ au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363 ], ruleLogic=AND), $.timestamp=MatchingRuleGroup(rules= [ au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363 ], ruleLogic=AND), $.resource_external_id=MatchingRuleGroup(rules= [ au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363 ], ruleLogic=AND), $.live=MatchingRuleGroup(rules= [ au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363, au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363 ], ruleLogic=AND), $.resource_type=MatchingRuleGroup(rules= [ au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363 ], ruleLogic=AND), $.parent_resource_external_id=MatchingRuleGroup(rules= [ au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363 ], ruleLogic=AND), $.service_id=MatchingRuleGroup(rules= [ au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363 ], ruleLogic=AND), $.event_details.gateway_account_id=MatchingRuleGroup(rules= [ au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363 ], ruleLogic=AND), $.event_details.amount=MatchingRuleGroup(rules= [ NumberTypeMatcher(numberType=INTEGER) ], ruleLogic=AND), $.event_details.net_amount=MatchingRuleGroup(rules= [ NumberTypeMatcher(numberType=INTEGER) ], ruleLogic=AND), $.event_details.fee=MatchingRuleGroup(rules= [ NumberTypeMatcher(numberType=INTEGER) ], ruleLogic=AND) } ) } ), Generators(categories={}), [ contentType : application/json ], null, application/json, null, application/json) ], Consumer(name=ledger), Provider(name=connector), [pactSpecification:[version: 3.0.0], pact-jvm:[version: 3.6.15]], null, [ au.com.dius.pact.model.v3.messaging.Message(a dispute lost event, [], PRESENT({"event_type": "DISPUTE_LOST", "service_id": "service-id", "resource_type": "dispute", "event_details": {"gateway_account_id":"a-gateway-account-id", "amount": 6500, "fee": 1500, "net_amount": -8000}, "live": true, "timestamp": "2022-01-19T07:59:20.000000Z", "resource_external_id": "payment-external-id", "parent_resource_external_id": "external-id"}), MatchingRules(rules={body=Category(name=body, matchingRules={$.event_type=MatchingRuleGroup(rules=[au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363], ruleLogic=AND), $.timestamp=MatchingRuleGroup(rules=[au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363], ruleLogic=AND), $.resource_external_id=MatchingRuleGroup(rules=[au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363], ruleLogic=AND), $.live=MatchingRuleGroup(rules=[au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363, au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363], ruleLogic=AND), $.resource_type=MatchingRuleGroup(rules=[au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363], ruleLogic=AND), $.parent_resource_external_id=MatchingRuleGroup(rules=[au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363], ruleLogic=AND), $.service_id=MatchingRuleGroup(rules=[au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363], ruleLogic=AND), $.event_details.gateway_account_id=MatchingRuleGroup(rules=[au.com.dius.pact.model.matchingrules.TypeMatcher@3c3e363], ruleLogic=AND), $.event_details.amount=MatchingRuleGroup(rules=[NumberTypeMatcher(numberType=INTEGER)], ruleLogic=AND), $.event_details.net_amount=MatchingRuleGroup(rules=[NumberTypeMatcher(numberType=INTEGER)], ruleLogic=AND), $.event_details.fee=MatchingRuleGroup(rules=[NumberTypeMatcher(numberType=INTEGER)], ruleLogic=AND)})}), Generators(categories={}), [contentType: application/json], null, application/json, null, application/json) ])``` (So sorry, I tried my best to format the one line)

sandor.arpa
2022-06-24 10:22
And this is the response: ```BodyComparisonResult(mismatches={$.event_details.net_amount=[BodyMismatch(expected=-8000, actual=-8000, mismatch=Expected -8000 (JsonPrimitive) to be an integer, path=$.event_details.net_amount, diff=null)]}, diff=[{, - "event_type": "DISPUTE_LOST",, - "service_id": "service-id",, - "resource_type": "dispute",, + "resource_external_id": "resource-external-id",, "event_details": {, - "amount": 6500,, "gateway_account_id": "a-gateway-account-id",, - "fee": 1500,, - "net_amount": -8000, + "net_amount": -8000,, + "amount": 6500,, + "fee": 1500, },, - "live": true,, "timestamp": "2022-01-19T07:59:20.000000Z",, - "resource_external_id": "payment-external-id",, - "parent_resource_external_id": "external-id", + "parent_resource_external_id": "external-id",, + "service_id": "service-id",, + "live": true,, + "resource_type": "dispute",, + "event_type": "DISPUTE_LOST", }])```

sandor.arpa
2022-06-24 10:24
the variable in question is `net_amount`

matt.fellows
2022-06-24 10:25
Right, I need the actual Pact file sorry (i.e. the json file), not the Java model of it.

matt.fellows
2022-06-24 10:25
Also, i?d like to see the actual JSON response from your provider, not the interpretation of it in the log file

matt.fellows
2022-06-24 10:26
I think if you set DEBUG logging, you?ll get a raw dump of it in the terminal output

matt.fellows
2022-06-24 10:26
(I ask because this helps rule in/out certain classes of bugs in the Java code. If the input and output is correct, we can assume it?s probably a bug in Pact JVM)

sandor.arpa
2022-06-24 10:28
We don't have a pact file as per se. It's generated in realtime


matt.fellows
2022-06-24 10:29
what do you mean, sorry? How is the provider verifying it? This is a mode I?m not aware of :thinking_face:

matt.fellows
2022-06-24 10:30
That file should produce a JSON contract though right?

matt.fellows
2022-06-24 10:31
and you publish that to the broker?

sandor.arpa
2022-06-24 10:38
``` { "consumer": { "name": "ledger" }, "provider": { "name": "connector" }, "messages": [ { "_id": "c3d524ebb49c46e1e8b100a94d9c880b6a0cc43b", "description": "a dispute lost event", "metaData": { "contentType": "application/json" }, "contents": { "event_type": "DISPUTE_LOST", "service_id": "service-id", "resource_type": "dispute", "event_details": { "amount": 6500, "gateway_account_id": "a-gateway-account-id", "fee": 1500, "net_amount": -8000 }, "live": true, "timestamp": "2022-01-19T07:59:20.000000Z", "resource_external_id": "payment-external-id", "parent_resource_external_id": "external-id" }, "matchingRules": { "body": { "$.event_type": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.timestamp": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.resource_external_id": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.live": { "matchers": [ { "match": "type" }, { "match": "type" } ], "combine": "AND" }, "$.resource_type": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.parent_resource_external_id": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.service_id": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.event_details.net_amount": { "matchers": [ { "match": "integer" } ], "combine": "AND" }, "$.event_details.amount": { "matchers": [ { "match": "integer" } ], "combine": "AND" }, "$.event_details.gateway_account_id": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.event_details.fee": { "matchers": [ { "match": "integer" } ], "combine": "AND" } } } } ], "metadata": { "pactSpecification": { "version": "3.0.0" }, "pact-jvm": { "version": "3.6.15" } }```

sandor.arpa
2022-06-24 10:38
I think this is the one you meant?

sandor.arpa
2022-06-24 11:03
provider response: ```{ "resource_external_id": "resource-external-id", "event_details": { "gateway_account_id": "a-gateway-account-id", "net_amount": -8000, "amount": 6500, "fee": 1500 }, "timestamp": "2022-01-19T07:59:20.000000Z", "parent_resource_external_id": "external-id", "service_id": "service-id", "live": true, "resource_type": "dispute", "event_type": "DISPUTE_LOST" }```

mwilso29
2022-06-24 11:19
has joined #pact-jvm

sandor.arpa
2022-06-24 11:33
One more thing to add, when running in IDE against a local pact file: ? without `matchingRules` - it passes ? with `matchingRules` but `net_amount` type set to `number` - it passes ? with `matchingRules` and `net_amount` type is `integer` - fails

sandor.arpa
2022-06-24 11:39
(Running from PactFolder on provider)

sandor.arpa
2022-06-24 11:42
Using PactVerifyProvider, not State

matt.fellows
2022-06-24 12:02
interesting.

matt.fellows
2022-06-24 12:02
it sounds like it?s a bug


matt.fellows
2022-06-24 12:10
I wonder if a DEBUG level log of the above might yield a useful hint


tjones
2022-06-24 12:38
I don't know the jvm testing ecosystem, but can you just put all your tests in one class that two annotated classes inherit from?

renaud.meurisse
2022-06-24 12:47
has joined #pact-jvm

sandor.arpa
2022-06-24 13:25
The stacktrace that is provided: ```at au.com.dius.pact.provider.junit.target.BaseTarget.getAssertionError(BaseTarget.kt:73) at au.com.dius.pact.provider.junit.target.AmqpTarget.testInteraction(AmqpTarget.kt:50) at au.com.dius.pact.provider.junit.InteractionRunner$interactionBlock$statement$1.evaluate(InteractionRunner.kt:204) at au.com.dius.pact.provider.junit.InteractionRunner.run(InteractionRunner.kt:145) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:147) at au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:52)```

uglyog
2022-06-24 23:11
Please raise an issue, this is a defect

rk8085858
2022-06-26 08:12
has joined #pact-jvm

sandor.arpa
2022-06-27 08:12
How do I do that?

alex.savage
2022-06-27 08:26
has joined #pact-jvm

simon.selvadurai
2022-06-27 08:28
has joined #pact-jvm

robert.strehli
2022-06-27 08:52
Good idea. I'll try that out thanks


sandor.arpa
2022-06-27 09:43
Thank you!

yasir.khan
2022-06-27 11:21
has joined #pact-jvm

willem.basson
2022-06-27 11:25
has joined #pact-jvm

edward.francis
2022-06-27 11:32
has joined #pact-jvm

laura.cabantous
2022-06-27 11:35
has joined #pact-jvm

ruslan.charuh
2022-06-27 12:18
has joined #pact-jvm

pramod-arjun.bhalerao
2022-06-27 12:54
has joined #pact-jvm

muirandy
2022-06-27 13:53
Hi all. I missed this thread!! We implemented only for Json Schema as that was what we needed. We didn't have scope to do more.

gaurav.bajpai
2022-06-27 13:54
is there a plan to implement AVRO in near future?

samikshaphulzele
2022-06-27 14:00
Pact doesn't support avro @gaurav.bajpai, not sure the next release would support AVRO. Can anyone from community comment here

ssomepalli
2022-06-27 14:30
has joined #pact-jvm


yousafn
2022-06-27 15:06
I can see you have Samiksha as you commented on the video. I haven't used Avro, and giving this video a watch now. I haven't seen any community examples yet

yousafn
2022-06-27 15:07
I believe pact-plugins will be the way forward here https://github.com/pact-foundation/pact-plugins

owen.oclee.old
2022-06-27 16:13
has joined #pact-jvm

oherescu
2022-06-27 19:21
has joined #pact-jvm

nathan.tejuco
2022-06-28 03:50
has joined #pact-jvm

tjones
2022-06-28 04:41
This is great, thanks @uglyog!

uglyog
2022-06-28 04:46
JUnit and Maven support coming next

jun.ito
2022-06-28 07:47
has joined #pact-jvm

daniel.shamaeli
2022-06-28 09:01
has joined #pact-jvm

michael.oloyede
2022-06-28 09:55
has joined #pact-jvm

gustavs.slutins
2022-06-28 14:26
Hello, is there a flag or variable we can pass into the jvm build in order to completely avoid the pact tests for the providers?

uglyog
2022-06-29 03:34
There are ways of filtering tests depending on what test framework you use, but these will have nothing to do with Pact

lucas.azzola
2022-06-29 04:18
has joined #pact-jvm

jens.suhr
2022-06-29 09:25
has joined #pact-jvm

thammarith.likittheer
2022-06-29 10:46
has joined #pact-jvm

andrevpuc
2022-06-29 14:24
has joined #pact-jvm

mylesjj
2022-06-29 16:26
has joined #pact-jvm

jens.suhr
2022-06-29 21:06
Has version 4.3.10 of the Gradle plugin already been published? I can?t find it at https://plugins.gradle.org/plugin/au.com.dius.pact

uglyog
2022-06-30 01:01
There is an issue with the Gradle publishing (something has changed with the Gradle portal). Just working though that, but you can use the version that is published to Maven Central.

jens.suhr
2022-06-30 07:33
OK, thank you! :thumbsup:

oliviawalsh1
2022-06-30 09:49
has joined #pact-jvm

robert.strehli
2022-06-30 14:00
Hey, I have a question about verifying contracts on branches. I have a consumer branch A and a provider branch X. I would like to verify now that provider branch X works with the new contract on consumer branch A. I already checked the options: ? Have the same branch name for provider and consumer --> That's not a possible option for me ? Use the consumerVersionSelectors --> I'm using already "branches" and would need to implement this workaround. https://pact-foundation.slack.com/archives/C9UN99H24/p1654611672907539 OR stepping back and use tags again. My question now, is there any other option?

uglyog
2022-07-01 00:12
branches support is a work in progress. You can provide the raw json for the selectors using the `pactbroker.consumerversionselectors.rawjson` system property

hiepluong2205
2022-07-01 06:40
has joined #pact-jvm

robert.strehli
2022-07-01 08:46
ok I see thanks!

saleh.elnagar
2022-07-01 13:20
has joined #pact-jvm

animesh.kumar
2022-07-03 16:54
has joined #pact-jvm

omri.benyair
2022-07-04 03:14
has joined #pact-jvm

chriswilliamsef
2022-07-04 13:11
has joined #pact-jvm

rioka68
2022-07-04 13:32
has joined #pact-jvm

heinenm
2022-07-04 14:01
has joined #pact-jvm

heinenm
2022-07-04 14:10
Hi, My application calls a.o. a few file download endpoints that should be covered by consumer driven contract tests. I don't care about the downloaded content but want to verify that the body is not empty by checking that the Content-Length header is set to a value > 0. Used version: *au.com.dius.pact.consumer:junit:4.3.10* Consumer code: ```@Override protected RequestResponsePact createPact(final PactDslWithProvider aBuilder) { final Map<String, String> requestHeaders = ChatTestUtil.createRequestHeaderMap(); return aBuilder// .given("A text prod finished successfully")// .uponReceiving("A request to download text")// .pathFromProviderState("/textresult/${jobId}", "/textresult/" + ChatTestUtil.DUMMY_JOB_ID)// .method("GET")// .headers(requestHeaders) .willRespondWith()// .status(200)// .headers(Map.of("Content-Type", "text/plain"))// .matchHeader("Content-Length", "[1-9][0-9]+")// .body(PactDslRootValue.stringType()) //.body(PactDslRootValue.stringMatcher(".*", "whatever")) //.withBinaryData("FooBar".getBytes(), "text/plain") .toPact(); }``` The variant with "*.body(PactDslRootValue.stringType())*" fails with following exception on provider side: ``` java.lang.AssertionError: Failures: 1) Verifying a pact between Core_Chat_Client and Chat_Service - A request to download text 1.1) BodyMismatch: / BodyMismatch: Expected body 'string' to match 'Participants: TestUser TestUser sent message 16 Oct 2001 10:14 PM +02:00 Hello World TestUser sent message 16 Oct 2001 10:14 PM +02:00 Lorem Ipsumupczl ' using equality but did not match``` The variant with "*.body(PactDslRootValue.stringMatcher(".*", "whatever")*" fails with also on provider side: ``` java.lang.AssertionError: Failures: 1) Verifying a pact between Core_Chat_Client and Chat_Service - A request to download text 1.1) BodyMismatch: / BodyMismatch: Expected body 'whatever' to match 'Participants: TestUser TestUser sent message 16 Oct 2001 10:14 PM +02:00 Hello World TestUser sent message 16 Oct 2001 10:14 PM +02:00 Lorem Ipsumphaai ' using regex '.*' but did not match``` And the last variant "*.withBinaryData("FooBar".getBytes(), "text/plain")*" fails also: ``` java.lang.AssertionError: Failures: 1) Verifying a pact between Core_Chat_Client and Chat_Service - A request to download text 1.1) BodyMismatch: / BodyMismatch: Expected body 'FooBar' to match 'Participants: TestUser TestUser sent message 16 Oct 2001 10:14 PM +02:00 Hello World TestUser sent message 16 Oct 2001 10:14 PM +02:00 Lorem Ipsumxetoj ' using equality but did not match``` How can I verify that the body of a response is not empty?

omri.eyal
2022-07-05 06:22
has joined #pact-jvm

shen-yu
2022-07-05 15:35
has joined #pact-jvm

ben.foster
2022-07-05 15:42
has joined #pact-jvm

maarten.gryp
2022-07-05 16:20
has joined #pact-jvm

uglyog
2022-07-06 03:44
I think `PactDslRootValue.stringMatcher` is the only one that works on plain text bodies. You should use `.+` as the regex as `.*` can match an empty string (* means zero or more), and you may need to add the start and end markers.

uglyog
2022-07-06 03:44
Try `^.+$`

megha.t
2022-07-06 06:56
has joined #pact-jvm

ravindra.dhaka
2022-07-06 07:08
has joined #pact-jvm

mrigendra.ranjan
2022-07-06 07:08
has joined #pact-jvm

deepak.bhoria
2022-07-06 07:11
has joined #pact-jvm

cjenkins
2022-07-06 07:17
has joined #pact-jvm

gustavo.chain
2022-07-06 08:04
has joined #pact-jvm

tobias.friedrich
2022-07-06 08:31
has joined #pact-jvm

heinenm
2022-07-06 08:34
Thanks for your suggestion @uglyog. We found the problem meanwhile. *Pact verification fails in case that the body contains line breaks, e.g. "Hello \r\n World".* ```Failures: 1) Verifying a pact between Core_Chat_Client and Chat_Service - A request to download text 1.1) BodyMismatch: / BodyMismatch: Expected body 'whatever' to match 'Hello World' using regex '^.+$' but did not match at au.com.dius.pact.provider.junit5.PactVerificationContext.verifyInteraction(PactJUnit5VerificationProvider.kt:94) at foo.ContractVerificationTest.pactVerificationTestTemplate(ContractVerificationTest.java:147)``` I attached also the JSON contract. Should I open a bug for this issue?

uglyog
2022-07-06 10:01
Yes, please do

ganesh.panchagnula-no
2022-07-06 11:50
has joined #pact-jvm

morten.gejl
2022-07-06 13:02
has joined #pact-jvm

varunthaper
2022-07-06 15:17
has joined #pact-jvm

jwheatley
2022-07-06 17:12
has joined #pact-jvm

tobias.friedrich
2022-07-06 17:45
Recently I was also looking for a valid example of how to make use of `V4Pact` for messages and also came up with a similar solution like @michael.branders. What confused me about that was the use of `usingLegacyMessageDsl` though:thinking_face: Maybe it's because of the naming, but to me this method kind of sounds like it should not be used :man-shrugging: Is there also any "non-legacy" way of creating V4Pacts for messages? Sorry for reviving this old thread!

b.1.alpha
2022-07-06 17:53
Can we use can-i-deploy without the tags in java?

b.1.alpha
2022-07-06 17:55
https://docs.pactflow.io/docs/workshops/ci-cd/workshop/prerequisite-concepts INFO As of July 2021, recording deployments using the `record-deployment` command has just been released, and support for the corresponding selector `{ deployed: true }` has not yet been added to all the Pact client libraries. The previous method of recording releases was to use https://docs.pact.io/pact_broker/tags. If you are not using one of the libraries that currently supports the `{ deployed: true}` selector (currently Javscript and Ruby support it), you will need to use tags in the meantime as per the documentation in the Tags page.

b.1.alpha
2022-07-06 18:24
Based on this https://docs.pact.io/pact_broker/branches#support There has been no development on the jvm tag replacement for a year, that cant be right

noor.hashem
2022-07-06 20:23
has joined #pact-jvm

uglyog
2022-07-06 23:17
I was hoping of creating a new DSL that better supports all the V4 options, and then people could still use the old ones. Just haven't had the time to do that yet.

uglyog
2022-07-07 00:42
4.3.11 has been released with support with both Gradle and JUnit 5

dormeiri
2022-07-07 09:41
has joined #pact-jvm


andreaschung1
2022-07-07 12:28
has joined #pact-jvm

b.1.alpha
2022-07-07 18:47
How can you run the @AllowOverridePactUrl for pact-jvm in localhost. We are doing this and its not working ```PACT_URL="https://blah.pactflow.io/ngc-provider-service/consumer/ngc-consumer/version/f8823729" mvn clean test \ -PproducerContractT ...``` https://github.com/pact-foundation/pact-jvm/commit/5b367c91e6c006542b6af197f0393c2cc64fc889

b.1.alpha
2022-07-07 19:32
We also looked at passing PACT_URL into the jvm vars based on this https://github.com/pact-foundation/pact-jvm/commit/d50014ce2e07fb742725b2a68cd5fe7d21332cbe#diff-954905711f18b5188b68618e2a8af8507930949ce9bbd62a25f2290feaff8c41L105. We use maven and surefire-plugin. This also did not work. ``` mvn clean test \ -PproducerContractTestWithBroker \ -Dtest=GetCartsProviderContractWithBrokerRunnerTest \ -DPACT_URL="https://blah.pactflow.io/pacts/provider/ngc-provider-service/consumer/ngc-consumer/version/12341234" \```


parvatshiva
2022-07-07 22:05
has joined #pact-jvm

uglyog
2022-07-07 23:43
The property needs to be: ```pact.filter.pacturl```

b.1.alpha
2022-07-08 00:32
Can we leave it blank, and set it in the command line when needed like this ``` mvn clean test \ -PproducerContractTestWithBroker \ -Dtest=GetCartsProviderContractWithBrokerRunnerTest \ -Dpacturl="https://blach.pactflow.io/pacts/provider/ngc-provider-service/consumer/ngc-consumer/version/1234" \```

uglyog
2022-07-08 00:33
No, the POM needs to have the property from the command line

b.1.alpha
2022-07-08 00:37
-Dpact.url=?blah?


b.1.alpha
2022-07-08 00:39
hrm, didnt seem to work

b.1.alpha
2022-07-08 00:42
I know i have a pact here that should fail, but my tests are all passing with the pact.url set on provider main

uglyog
2022-07-08 00:50
You'll need to look at at debug level logs to see what is going on

b.1.alpha
2022-07-08 00:51
```Pending Failures: 1) Verifying a pact between ngc-consumer and ngc-provider-service - Get all carts details has a matching body 1.1) body: $.meta.page Expected noLimit=1766809366 but was missing { - "count": 264599894, - "noLimit": 1766809366, - "offset": 2071672504, - "total": 621680125 + "limit": 200, + "total": 1, + "offset": 0, + "count": 1 }```

b.1.alpha
2022-07-08 00:52
So it looks like it did fail, but my tests showed no failures. Interesting

uglyog
2022-07-08 00:52
> Pending Failures: It is pending, it will not fail the build

b.1.alpha
2022-07-08 00:52
ohhhhh

b.1.alpha
2022-07-08 00:53
I read ?This test should correctly fail with the error `Could not find key "color"` in the output.? and expected failed tests, but since its pending you have to read the output


uglyog
2022-07-08 00:59
I'm a bit confused, that workshop is a node project, you are using JVM, why would you expect the same error when your payload looks different

b.1.alpha
2022-07-08 01:03
I mean, we are doing the workshop steps, but we make different changes and assert as needed so we can follow along

b.1.alpha
2022-07-08 01:04
?but in jvm because well we want to fully grok the workflow

b.1.alpha
2022-07-08 01:04
we are also in gitlab so there are a few differences, but we are almost done now


b.1.alpha
2022-07-08 01:07
we expect a similar workflow step here, we want to see the failure in the provider localhost when it pulls the contract that does not match

b.1.alpha
2022-07-08 01:09
The workshop is a good way to demo pactflow working. So we will run through every step but in our mvn/jvm/gitlab. Does that make it clear?

b.1.alpha
2022-07-08 01:14
So in the test log it also talks about bad auth tokens, but I double checked it, and the auth token is the read/write pact token.

b.1.alpha
2022-07-08 01:15
I PM?d you the log as it has personal details

b.1.alpha
2022-07-08 01:19
It also talks about Given request with bad headers, bad request headers

uglyog
2022-07-08 01:28
The auth tokens it is talking about are from you auth system, not pactflow

uglyog
2022-07-08 01:28
I think you should mock that out if possible

jonathan.dowling
2022-07-08 11:37
has joined #pact-jvm

jonathan.dowling
2022-07-08 11:52
Hi. I'm trying to write a Pact test for gRPC. Can I control the port that the Pact Mock Service Provider listens on? I would like it to mimic the standard port of the external service that it's standing in for. I've tried this annotation but I still get a random port, and I get a deprecation warning on the "port" parameter. `@PactTestFor(pactMethod = "someMethod", port="5000")`

alex423
2022-07-08 13:59
has joined #pact-jvm

francis.williams
2022-07-08 19:52
has joined #pact-jvm

dmitry.sarkisov
2022-07-08 20:07
has joined #pact-jvm


neokree
2022-07-09 10:50
has joined #pact-jvm

lynn.alhaimy
2022-07-10 18:20
has joined #pact-jvm

jonathan.dowling
2022-07-11 06:54
> a new mock server config annotation you can use to set the port I looked at the code you linked but I don't see any annotation setting the port? From what I understand, the example code shows how to _retrieve_ the mock server port in order to set up the channel that will communicate with the already running port. I don't see how one sets the port with that code?

jonathan.dowling
2022-07-11 10:40
I've spent some time looking through the code for the grpc pact plug-in now and it looks like the port for the mock server is never set to any configurable value, always taking the default value of 0 and getting a random port assigned. :disappointed:

guillermo.aguirre
2022-07-11 10:47
Anyone know if there's an existing dependency issue/conflict with PACT provider and Xerces?

jonathan.dowling
2022-07-11 11:16
PluginManager.kt in io.pact.plugin.driver:core:0.1.2 is what led me to this conclusion. I'd be happy to be wrong though, if anyone knows another way.

guillermo.aguirre
2022-07-11 12:19
I'm getting this error when running the producer : `Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.`

guillermo.aguirre
2022-07-11 12:20
Which if my googling is correct is due to an XML parsing error, however this only fails on producer tests, not when running my app

eirikval
2022-07-11 15:08
has joined #pact-jvm

sahil.jain
2022-07-12 10:21
has joined #pact-jvm

sahil.jain
2022-07-12 10:46
Hello Everyone. I am bit new to Contract testing and recently started exploring it for consumer driven contract testing in Android App. The use case I am trying to solve is to generate pact file while i am running my UI Tests in Android app. My Android app makes multiple API requests to our backend server which i have currently mocked the responses through "Wiremock" framework. The next step i want to do is to record all the interactions made by the app and create a pact file so as i can validate it against my reack backend server. In order to do so i have integrated "Wiremock Pact Generator" developed by Atlassian team : https://bitbucket.org/atlassian/wiremock-pact-generator/src/master/ but i am facing crash while running my UI tests. ```com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:108) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.servlets.gzip.GzipHandler.handle(GzipHandler.java:479) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:499) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:784) Caused by: java.nio.file.NoSuchFileException: target/pacts/the-consumer-the-provider-febea806-232d-4527-bacb-d501e5048f78-pact.json at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214) at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434) at java.nio.file.Files.newOutputStream(Files.java:216) at java.nio.file.Files.write(Files.java:3292) at com.atlassian.ta.wiremockpactgenerator.pactgenerator.LocalFileSystem.saveFile(LocalFileSystem.java:14) at com.atlassian.ta.wiremockpactgenerator.pactgenerator.PactSaver.saveFile(PactSaver.java:39) ... 24 more``` Can someone please help why its not able to save pact file? or i am doing something wrong here. Thanks in Advance.

jonathan.dowling
2022-07-12 13:40
@uglyog Did I misunderstand the code you linked? Is there a way to set the port? I don't see any port being set in the code you linked, the port only gets _read_ from the MockServer.

kyriacos.elia
2022-07-12 15:43
has joined #pact-jvm

fabricio.mendes.ti
2022-07-12 16:33
has joined #pact-jvm

srinagasai.krishnasan
2022-07-12 21:15
how do we support Integer class type within a response body. We have `integerType` that supports primitive int. Where as for Integer the value can be either null or plain integer. How can this be handled?

jarmy
2022-07-12 21:51
On a related note to above, we have a provider that returns either null or an integer for one of its response keys. I looked into using `.valueFromProviderState("degree", "set degree to null", null)` but I've been unable to figure out how to validate it in the provider side using `@State` with SpringBootTest. Any help would be appreciated!

cameron.allan853
2022-07-12 23:18
has joined #pact-jvm

matt.fellows
2022-07-13 03:00
Please see My answer in #general

matt.fellows
2022-07-13 03:01
This is just another variant of optional field which we don't support. See http://docs.pact.io for hire to deal with it

jeroen.lamain
2022-07-13 08:49
has joined #pact-jvm

kyriacos.elia
2022-07-13 09:17
Hey all, I?ve been looking online but I can?t seem to find a good guide about how to upgrade an existing JVM Pact suite onto v4 Pact spec. Anyone know of any good references?

programmingwithbangal
2022-07-13 12:48
has joined #pact-jvm

rohitkeshwani07
2022-07-13 13:28
has joined #pact-jvm

gjvengelen
2022-07-13 18:18
has joined #pact-jvm


lorenz.ammon
2022-07-14 08:52
has joined #pact-jvm

remigijus.mazulis
2022-07-14 08:53
has joined #pact-jvm

seanruffatti
2022-07-14 14:40
has joined #pact-jvm

paul.simms
2022-07-14 15:55
Hi, We are trying to make the move from tags to environments and deployments to overcome many problems we are having our workflow. Early work in JS looks promising. However we have hit a snag in Java when trying to upgrade the version from 4.3.9 to the new 4.3.11 (or indeed 4.3.10). Running JUnit5 with maven. We get the error during runtime of [ERROR] pactVerificationTestTemplate{PactVerificationContext, HttpRequest} Time elapsed: 6.217 s <<< ERROR! java.lang.RuntimeException: java.lang.NoSuchMethodError: 'void kotlin.jvm.internal.FunctionReferenceImpl.<init>(int, java.lang.Class, java.lang.String, java.lang.String, int)' Caused by: java.lang.NoSuchMethodError: 'void kotlin.jvm.internal.FunctionReferenceImpl.<init>(int, java.lang.Class, java.lang.String, java.lang.String, int)' The tests run fine against ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.3.9</version> </dependency>``` but give that error in 4.3.11. Appreciate any help in this. Many thanks

rholshausen
2022-07-14 18:45
That looks like a conflict with Kotlin standard library versions. I'm just going through the change log to see what has changed since 4.3.9

rholshausen
2022-07-14 18:50
Can you check the dependency tree of your project? Pact-JVM is compiled against Kotlin stdlib 1.5.31

nico.neirinck
2022-07-15 06:10
has joined #pact-jvm

k.bangarusamy
2022-07-15 14:36
has joined #pact-jvm

harinder.kaur
2022-07-15 17:19
has joined #pact-jvm

mahidasp
2022-07-16 17:30
has joined #pact-jvm

juan.aa.espiritu
2022-07-17 08:39
has joined #pact-jvm

thomas.loudon
2022-07-18 11:05
has joined #pact-jvm

david.hayden
2022-07-18 11:12
has joined #pact-jvm

hakan.b.jansson
2022-07-18 14:04
has joined #pact-jvm

jakehowden
2022-07-18 15:54
has joined #pact-jvm

rarora
2022-07-19 09:07
Hi team I am facing issue related to consumer filtering. ? I have multiple consumer(say C1 and C2) for one provider. ? Both consumer publish their individual contracts. ? When feature branch of C1 publishes new contract, webhook triggers build for provider with pact Url and consumer name environment variables for AllowOverridePactUrl annotation. ? When provider build runs it fails with Provider state call back failed for C2. Below error log shows filter consumer name is ?sync-service? and has pact url but its still trying to find state in ?TaskRunner? provider test. It should check in SyncServiceToProductCT ```TaskRunnerToProductCT > sync-service - GET Product by Product Code STANDARD_OUT [06:17:38,247][INFO] provider.junit5.PactVerificationStateChangeExtension - Invoking state change method 'GetByProductCode':SETUP Verifying a pact between sync-service and product-service [from Pact Broker https://pact-broker.rc.vkp.viatorsystems.com/pacts/provider/product-service/consumer/sync-service/pact-version/9ba7240b86a1ad9f4900fa75e3dab5619744a4e5/metadata/Y3ZuPTk1MTJlNzIzNGEzMjdhYjg4ZjZkMjMxNTA5ZWE2NWUwYjliZTRkMGQmY3Z0W109ZmVhdHVyZV9TVVBQTFktODMxNS1za2lwLW5vbi1zYXBpLXByb2R1Y3RzLXdoZW4tZW5hYmxlLXNjaGVkdWxpbmctcGFjJnc9dHJ1ZQ] Given GetByProductCode GET Product by Product Code [06:17:38,270][WARN] api.text.TextContentHelper - ContentRef not found :: {"contentRef":"CR-REF1"} returns a response which has status code 200 (OK) has a matching body (OK) [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator - Not all of the 7 were verified. The following were missing: [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator - Get First Publish Requested User By product code [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator - GET Supplier by Product Code [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator - Lookup Product Details [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator - GET product code request [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator - GET products status [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator - GET Supplier by Product Code SupplyTaskRunnerToProductServiceCT > sync-service - Get First Publish Requested User By product code STANDARD_OUT [06:17:38,279][ERROR] provider.junit5.PactVerificationStateChangeExtension - Provider state change callback failed au.com.dius.pact.provider.junitsupport.MissingStateChangeMethod: Did not find a test class method annotated with @State("GetFirstPublishRequestedUser") for Interaction "Get First Publish Requested User By product code" with Consumer "sync-service" at au.com.dius.pact.provider.junit5.PactVerificationStateChangeExtension.invokeStateChangeMethods(PactVerificationStateChangeExtension.kt:125) ~[junit5-4.1.32.jar:4.1.32]``` Please suggest how to fix it

rarora
2022-07-19 09:12
version: ```'au.com.dius.pact.provider:junit5:4.1.32'```

rarora
2022-07-19 09:13
```@Provider("product-service") @VerificationReports @PactBroker(consumerVersionSelectors = {@VersionSelector(consumer = "sync-service", tag = "develop")}) @AllowOverridePactUrl public class SyncServiceToProductCT {```

qingyuliu
2022-07-19 09:42
Hi team, in the consumer side message level contract test, we use the *MessagePactBuilder* to build a message wrapped in a *MessagePact* type. And store the message into PACT broker. However, in the producer side test, under the @*PactVerifyProvider,* provider will wrap the message in a *MessageAndMetadata* type. And then we pass this back to PACT which will compare it to what is held in the PACT broker. I'm wondering since the message generated by consumer is wrapped in *MessagePact* and the message generated by provider is wrapped in *MessageAndMetadata.* How could we compare these two different type of object? Thanks!

chrstnklb
2022-07-19 10:58
has joined #pact-jvm

andrew.favaloro
2022-07-19 19:36
has joined #pact-jvm

tarun.gulati1988
2022-07-19 19:41
has joined #pact-jvm

boweixu
2022-07-19 20:39
has joined #pact-jvm

uglyog
2022-07-20 00:42
Those are two different things. `MessagePact` represents the Pact file and what is stored in the broker. When the Pact is verified, the pact file will be fetched from the broker, loaded as a `MessagePact` class, then the provider method will be called which will return the message data as a `MessageAndMetadata` class. The Pact framework will then do the comparison based on the values of these two classes.

uglyog
2022-07-20 02:51
Can you raise an issue for this?

qingyuliu
2022-07-20 03:10
Thanks @uglyog, I have another question that under the @Pact annotation, the consumer will define the expected interaction between consumer and provider. Will the pact annotation also generate the PACT, the mock service for the consumer side verification test to use?

juanalvarezarquillos
2022-07-20 05:46
has joined #pact-jvm

jkaur
2022-07-20 06:32
has joined #pact-jvm

steve.heasman
2022-07-20 09:08
has joined #pact-jvm

je.alvinez
2022-07-20 11:17
has joined #pact-jvm

paul.simms
2022-07-20 13:03
@rholshausen Thank you for your suggestion - and apologies for your response (we had delays in accessing our dev broker version). We have added in ```<dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib-common</artifactId> <version>1.5.31</version> </dependency>``` to our pom.xml - but are still seeing the same runtime error: [ERROR] pactVerificationTestTemplate{PactVerificationContext, HttpRequest} Time elapsed: 3.168 s <<< ERROR! java.lang.RuntimeException: java.lang.NoSuchMethodError: 'void kotlin.jvm.internal.FunctionReferenceImpl.<init>(int, java.lang.Class, java.lang.String, java.lang.String, int)' Caused by: java.lang.NoSuchMethodError: 'void kotlin.jvm.internal.FunctionReferenceImpl.<init>(int, java.lang.Class, java.lang.String, java.lang.String, int)' with version 4.3.10/11 ```<groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId>``` . Any further suggestions. Many thanks

matkruse
2022-07-20 14:53
has joined #pact-jvm

2billy
2022-07-20 16:56
has joined #pact-jvm

2billy
2022-07-20 16:58
Any direction regarding pact contract testing, Kafka avro messages and also using Confluent schema registry? thx!

matt.fellows
2022-07-20 22:29
Somebody asked about avro the other day. Try a quick search for some useful links/ materials (sorry on mobile)

christopher.forbes
2022-07-21 09:27
has joined #pact-jvm

sandy.oberoi
2022-07-21 18:57
has joined #pact-jvm

adelamarre
2022-07-21 19:37
has joined #pact-jvm

husamhindustani
2022-07-22 06:52
has joined #pact-jvm

madhulika.mitra
2022-07-22 14:28
Hi Team. I have a question regarding matching in pact-jvm. We can specify the matching rules while creating the PactDslJsonBody , but in case we are using the body from an existing json object we create in our project, could we additionally specify the matching rules ? - I do have an open enhancement on this https://github.com/pact-foundation/pact-jvm/issues/1541 :slightly_smiling_face: .

abudi.hijazi.01
2022-07-22 15:38
Anyone know how to implement consumer version selectors to filter through pacts, not by using tags. This link https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors talks about using environments and other things, but in the code implementation for Java they only use tags to filter through consumers. I can't find any other code examples I'm using junit runners

harley
2022-07-23 02:15
has joined #pact-jvm



paul.simms
2022-07-25 08:15
Any further suggestions please - we want to move towards deployments rather than releases. But this is stopping the Java provider examples. Thanks

japlavaren
2022-07-25 09:21
has joined #pact-jvm

alasdair.ryan
2022-07-25 10:45
has joined #pact-jvm

hui.supat
2022-07-25 13:22
has joined #pact-jvm

balaramvineethvenugop
2022-07-25 17:06
has joined #pact-jvm

jarmy
2022-07-25 18:05
@marcin.baranowski953 I think the problem is how you're reading the spring properties. You'll want to use the `@PactBroker` annotation. e.g. ```@PactBroker( url = "${pactbroker.url}", consumerVersionSelectors = { @VersionSelector(tag = "master"), @VersionSelector(tag = "prod"), @VersionSelector(tag = "dr") })```

alan.still
2022-07-25 18:18
has joined #pact-jvm

yshkedi
2022-07-25 21:16
has joined #pact-jvm

apapia
2022-07-26 02:27
has joined #pact-jvm

uglyog
2022-07-26 05:08
I got this error as well. Looks like a bug with the Kotlin compiler. I changed the function signature that was causing the issue, and the exception went away. I'll release a fix for this soon.

paul.simms
2022-07-26 08:22
@uglyog Thanks. If possible can you please post here when that is available.

rziembicki
2022-07-26 10:47
has joined #pact-jvm

dpal
2022-07-26 10:58
has joined #pact-jvm

dgrace
2022-07-26 11:02
has joined #pact-jvm

dgowdappa
2022-07-26 11:02
has joined #pact-jvm

gustavs.slutins
2022-07-26 11:38
Hey. I was wondering if its possible to have multiple VerifyContractTest classes on the provider verification? I want some tests to use testTarget but other tests to use MockMvc with testTarget.


paul.simms
2022-07-26 12:39
@matt.fellows Yes, thanks. Just tried that and it works now :partying_face: Need to work through your guides now, and start to deploy around services, so we can start moving away from tags. Many thanks

sascha_pactflow
2022-07-26 20:29
has joined #pact-jvm

hunsolitude
2022-07-26 22:34
has joined #pact-jvm

maksym_odanets
2022-07-27 08:07
has joined #pact-jvm

andrew.january
2022-07-27 09:03
has joined #pact-jvm

davidf
2022-07-27 09:17
has joined #pact-jvm

harii.ravii
2022-07-27 16:50
Hi Team, I Need your inputs what i am doing wrong here on Consumer Contracts. When i run the Test it says no one is called but when i run with debugger i notice MockServer and the healthcheck end point have same host and port number and the end point as well. Please guide me what i am missing here

harii.ravii
2022-07-27 16:50
```@ExtendWith(PactConsumerTestExt.class) @ExtendWith(MockitoExtension.class) @PactTestFor(providerName = "ProviderService") public class HealthCheckTest { @Pact(consumer = "Consumer") public RequestResponsePact getHealthCheck(PactDslWithProvider builder) { Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "text/plain"); headers.put("callchainid", "a4275861-f60a-44ab-85a6-c0c2c9df5e27"); return builder .given("get health check") .uponReceiving("get health data") .path("/health") .method("GET") .headers(headers ) .willRespondWith() .status(200) .body("{\"status\":\"UP\",\"components\":{\"db\":{\"status\":\"UP\",\"details\":{\"database\":\"PostgreSQL\",\"validationQuery\":\"isValid()\"}}}}") .toPact(); } @Test @PactTestFor(pactMethod = "getHealthCheck") void getHealthData(MockServer mockServer) { WebClient webClient=WebClient.builder().baseUrl(mockServer.getUrl()).build(); final String callChainId="a4275861-f60a-44ab-85a6-c0c2c9df5e27"; ThreadContext.put(CallChainIdService.HEADER_NAME, callChainId); AsyncClient asyncClient=new AsyncClient(webClient); Mono<ClientResponse> responseMono=asyncClient.getHealthCheck(); System.out.println(responseMono); }```

harii.ravii
2022-07-27 16:52
Client Class ```@Log4j2 @Service public class AsyncClient implements CMClient { private final WebClient CLIENT; public AsyncClient( @Qualifier("cm-api") WebClient cm ) { CLIENT = cm; } @Override public Mono<ClientResponse> getHealthCheck() { return get(MediaType.TEXT_PLAIN, "/health"); } private Mono<ClientResponse> get(MediaType contentType, String uri, Object... params) { return CLIENT .mutate() .defaultHeader(CallChainIdService.HEADER_NAME, ThreadContext.get(CallChainIdService.HEADER_NAME)) .build() .get() .uri(uri, params) .accept(contentType) .exchange(); } }```

harii.ravii
2022-07-27 16:53
When i run the test

harii.ravii
2022-07-27 16:53
```au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: method: GET path: /health query: {} headers: {callchainid=[a4275861-f60a-44ab-85a6-c0c2c9df5e27], Content-Type=[text/plain]} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING```

harii.ravii
2022-07-27 16:54
Please guide me what i am missing here

ankit.mittal
2022-07-28 10:00
has joined #pact-jvm

vishal.kukreja
2022-07-28 10:22
has joined #pact-jvm

ankit.mittal
2022-07-28 16:51
Hi Team, In most of the documentations, it is recommended to use the branching approach instead the tags. But, in one of the document, it is mentioned *TBC* for *pact-jvm*. So, want to confirm what is status of roll out for pact-jvm client library. PFB the Link, where it is mentioned as TBC: https://docs.pact.io/pact_broker/branches

robert.henzel
2022-07-28 19:50
has joined #pact-jvm

james.perepiczka
2022-07-28 22:09
Hi, for the java gradle plugin, in the canIDeploy task, is it possible to prevent it from failing if no verifications exist and only fail on failed verifications?

james.perepiczka
2022-07-28 22:54
I have another question also, when verifying a pact as a provider using the following attributes ```@PactBroker(url = "${pactbroker.url}", consumerVersionSelectors = { @VersionSelector(tag = "main") })``` I can see from the output that it is correctly targetting a main consumer ```Verifying a pact between saasConsumer and saasProvider for tag main``` However whenever I look at the broker, it shows verifications against multiple previous versions of the contract both on the main branch and a couple of other feature branches, is there a reason for this?

james.perepiczka
2022-07-28 22:55
I can only assume it is because the contract hasnt changed but I cant see why it would present this behaviour

james.perepiczka
2022-07-28 23:22
Last question: Is there any functionality in the gradle plugin for recording a release or do you have to use the cli for that?

matt.fellows
2022-07-28 23:23
I would highly recommend ditching the canIDeploy maven task, and instead use the https://docs.pact.io/implementation_guides/cli

matt.fellows
2022-07-28 23:23
(which yes, you can record releases etc. from also)

matt.fellows
2022-07-28 23:25
The broker automatically versions the contract behind the scenes, separate to your consumer versions. If the hash of the contents is the same, and the provider verifies that pact, then any versions of the consumer associated with the same contract will also be validated

uglyog
2022-07-29 00:04
branches support has only just been released. You'll need to use the latest version of Pact-JVM

uglyog
2022-07-29 00:05
Please raise a Github issue for this request

matt.fellows
2022-07-29 00:52
this is how a new consumer version can publish a new contract that hasn?t changed, and it?s still safe to deploy without re-testing the provider

adrianminnock123
2022-07-29 08:53
has joined #pact-jvm

adam.witko
2022-07-29 09:38
@adam.witko has left the channel

massimiliano.devivo
2022-07-29 12:12
has joined #pact-jvm

vishal.kukreja
2022-07-29 12:53
Hi, I am trying to integrate pact in Android Project. while I did not find any sort of documentation for integrating Pact in Android project. Till now what I have done is:- ```@HiltAndroidTest @Config(sdk = [Build.VERSION_CODES.Q]) @PactTestFor( providerName = "our_provider" ) @PactFolder("target/pacts") @ExtendWith( PactConsumerTestExt::class) class VerificationEstimationPactTest { private var HEADERS: MutableMap<String, String> = HashMap() private var JSON: String? = null @get:Rule var rule: TestRule = InstantTaskExecutorRule() @get:Rule var hiltRule = HiltAndroidRule(this) @Inject lateinit var viewModel: MutualFundVerificationViewModel init { HEADERS["Content-Type"] = "application/json" JSON="{\n" + " \"estimationDate\": \"2022-07-26T10:59:29.935Z\",\n"+ " \"oEstimationDate\": \"2022-07-27T10:59:56.342Z\",\n"+ " \"estimationDate\": \"2022-07-27T11:12:26.640Z\",\n"+ " \"gstimationDate\": \null \n"+ " }" } @Before fun setUp() { hiltRule.inject() } @Throws( UnsupportedEncodingException::class ) @Pact(provider = "our_provider", consumer = "our_consumer") fun createFragment(builder: PactDslWithProvider): RequestResponsePact { return builder .given("data count is > 0") .uponReceiving("a request for json data") .path("/provider.json") .method("GET") .willRespondWith() .status(200) .headers(HEADERS) .body(JSON) .toPact() } @Test @PactTestFor(pactMethod = "createFragment") fun should_process_the_json_payload_from_provider() { // val observer: TestObserver<VerificationTimeResponse> = viewModel.flowUseCase.getVerificationTime().test() // observer.assertNoErrors() /*observer.assertValue( VerificationTimeResponse( Timestamp("2022-07-26T10:59:29.935Z".toLong()), Timestamp("2022-07-27T10:59:56.342Z".toLong()), Timestamp("2022-07-27T11:12:26.640Z".toLong()), null ) )*/ }``` still unable to generate the contract file. Kindly help for same.

alan.still
2022-07-29 13:15
Hi Team :wave: , I?ve been seeing some ?strangeness? in our logs when our Provider Verification step runs in our build. We are using the junit5 Provider annotations, however 1 of our @PactVerifyProvider annotated methods is not publishing any verification - whereas the other 4 provider tests we have in the same class all do. In our build in pass in the following args to the task ? pact.provider.version -> git SHA ? pact.provider.tag -> branch-name ? pact.provider.branch -> branch-name ? pact.provider.environment -> env (we have set up DEV/PROD) ? pact.verifier.publishResults -> always true ? pactbroker.auth.token -> auth token Is there something in the combination of the tags we are sending that could cause this to happen for a single provider? TIA

andrevdrodrigues
2022-07-29 13:26
Hello @matt.fellows, how are you? Buddy, do you know if is there some advance with the support to AVRO? Thanks a lot :slightly_smiling_face:

matt.fellows
2022-07-30 10:56
Hi Andre, no to my knowledge there is no AVRO support yet

matt.fellows
2022-07-30 10:57
if you wanted to write a plugin as per above, that?s an option or try something like https://medium.com/@ivangsa/consumer-driven-contract-testing-for-grpc-pact-io-d60155d21c4c

matt.fellows
2022-07-30 11:15
I can?t advise about the above, but I will say there should be nothing specific about an Android Pact test. You do need to run the tests as a pure unit test, and not run in any emulator/android environment

hareesh.dj
2022-07-30 12:01
has joined #pact-jvm

heera
2022-07-31 08:00
has joined #pact-jvm

harii.ravii
2022-08-01 00:24
Hi Team, Please let me know does PACT Mock Server support spring webclient ?

abubics
2022-08-01 01:13
Yeah, it's hard to see how the provider is being invoked in this code. ? If you're making API calls directly from your Fragment, that's already a sign of questionable encapsulation. ? Something that seems missing is injection of the Pact stub service URL into the HTTP client.

uglyog
2022-08-01 03:18
The only thing I can think of, is that it is not being run. The test methods will be run based on what Pact files are fetched from the broker.

uglyog
2022-08-01 03:20
Depends on what you mean by "support spring webclient". The mock server is just an HTTP server that gets it's behaviour from a Pact file.

harii.ravii
2022-08-01 05:41
Here is my example which is no working on WebClient

harii.ravii
2022-08-01 05:41
```@ExtendWith(PactConsumerTestExt.class) @ExtendWith(MockitoExtension.class) @PactTestFor(providerName = "ProviderService") public class HealthCheckTest { @Pact(consumer = "Consumer") public RequestResponsePact getHealthCheck(PactDslWithProvider builder) { Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "text/plain"); headers.put("callchainid", "a4275861-f60a-44ab-85a6-c0c2c9df5e27"); return builder .given("get health check") .uponReceiving("get health data") .path("/health") .method("GET") .headers(headers ) .willRespondWith() .status(200) .body("{\"status\":\"UP\",\"components\":{\"db\":{\"status\":\"UP\",\"details\":{\"database\":\"PostgreSQL\",\"validationQuery\":\"isValid()\"}}}}") .toPact(); } @Test @PactTestFor(pactMethod = "getHealthCheck") void getHealthData(MockServer mockServer) { WebClient webClient=WebClient.builder().baseUrl(mockServer.getUrl()).build(); final String callChainId="a4275861-f60a-44ab-85a6-c0c2c9df5e27"; ThreadContext.put(CallChainIdService.HEADER_NAME, callChainId); AsyncClient asyncClient=new AsyncClient(webClient); Mono<ClientResponse> responseMono=asyncClient.getHealthCheck(); System.out.println(responseMono); }```

harii.ravii
2022-08-01 05:41
Client Class:

harii.ravii
2022-08-01 05:42
```@Log4j2 @Service public class AsyncClient implements CMClient { private final WebClient CLIENT; public AsyncClient( @Qualifier("cm-api") WebClient cm ) { CLIENT = cm; } @Override public Mono<ClientResponse> getHealthCheck() { return get(MediaType.TEXT_PLAIN, "/health"); } private Mono<ClientResponse> get(MediaType contentType, String uri, Object... params) { return CLIENT .mutate() .defaultHeader(CallChainIdService.HEADER_NAME, ThreadContext.get(CallChainIdService.HEADER_NAME)) .build() .get() .uri(uri, params) .accept(contentType) .exchange(); } }```

harii.ravii
2022-08-01 05:42
when i run the test , it says no one is calling the mock

harii.ravii
2022-08-01 05:42
```au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: method: GET path: /health query: {} headers: {callchainid=[a4275861-f60a-44ab-85a6-c0c2c9df5e27], Content-Type=[text/plain]} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING```

harii.ravii
2022-08-01 05:43
when i run with the debugger, i notice mockserver url got passed and some how the mock server unable to match the health check call

harii.ravii
2022-08-01 05:43
when i use webClient to directly call the health endpoint in my test class i got the response..

harii.ravii
2022-08-01 05:43
``` String json = WebClient.create() .get() .uri(mockServer.getUrl()+"/health") .exchange() .block() .bodyToMono(String.class) .block(); System.out.println(json);```

harii.ravii
2022-08-01 05:45
My eyes are going to it pact mockserver does it has support for webclient

uglyog
2022-08-01 06:02
Check the logs, you will see all the requests the mock server received

harii.ravii
2022-08-01 06:17
I am confused.. when i run the test, the log shows ?he following requests were not received?

harii.ravii
2022-08-01 06:17
```au.com.dius.pact.consumer.PactMismatchesException: The following requests were not received: method: GET path: /health query: {} headers: {callchainid=[a4275861-f60a-44ab-85a6-c0c2c9df5e27], Content-Type=[text/plain]} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING```

harii.ravii
2022-08-01 06:17
are you talking about this log or different one

uglyog
2022-08-01 06:21
I assume `AsyncClient` is asynchronous. In your example that works, you have calls to `.block()`, but in the test you do not.

alan.still
2022-08-01 08:41
Thanks @uglyog, could you give me more detail on how these pacts would be retrieved and if there is something available on cli or HAL Browser where I can run this against our broker? Could the flags we use in our verification step impact the pacts that are returned? Specifically, I?m wondering about the environment flag we are using. Would that require the pact to be both published and recorded for it to be returned as a pact that needs verification?

adam.redlisiak
2022-08-01 10:18
has joined #pact-jvm

altan.demirkiran846
2022-08-01 14:38
has joined #pact-jvm

nick080
2022-08-01 14:44
has joined #pact-jvm

vishal.kukreja
2022-08-01 15:06
Hi I am unable to generate contract and have given lot of time for doing so and rnd, I am an android developer , Is anyone could help me in that.

vishal.kukreja
2022-08-01 15:06
?

vishal.kukreja
2022-08-01 15:07
``` @HiltAndroidTest @Config(sdk = [Build.VERSION_CODES.Q]) @PactTestFor( providerName = "our_provider" ) @PactDirectory("presentation/target/pacts") @ExtendWith( PactConsumerTestExt::class ) class VerificationEstimationPactTest { private var HEADERS: MutableMap<String, String> = HashMap() private var JSON: String? = null @get:Rule var rule: TestRule = InstantTaskExecutorRule() @get:Rule var hiltRule = HiltAndroidRule(this) lateinit var viewModel: InvestorsProfileViewModel init { HEADERS["Content-Type"] = "application/json" JSON="{\n" + " \"score\":45,\n" " \"profile\": \"RISK_AVERSE\"\n" + "}" } @Before fun setUp() { hiltRule.inject() } @Throws( UnsupportedEncodingException::class ) @Pact(provider = "our_provider", consumer = "our_consumer") fun createFragment(builder: PactDslWithProvider): RequestResponsePact { return builder .given("data count is > 0") .uponReceiving("a request for json data") .path("/provider.json") .method("GET") .willRespondWith() .status(200) .headers(HEADERS) .body(JSON) .toPact() } @Test @PactTestFor(pactMethod = "createFragment") fun should_process_the_json_payload_from_provider() { val observer: TestObserver<InvestorProfile> = viewModel.getInvestorProfileUseCase.buildUseCaseObservable( GetInvestorProfileUseCase.Params.GetInvestorProfileUseCase()).test() observer.assertNoErrors() observer.assertValue( InvestorProfile( 45,"RISK_AVERSE" ) ) } }```

ali.ustek
2022-08-01 15:09
has joined #pact-jvm

momarquez
2022-08-01 19:37
has joined #pact-jvm

harii.ravii
2022-08-01 21:14
thanks .. this helps


matt.fellows
2022-08-01 22:52
> should_process_the_json_payload_from_provider this function should call the mock server created by Pact. You aren?t injected the MockServer into that function, whtere you can get the base URL and configure your API client

matt.fellows
2022-08-01 22:53
Here is an example (in Java) that shows how to dynamically configure the API client with the mock server URL: https://github.com/pactflow/example-consumer-java-junit/blob/master/src/test/java/com/example/products/ProductsPactTest.java#L70-L71

matt.fellows
2022-08-01 22:53
For clarity - you _must_ send the request to the Pact mock server, and not the real thing, or mocked out with another framework

uglyog
2022-08-01 23:18
None of those affect which Pact files are retrieved, they are used to record the values when the validation is complete. Can you provide your Pact test? Or the logs from the run?

abubics
2022-08-02 00:41
If all of this isn't making sense, you could try showing us the code you want to test, instead of the test that "doesn't work" :slightly_smiling_face:

uglyog
2022-08-02 03:16
Just checked your logs you sent through to the Smartbear support email. The problem is that the verification is based on the Pact contracts that are fetched from Pactflow, not what is defined in the test class. There is no interaction in the Pacts fetched for verification for `@PactVerifyProvider("PSP Success ? Work Order Notification")`, so there won?t be a result for that method.

matt.fellows
2022-08-02 03:23
I?m assuming there is output that shows the notices Ron? In Pact JS for example, it prints the notices that says why it has selected a particular pact to verify, e.g. ```The pact at https://test.pactflow.io/pacts/provider/e2e%20Provider%20Example/consumer/e2e%20Consumer%20Example/pact-version/9603a4c918997285c6b5230042b3dee3bb776ced is being verified because the pact content belongs to the consumer version matching the following criterion: * latest version from branch 'master' (10.0.1-master+5.ff58e7a.SNAPSHOT.fv-az83-114) This pact is in pending state for this version of e2e Provider Example because a successful verification result for a version of e2e Provider Example with tag 'master' has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at https://docs.pact.io/go/pending``` (via https://github.com/pact-foundation/pact-js/runs/7603983107?check_suite_focus=true#step:4:8034)

uglyog
2022-08-02 03:25
Yes, it is in the output from the verification build

andrevdrodrigues
2022-08-02 08:33
Ok, thanks :wink:

alan.still
2022-08-02 10:03
The notices that we get back in our verification build are only for the tests that are working. There is no notice provided for the missing Provider.

alan.still
2022-08-02 10:30
We also see the contract being published successfully in our consumer repo pipeline ```Created mfg-work-order-notification version 42d37704d59a3116347156ca05520c5380ecf523 with branch TRF-1901 and tags TRF-1901 79 Pact successfully published for mfg-work-order-notification version 42d37704d59a3116347156ca05520c5380ecf523 and provider mfg-psp. 80 View the published pact at https://moo-print.pactflow.io/pacts/provider/mfg-psp/consumer/mfg-work-order-notification/version/42d37704d59a3116347156ca05520c5380ecf523 81 Events detected: contract_published, contract_requiring_verification_published, contract_content_changed (first time any pact published for this consumer with consumer version tagged TRF-1901)```

alan.still
2022-08-02 10:33
I guess what I?m not fully grasping yet is what pacts are returned by the broker when you say ?Pact contracts that are fetched from Pactflow?. Is this all pacts for the pacticipant or will the result set be filtered by version/tag/branch/environment?

alan.still
2022-08-02 10:46
FWIW, I think the issue is somewhere in our process and how we are using the tooling more pact itself.

ali.ustek
2022-08-02 12:19
Hi everyone, is anyone using Avro with pact?


ali.ustek
2022-08-02 17:07
@matt.fellows can we create a channel for avro? i.e. #pact-avro, too see if it gets any traction, I have started talks where I work to start an open source project for the avro plugin

rubemfsv15
2022-08-02 20:13
has joined #pact-jvm

uglyog
2022-08-02 22:52
The pacts are filtered by the Provider name, consumer version selectors (if you are using those) and then consumer tags (via pactbroker.consumers property) and then maybe by any of the filter properties (see https://github.com/pact-foundation/pact-jvm/blob/master/docs/system-properties.md)

matt.fellows
2022-08-02 23:22
yes - done!

rene.klatt
2022-08-03 06:13
has joined #pact-jvm

imayat
2022-08-03 09:42
has joined #pact-jvm

mark.shand
2022-08-03 10:15
has joined #pact-jvm

gunjan.titiya
2022-08-03 11:51
has joined #pact-jvm

chaitanya.guttula
2022-08-03 12:43
has joined #pact-jvm

deb.kimnach
2022-08-03 12:48
has joined #pact-jvm

mike.key
2022-08-03 21:34
Is this the appropriate version to use for a java 8 project using Junit5?

kaiquan.shi
2022-08-04 03:38
has joined #pact-jvm

aalexandrumihai
2022-08-04 10:15
has joined #pact-jvm

aalexandrumihai
2022-08-04 10:31
Hello everyone! Lets consider the following snippet: ```void setup { mockClient instantiation } public void pactTest(){ pact for a POST to the client }``` This worked fine untill we implemented service descovery, and due to that, in setup is now an extra GET call to the mock server which generates Unexpected Request error. Debugging this, I discovered that the pactTest runs just fine, the post request is made after the get one and even if asserts are run and everything is ok, in the end it fails due to that unexpected request error. My question would be, is there any method to ignore the unexpected request, or to tell mock server how to respond to it, without adding it into the pact file ? Thanks in advance

alex.makdessi
2022-08-04 13:03
has joined #pact-jvm

matt.fellows
2022-08-04 13:31
Can you mock it out with the usual mocking tools?

matt.fellows
2022-08-04 13:32
I'm not aware of a way to exclude interactions, but you could post process the pact file to remove them (not ideal)

matt.fellows
2022-08-04 13:33
Is the discovery service on a different host/port?

aalexandrumihai
2022-08-04 13:35
Discovery call hits the target service, the mock in this situation, with GET on "/", otherwise, nothing different than a normal call to that service. As post process, we dont want it either. Trying to play with the mock server, I see that only interactions I can describe, ar the ones from @Pact annotated methods, nothing directly from setup

aalexandrumihai
2022-08-04 13:42
Also, I discovered that if I add the GET interaction in pact method definition , that will fail too because the discovery is done only at webClient startup in setup, so it wont be received bundled with the POST, and fail with request not matched. It tries to match the POST it receive at the actual call with the GET I describe in pact as being the first call.

ynechaieva
2022-08-04 14:11
has joined #pact-jvm

tjones
2022-08-04 15:56
I'm not sure I understand the service discovery pattern used here. Is the service being hit with the discovery request too? Isn't that a circular dependency?

tjones
2022-08-04 16:00
Anyway, if it's done only at web client startup, and your client is stateless, you could maybe write a contract test for your discovery interaction, then start the client, then do the rest of the interactions

aalexandrumihai
2022-08-04 18:45
We are consumers, we fire the service descovery when we instantiate the webClient for the service we use. I'll try tomorrow to do what you suggested

thanuxxxx
2022-08-04 19:40
I am trying to use `@consumerVersionSelectors` in my provider's tests from this https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors#verifying-the-latest-development-test-and-master-pacts but it seems `consumerVersionSelectors` method is deprecated. ``` /** @deprecated */ @Deprecated VersionSelector[] consumerVersionSelectors() default {@VersionSelector( tag = "${pactbroker.consumerversionselectors.tags:}", latest = "${pactbroker.consumerversionselectors.latest:}", consumer = "${pactbroker.consumers:}" )};``` For `maven provider version 4.3.12.` What is the alternative for this annotation?

gaurav.bajpai
2022-08-04 20:46
Hi Guys, need some help, I am writing pact test for some services, say there are three service, service A, B and C A and B both are consumer to different APIs exposed by C A has a pact consumer test, consumer=A, Provider=C B has a pact consumer test, consumer=B, Provider=C C has two different pact verification tests to verify both pacts when I just run consumer test for A and run verification test in C to verify that pact, it works fine, as soon as I run both consumer test for A and B and then run verification test for C, i get this error java.lang.AssertionError at PactVerificationStateChangeExtension.kt:52 Caused by: http://au.com.dius.pact.provider.junitsupport.MissingStateChangeMethod at PactVerificationStateChangeExtension.kt:125 Is it not allowed to put the same provider name in more than one consumer tests? or I am missing something in my configuration cc @matt.fellows @bethskurrie

tjones
2022-08-04 22:29
usually service discovery is used to find where the services are - which you would need to know in order to hit `/`

gaurav.bajpai
2022-08-05 01:49
I tried to follow the suggestions on this link - https://github.com/pact-foundation/pact-jvm/issues/1581 but it did not help

bethskurrie
2022-08-05 03:30
Please don?t @ the maintainers Gaurav.

bethskurrie
2022-08-05 03:32
Also, neither Matt nor I maintain or use pact JVM, so we cannot help you.

bethskurrie
2022-08-05 03:32
Ron is unwell at the moment unfortunately, so hopefully someone else from the channel can help you out.

thanuxxxx
2022-08-05 03:47
Looks like we don't have any annotations for consumer version selectors like branch, environment and I found https://github.com/pact-foundation/pact-jvm/pull/1471 as an alternative

aalexandrumihai
2022-08-05 07:48
we use service descovery to see what actions we can perform next and what are the paths for it. Thats because our services are HATEOAS.

aalexandrumihai
2022-08-05 07:50
anyway, in simple terms, we as a consumers, send a GET request on the service when instantiating the webClient, which, as I mentioned, cause our pact test to fail with unexpected request, even though the pact test itself run successfully and the request is sent to mock server and the response is sent by it

tjones
2022-08-05 07:51
Oh right! I think that isn't typically what people mean by service discovery, but I see what you mean now. Technically I guess HATEOAS is a REST pattern, but nowadays that just means ?http and json?, so it's not a good way to talk about it, unfortunately.

tjones
2022-08-05 07:51
How do you like it? I've always wanted to try it

matt.fellows
2022-08-05 07:53
Ok then my suggestion would be to mock out the initial service discovery call during instantiation, and have a dedicated pact test that only checks that

matt.fellows
2022-08-05 07:53
We want to avoid writing pact tests that test too many things at once

matt.fellows
2022-08-05 07:54
Fwiw the pact broker implements HATEOS via HAL (with some additions)

matt.fellows
2022-08-05 07:56
It works well, but it can confuse many people who just expect to hit predefined paths and makes things like documentation difficult, because there is poor support/tools for it (e.g. it doesn't fit the OAS model all that well)

tjones
2022-08-05 08:07
With pact you might have a problem when it comes to the URLs, since pact will want to know what they are. How did this get solved for the broker, Matt? From provider state?

tjones
2022-08-05 08:09
Oh, if you can inject your config, you could absolutely do that with fromProviderState, I reckon

dineshh.wot2021
2022-08-05 10:17
has joined #pact-jvm

fernandapontual5
2022-08-05 11:34
has joined #pact-jvm

sridhar140895
2022-08-05 11:58
has joined #pact-jvm

glenn
2022-08-06 18:13
has joined #pact-jvm

matt.fellows
2022-08-07 12:06
> How did this get solved for the broker, Matt? From provider state? Because the Ruby app doesn?t support v3, it uses a ?Hal relation proxy? - https://github.com/pact-foundation/pact_broker/blob/467780123bd717500f4317b34ade68471d2ff61a/spec/service_consumers/hal_relation_proxy_app.rb#L3-L5


matt.fellows
2022-08-07 12:08
FWIW there is a https://github.com/pactflow/example-siren example Ron created in JS which shows how Pact can better support hypermedia APIs

matt.fellows
2022-08-07 12:09
Also a blog explaining why hypermedia APIs are actually hard to test with Pact (ironically). Despite it being Level 4 REST (or perhaps because of!) we don?t actually get many requests for supporting hypermedia APIs with Pact.

sandy.mechie
2022-08-07 21:46
has joined #pact-jvm

prapurna.manda3
2022-08-08 07:38
has joined #pact-jvm

heinenm
2022-08-08 08:58
Thanks @uglyog, I confirm that your fix for #1579 is working. I have another question regarding the verification of file downloads. Now I want to verify that the body is not empty for files with mimetype "application/pdf" or "application/octet-stream". I tried to use the same matcher _PactDslRootValue.stringMatcher("^.+$", "whatever")_ that I used for text downloads, but this does not work. Consumer code: ```protected RequestResponsePact createPact(final PactDslWithProvider aBuilder) { return aBuilder// .given("A image prod finished successfully")// .uponReceiving("A request to download an image")// .pathFromProviderState("/result/${jobId}", "/result/" + ChatTestUtil.DUMMY_JOB_ID)// .method("GET")// .headers(myRequestHeaders) // .willRespondWith()// .status(200)// .headers(Map.of("Content-Type", "application/pdf"))// .matchHeader(ChatProductionApi.HEADER_PARAM_PAGE_COUNT, "[0-9]+")// .body(PactDslRootValue.stringMatcher("^.+$", "whatever"))``` The generated pact file looks like this: ```{ "consumer": { "name": "Core_Chat_Client" }, "interactions": [ { "description": "A request to download an image", "providerStates": [ { "name": "A image prod finished successfully" } ], "request": { "generators": { "path": { "dataType": "STRING", "expression": "/result/${jobId}", "type": "ProviderState" } }, "headers": { "RM-MDC-TOKEN": "dummyTraceId" }, "method": "GET", "path": "/result/dummyJobId" }, "response": { "headers": { "Content-Type": "application/pdf", "PDF-PAGE-COUNT": "32" }, "matchingRules": { "header": { "PDF-PAGE-COUNT": { "combine": "AND", "matchers": [ { "match": "regex", "regex": "[0-9]+" } ] } } }, "status": 200 } } ], "metadata": { "pact-jvm": { "version": "4.3.13" }, "pactSpecification": { "version": "3.0.0" } }, "provider": { "name": "Chat_Service" } }``` Failure on provider side: ```Failures: 1) Verifying a pact between Core_Chat_Client and Chat_Service - A request to download an image has a matching body 1.1) body: / Actual body 'Hello World' is not equal to the expected body 'whatever' java.lang.AssertionError: Core_Chat_Client - Upon A request to download an image Failures: 1) Verifying a pact between Core_Chat_Client and Chat_Service - A request to download an image has a matching body 1.1) body: / Actual body 'Hello World' is not equal to the expected body 'whatever' at au.com.dius.pact.provider.junit5.PactVerificationContext.verifyInteraction(PactVerificationContext.kt:66) at com.recommind.autotest.ContractVerificationTest.pactVerificationTestTemplate(ContractVerificationTest.java:147) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at ...``` The provider simply sent "Hello World" as response body in this test. How can I validate that the provider sends any data in the response body for mimetypes other than plain text ?

jaroslavburi
2022-08-08 14:44
has joined #pact-jvm

gaurav.bajpai
2022-08-08 15:23
Hi Guys, trying to build a pact test for an API that returns a String (not a json), the consumer side pact method looks like this ```builder .given('the instruction is accepted') .uponReceiving('a request to create instruction') .path("$BASE_URL/instruction") .method('POST') .headers('Content-Type', 'application/json', 'Accept', 'application/json') .body(buildPactDslJsonBody()) .willRespondWith() .status(201) .body("1234") .headers(Map.of('Content-Type', 'application/json')) .toPact() but when the pact is produced, it looks like this { "status": 201, "headers": { "Content-Type": "application/json" }, "body": 1234 } instead of string its converting the response body to a number, is the string response not supported by pact libs?```

manumahendran
2022-08-08 16:14
has joined #pact-jvm

manumahendran
2022-08-08 16:16
You have .body twice "body(buildPactDslJsonBody())" @gaurav.bajpai

gaurav.bajpai
2022-08-08 16:16
first is request

manumahendran
2022-08-08 16:17
ahk, my bad

manumahendran
2022-08-08 16:18
what happens when you run the tests?

manumahendran
2022-08-08 16:19
run the verification?

manumahendran
2022-08-08 16:21
#general Does anyone have any documentation regarding how the internal libraries of pact such as pactdslprovider work?

manumahendran
2022-08-08 16:21
@gaurav.bajpai Can you try remobing the content type

manumahendran
2022-08-08 16:21
removing*

gaurav.bajpai
2022-08-08 17:17
pact verification fails because it expects a string instead of a number

gaurav.bajpai
2022-08-08 17:18
I already tried removing content type, it doesn't help

lmendonca
2022-08-08 22:18
has joined #pact-jvm

jbrauchler
2022-08-08 22:44
has joined #pact-jvm

uglyog
2022-08-08 23:19
Use `withBinaryData`, it does exactly what you need

uglyog
2022-08-08 23:21
You are setting the content type to `application/json`, so the body will be a number. If it is just text, use `text/plain`

uglyog
2022-08-08 23:22
What are you looking to do?

tylerkron
2022-08-09 02:29
You probably need to tag someone @mike.key :wink:

tylerkron
2022-08-09 02:30
We have a monolith that?s still stuck on Java 8 so we can?t use `4.2.x` or `4.3.x`.

mike.key
2022-08-09 02:31
Not usually, but in this case maybe

tylerkron
2022-08-09 02:39
What?s the TL;DR? We are using: ? `au.com.dius.pact:consumer:4.1.39` ? `au.com.dius.pact:provider:4.1.39` ? On a Java 8 app ? Using Pactflow The problem is, when running provider verification, we get a no pacts found exception. Tomorrow I can post more details from setting breakpoints in the pact libraries.

tylerkron
2022-08-09 02:42
Anything you?d add to this @mike.key?

mike.key
2022-08-09 02:48
Jake is the right person to ask not me, I believe it's more of an error from the PactBroker code in CI that can't find the system vars that define where the broker is?different errors locally vs CI

tylerkron
2022-08-09 02:55
@jbrauchler

manumahendran
2022-08-09 07:57
im trying to understand how internal classes and libraries of pact works. its for my understanding/learning.

uglyog
2022-08-09 07:59
There won't be any documentation on internal libraries and classes. You'll need to read the source code.

cristideacc
2022-08-09 09:05
has joined #pact-jvm

cristideacc
2022-08-09 09:16
hello guys, i am using `valueFromProviderState` syntax in a test and i was wondering if there is any trick to apply a function on the value return by the state provider i.e the state populates the map with `userId` in the test to use something like ```newJsonBody((payload) -> payload.valueFromProviderState("id", () -> Base64.encode("${userId}"), "MTIzCg==")) .build() ```

cristideacc
2022-08-09 09:17
what i am trying to achieve is to avoid exposing same value from provider state with many variation (userId, userId in base64 and so on). please also suggest other way to achieve this

uglyog
2022-08-09 09:27
The provider state callback is the place to do it, in the consumer test you use an example value, and then you can replace it with whatever you need in the provider state callback

cristideacc
2022-08-09 10:11
@uglyog thank you for your response but i am not sure i follow, i invoke the provider state callback (`valueFromProviderState("id", "${userId}", "whatever")`) but i would like to be able to manipulate/change the injected value of userId (for example, encode it)

cristideacc
2022-08-09 10:12
can you give me an example on how to achieve that?

manumahendran
2022-08-09 12:35
ok

jbrauchler
2022-08-09 16:46
@uglyog

alison.stuart.contrac
2022-08-09 20:41
has joined #pact-jvm

uglyog
2022-08-09 23:03
That is the correct version to use with JDK 8

uglyog
2022-08-09 23:06
`valueFromProviderState("id", "${userId}", "whatever")` does not invoke anything, it configures things so that when provider state callback is invoked *on the provider side*, it will use the values returned from that instead of the example one. On the consumer side, it uses the example value.

uglyog
2022-08-09 23:07
So, coming back to your question, if you want to base 64 encode things, in the consumer test, you base 64 encode the example value (`whatever`), and then, in the provider verification test, you base 64 encode the returned `userId` value in the provider state callback.

remigijus.mazulis
2022-08-10 07:12
@remigijus.mazulis has left the channel

cristideacc
2022-08-10 07:32
got it, thank you. the goal was to avoid exposing flavours for the same value (`userId`) in the provider state callback. i managed to do this by adding a new generator to `LambdaDslJsonBody` which works almost the same as `ProviderStateGenerator` but before returning the value, applies a function which is provided as param. so the provider state callback does not duplicate returned values (with different flavours). not sure if would be widely used but seems like a simple addition to `ProviderStateGenerator` and `valueFromProviderState` i.e. default no op function as param for `valueFromProviderState` and `ProviderStateGenerator` class attribute which would be applied on value returned by ```this.ep.containsExpressions(this.expression, true) ? this.ep.parseExpression(this.expression, this.dataType, (ValueResolver)(new MapValueResolver(map)), true) : map.get(this.expression);``` and on `example` value

tylerkron
2022-08-10 14:58
Thanks @uglyog - we?ll dig in more and try to find more details on the failure here.

tischnerd
2022-08-11 06:49
has joined #pact-jvm

tischnerd
2022-08-11 08:39
Hello :wave: This might probably be a quick one, but it was not directly clear from the doc for me. I am using the newest Kotlin API. Are the methods `headers(...)` and `matchHeader(...)`, if not using REGEX in the first place, identical? I.e. do the following behave the same? ```builder .given(...) .uponReceiving(...) ... .headers("foo", "bar") // vs .matchHeader("foo", "bar")``` (same goes for other similar methods that have a `matchXXX` equivalent)

uglyog
2022-08-11 08:41
`headers` just sets the headers, `matchHeader` sets the headers and also sets up a regex matcher

tischnerd
2022-08-11 08:43
so when not interested in regex, i.e. just having a static value that should be matched 1:1, we can just use `headers` and it will also assert that the header has been send?

uglyog
2022-08-11 08:45
It will send the header with the value, and then on the provider side it will check that it receives that header with the same value

tischnerd
2022-08-11 08:50
For Kotlin, any opinions on a Lambda DSL for the actual `uponReceiving ... willRespondWith ...` part? I noticed that some examples in the docs indent the parts to visually separate the request and the response: ```builder .given("foo") .uponReceiving("something") .path("ping/pong") .method("POST") .body("Hello") .willRespondWith() .successStatus() .body("World") .build()``` But with most auto-formatting tools (IDE, Spotless, ...) this might not always be possible to achieve and it will just collapse back to: ```builder .given("foo") .uponReceiving("something") .path("ping/pong") .method("POST") .body("Hello") .willRespondWith() .successStatus() .body("World") .build()``` Now, it is fairly simple to add a Lambda DSL to achieve this indents: ```builder .given("foo") .uponReceiving("something") .path("ping/pong") { method("POST") body("Hello") }.willRespondWith() successStatus() body("World") }.build()``` Should I invest time into creating a PR, or am I overlooking something here? (I noticed one issue between `uponReceiving` and `path` though, since they are changing types from `...WithoutPath` to `...WithPath`, so I only managed to make the DSL cut at the `path` method)

tischnerd
2022-08-11 08:50
that sounds like a yes then. alright, thank you! :thumbsup:

tischnerd
2022-08-11 08:51
for reference, that would be the code to add such DSLs: ```fun PactDslRequestWithoutPath.path( path: String, addRequestMatchers: PactDslRequestWithPath.() -> PactDslRequestWithPath ): PactDslRequestWithPath = addRequestMatchers(path(path)) fun PactDslRequestWithoutPath.matchPath( pathRegex: String, pathExample: String, addRequestMatchers: PactDslRequestWithPath.() -> PactDslRequestWithPath ): PactDslRequestWithPath = addRequestMatchers(matchPath(pathRegex, pathExample)) fun PactDslRequestWithoutPath.pathFromProviderState( pathExpression: String, pathExample: String, addRequestMatchers: PactDslRequestWithPath.() -> PactDslRequestWithPath ): PactDslRequestWithPath = addRequestMatchers(pathFromProviderState(pathExpression, pathExample)) fun PactDslRequestWithPath.willRespondWith(addResponseMatchers: PactDslResponse.() -> PactDslResponse): PactDslResponse = addResponseMatchers(willRespondWith())```

uglyog
2022-08-11 08:52
PRs that make things better are always welcome

tischnerd
2022-08-11 08:53
awesome. will look into it, thanks :thumbsup:

uglyog
2022-08-11 08:58
Those DSLs are really old. They were written in 2014, and have just been added to over the years. I was planning on creating a new DSL for the V4 Pact format which has separate builders for the different types.

tischnerd
2022-08-11 08:59
ah, sounds cool. looking forward to that :thumbsup:

yousafn
2022-08-11 09:59
Like it @tischnerd thanks for sharing for thoughts with the group and for any additions in the future. We look forward to supporting you with any PR?s! Very neat thought, and will making grokking code in an IDE much nicer :ok_hand:

joel.wochele
2022-08-11 12:53
has joined #pact-jvm

tylerkron
2022-08-11 15:27
We followed up with a question in #pactflow

abubics
2022-08-11 23:32
I have some similar helper functions, I can share them here (or in PR comments) if you'd like more ideas :)

heinenm
2022-08-12 08:23
Thanks, it works!

yousafn
2022-08-12 11:41
Spread the helper love @abubics :yellow_heart: - I?m sure you?ve many little gems from over the years

evert.vanloo
2022-08-12 12:16
has joined #pact-jvm

tischnerd
2022-08-12 13:15
Sorry if this is simple stuff, but I feel like I am doing something fundamentally wrong when writing my (first more complex) body matcher (with *Kotlin* Lambda DSL). I guess I am misunderstanding one of the methods and its syntax. Unfortunately, the doc only showed very simple examples when it comes to the Lambda DSL. ```body(newJsonObject { newArray("value_added_taxes") { eachLike { integerType("id") newArray("values") { decimalType("rate") datetime("valid_since") // "2020-04-15T17:30:00Z" datetime("valid_until") // "2020-06-15T17:30:00Z" } } } })``` https://i.imgur.com/mLhIT5Y.png the generator creates this response (from the debug logger): https://i.imgur.com/yNrfnCS.png which is definitely not what I intended to get. i was more thinking of: ```{ "value_added_taxes": [ { "id": 0, "values": [ "rate": 0.12, "valid_since": "2020-04-15T17:30:00Z", "valid_until": "2020-06-15T17:30:00Z" ] } ] }```

jors.matthys
2022-08-12 13:27
has joined #pact-jvm

ricardo.maury
2022-08-12 18:34
has joined #pact-jvm

abubics
2022-08-14 07:28
Pretty sure I've shared these before, but here's my most recent sample :) ```import au.com.dius.pact.consumer.ConsumerPactBuilder import au.com.dius.pact.consumer.MockServer import au.com.dius.pact.consumer.PactTestExecutionContext import au.com.dius.pact.consumer.PactTestRun import au.com.dius.pact.consumer.PactVerificationResult import au.com.dius.pact.consumer.PactVerificationResult.Ok import au.com.dius.pact.consumer.dsl.LambdaDsl import au.com.dius.pact.consumer.dsl.LambdaDslJsonBody import au.com.dius.pact.consumer.dsl.LambdaDslObject import au.com.dius.pact.consumer.dsl.PactDslRequestWithPath import au.com.dius.pact.consumer.dsl.PactDslResponse import au.com.dius.pact.consumer.dsl.PactDslWithProvider import au.com.dius.pact.consumer.dsl.PactDslWithState import au.com.dius.pact.consumer.dsl.newJsonArray import au.com.dius.pact.consumer.dsl.newObject import au.com.dius.pact.consumer.model.MockProviderConfig import au.com.dius.pact.consumer.runConsumerTest import au.com.dius.pact.core.model.BasePact import au.com.dius.pact.core.model.RequestResponsePact import io.kotest.matchers.shouldNotBe import retrofit2.Call import retrofit2.Response import java.time.ZonedDateTime import java.util.Base64 fun pactBuilder() = ConsumerPactBuilder .consumer("[redacted]-consumer") .hasPactWith("[redacted]-api") fun buildPact( builder: PactDslWithProvider.() -> PactDslResponse ): RequestResponsePact = pactBuilder().builder().toPact() fun buildPact( given: String, builder: PactDslWithState.() -> PactDslResponse ): RequestResponsePact = pactBuilder().given(given).builder().toPact() operator fun <R> BasePact.invoke(auth: Boolean = true, createCall: RedactedClient.() -> Call<R>): R? { println() val result: PactVerificationResult = runConsumerTest( this, MockProviderConfig.createDefault(), object : PactTestRun<Response<R>> { override fun run(mockServer: MockServer, context: PactTestExecutionContext?): Response<R> { val client = buildClient<RedactedClient>(mockServer.getUrl(), auth) return client.createCall().execute() } } ) println("testPact result: $result") return ((result as? Ok)?.result as? Response<R>?)?.body() } fun PactDslRequestWithPath.jsonHeader() = matchHeader("Content-Type", "^application/json.*$", "application/json; charset utf-8") fun PactDslRequestWithPath.authHeader(user: String = "admin", pass: String = "admin") = matchHeader("Authorization", "^Basic .*$", "Basic ${"$user:$pass".base64}") val String.base64: String get() = Base64.getEncoder().encodeToString(encodeToByteArray()) fun oneOf(vararg values: String): String = values.joinToString("|") fun LambdaDslObject.zonedDateTime( fieldName: String, example: String = "2021-04-28T00:32:16.450595Z" ): LambdaDslObject = datetime( fieldName, "YYYY-MM-dd'T'HH:mm:ss.SSSSSSXXX", ZonedDateTime.parse(example) ) fun LambdaDslJsonBody.arrayLike(fieldName: String, eachBuilder: LambdaDslObject.() -> Unit): LambdaDslObject = minArrayLike(fieldName, 1) { eachBuilder(it) } infix fun PactDslRequestWithPath.jsonBody(bodyBuilder: LambdaDslJsonBody.() -> Unit): PactDslRequestWithPath = body(LambdaDsl.newJsonBody(bodyBuilder).build()) infix fun PactDslResponse.jsonBody(bodyBuilder: LambdaDslJsonBody.() -> Unit): PactDslResponse = body(LambdaDsl.newJsonBody(bodyBuilder).build()) fun PactDslResponse.jsonArray(times: Int = 1, body: LambdaDslObject.() -> Unit): PactDslResponse = body(newJsonArray { repeat(times) { newObject(body).build() } }) fun PactDslResponse.jsonArray(vararg body: LambdaDslObject.() -> Unit): PactDslResponse = body(newJsonArray { body.map { newObject(it).build() } }) infix fun <T> Iterable<T>.shouldContainMatch(findMatch: T.()->Boolean) = find(findMatch) shouldNotBe null```

abubics
2022-08-14 07:29
Sorry my reply is a bit late, I did just post a `datetime` example over in the other thread :slightly_smiling_face: it's a bit fiddly to get things working as DSL out of the gate, I mostly got those helpers from making them work manually, then extracting them out.

prateekm33
2022-08-15 00:46
has joined #pact-jvm

ahmed.fahmy
2022-08-15 09:10
has joined #pact-jvm

tpaktopsp
2022-08-15 18:47
has joined #pact-jvm

julian.schmidt
2022-08-16 09:03
has joined #pact-jvm

jack340
2022-08-16 09:11
has joined #pact-jvm

g.varga
2022-08-16 11:55
has joined #pact-jvm

gaurav.bajpai
2022-08-16 13:33
@uglyog text/plain doesn't work either

gaurav.bajpai
2022-08-16 13:34
Hi @uglyog , any suggestion for this?

lnthai2002
2022-08-16 15:02
has joined #pact-jvm

sarunas.kavaliauskas
2022-08-16 19:15
has joined #pact-jvm

tbansal
2022-08-17 10:30
has joined #pact-jvm

dekkofilms
2022-08-17 21:14
has joined #pact-jvm

nirajlalr
2022-08-18 09:46
has joined #pact-jvm

jon669
2022-08-18 11:14
has joined #pact-jvm

jon669
2022-08-18 11:21
I?ve been wondering the same thing. I have a service that has many endpoints and don?t want to have one HUGE verification test class. It would be nice to segment the tests into classes based on their endpoints.

gustavs.slutins
2022-08-18 11:25
Never really figured it out without having to write spaghetti. The easiest solution is to just rename the provider for each test that requires a different class, but we decided not to go with this, since it would look messy in the broker.


jon669
2022-08-18 14:52
This will only run verification tests on the `/customer` endpoint. ```@PactFilter(value = {"^/customer"}, filter = InteractionFilter.ByRequestPath.class) public class CustomerContractVerificationTest { ...```

michael.birchmeier
2022-08-18 19:27
has joined #pact-jvm

ben.crinion
2022-08-18 19:42
@ben.crinion has left the channel

jwang
2022-08-18 21:07
has joined #pact-jvm

msiyaj1
2022-08-18 22:03
has joined #pact-jvm

ben.hansen
2022-08-19 00:44
has joined #pact-jvm

lottie.kett
2022-08-19 12:08
has joined #pact-jvm


paul.lynn
2022-08-19 14:18
has joined #pact-jvm

duynguyenptithcm
2022-08-20 07:22
has joined #pact-jvm

uglyog
2022-08-21 23:25
You verification test needs to have all the provider state callbacks. The error message should be quite clear, look in the logs and it will show you what method you need to add.


abubics
2022-08-22 05:56
oh, forgot to include the call-site examples . . . they'd answer your original query a bit better . . .

gaudenz.halter
2022-08-22 07:52
has joined #pact-jvm

tischnerd
2022-08-22 08:21
thanks for the datetime example. but what about the test? something in the DSL syntax must be terribly wrong, cause the generated json has a totally wrong structure

tischnerd
2022-08-22 08:21
i just want a basic check that i get a json object that has an array where each array item has some entries. but somehow it moved all stuff into the top level in the generated json

tischnerd
2022-08-22 09:12
nvm. i found the issue. 2 mistakes: 1. `eachLike` is already an array. so ```newArray("foo") { eachLike { ... } }``` should just be: ```eachLike("foo") { ... }``` and 2. i was mixing up all the implicit `this` and explicit `it`s, ultimately adding to the wrong object

tischnerd
2022-08-22 09:30
@abubics i like that `arrayLike`, will use that in my own code base until u add it to pact directly. thanks

tischnerd
2022-08-22 10:03
I know this may sound a bit weird, but I have an use case where a response must only return a decimal that is like `0.12`, `0.35` or `0.5` etc. Essentially, it is "percentage" with maximal 2 digits after the separator. How would I add this to my contract? `decimalType` allows all kinds of decimals, such as `-1234.23456` `stringMatcher` will make it a string type instead of decimal Is there maybe some more general `matches(...)` which I could then tell the type + a custom regex matching? If not, how could I implement what I need as extension? Any hints? While at it, what about other similar stuff, such as _"any positive number"_?

harold.robson
2022-08-22 13:07
has joined #pact-jvm

bentzion.schochet
2022-08-22 13:27
has joined #pact-jvm

mat.delong
2022-08-22 14:03
has joined #pact-jvm

lnthai2002
2022-08-22 21:04
hello, i have an aggregation pom named all-modules-pom.xml and it has a build section with pact broker info but when i run mvn pact:publish -f all-modules-pom.xml i got error. Can you advise a solution?

abubics
2022-08-22 23:30
ok, I've gone and got some call-site examples for you :slightly_smiling_face:

uglyog
2022-08-22 23:31
There was a really old issue for using a format string (similar to how dates work), but there hasn't been anyone asking for it

uglyog
2022-08-22 23:31
A regex matcher will work

abubics
2022-08-22 23:32
This one uses the ZonedDateTime helper: ``` scenario("incomplete") { val pact = buildPact(given = "transaction in progress") { uponReceiving("a request to check the status of a running transaction").run { method("GET").matchPath( "/admin/amendment-batch/${RegexUUID}", "/admin/amendment-batch/${ConstUUID}" ).authHeader() }.willRespondWith().run { status(200) jsonBody { zonedDateTime("startDate") array("amendments") { a -> a.`object` { it.uuid("id", ConsistentUUID) it.zonedDateTime("startDate") it.zonedDateTime("endDate") it.stringValue("status", "Success") } a.`object` { it.uuid("id", ConsistentUUID) it.zonedDateTime("startDate") it.stringValue("status", "InProgress") } a.`object` { it.uuid("id", ConsistentUUID) it.stringValue("status", "NotStarted") } } } } } val response = pact { checkPublishAmendmentStatus(UUID.randomUUID().toString()) } println("In-progress transaction response: $response") response!!.apply { amendments shouldContainMatch { status == "Success" } amendments shouldContainMatch { status == "InProgress" } amendments shouldContainMatch { status == "NotStarted" } } }```

abubics
2022-08-22 23:35
this on uses jsonArray, but I think you're already good with it :sweat_smile: ``` scenario("published only") { val pact = buildPact(given = "several published amendments") { uponReceiving("a request to list admin amendments").run { method("GET").path("/admin/amendments") .query("unpublished=false") .authHeader() }.willRespondWith().run { status(200).jsonArray(3) { uuid("amendmentId", ConsistentUUID) stringType("displayId", "VC999") booleanValue("unpublished", false) } } } val response = pact { listAdminAmendments(unpublished = false) } response!!.forEach { it.amendmentId shouldBe ConsistentUUID it.displayId shouldBe "VC999" it.unpublished shouldBe false } }```

abubics
2022-08-22 23:36
Before I added quite so many DSL helpers, I was just using the Java8 lambda DSL with lots of `with`, `apply`, and `run`

tischnerd
2022-08-23 06:53
yeah. looks cool. thank you :slightly_smiling_face:

tischnerd
2022-08-23 06:54
how would that look like? if i use `stringMatcher` it would make it a string, i.e. `"123"` instead of a number type in json `123` in the generated json request/response. I need it to be a number type, but still want to have a matcher on it - didnt find any method for that at first glance

abubics
2022-08-23 06:54
Could definitely be improved with a native Kotlin DSL, instead of just a hack on top. But that was good enough while I haven't had time to contribute to the core libs.

volker.wengert
2022-08-23 10:59
has joined #pact-jvm

lnthai2002
2022-08-23 16:10
Hello, is there recommendation for using pact in a monorepo in which there are many projects interacting with each other through REST API ? Can a single can-i-deploy at a specific commit of the monorepo tell if all consumers and providers are compatible?

sathish.sundararajan
2022-08-23 19:32
has joined #pact-jvm

matt.fellows
2022-08-23 23:25
You'd need to identify each logical application within the mono repo. Pact can't magically know that your project is a mono repo or not

matt.fellows
2022-08-23 23:28
Hmmm. I wonder if a commit Sha _could_ be used to determine that in the future? Cc: @bethskurrie

patrick.lu
2022-08-24 02:12
has joined #pact-jvm

krishna.cv
2022-08-24 04:38
has joined #pact-jvm

bethskurrie
2022-08-24 04:41
You can enter all the applications in the monorepo in a single can-i-deploy command. I?ve done a demo https://github.com/pact-foundation/pact_broker/blob/master/script/data/monorepo.rb. ```pact-broker can-i-deploy --pacticipant monorepo-consumer-1 --version 1 --pacticipant monorepo-consumer-2 --version 1 --to-environment production Computer says no ¯_(?)_/¯ # CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT# --------------------|-----------|------------|-----------|----------|-------- monorepo-consumer-1 | 1 | provider-1 | 1 | false | 1 monorepo-consumer-2 | 1 | provider-2 | 1 | true | 2 # VERIFICATION RESULTS -------------------- 1. http://localhost:9292/pacts/provider/provider-1/consumer/monorepo-consumer-1/pact-version/6e0b1c114e7b8a4775ff584af54bac734408e31a/metadata/Y3ZuPTE/verification-results/109 (failure) 2. http://localhost:9292/pacts/provider/provider-2/consumer/monorepo-consumer-2/pact-version/dd1edab05d6a9f4ff7dc4f17dbf3ea585c8220cb/metadata/Y3ZuPTE/verification-results/110 (success) # The verification for the pact between version 1 of monorepo-consumer-1 and the version of provider-1 currently deployed or released to production (1) failed```

bethskurrie
2022-08-24 04:45
The `--to-environment` flag ensures that you are backwards compatible with all the applications that are already deployed in that environment. It may get confused if you have a bi-directional dependency between two apps within the monorepo, and each has a change that depends on the other. In that case, you may want to list each dependency explicitly and not use the --to-environment.

bethskurrie
2022-08-24 04:45
ugh, actually, you currently only can specify branch, tag, or version number in the explicit selectors. but it wouldn?t be much work to support: ```pact-broker can-i-deploy \ --pacticipant monorepo-consumer-1 --version 1 \ --pacticipant monorepo-consumer-2 --version 1 \ --pacticipant provider-1 --environment production \ --pacticipant provider-2 --environment production```

matt.fellows
2022-08-24 05:00
Yeah, so I was suggesting/asking if we could potentially _infer_ all of those by the virtue the git sha being identical.

bethskurrie
2022-08-24 05:24
theoretically yes.

bethskurrie
2022-08-24 05:24
but currently, no.

bethskurrie
2022-08-24 05:46
Ok, I?ve tested the monorepo with bi-directional dependencies between the monorepo apps, and it works as you would hope https://github.com/pact-foundation/pact_broker/blob/master/script/data/monorepo-bi-directional.rb

bethskurrie
2022-08-24 05:47
So, my advice is to use this format `pact-broker can-i-deploy --pacticipant monorepo-app-1 --version 2 --pacticipant monorepo-app-2 --version 2 --to-environment production`

bethskurrie
2022-08-24 05:47
you still need to explicitly name each app in the monorepo, but that shouldn?t change very often.

ravishankar.emc
2022-08-24 06:00
has joined #pact-jvm

alan.zhu
2022-08-24 08:54
has joined #pact-jvm

nabil.bourenane
2022-08-24 14:19
has joined #pact-jvm

lnthai2002
2022-08-24 19:59
Thank you very much. I am still confuse about the environment. Let say I have 5 applications in my monorepo con1, con2, con3 and prov1, prov2. All consumer apps uses both prov1 and prov2. Here is the 2 questions: 1/When publishing pact file from consumer test to pact broker, how can i specify the environment on the maven command line? I tried to set the environment in the pom like the screenshot below but i dont see any environment in the pact broker UI. 2/Now assuming that i have all the pact files uploaded to pact broker, i still need to list all the pacticipants in the can-i-deploy to make sure they all compatible, why do i need to specify --to-environment?

bethskurrie
2022-08-24 23:17
1. you don?t specify the environment when you publish the pacts. you specify it when you https://docs.pact.io/pact_broker/recording_deployments_and_releases using the pact cli. 2. if you only want to check if the monorepo apps are compatible with each other, you don?t need the --to-environment. If you are deploying the monorepo to an an envrionment where they also talk to other applications outside the monorepo apps, you do need the --to-environment.

bethskurrie
2022-08-24 23:18
I think it probably wouldn?t hurt to put the --to-environment in there anyway, because it means that if you add another dependency later on, it will be automatically added to the command (if that?s what you want).

tjones
2022-08-24 23:32
You also have to be careful in the order you run commands. I have an application that is its own consumer, and I have to run the pact tests first, and then publish the pact, before I can run the verification.

rholshausen
2022-08-25 00:06
Oh, I see the problem, there is no way with the DSL to configure a regex with a number value.

rholshausen
2022-08-25 00:17
Can you raise a GitHub issue for that at https://github.com/pact-foundation/pact-jvm

rholshausen
2022-08-25 00:19
I don't know Maven that well, but it looks like it is not finding the Pact plugin. Can you try adding it to your project POM?

bethskurrie
2022-08-25 04:34
meta

tjones
2022-08-25 04:55
> Essentially, it is "percentage" with maximal 2 digits after the separator. This is an aside, but personally I would do this with a string instead of a number. That way I would have full control, rather than it come down to how the number was serialised by whatever JSON library wrote it.

ami.ta
2022-08-25 06:05
has joined #pact-jvm

me1001
2022-08-25 07:24
has joined #pact-jvm

nidzgorskiadrian
2022-08-25 08:05
has joined #pact-jvm

abudi.hijazi.01
2022-08-25 10:59
Is there any way to test that an error has been thrown during the pact test ```@Provider("provider") @PactFolder("pacts") @ExtendWith(VertxExtension.class) public class PactContractTest { final static AuthSessionRepository authSessionRepositoryMock = mock(AuthSessionRepository.class); final static AuthCodeRepository authCodeRepositoryMock = mock(AuthCodeRepository.class); final static DateUtils dateUtilsMock = mock(DateUtils.class); final static WebClient webClientMock = mock(WebClient.class, RETURNS_DEEP_STUBS); static WebClient webTestClient; @BeforeAll static void init(Vertx vertx, VertxTestContext testContext) { var options = new WebClientOptions().setDefaultPort(8888); webTestClient = WebClient.create(vertx, options); TestSetupHelper.setupAndDeployVerticleForTests(vertx, testContext, authSessionRepositoryMock, authCodeRepositoryMock, dateUtilsMock, webClientMock); } @BeforeEach void set_context(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", 8888, "/")); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(VertxTestContext testContext, PactVerificationContext context) throws MalformedURLException { context.verifyInteraction(); testContext.completeNow(); } @State("returns id token as jwt") void create_id_token_as_jwt(){ } @State("token error") void assert_correct_error_is_thrown_for_bad_token_request(PactVerificationContext context) { // Assert that a certain exception is thrown } }``` in one of my tests I am expecting a custom error to be thrown, can I catch it in my pact test or is that out of the scope of pact?

dealandi
2022-08-25 11:50
has joined #pact-jvm

jreynolds
2022-08-25 12:44
has joined #pact-jvm

josh.steffensmeier
2022-08-25 13:18
has joined #pact-jvm

tjones
2022-08-25 14:30
I?m not sure what you?re asking for - this looks like a pact verification, so wouldn?t the error be marshalled and sent as a response?

tjones
2022-08-25 14:30
If yes, you can just put the error payload in the pact test like normal

abudi.hijazi.01
2022-08-25 14:31
There's an error sent in the response, that is tested in the pact interaction. There is also an internal error that is thrown in java, I was just asking if I can somehow assert that, the specific error has been thrown

abudi.hijazi.01
2022-08-25 14:32
With state, it runs before the pact test, so I can't expect an error to have been thrown when the test hasn't run yet

abudi.hijazi.01
2022-08-25 14:38
That's why I was asking if this was outside the scope of pact

lnthai2002
2022-08-25 15:44
you are right, this is maven issue indeed. It works if I invoke the goal like this: http://au.com.dius.pact.provider:maven:4.1.17:publish

lnthai2002
2022-08-25 20:08
Hello, when running verify (and publish result) on the provider side, I have to specify the version of the provider -Dpact.provider.version="1.2.3-$(git rev-parse --short HEAD)". However, the base version of the provider is usually defined in the pom of the provider (project.version). Is there some config in the pom that I can set so that I do not have to pass this directive to maven? I see for the consumer, i can do:

uglyog
2022-08-25 23:20
I assume the error that is thrown in Java is on the consumer side? On the provider side, if the response is an error, but matches what is in the Pact file, the test will pass.

tischnerd
2022-08-26 11:28
agreed. unfortunately, i dont have control over it. but yeah, the actual issue expands to stuff like "test that a number type is positive", which sounds like a valid use case

mhtkandpal10
2022-08-26 11:29
has joined #pact-jvm


lnthai2002
2022-08-26 13:50
thank you for the link to the record deployment, I need to add that to the CI/CD deployment job

dwalleck
2022-08-26 20:51
has joined #pact-jvm

lijinze01
2022-08-26 22:20
has joined #pact-jvm

mhaller
2022-08-27 00:19
has joined #pact-jvm

mvliannoi
2022-08-29 03:41
has joined #pact-jvm

haobei.ma
2022-08-29 06:06
has joined #pact-jvm

maram.elsayed
2022-08-29 08:52
has joined #pact-jvm

helloitsdave
2022-08-29 14:51
has joined #pact-jvm

mberkowitz
2022-08-29 16:16
has joined #pact-jvm

harii.ravii
2022-08-29 16:18
Hi Team, Need your input. I would like to know if there are any maven properties to enable/disable pact test when we run mvn clean install on the provider side.

lnthai2002
2022-08-29 16:42
I have the same concern last week and I end up using maven profile to enable pact test

matt.bremer
2022-08-29 20:10
has joined #pact-jvm

lennart.querter
2022-08-30 09:24
has joined #pact-jvm

lennart.querter
2022-08-30 09:26
@lennart.querter has left the channel

veaceslav.gaidarji
2022-08-30 15:29
has joined #pact-jvm

sharonw
2022-08-30 15:29
has joined #pact-jvm

grace.quek
2022-08-30 15:32
has joined #pact-jvm

s.kadium1
2022-08-30 16:12
has joined #pact-jvm

s.kadium1
2022-08-30 16:29
Hi, I'm facing the below issue while publishing the pact json : ```Publishing 'ppe-service-bus-issue-compilation-ppe-service-ent-issue-compilation.json' ... FAILED! 409 Conflict - {"error":"Cannot change the content of the pact for ppe-service-bus-issue-compilation version 1.0.0 and provider ppe-service-ent-issue-compilation, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number. For more information see https://docs.pact.io/go/versioning"}``` I'm not sure why it is failing and the same json file is getting verified when the run the provider from my local machine pointing to the json file. Any idea?

s.kadium1
2022-08-30 17:04
I have tried to invoke the endpoint that publishes the contract with a similar body mentioned below and got a response: ```{ "pacticipantName": "Foo", "pacticipantVersionNumber": "dc5eb529230038a4673b8c971395bd2922d8b240", "branch": "main", "tags": ["main"], "buildUrl": "https://ci/builds/1234", "contracts": [ { "consumerName": "Foo", "providerName": "Bar", "specification": "pact", "contentType": "application/json", "content": "<base64 encoded JSON pact>" } ] }``` Response: ```{ "notices": [ { "type": "error", "text": "Cannot change the content of the pact for ppe-service-ent-issue-compilation version 1.0.0 and provider ppe-service-ent-issue-compilation, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number. For more information see https://docs.pact.io/go/versioning" }, { "type": "info", "text": "" } ], "errors": { "contracts": [ "Cannot change the content of the pact for ppe-service-ent-issue-compilation version 1.0.0 and provider ppe-service-ent-issue-compilation, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number. For more information see https://docs.pact.io/go/versioning" ] } }``` I dont see any difference in the content that is causing this issue

matt.fellows
2022-08-30 22:07
Have you compared the versions to see the difference? My guess is the binary content is different


sumanta.roy
2022-08-31 01:33
has joined #pact-jvm

shuying.lin
2022-08-31 05:45
has joined #pact-jvm

s.kadium1
2022-08-31 06:56
Hey Matt, the version available in the pact server is same as the version im trying to upload.. agreed there is an update in the pact json, but these logs are not helping to find the actual conflict and now all our services are failing to get deployed with this error

matt.fellows
2022-08-31 06:57
why are you using the same version though? Have you read the versioning guide?

s.kadium1
2022-08-31 08:00
im kinda new to this.. let me try to put it this way.. so we have this ppe-service-ent-issue-compilation consumer that has a version 1.0.0 and now that the provider is passing few more properties in the response.. so the provider pact is updated with the new values..

s.kadium1
2022-08-31 08:00
when i put this json locally and run pact verify it is working like a charm.. only when im connecting to the actual pact broker it is throwing this exception..

s.kadium1
2022-08-31 08:01
the version is handled automatically i guess

s.kadium1
2022-08-31 08:01
apologies if im speaking rubbish

victor.lopez
2022-08-31 10:08
has joined #pact-jvm

s.kadium1
2022-08-31 10:09
Hi Matt, thanks for the suggestion, we have updated the version from 1.0.0 to 2.0.0 and it got published successfully, but I have question here: From last 3 years, we have been publishing the contract with the same version i.e. 1.0.0 and haven't come across this conflict error until now. Just wanted to know, if there is any cap under a specific version to have only a certain number of updates for a specific version?

s.kadium1
2022-08-31 10:34
And we were not updating the pact version because of the way we are handling our apis: ? We do not maintain older versions of our apis ? Normally versioning shows which consumer and provider versions are compatible ? Thats not a requirement or even a scenario for us

matt.fellows
2022-08-31 13:06
You can disable this check, but it's not recommended. If you search the pact docs you should be able to find the setting (it has the word "dangerous" and "modification" in it I think). You may have upgraded the broker which has enabled this setting.

matt.fellows
2022-08-31 13:08
What do you mean you don't maintain older version of your APIs? That's not why versioning is important, it tracks the version of your code that is being deployed. I highly recommend reading the versioning guide and the CI/CD guide to understand what guarantees you might be missing out on

s.kadium1
2022-08-31 14:21
thanks Matt for the valuable comments, we will take it further to implement the best practices to be incorporated to handle the pact publishing strategy

s.kadium1
2022-08-31 14:22
one last question, so are we saying that the pact broker update might be the reason for this exception to crop up?

nfinley
2022-08-31 15:52
has joined #pact-jvm


hartror
2022-09-01 06:26
has joined #pact-jvm

uralsmh
2022-09-01 10:37
has joined #pact-jvm

krystof.sykora
2022-09-01 12:34
has joined #pact-jvm

lesa
2022-09-01 14:34
has joined #pact-jvm

gunesmes
2022-09-01 15:31
has joined #pact-jvm

edouard.lopez
2022-09-02 10:04
Hello, some of our provider cannot verify its contracts any more and return an emty list of pacts from http://broker.org/pacts/provider/ms.advice-conversation/for-verification ```{ "_embedded": { "pacts": [] }, "_links": { "self": { "href": "http://broker.org/pacts/provider/ms.advice-conversation/for-verification", "title": "Pacts to be verified" } } }``` Yet I do have contracts in `/pacts/provider/ms.advice-conversation/`. What am I missing here?

edouard.lopez
2022-09-02 10:08
I recently created environment on my broker, could that be the cause of it? ``` docker run \ --rm pactfoundation/pact-cli:latest \ pact-broker \ create-environment \ --name prod \ --display-name "Production environment" \ --contact-name "see #pact-contract-testing-support" \ --production \ --broker-base-url $${PACT_BROKER_BASE_URL} \ --verbose```

matt.fellows
2022-09-02 10:21
The pacts to verify depends on selectors. What selectors are you using?

fabio.rodrigues
2022-09-02 10:35
i also got that sometimes


edouard.lopez
2022-09-02 14:50
@matt.fellows I didn't configure any selectors, where can I see that?

fabio.rodrigues
2022-09-02 14:53
when you set up wich pact to test , you don't use a consumer selector ?

fabio.rodrigues
2022-09-02 14:54
for example in pactnet we have something like this

fabio.rodrigues
2022-09-02 14:54
```ConsumerVersionSelectors = new[] { new ConsumerVersionSelector { MainBranch = true, Consumer = ConsumerParticipant } },```

edouard.lopez
2022-09-02 14:54
@fabio.rodrigues Not at the moment

fabio.rodrigues
2022-09-02 14:54
in jvm you should have something similar


edouard.lopez
2022-09-02 14:55
We have this error in CI: ```> Task :testContract FAILED AdvisorsControllerContractVerificationTest > pactVerificationTestTemplate(PactVerificationContext) > com.manomano.ms.advice_conversation.application.controllers.AdvisorsControllerContractVerificationTest.initializationError FAILED au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify Provider: ms.advice-conversation Source: Pact Broker https://broker.org at app//au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:50)```

fabio.rodrigues
2022-09-02 14:56
you should have a log entry (maybe you need to set the log level to debug) where you can see the post call to retrieve the contracts

fabio.rodrigues
2022-09-02 14:57
something like POST <pactflowBaseUrl>/<provider>/for-verification with Json Body {xxxxxxx:xxx, xxxx:xxxxx}

fabio.rodrigues
2022-09-02 14:58
in c# one: ```[10h26] 2022-08-31T07:31:01.8906579Z [DEBUG][pact_verifier::pact_broker] Sending JSON to https://outsystems.pactflow.io/pacts/provider/application-versioning-service/for-verification using POST: {"providerVersionTags":[],"includePendingStatus":true,"consumerVersionSelectors":[{"consumer":"publish-service","mainBranch":true}]}```

fabio.rodrigues
2022-09-02 14:58
see if you can find something similar

fabio.rodrigues
2022-09-02 14:59
and what response it got

edouard.lopez
2022-09-02 15:02
Got `POST` with ```"{"consumerVersionSelectors":[],"includePendingStatus":false}"``` ``` 08:59:10.342 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 >> "POST /pacts/provider/ms.advice-conversation/for-verification HTTP/1.1[\r][\n]" 08:59:10.345 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 >> "Content-Type: application/json; charset=UTF-8[\r][\n]" 08:59:10.348 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 >> "Accept: application/hal+json, application/json[\r][\n]" 08:59:10.349 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 >> "Accept-Encoding: gzip, x-gzip, deflate[\r][\n]" 08:59:10.350 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 >> "Content-Length: 60[\r][\n]" 08:59:10.351 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 >> "Host: http://broker.org [\r][\n]" 08:59:10.352 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 >> "Connection: keep-alive[\r][\n]" 08:59:10.355 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 >> "User-Agent: Apache-HttpClient/5.1.3 (Java/11.0.16)[\r][\n]" 08:59:10.356 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 >> "[\r][\n]" 08:59:10.361 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 >> "{"consumerVersionSelectors":[],"includePendingStatus":false}" 08:59:10.388 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 << "HTTP/1.1 200 OK[\r][\n]" 08:59:10.388 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 << "Date: Wed, 31 Aug 2022 08:59:10 GMT[\r][\n]" 08:59:10.388 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 << "Content-Type: application/hal+json;charset=utf-8[\r][\n]" 08:59:10.388 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 << "Content-Length: 191[\r][\n]" 08:59:10.388 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 << "Connection: keep-alive[\r][\n]" 08:59:10.389 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 << "Vary: Accept[\r][\n]" 08:59:10.389 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 << "X-Pact-Broker-Version: 2.102.1[\r][\n]" 08:59:10.389 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 << "X-Content-Type-Options: nosniff[\r][\n]" 08:59:10.389 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 << "[\r][\n]" 08:59:10.389 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-1 << "{"_embedded":{"pacts":[]},"_links":{"self":{"href":"http://broker.org /pacts/provider/ms.advice-conversation/for-verification","title":"Pacts to be verified"}}}"```

edouard.lopez
2022-09-02 15:04
We are using ``X-Pact-Broker-Version: 2.102.1` and pact lib `4.3.14`

fabio.rodrigues
2022-09-02 15:44
yeah, you're not using any selectors

fabio.rodrigues
2022-09-02 15:44
try to set includePendingStatus as true

alanwallaceross
2022-09-02 16:27
has joined #pact-jvm

wdridi1
2022-09-02 18:59
has joined #pact-jvm

daviseago
2022-09-03 02:16
has joined #pact-jvm

edouard.lopez
2022-09-05 15:14
Related to my previous messages (above), I do have a contract between my consumer and provider as seen in the first image but none when I select the `latest version` on the consumer. That could explains `NoPactsFoundException` , but I don't understand how this happens? It was working before and my upgrade to `2.102.1` was a more than a month ago. ```au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify```

hsanghavi538
2022-09-06 02:33
has joined #pact-jvm

thibaut.bodart
2022-09-06 10:41
has joined #pact-jvm

bastien.decroix
2022-09-06 11:45
has joined #pact-jvm

pabcagi
2022-09-06 12:28
has joined #pact-jvm

pabcagi
2022-09-06 12:38
Hi, one question, I have an openAPI 3.0.3 spec with "oneOf" for body responses, when I match the pact agains swagger-mock-validator, I get the error "response.body.incompatible: 1". exists any matcher that allows to match with one of the responses?

patrickbadley
2022-09-06 13:25
has joined #pact-jvm

edouard.lopez
2022-09-06 15:52
What the alternative to of `consumerVersionSelectors` in `@PactBroker` annotation? I get this IDE message? JavaDoc says to use the same method (apologies I'm not familiar with Java) > Use consumerVersionSelectors method or pactbroker.consumerversionselectors property instead


james.grubb
2022-09-06 19:19
has joined #pact-jvm

snehasingh291506
2022-09-06 19:42
has joined #pact-jvm

patrickbadley
2022-09-06 19:54
@patrickbadley has left the channel

senchu.pampoorickal
2022-09-06 20:15
has joined #pact-jvm

senchu.pampoorickal
2022-09-06 20:18
:wave: Hello, team!

senchu.pampoorickal
2022-09-06 20:40
I am new to PACT and trying to use pact-java for contract testing for a java microservice. I understand the concept of consumer test which generates a pact contract file and uploaded it to the broker. Now I have a question about provider side testing. I read that the provider tests are run against the actual service. So I start the provider service in a container environment in my pipeline before tests are run. My provider service interacts with a database and based on the value obtained from the DB do some logic processing and replay with the response. These are the api's I need to do the provider side testing 1. POST api to create a new transaction. This API will respond with a unique transaction id and owner id. 2. POST api to get the base encoded value of transaction .The request accepts the transaction id and own id in the request body and validate against with db and if the details provided in the request is correct respond with base64 encoded value if the entry is not present in the db respond with a 404 status code. I have create a provider test for the api 1 but for the API 2 to test I need the transaction id and owner id obtained as response of API test 1. Qn1 : Do need to run the provider api against the actual server in a test docker container in pipeline. Qn2 : Do we need to mock the service layer in the provider service as we interested only in the contract Qn3 : How to get the provider testing 1 response and it can be used as input for provider side test 2

bethskurrie
2022-09-06 23:06
@edouard.lopez are you able to share a redacted copy of your database with me so I can debug it? It should always have a latest version!!!

bethskurrie
2022-09-06 23:07
If you can export a dump of your database, import it into a new db, then run this script https://github.com/pact-foundation/pact_broker/blob/master/script/prod/redact-data.sql

bethskurrie
2022-09-06 23:07
You?ll need to identify the id of the problem consumer and provider before you redact it, so I know which data to look for.

bethskurrie
2022-09-06 23:12
It doesn?t seem to affect all consumers, because the one in the test broker is working fine with that selector.



tjones
2022-09-07 03:07
We'll need more information to be able to help with this. What is in your pact? What is in your spec?

tjones
2022-09-07 03:08
Pact doesn't support "or", because that's not how it works - for more information see https://docs.pact.io/faq#why-is-there-no-support-for-specifying-optional-attributes

tjones
2022-09-07 03:09
but, if your pact matches one of the oneOf types, it should still pass. So I think something else is going on.

james.weng
2022-09-07 03:22
Hi do we have an example to use consumer version selector in kotlin? Thanks. Where in the code should i put this in ? ```@PactBrokerConsumerVersionSelectors fun consumerVersionSelectors(): SelectorBuilder = SelectorBuilder() .branch("main") .environment("prod") .environment("qa") .environment("int")```


james.weng
2022-09-07 03:38
Thanks. I give it a try

uglyog
2022-09-07 03:42
Qn1: You can either run it against the actual service, or you can use a test to run the verification. Using a test means you can mock out collaborators and persistence layers so you don't need things like a database. See https://github.com/pact-foundation/pact-jvm/tree/master/provider/junit5

uglyog
2022-09-07 03:43
Qn2: You don't *need* to mock anything, but it does make the tests easier to write

uglyog
2022-09-07 03:45
Qn3: No, Pact tests the different interactions in isolation, so you can't have dependencies between them. You use Provider States to setup the correct state for each interaction. See https://docs.pact.io/getting_started/provider_states


uglyog
2022-09-07 06:00
You don't need `called = true` or the `companion object`, those were just for that test

uglyog
2022-09-07 06:01
Do you have any Pacts with the branch set as `master`?

james.weng
2022-09-07 06:02
yup i believe so

james.weng
2022-09-07 06:03
the code keep saying consumerVersionSelectors is never used. is that right?

uglyog
2022-09-07 06:05
It should be called, but at runtime so the IDE won't know that.

uglyog
2022-09-07 06:06
we will need to look at the debug logs to see what selectors are being sent to the broker

james.weng
2022-09-07 06:06
i see this `16:05:17.740 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 >> "[\r][\n]" 16:05:17.740 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 >> "{"consumerVersionSelectors":[{"branch":"master"}],"includePendingStatus":false}" 16:05:18.004 [Test worker] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"

james.weng
2022-09-07 06:07
whole debug log

uglyog
2022-09-07 06:07
Ok, looks like those selectors are working correctly

james.weng
2022-09-07 06:08
but i dont quite understand at pactflow everything seem to be ticked off

james.weng
2022-09-07 06:08
like would i expect that only master get verified?

james.weng
2022-09-07 06:09
i see all the consumers with the provider branches . i thought would only be master. correct me if i am not understanding something right

uglyog
2022-09-07 06:10
> The pact at https://airwallex.pactflow.io/pacts/provider/SmeApiPactProvider/consumer/ApprovalsApproveMutationPactConsumer/pact-version/5cff543e5114655ded425a6a84b03457f5f9b468 is being verified because the pact content belongs to the consumer version matching the following criterion:\n * latest version from branch 'master' (9ebc76da)

uglyog
2022-09-07 06:10
That is in the logs, so the selectors are working

uglyog
2022-09-07 06:10
You can see that version is the one in your screenshot

james.weng
2022-09-07 06:11
but why does all the consumer version seem to be "verified"

james.weng
2022-09-07 06:11
from the pactflow ui

uglyog
2022-09-07 06:11
I have just deleted the log, in case it has sensitive info in it

james.weng
2022-09-07 06:12
thanks!

james.weng
2022-09-07 06:12
could you help me understand a little how i should read the pactflow UI

james.weng
2022-09-07 06:12
to match w the selectors

uglyog
2022-09-07 06:12
They will all be verified if the Pacts are all the same

james.weng
2022-09-07 06:13
i see but if only master is unique and the rest is different

james.weng
2022-09-07 06:13
only master will have a tick?

uglyog
2022-09-07 06:13
The Pact broker creates versions of Pacts based on their contents, so if they have the same contents, they are the same Pact

james.weng
2022-09-07 06:13
got it

uglyog
2022-09-07 06:14
Yes, if master was different, it should only be verified

pabcagi
2022-09-07 06:14
yes, it should match, but i got this even with a simple example. This is my pact.json ```{ "consumer": { "name": "consumer-sync" }, "interactions": [ { "description": "Read item", "request": { "matchingRules": { "path": { "combine": "AND", "matchers": [ { "match": "regex", "regex": "/read/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" } ] } }, "method": "GET", "path": "/read/2b4665bb-8cf0-dc20-1d1c-fc143c17eb84" }, "response": { "body": { "id": "e2490de5-5bd3-43d5-b7c4-526e33f71304", "number": 100 }, "generators": { "body": { "$.id": { "type": "Uuid" }, "$.number": { "max": 2147483647, "min": 0, "type": "RandomInt" } } }, "headers": { "Content-Type": "application/json" }, "matchingRules": { "body": { "$.id": { "combine": "AND", "matchers": [ { "match": "regex", "regex": "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" } ] }, "$.number": { "combine": "AND", "matchers": [ { "match": "number" } ] } } }, "status": 200 } } ], "metadata": { "pact-jvm": { "version": "4.3.9" }, "pactSpecification": { "version": "3.0.0" } }, "provider": { "name": "provider-sync" } }``` And this is my openApi spec ```openapi: 3.0.3 info: title: example-api description: | Example Public API. version: 0.3.0-SNAPSHOT license: name: mylicense url: https://mydomain.com/license servers: - url: https://mydomain.com/service paths: /read/{uuid}: get: summary: "Read one item" operationId: "read" parameters: - in: path name: uuid schema: type: string format: uuid required: true description: UUIDv4 of the item responses: "200": description: OK content: application/json: schema: type: "object" oneOf: - $ref: "#/components/schemas/read" - $ref: "#/components/schemas/readDetail" "404": description: "Item Not Found" "403": description: "Forbiden Access" "401": $ref: "#/components/responses/UnauthorizedError" components: responses: UnauthorizedError: description: Access token is missing or invalid BadRequestError: description: Request parameters invalid schemas: read: required: - id properties: id: type: string format: uuid readDetail: required: - id properties: id: type: string format: uuid number: type: integer format: int32``` And this is my swagger-mock-validator response: ```Mock file "pacts/consumer-sync-provider-sync.json" is not compatible with spec file "openapitest.yml" 1 error(s) response.body.incompatible: 1 0 warning(s) { warnings: [], errors: [ { code: 'response.body.incompatible', message: 'Response body is incompatible with the response body schema in the spec file: should match exactly one schema in oneOf', mockDetails: { interactionDescription: 'Read item', interactionState: '[none]', location: '[root].interactions[0].response.body', mockFile: 'pacts/consumer-sync-provider-sync.json', value: { id: 'e2490de5-5bd3-43d5-b7c4-526e33f71304', number: 100 } }, source: 'spec-mock-validation', specDetails: { location: '[root].paths./read/{uuid}.get.responses.200.content.application/json.schema.oneOf', pathMethod: 'get', pathName: '/read/{uuid}', specFile: 'openapitest.yml', value: [ { required: [ 'id' ], properties: { id: { type: 'string', format: 'uuid' } } }, { required: [ 'id' ], properties: { id: { type: 'string', format: 'uuid' }, number: { type: 'integer', format: 'int32' } } } ] }, type: 'error' } ] } Error: Mock file "pacts/consumer-sync-provider-sync.json" is not compatible with spec file "openapitest.yml"```

james.weng
2022-09-07 06:14
For this unit test because it is always needing a pact flow token. Is there a good practice i can run it locally? It works well in my pipeline but im just wondering if there is a good way to run it locally.

james.weng
2022-09-07 06:15
or user always have to manually set the environment variable to make it work

uglyog
2022-09-07 06:15
If the token is set with an environment variable, you can use that locally.

uglyog
2022-09-07 06:16
It is the safest way, because the token will be gone when you close your console

james.weng
2022-09-07 06:18
the error message it returns for incorrect token dosen look very indicative to user? is there a way i can make it more explicit? `Parameter specified as non-null is null: method com.airwallex.expenseservice.graphql.MutationPactTest.setUp, parameter context java.lang.NullPointerException: Parameter specified as non-null is null: method com.airwallex.expenseservice.graphql.MutationPactTest.setUp, parameter context at com.airwallex.expenseservice.graphql.MutationPactTest.setUp(MutationPactTest.kt)`

james.weng
2022-09-07 06:19
i deleted my code snippets above in case there is something sensitve fyi

uglyog
2022-09-07 06:22
That is Kotlin failing because the parameter is null, not much we can so about that message. You can add `?` to the type of the context, but it will be null in the method

uglyog
2022-09-07 06:22
I don't think the context can be used in the setup, it is not created yet

james.weng
2022-09-07 06:34
Would it be advisable to use the read only token for running locally?

pabcagi
2022-09-07 06:38
it's extrange. I don't know what it happens. What is wrong?

nagasrinivas.thota
2022-09-07 06:56
has joined #pact-jvm

tjones
2022-09-07 07:15
My guess is that `format: uuid` is not the same in the validator as in your pact - it's challenging because the openapi spec doesn't define uuid.

tjones
2022-09-07 07:15
I agree that your pact matches that spec, so this is a problem with the validator I reckon. I would contact them on their issue tracker.

pabcagi
2022-09-07 07:19
I have tried also to remove the uuid and use a number and a string, and happens the same. But if I remove one of the refs in the "oneof" response, the pact passes and it's verified.

pabcagi
2022-09-07 07:19
So I think the problem is with the oneOf

pabcagi
2022-09-07 07:30
maybe the problem is with swagger-mock-validator

tjones
2022-09-07 08:06
definitely


pabcagi
2022-09-07 08:10
thanks Timothy

pabcagi
2022-09-07 08:12
one more question why exists two different swagger-mock-validator one in bitbucket and another in github from pactflow?


tjones
2022-09-07 08:13
No idea, ask in #pactflow

pabcagi
2022-09-07 08:13
thanks!

edouard.lopez
2022-09-07 09:28
I will work with one of our SRE to that goal

mahinsyeda99
2022-09-07 09:40
has joined #pact-jvm

lisnychyis
2022-09-07 14:00
has joined #pact-jvm

lisnychyis
2022-09-07 14:34
Hi guys, maybe you can help me. i am trying to understand what should i change in my `provider` test. ```@Provider("provider-adapter") @PactFolder("pacts") class ProviderContractTest { @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun testTemplate(pact: Pact?, interaction: Interaction?, context: PactVerificationContext?) { context?.verifyInteraction() } @BeforeEach fun before(context: PactVerificationContext?) { context?.target = MessageTestTarget() } @State("ProviderState") fun providerState() { } @Suppress("unused") @PactVerifyProvider("some test") private fun verifyProvider(): String { return "{ \"name\" : \"test\"}" } }``` After test run i am getting the following message: ```Only message interactions can be used with an AMPQ test target java.lang.UnsupportedOperationException: Only message interactions can be used with an AMPQ test target at au.com.dius.pact.provider.junit5.MessageTestTarget.prepareRequest(TestTarget.kt:184) at au.com.dius.pact.provider.junit5.PactVerificationExtension.beforeTestExecution(PactVerificationExtension.kt:117) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeTestExecutionCallbacks$5(TestMethodTestDescriptor.java:188) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:199)```

marek.czerwinski
2022-09-07 16:07
has joined #pact-jvm

uglyog
2022-09-07 23:17
You have set `context?.target = MessageTestTarget()`, but the pact files being verified must contain HTTP interactions.

xiaofeng02111
2022-09-08 03:20
has joined #pact-jvm

jayvdb
2022-09-08 06:22
has joined #pact-jvm

lisnychyis
2022-09-08 08:25
@uglyog thanks for you reply. hmm but don?t see http interactions instructions in pact file.

vvarunbajpai1988
2022-09-08 12:13
has joined #pact-jvm

zakir
2022-09-08 12:55
has joined #pact-jvm

gregory.hanson
2022-09-08 12:56
has joined #pact-jvm

zakir
2022-09-08 13:00
Hello, I'm having provider authorization problem with pact 4.3.14 I've added the authorization in the following method. However, it fails with the following message: `expected status of 200 but was 401` ``` @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context, HttpRequest request){ request.addHeader("Authorization", "Bearer a_valid_jwt_token"); context.verifyInteraction(); }``` Thanks in advance.

matt.fellows
2022-09-08 13:20
I?d suggest enabling debug level logs to see if Pact is passing it through. If you can log in your auth API that would help also

zakir
2022-09-08 13:22
Ok, trying

zakir
2022-09-08 13:32
Thanks for your quick reply. I've found the problem. In the `application.yml` file I have the following entries with different `issuer` value. ``` security: oauth2: resourceserver: jwt: issuer-uri: okta: oauth2: issuer: client-id: client-secret: ``` We don't need both of them. It actually confusing. So I removed the above one.

ashishmerani
2022-09-08 21:54
has joined #pact-jvm

ashishmerani
2022-09-08 22:11
Hey all, I am writing a simple provider test with ```"au.com.dius.pact.provider:junit5:4.1.39"``` I have specified `@PactFolder("src/contractTest/")` but the test fails with the following error ```1.1) Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)``` It fails on `context.verifyInteraction();` under ``` @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(PactVerificationContext context) { context.verifyInteraction(); }``` I am trying to understand why it is making the call to localhost when I have specified a local path under @PactFolder annotation. Can anyone help?

matt.fellows
2022-09-08 22:15
You need to specify a target of the provider test - i.e. where the running provider is to test the contracts against. As you haven't specified one it's using the default

matt.fellows
2022-09-08 22:15
Check out the docs/examples for how to specify the location of your provider

ashishmerani
2022-09-08 22:25
Could you point me to an example that has this setup? Thank you.

matt.fellows
2022-09-08 22:34
Howtoexamples


matt.fellows
2022-09-08 22:35
Or the JVM docs at http://docs.pact.io

ashishmerani
2022-09-08 22:37
I did go through them once but I'll look more. Thanks.

uglyog
2022-09-08 23:01
You're loading from a directory with `@PactFolder("pacts")`

uglyog
2022-09-08 23:02
It will load all matching pacts from that directory

ashishmerani
2022-09-08 23:44
Looks like I have to specify the test target (from docs-> ) ``` @BeforeEach void before(PactVerificationContext context) { context.setTarget(HttpTestTarget.fromUrl(new URL(myProviderUrl))); // or something like // context.setTarget(new HttpTestTarget("localhost", myProviderPort, "/")); }```

ashishmerani
2022-09-08 23:44
Does that mean I have to serve my contract file just for pact to verify? :thinking_face:

matt.fellows
2022-09-08 23:45
In not sure what you mean sorry

matt.fellows
2022-09-08 23:47
You need to start the provider locally, and then point test target at the provider

matt.fellows
2022-09-08 23:47
Pact needs to check your provider is compatible with the contract

ashishmerani
2022-09-08 23:51
I didn't start it locally. I will try that. Thank you.

matt.fellows
2022-09-08 23:52
:+1:

james.weng
2022-09-09 00:43
I have published a pact with a different provider version and branch and tests mentioned it is published but i dont see it in pactflow. Is there a reason why? Eg i published one for master branch but i still see the feature branch name?

james.weng
2022-09-09 01:49
@uglyog is pact having some issues w the publishing? I see for provider but pactflow is just not updated. ```worker","logger":"au.com.dius.pact.provider.DefaultVerificationReporter","message":"Published verification result of \u0027Ok(interactionIds\u003d[43fe5659a8234dd73c1f537b59b7ccf92091e6c8])\u0027 for consumer \u0027Consumer(name\u003dApprovalsApproveMutationPactConsumer)\u0027","context":"default"}```

james.weng
2022-09-09 01:49
even for a similar use case of a branch that i was doing yesterday. or somehow i overlooked something..hmm

uglyog
2022-09-09 01:59
If you go to the Matrix tab, you will see all the publish and verification details

uglyog
2022-09-09 02:01
> Eg i published one for master branch How are you setting the provider branch?

james.weng
2022-09-09 02:09
in the pipeline. upon investigating further could be the tests are not run or skipped at times . more of configuration issue on my end. thanks for checking

lisnychyis
2022-09-09 07:45
yes, but i only have this pact file there.

ramesh.ambastha
2022-09-09 11:06
has joined #pact-jvm

nickm
2022-09-12 17:15
has joined #pact-jvm

uzma_khan
2022-09-12 18:13
has joined #pact-jvm

uzma_khan
2022-09-12 18:31
Has anyone here used maven to publish pacts to pactflow?

uzma_khan
2022-09-12 18:51
Specifically looking for advice on using api tokens along with pact:publish target


rholshausen
2022-09-12 23:01
But we recommend you use the Pact CLI instead, if you can

bethskurrie
2022-09-13 01:18
@edouard.lopez I?m keen to have a look at this. I?ve had a look at Fabio?s issue, but I haven?t been able to reproduce it.

bethskurrie
2022-09-13 01:19
> Would it be advisable to use the read only token for running locally? @james.weng yes.

james.weng
2022-09-13 01:19
Yeap this is what we did. Thanks

bethskurrie
2022-09-13 01:20
And use the system account token for CI/CD

zakir
2022-09-13 07:15
Hello, I'm trying to run 2 pact tests. However, they failed with the following exception. ```2022-09-13 13:09:20.063 ERROR 43371 --- [ main] o.s.test.context.TestContextManager : Caught exception while allowing TestExecutionListener [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@63ce874f] to prepare test instance [no.mentordigital.campaigndb.contracts.ITCampaignApiContractCampaignMasterAdmin@41ac1ebf] java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.PortInUseException: Port 8080 is already in use``` If I remove one test, the other executes successfully. Below are given my tests ```@Slf4j @Provider("campaign-manager") @Consumer("subscription") @PactBroker( url = "http://0.0.0.0:9292/", authentication = @PactBrokerAuth(token = "a-valid-token")) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) public class ITCampaignApiContractSubscription { @Autowired ObjectMapper objectMapper; @Autowired CampaignRepository campaignRepository; @Autowired ProductRepository productRepository; @MockBean ClientRegistrationRepository clientRegistrationRepository; @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", 8080)); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @State("It has a request to get a campaign by slug name") public void toStateWithData() { saveCampaignForContractTest(); }``` ```@Slf4j @Provider("campaign-manager") @Consumer("campaign-master-admin") @PactBroker( url = "http://0.0.0.0:9292/", authentication = @PactBrokerAuth(token = "a-valid-token")) @SpringBootTest( classes = TestWebSecurityConfig.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) class ITCampaignApiContractCampaignMasterAdmin { @Autowired ObjectMapper objectMapper; @Autowired CampaignRepository campaignRepository; @Autowired ProductRepository productRepository; @MockBean ClientRegistrationRepository clientRegistrationRepository; @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", 8080)); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @State("It has a request to get a campaign by id") public void toStateWithData() { saveCampaignForContractTest(); }``` I tried with different ports, but no luck.

uglyog
2022-09-13 07:25
This is not a Pact issue. Your test is trying to start the server on a port that is already being used. I assume that your test is not stopping your server correctly (i.e. the first test runs, and uses port 8080, then the second one runs and 8080 is already in use)

uglyog
2022-09-13 07:25
You can get each test to use a random port

uglyog
2022-09-13 07:26
Or try work out why the server is not shutting down correctly

zakir
2022-09-13 07:26
Yes, that is the problem. But 2 pact tests cannot run together. The 1st one doesn't shutdown the server properly.

uglyog
2022-09-13 07:27
Use a random port then

tjones
2022-09-13 07:27
Pact should shutdown the server correctly, unless there's something misconfigured

zakir
2022-09-13 07:28
I used the random port like below, but didn't work ```@Provider("campaign-manager") @Consumer("campaign-master-admin") @PactBroker( url = "http://0.0.0.0:9292/", authentication = @PactBrokerAuth(token = "")) @SpringBootTest( classes = TestWebSecurityConfig.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class ITCampaignApiContractCampaignMasterAdmin { @Autowired ObjectMapper objectMapper; @Autowired CampaignRepository campaignRepository; @Autowired ProductRepository productRepository; @MockBean ClientRegistrationRepository clientRegistrationRepository; @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost")); }```

uglyog
2022-09-13 07:28
This is a Spring test. Spring manages the test context.

uglyog
2022-09-13 07:30
You need to set the port here: ```context.setTarget(new HttpTestTarget("localhost", <port>));```

zakir
2022-09-13 07:30
I used random port ```@SpringBootTest( classes = TestWebSecurityConfig.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)``` That's why I didn't use any port

uglyog
2022-09-13 07:31
You can inject it into the test using the ```@LocalServerPort``` annotation

zakir
2022-09-13 07:33
Ok, trying

zakir
2022-09-13 07:35
It works !!

zakir
2022-09-13 07:36
Thanks a lot :+1:

zakir
2022-09-13 07:36
:heart:

dpal
2022-09-13 10:47
> Hello, Hello, the import for the below is not happening for me.

dpal
2022-09-13 10:47
```import au.com.dius.pact.provider.junit5.AmpqTestTarget```

dpal
2022-09-13 10:48
using the below dependency for it ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.3.14</version>``` any help will be appreciated. Thanks

stefan.tertan
2022-09-13 15:28
has joined #pact-jvm

uzma_khan
2022-09-13 20:18
Haven't used Pact CLI, but getting an odd error with maven. Execution default-cli of goal au.com.dius.pact.provider:maven:4.1.7:publish failed: Expected a HAL+JSON response from the pact broker, but got a response with no '_links'. URL: 'http://test-pactflow.pactflow.io', LINK: 'pb:publish-pact' -> [Help 1]

tjones
2022-09-14 00:54
Not much to go on here. What error are you getting? What have you tried?

konitzert
2022-09-14 07:11
has joined #pact-jvm

edouard.lopez
2022-09-14 08:48
One project in my company added the ``@Consumer(?)`` annotation on the provider verification class, am I correct assuming this will only verify the provider contract between given provider and consumer, excluding others? ```@Provider("ms.seller-opt-out") @Consumer("ms.channel-management-rule-applier") ? public class SellerOptOutRuleRuleApplierPublisherPactTest {``` I see you ~can use system property https://docs.pact.io/implementation_guides/jvm/docs/system-properties~ https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors to do this. Is there still some use-cases for the annotation approach?

dpal
2022-09-14 10:26
I tried "mvn clean install" and I always get "can not resolve symbol AmpqTestTarget"

daniel.puiu
2022-09-14 13:43
has joined #pact-jvm

ashishmerani
2022-09-14 23:01
Is there a way to make sure that if provider changes the name from `id` to `ids` the contract test would fail? ```{ "id": "5", "type": "something" }``` I looked at .stringValue which only compares "5" and not `id` itself.

tjones
2022-09-15 01:12
I'm not sure I understand your question. If you give pact this object, and the provider changes so that the field you are expecting (in this case `"id"`) is not there any more (which would happen if it was renamed) then the pact will fail. If it's not failing, there's something else going on

ashishmerani
2022-09-15 01:22
Yes, I did rename the field from `id` to `ids` in provider. Contract still passed. I tired using `.stringType("id", "5")` from `PactDslJsonBody` and ``` object.stringType("id", "5");``` from `LambdaDsl.newJsonBody;` still the test won't fail.

ashishmerani
2022-09-15 01:24
If I change the data type of id from String to int in provider with `.stringType("id", "5")` (from consumer) that it does fail.

tjones
2022-09-15 01:26
Are you sure that the provider isn't returning the `id` property?

tjones
2022-09-15 01:27
I'm not too familiar with the JVM DSL - can you share more of your test?

ashishmerani
2022-09-15 01:27
Let me check once again in debug mode for `context.verifyInteraction();`

abubics
2022-09-15 01:37
If the provider changes a field name (e.g. `id` to `ids`), the consumer test still won't fail, but the provider verification should.

tjones
2022-09-15 01:47
Oh right! Yes, that's a good callout. The consumer test is setting up the expectations for the provider. It will only fail if: 1) Your client doesn't send the request you said it would 2) Your client didn't understand the response you said it would. If the client's expectations (recorded in the pact) don't match the provider, the verification will fail later on.

ashishmerani
2022-09-15 01:49
Yes, in my case consumer is asking for `id` in contract and provider renamed it to `ids` I am expecting the provider test to fail but it passes.

ashishmerani
2022-09-15 01:52
in `PactVerificationContext.kt` expectedResponse has ``` status: 200 headers: {Content-Type=[application/json]} matchers: MatchingRules(rules={body=Category(name=body, matchingRules={$.id=MatchingRuleGroup(rules=[au.com.dius.pact.core.model.matchingrules.TypeMatcher@3bf0d1fb], ruleLogic=AND, cascaded=false), $.type=MatchingRuleGroup(rules=[au.com.dius.pact.core.model.matchingrules.TypeMatcher@3bf0d1fb], ruleLogic=AND, cascaded=false)})}) generators: Generators(categories={}) body: PRESENT({"id":"5","type":"House"})``` actualResponse has ```ProviderResponse(statusCode=200, headers={Date=[Thu, 15 Sep 2022 ], Content-Type=[application/json], Transfer-Encoding=[chunked]}, contentType=application/json, body={"type":"House","id":"5"})```

ashishmerani
2022-09-15 01:52
expect and actual both match in provider; that's why it's passing I think.

ashishmerani
2022-09-15 01:53
I have renamed all instances of `id` to `ids` tho :thinking_face:

tjones
2022-09-15 04:49
If you have renamed them all, then the question is why your actual response doesn't have the new name

tjones
2022-09-15 04:49
are you mocking the actual response? (this is not a good idea)


jaswanth.ooty
2022-09-15 11:39
From what I know, the only way to verify specific interactions is to use @PactFilter https://docs.pact.io/implementation_guides/jvm/provider/junit#interaction-filtering So to do this dynamically, we could to pass the interaction filter value as an env variable to the test runner. Hopefully this is that they are after ?

saurabh.goel
2022-09-15 12:59
Hello, i am able to trigger my provider build successfully through "contract_requiring_verification_published" event. but the provider verification takes contract with commit id from consumer's master branch, rather then the feature branch which triggered this verification. How can I force provider verification to use this commit id? I am triggering the drone build like this ```https://ci-server/api/repos/comp/proj/builds?branch=ct_update_consumer_ver&pact_url=${pactbroker.pactUrl}&pact_consumer=${pactbroker.consumerName}&pact_consumer_branch=${pactbroker.consumerVersionBranch}&pact_consumer_version=${pactbroker.consumerVersionNumber}``` and pact tests are getting executed with simple gradle run test which runs everything else too ```- ./gradlew clean build -PisDroneCI=true -Prevision=${DRONE_COMMIT} -Ptag=${DRONE_TAG} -PbuildNumber=${DRONE_BUILD_NUMBER} -PbuildVersion=$(cat .tags) --stacktrace```

l.heluszko
2022-09-15 13:12
has joined #pact-jvm


ashishmerani
2022-09-15 14:41
It's using org.mockito.Mockito.when to mock

ashishmerani
2022-09-15 14:42
Is that not recommended?

abubics
2022-09-16 01:43
nah, mocking the repository response in the provider verification is fine (*as long as it the repo shape isn't what ends up on the wire)

abubics
2022-09-16 01:43
have you checked that the response from the provider is actually sending back what you expect? (outside of the test)


ashishmerani
2022-09-16 01:49
That's while test is running. How can I do it outside the test? Since it spins up a mock server

ashishmerani
2022-09-16 01:49
Making calls to mock server on given path in browser throws error

abubics
2022-09-16 01:50
Right, that indicates that you haven't actually renamed it to `ids` everywhere. If the actual response (in & out of the test) returns `{"type":"House","id":"5"}`, then your controller is rendering out a class (or whatever) with `id`.

abubics
2022-09-16 01:50
The provider verification doesn't start a mock server, it should start your provider :thinking_face:

abubics
2022-09-16 01:51
Without seeing the code, though, it's going to be hard to debug. If it's easy enough, the next step might be to link a repo that reproduces this issue.

ashishmerani
2022-09-16 01:54
I am using the workshop example from https://github.com/pact-foundation/pact-workshop-jvm-spring/ and renamed the id to ids in Product.java to try and fail the provider

ashishmerani
2022-09-16 01:57
If you debug (step into) on this line https://github.com/pact-foundation/pact-workshop-jvm-spring/blob/c642c739c49ff8543f05f0bcb517bd3529ba9a5e/provider/src/test/java/au/com/dius/pactworkshop/provider/ProductPactProviderTest.java#L55 It should have mock server url (localhost:port) and path is binded to compare actual response vs expected (from consumer)

ashishmerani
2022-09-16 01:58
I'll create a repo on GitHub and try to replicate this issue with some steps and share it here.

abubics
2022-09-16 01:59
Which step do you have checked out?

ashishmerani
2022-09-16 02:01
Go all the way to step 11 and update id in Product.java and run provider test

ashishmerani
2022-09-16 02:01
Rename id to ids

abubics
2022-09-16 02:02
Are you reaming the private field?

abubics
2022-09-16 02:02
Pretty sure that won't work, you need to rename the getters/setters for `Response.of` to work in the controller. ``` public String getId() { return id; } public void setId(String id) { this.id = id; }```


abubics
2022-09-16 02:17
The private member won't be used by Spring's conversion helper. Anyway, this isn't a Pact question anymore, it's about Java Beans & Spring.

abubics
2022-09-16 02:18
Does it work if you rename `getId` to `getIds`?

ashishmerani
2022-09-16 02:34
Yes, It does fail the test now as expected. I though pact was caching somehow. Thank you :thumbsup:

abubics
2022-09-16 02:35
You should be able to confirm that it's not Pact by running the provider, and getting `id` in the response :)

ashishmerani
2022-09-16 02:53
appreciate your time helping me debug this. :thank_you:

alecat88
2022-09-16 10:25
has joined #pact-jvm

ruben.perezg
2022-09-16 10:37
HI :slightly_smiling_face: In our scenario, we have our _Pact Broker_ with the _Webhook_ created (with the new `contract_requiring_verification_published` event), that triggers the needed provider builds once a contract change is detected. As a parameter, it sends the URL of the pact version to verify. Also, in our JVM provider applications so far we have set the consumer version selectors in Gradle, so that the versions to verify are the latests from the main branch and the latests deployed/released. In our case using the workaround `rawjson`, given that the `@ConsumerVersionSelector` annotation didn't support _branches_ or _deployments_. So my question is how do I let Pact know in my provider code that when the build has been triggered by the Broker, what I need to check is the pact version that the webhook has sent instead of the one defined in the `rawjson` property?

chris.armbrester
2022-09-16 11:45
has joined #pact-jvm

zohaibse011
2022-09-16 13:28
has joined #pact-jvm

nvenkataraman
2022-09-16 17:17
has joined #pact-jvm

zach.davis
2022-09-16 20:18
has joined #pact-jvm

jorbraken
2022-09-16 20:29
has joined #pact-jvm

paul.ologeh
2022-09-16 23:25
has joined #pact-jvm

senchu.pampoorickal
2022-09-18 19:10
Hi There, I am writing the pact provider test on the application running with Spring and Junit 4. I am using the http://au.com.dius.pact.provider dependenc and came across 2 questions and it will be really appreciated anyone can guide on this 1. What I understand from the documentation is while doing provider testing we need to test against the actual server in test. And I am using a docker container hosted with application and hitting the pact provider test against the application in testing container. The situation I came across is the base url("127.0.0.1"), port (443) and protocol (https) can vary and I need this values to be passed from some environment variables in the CI pipeline. Can anyone guide on this ```@TestTarget public final Target target = new HttpTarget("https", "127.0.0.1", 443, "api", true);``` 2. I have a job in the pipeline which build the application by running the "mvn clean install" command . The provider test also runs in this scenario and as the environment is not ready it will fail the test and build will not succeed. I want to control the running of pact provider test only when invoked individually in a job for pact provider testing. In all the other cases if anyone invoke the command "mvn clean install" pact provider test cases should not run. How to handle this situation. Thanks in advance for the help and guidance


ruben.perezg
2022-09-19 06:36
Oh, thank you! I missed that one :sweat_smile: So if I understand the documentation right, I need to also add `pact.filter.pacturl` and `pact.filter.consumers` the same way I'm adding the others as system properties. My guess is that the `pact.filter.consumers` will always have value (I know its value beforehand), but the `pact.filter.pacturl` will only have a proper value when an actual webhook execution has triggered that provider build. And if that property doesn't have a proper value, then a "normal" build will be executed, using the consumer selector logic that normally applies. Is that right?

uglyog
2022-09-19 06:40
No, you just need `pact.filter.pacturl` set to the webhook URL.

uglyog
2022-09-19 06:42
If you are setting up different tests for different consumers, then you can filter the different tests by consumers so only the one for the correct consumer will run, but I don't recommend that

uglyog
2022-09-19 06:43
An, Yes, if the `pact.filter.pacturl` is not set, it will run as normal

ruben.perezg
2022-09-19 06:45
ahhh, so the `pact.filter.consumers` is helpful then when we have a provider that has many consumers, so that a contract change only triggers the tests of the proper consumer instead of running all the tests with that pactUrl. Makes a lot of sense :slightly_smiling_face:

ruben.perezg
2022-09-19 06:46
thank you very much!

purushothamv02
2022-09-19 14:19
has joined #pact-jvm

lcruz
2022-09-19 23:05
has joined #pact-jvm

sweiba
2022-09-20 07:26
has joined #pact-jvm

adam910
2022-09-20 12:32
has joined #pact-jvm

p.pommerencke
2022-09-20 14:00
has joined #pact-jvm

anhtvuong
2022-09-21 01:39
has joined #pact-jvm

anhtvuong
2022-09-21 01:54
:wave: Hello, team!

timothee.ville
2022-09-21 08:09
has joined #pact-jvm

tymoschuk.jane
2022-09-21 12:38
has joined #pact-jvm

tony.nguyen
2022-09-21 13:41
has joined #pact-jvm

sashi.kandru
2022-09-21 13:45
has joined #pact-jvm

anhtvuong
2022-09-21 16:12
I'm looking for consumer and producer examples that are not using Springboot, Gradle, and Makefile but only with Maven. Thanks.

khaled.bali
2022-09-21 18:01
has joined #pact-jvm

m.mertens
2022-09-21 18:41
has joined #pact-jvm


anhtvuong
2022-09-21 23:49
Thanks @matt.fellows However, those examples are for Springboot which don't use pom.xml but gradle. I did exercise that good repo. Since I'm interested in kafka/messaging, hence I tried consumer-kafka and producer-kafka examples and ran into issue on producer, which also Springboot using gradle and Makefile.

matt.fellows
2022-09-21 23:50
I?m sorry, we just don?t have examples for every combination. I?m assuming it can?t be that hard to extrapolate the gradle dependencies to Maven?

mforsman
2022-09-22 09:13
has joined #pact-jvm

mforsman
2022-09-22 09:18
Hey! I?m trying out Pact for Java. Naturally I wanted to start out with the consumer, but it looks like all the Java documentation is written for the previous API (3.x.x), and they don?t seem to work for v4. The example https://docs.pact.io/implementation_guides/jvm/consumer/junit use the following api/format: ``` @Pact(provider="test_provider", consumer="test_consumer") public RequestResponsePact createPact(PactDslWithProvider builder) {``` However, this isn?t compatible with the latest version: ``` <dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>4.3.14</version> <scope>test</scope> </dependency>``` `java.lang.UnsupportedOperationException: Method testPact does not conform required method signature 'public http://au.com.dius.pact.core.model.V4Pact xxx(PactBuilder builder)'` Could someone point me in the direction of an updated example using the new DSL?

shivendra.singh1
2022-09-22 10:04
has joined #pact-jvm

vaibhav.tiwari
2022-09-22 10:04
has joined #pact-jvm

akshaythakur2905
2022-09-22 10:06
has joined #pact-jvm

sukriti.kumari
2022-09-22 10:07
has joined #pact-jvm

p.kowalska
2022-09-22 10:35
has joined #pact-jvm

mazin.inaad
2022-09-22 13:21
has joined #pact-jvm

anhtvuong
2022-09-22 18:22
I have almost same contract tests - same class name, imports, provider, consumer names etc - and "mvn test" works in one simpler repo and fails on a bigger repo with errors below. I have compared pom.xml for libraries's versions, jdk 17 etc. I run out of clues. Hope some one ahs seen the errors. java.lang.IncompatibleClassChangeError: Expected static method 'java.lang.Object http://au.com.dius.pact.core.support.expressions.ExpressionParser.parseExpression(java.lang.String, http://au.com.dius.pact.core.support.expressions.DataType)' at http://au.com.dius.pact.consumer.junit.MessagePactProviderRule.parsePacts(MessagePactProviderRule.java:192) at http://au.com.dius.pact.consumer.junit.MessagePactProviderRule$1.evaluate(MessagePactProviderRule.java:96) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54) Process finished with exit code 255 import http://au.com.dius.pact.consumer.MessagePactBuilder; import http://au.com.dius.pact.consumer.dsl.DslPart; import http://au.com.dius.pact.consumer.dsl.PactDslJsonBody; import http://au.com.dius.pact.consumer.junit.MessagePactProviderRule; import http://au.com.dius.pact.consumer.junit.PactVerification; import http://au.com.dius.pact.core.model.annotations.Pact; import http://au.com.dius.pact.core.model.messaging.MessagePact; import com.google.protobuf.TextFormat; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import http://java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.Map; public class ApStateConsumerMessagePactTest { @Rule public MessagePactProviderRule mockProvider = new MessagePactProviderRule("producer-message", this); ... }

mastahfreak
2022-09-23 09:47
has joined #pact-jvm

kellie.persson
2022-09-23 17:50
has joined #pact-jvm


uglyog
2022-09-26 01:19
This means you have a mismatch in the versions of the Pact-JVM libraries. You need to make sure all the Pact-JVM libraries you use have the same major and minor versions.

mforsman
2022-09-26 06:33
Nice, thanks :+1:

vorashil.farzaliyev
2022-09-26 10:38
Hey everyone. I have been following the docs to implement BDCT with Rest Assured on provider side. Is it possible to have a look at the source code of the project you?re using in the https://www.youtube.com/watch?v=9qZN7wHEQ1U&list=PLwy9Bnco-IpfddOl7vk7xfmGSjMMCiSbiso we can see how you?re using Rest Assured along with other dependencies with Atlasssian

vorashil.farzaliyev
2022-09-26 10:38
Atlassian dependencies don?t have the best docs in the world unfortunately, so would be useful to see them in a working application

vorashil.farzaliyev
2022-09-26 10:38
@mahdi.ali FYI :point_up:


yousafn
2022-09-26 10:48
It is compatible with several of our directional consumer codebases listed here https://docs.pactflow.io/docs/examples#demos

yousafn
2022-09-26 10:48
and hey hey, thanks for checking out the video

vorashil.farzaliyev
2022-09-26 10:50
Thank you Yousaf. build.gradle definitely looks slimmer than I expected. Will give it a go again

kbon
2022-09-26 13:58
has joined #pact-jvm

edouard.lopez
2022-09-26 15:51
With the following consumer selectors I'm able to fetch the contract. However, it's still unclear to me why I need to specify the selector on this provider but not the other? Why do I need to specify the branch? I see many verified contract version include `HEAD` as a value ``` @PactBrokerConsumerVersionSelectors public static SelectorBuilder consumerVersionSelectors() { return new SelectorBuilder() .branch("abmm-5295"); // why do I need to specify the branch? }```

edouard.lopez
2022-09-26 15:52
Is there a selectors to match the latest contract whatever branch/tag?

fabio.rodrigues
2022-09-26 15:52
Maybe just send latest set to true and no branch,?

tanyaryzhova93
2022-09-26 18:53
has joined #pact-jvm

anand.krishnan
2022-09-27 10:45
has joined #pact-jvm

edouard.lopez
2022-09-27 11:21
I'm able to fetch a contract when I specify the branch with which the contract is labelled (`abmm-5295`). However, I haven't specified any branch in most of our projets and we still are able to fetch and verify. Did a default behaviour regarding the contract fetching mechanism changes in the past few months? Or is it cheering luck that they passed? cc @matt.fellows

edouard.lopez
2022-09-27 11:29
Using `enablePendingPacts = "true"` doesn't prevent `initializationError` when I only selection from `mainBranch()` (which has no associated contracts) ```AdvisorsControllerContractVerificationTest > pactVerificationTestTemplate(PactVerificationContext) > com.manomano.ms.advice_conversation.application.controllers.AdvisorsControllerContractVerificationTest.initializationError FAILED au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException at PactJUnit5VerificationProvider.kt:50```

estelle.margoutin
2022-09-27 12:00
has joined #pact-jvm

bethskurrie
2022-09-28 01:21
@edouard.lopez we could spend a lot of time trying to work out why it used to work and doesn?t now, but I think it would be better to spend that time adding in the branches and using them as recommended.

bethskurrie
2022-09-28 01:21
The Pact Broker is not expected to work without branches (or at least, tags, but they?re superseded by branches now)

bethskurrie
2022-09-28 01:23
This is the code that is used if there are no consumer version selectors provided. https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/pacts/pacts_for_verification_repository.rb#L138

bethskurrie
2022-09-28 01:24
but - you should be using consumer version selectors.

bethskurrie
2022-09-28 01:25
The default recommendation is: ? publish pacts/verifications with a branch ? verify the pacts from the main branch, and released/deployed.

bethskurrie
2022-09-28 01:27
That is `mainBranch()` and `deployedOrReleased()`

criss.trifan
2022-09-28 05:36
has joined #pact-jvm

edouard.lopez
2022-09-28 13:33
Thanks, we are publishing from the merge request pipeline so the contract are not tagged with the `mainBranch` , that's a mistake

vipatel
2022-09-28 15:29
has joined #pact-jvm

olaoluphilip
2022-09-28 15:51
has joined #pact-jvm

vieira.jluiz
2022-09-28 17:20
has joined #pact-jvm

shuo.yang.2006
2022-09-28 19:48
has joined #pact-jvm

bethskurrie
2022-09-29 03:55
If it?s from the merge request pipeline, then they should be included in the WIP pacts.

edouard.lopez
2022-09-29 12:49
Yep, WIP show them :v:

nirmalcbaral
2022-09-29 15:27
has joined #pact-jvm

ruppel.julian
2022-09-29 20:03
has joined #pact-jvm

alipala.ist
2022-09-29 20:28
has joined #pact-jvm

educationextended
2022-09-30 04:59
has joined #pact-jvm

ross.butler
2022-09-30 11:22
has joined #pact-jvm

koen.jans
2022-09-30 15:06
has joined #pact-jvm

lnthai2002
2022-09-30 21:29
Hello, does anyone know how to attach debugger to a pact provider test?

matt.fellows
2022-10-01 06:48
It should just be however you debug the language

matt.fellows
2022-10-01 06:48
What are you wanting to get from the debugger?

ksawery.karwacki
2022-10-01 13:12
has joined #pact-jvm

jesper.nilsson
2022-10-01 13:59
has joined #pact-jvm

mansillamarcelo90
2022-10-02 22:06
has joined #pact-jvm

yulia.tekin.86
2022-10-02 22:55
has joined #pact-jvm

rachel.anderson
2022-10-02 23:39
has joined #pact-jvm

lnthai2002
2022-10-03 20:41
my project is heavily dependent on mysql, infact, for each request to my provider, there is some tenant info on the jwt. The servlet filter extract this tenant info and build a connection to a dedicated mysql instance and pass it to subsequence calls of the same http request. This behavior is different when running the provider locally (since there is only 1 instance of mysql), thus i need to put the breakpoint in the servlet filter and trace the code from there. I was getting class not found error when I click on debug the provider test but i just realized it has nothing to do with the test itself but rather my m2 repo is corrupted

matt.fellows
2022-10-03 21:56
Argh, no fun :wink: Sounds like you?re back on track though

jason.stahl
2022-10-03 22:19
has joined #pact-jvm

sreeragsa
2022-10-04 03:03
has joined #pact-jvm

tara.costin
2022-10-04 14:45
has joined #pact-jvm

oscar.barbamanzano
2022-10-05 14:18
has joined #pact-jvm

yanov.alexander
2022-10-06 08:39
has joined #pact-jvm

yanov.alexander
2022-10-06 08:42
Hello, #pact-jvm . I am trying to write a consumer tests using MessagePactBuilder and ran into a problem that I can?t pass a string to the withContent method, since our provider sends an event with a string represantation, not the Json or Xml. The content type being passed is application/x-www-form-urlencoded. Are there any options for sent the string and not json or xml?

bxbivc
2022-10-06 10:05
has joined #pact-jvm

curtis.scott
2022-10-06 11:27
has joined #pact-jvm

riley.lee
2022-10-06 11:30
has joined #pact-jvm

oliver.smyth
2022-10-06 11:34
has joined #pact-jvm

kevin.campos
2022-10-06 11:35
has joined #pact-jvm

pstrnad
2022-10-06 12:04
has joined #pact-jvm

rachelxelizabethh
2022-10-06 13:20
has joined #pact-jvm

pratish
2022-10-06 21:08
has joined #pact-jvm

ilia
2022-10-06 22:18
has joined #pact-jvm

uglyog
2022-10-06 22:53
Looks like that DSL only support those types. Can you raise an issue for this?

thanuxxxx
2022-10-07 03:15
I see these two system variables ```Dpact.provider.branch=${GIT_BRANCH} Dpactbroker.providerBranch=${GIT_BRANCH}``` Are they the same?


thanuxxxx
2022-10-07 03:26
If I want to enable pending pact is this config enough? ``` stage('Contract Tests: Provider Verify') { when { expression { PACT_PROVIDER == true } } steps { sh """mvn test -Pcontract-tests-provider-verify \ -Dpact.verifier.publishResults=true \ -Dpact.provider.version=${GIT_COMMIT} \ -Dpact.provider.branch=${GIT_BRANCH} \ -->> register branch -Dpactbroker.providerBranch=${GIT_BRANCH} \ -->> enable pending pact -Dpact.broker.consumerversionselectors.rawjson=[{"mainBranch":true},{"deployed":true}]""" } }```

uglyog
2022-10-07 03:33
I imagine so, it looks ok to me.

uglyog
2022-10-07 03:34
Is it not working as you expect?

thanuxxxx
2022-10-07 03:44
I am testing it right now. I used to have `pactbroker.providerTags,` but we want to move away from tags.

edudelta
2022-10-07 15:57
has joined #pact-jvm

lnthai2002
2022-10-07 18:01
Hello guys, i am getting this error when i try to run pact provider verification with @WebMvcTest ```12:44:25.963 [main] WARN au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader - Failed to instantiate the value resolver, using the default java.lang.IllegalAccessException: class au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader cannot access a member of class au.com.dius.pact.core.support.expressions.SystemPropertyResolver with modifiers "private" at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361) at java.base/jdk.internal.reflect.Reflection.ensureMemberAccess(Reflection.java:99) at java.base/java.lang.Class.newInstance(Class.java:579) at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.setupValueResolver(PactBrokerLoader.kt:168) at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:99) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$$inlined$flatMap$lambda$1.invoke(PactJUnit5VerificationProvider.kt:80) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$$inlined$flatMap$lambda$1.invoke(PactJUnit5VerificationProvider.kt:37) at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:38) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.resolvePactSources(PactJUnit5VerificationProvider.kt:80) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:41) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:102)``` i am not sure what cause this but if i replace @WebMvcTest with @SpringBootTest then i dont get this error, however it requires other external components running (mysql, message broker,...) since the whole spring context is loaded

olsen.lee.r
2022-10-07 18:29
has joined #pact-jvm

johndunning
2022-10-08 18:05
has joined #pact-jvm

kentooooo.1230
2022-10-09 17:49
has joined #pact-jvm

uglyog
2022-10-09 22:19
Make sure you are not mixing different Pact-JVM library versions, they should ideally all be the same version

heinenm
2022-10-10 06:24
Hi all, we tried to cover a file download endpoint via consumer driven contract test. The endpoint serves XML and we don't care about the downloaded content or tag structure. We just want to verify that the body is not empty. Here are the things that we tried and the results: *Consumer class:* ```public class DownloadEndpointsCDCTest extends ConsumerPactTest { @Override protected RequestResponsePact createPact(final PactDslWithProvider aBuilder) { final DslPart expectedBodyResponse1 = PactDslRootValue.stringMatcher("^.+$", "whatever"); final DslPart expectedBodyResponse2 = PactDslRootValue.stringMatcher("^.+$", "<?xml version=\"1.0\" encoding=\"utf-8\"?><example>foo</example>"); return aBuilder// .given("A XML generation job finished successfully") .uponReceiving("A request to download XML") .pathFromProviderState("/xmlresult/${jobId}", "/xmlresult/" + "dummyJobId") .method("GET") .willRespondWith() .status(200) .headers(Map.of("Content-Type", "application/xml")) // .body(expectedBodyResponse1) .body(expectedBodyResponse2) .toPact(); } }``` *Generated contract:* ```{ "consumer": { "name": "XXX_Client" }, "interactions": [ { "description": "A request to download a XML", "providerStates": [ { "name": "A XML generation finished successfully" } ], "request": { "generators": { "path": { "dataType": "STRING", "expression": "/nativeresult/${jobId}", "type": "ProviderState" } }, "headers": { "RM-MDC-TOKEN": "dummyTraceId" }, "method": "GET", "path": "/xmlresult/dummyJobId" }, "response": { "body": "<?xml version=\"1.0\" encoding=\"utf-8\"?><example>foo</example>", "headers": { "Content-Type": "application/xml" }, "matchingRules": { "body": { "$": { "combine": "AND", "matchers": [ { "match": "regex", "regex": "^.+$" } ] } }, "header": { } }, "status": 200 } } ], "metadata": { "pact-jvm": { "version": "4.3.14" }, "pactSpecification": { "version": "3.0.0" } }, "provider": { "name": "XXX_Service" } }``` The verification fails on provider side. In case we use "*expectedBodyResponse1*" from the above example following exception is thrown (which is comprehensible because the content is not XML): _Content is not allowed in prolog._ _at http://au.com.dius.pact.provider.junit5.PactVerificationContext.verifyInteraction(PactVerificationContext.kt:66)_ In case we use "*expectedBodyResponse2*" from the above example following exception is thrown: _Verifying a pact between XXX_Client and XXX_Service - A request to download a XML has a matching body_ _body: $.example.#text Expected '' to match '^.+$'_ _at http://au.com.dius.pact.provider.junit5.PactVerificationContext.verifyInteraction(PactVerificationContext.kt:66)_ *How can we verify that a response of content type "application/xml" is not empty?* Used versions: Consumer: au.com.dius.pact.consumer:junit:4.3.14 Provider: au.com.dius.pact.provider:junit5:4.3.13

gpapadakis84
2022-10-10 12:32
has joined #pact-jvm

daftpunkapi
2022-10-11 09:22
has joined #pact-jvm

matteo.demasi
2022-10-11 12:08
has joined #pact-jvm

raul.romitan.ext
2022-10-11 12:17
has joined #pact-jvm

dominikdieter.krichba
2022-10-11 13:23
has joined #pact-jvm

ulrich.keil
2022-10-11 13:26
has joined #pact-jvm

mitchell.l.cooper
2022-10-11 13:45
has joined #pact-jvm

torsten.wiederkehr
2022-10-11 14:24
has joined #pact-jvm

mikey214
2022-10-11 22:32
has joined #pact-jvm

xi.luo
2022-10-12 05:11
has joined #pact-jvm

kim.crowe
2022-10-12 10:15
has joined #pact-jvm

lnthai2002
2022-10-12 16:00
Hello guys, is the pending pact the feature of the broker ? Is there a way to disable pending pact from provider test (as an argument to mvn verify command)? Since I have a mono repo and pact consumer/provider tests only run on merge CI/CD pipeline, at that time all providers and consumers must have valid contracts

yousafn
2022-10-12 16:25
Hey, It is configured in the providers verification build https://docs.pact.io/pact_broker/advanced_topics/pending_pacts#how-the-feature-is-enabled Can you provide the arguments you are providing in your provider verification?


lnthai2002
2022-10-12 17:13
Thank you for your suggestion, i added the pactbroker.enablePending=false to the provider verification command (mvn -DpipelineBuild=true --activate-profiles maven-profile,provider-pact-test -Dpackbroker.scheme=http -Dpactbroker.host=localhost -Dpactbroker.port=9292 -Dpactbroker.auth.username=pact_workshop -Dpactbroker.auth.password=pact_workshop -Dpact.provider.version="7.0.36-$(git rev-parse --short HEAD)" -Dpactbroker.enablePending=false -Dpact.verifier.publishResults=true --projects 60000-demo-service/demo-service --also-make -f all-modules-pom.xml clean verify) but i still see this: ```Verifying a pact between service2 (7.0.59-SNAPSHOT-e7ce7bb969) and demo-service [PENDING] Notices: 1) The pact at http://localhost:9292/pacts/provider/demo-service/consumer/service2/pact-version/d7dab96a7ad11995d05396a3b3595fbe44f3cc6f is being verified because the pact content belongs to the consumer version matching the following criterion: * latest version of service2 that has a pact with demo-service (7.0.59-SNAPSHOT-e7ce7bb969) 2) This pact is in pending state for this version of demo-service because a successful verification result for demo-service has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at https://docs.pact.io/go/pending [from Pact Broker http://localhost:9292/pacts/provider/demo-service/consumer/service2/pact-version/d7dab96a7ad11995d05396a3b3595fbe44f3cc6f/metadata/c1tdW2xdPXRydWUmc1tdW2N2XT02NyZwPXRydWU] Given contract 1 exists get contract 1 13:07:08.292 [main] DEBUG org.springframework.test.web.servlet.TestDispatcherServlet - GET "/v1/contracts?name=Contract%201", parameters={masked} 13:07:08.296 [main] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped to cloud.nakisa.demo.controllers.ContractController#findAll(String) 13:07:08.328 [main] INFO cloud.nakisa.demo.controllers.ContractController - findByName Contract 1 13:07:08.331 [main] DEBUG org.springframework.test.web.servlet.TestDispatcherServlet - Failed to complete request: java.lang.NullPointerException Request Failed - Request processing failed; nested exception is java.lang.NullPointerException Pending Failures: 1) Verifying a pact between service2 and demo-service - get contract 1 1.1) Request processing failed; nested exception is java.lang.NullPointerException```

lnthai2002
2022-10-12 21:36
Hi again, when running provider verification, i supply the pact.provider.version as `mvn -DpipelineBuild=true --activate-profiles maven-profile,provider-pact-test -Dpackbroker.scheme=http -Dpactbroker.host=localhost -Dpactbroker.port=9292 -Dpactbroker.auth.username=pact_workshop -Dpactbroker.auth.password=pact_workshop -Dpact.provider.version="7.0.36-$(git rev-parse --short HEAD)" -Dpactbroker.enablePending=false -Dpact.verifier.publishResults=true --projects 60000-demo-service/demo-service --also-make -f all-modules-pom.xml clean verify` and i see pact tries to verify this version of provider against all versions of consumer. Is there a way to tell pact to verify a particular version of the provider against one version of the consumer? I saw the Consumer Version Selector page (https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors) but it does not take the version (tag, branch, environment are supported) and I don't see it accept consumerVersionSelectors params (i checked with mvn help:describe -DgroupId=http://au.com.dius.pact.provider -DartifactId=maven -Dversion=4.1.17 -Ddetail=true)

uglyog
2022-10-12 21:44
That flag is only advice to the broker. The broker decides if a Pact is pending or not

uglyog
2022-10-12 21:45
I don't think you can specify a single consumer version

lnthai2002
2022-10-12 22:07
Ok, I think I can tag the consumer when I publish the pact. Do you have an example of specifying consumerVersionSelectors for provider verification on mvn command?

lnthai2002
2022-10-12 22:08
So the pending feature have to be disabled from the broker?


uglyog
2022-10-12 22:11
I don't know if it can, but you can try ask in the #pact-broker channel

suganyamuthukumar03
2022-10-13 11:01
has joined #pact-jvm

heinenm
2022-10-13 14:32
no ideas anyone? Should I enter a bug?

anhtvuong
2022-10-13 17:56
How can I express the following pact semantics in async messaging? There is either mandatory key, mandatory_cpu or mandatory_memory for a contract to be valid? So, it seems there can be two separate pacts, one with mandatory_cpu and the other with mandatory_memory key. For cpu pact, I need help on how to express multiple level_2 list which can be empty, can have optional keys, and must have mandatory_cpu. Second wishful thinking is if I can combine both cpu and memory in same pact? Thanks. Case 1: ?level_1? { ?level_2? { ?*mandatory_cpu*?: "value_1? } ?level_2? { } ?level_2? { ?optional_key_1?: ?optional_value_1? } } Case 2: ?level_1? { ?level_2? { ?optional_key_1?: ?optional_value_1? } ?level_2? { } ?level_2? { ?*mandatory_memory*?: "value_2? } }

francis.bonneau
2022-10-13 18:30
has joined #pact-jvm

lnthai2002
2022-10-13 20:27
Hello, when i run the provider verification (junit5spring:4.3.15), i got so much DEBUG log including http connection, BASIC auth cred echange and retry,... . How can i lower the level to WARN or INFO ?

lnthai2002
2022-10-13 22:26
Thank you, i checked your link and also found this https://docs.pact.io/implementation_guides/jvm/provider/junit5#using-an-annotated-method-with-a-builder so i added the static method to return the SelectorBuilder like this: ```@PactBrokerConsumerVersionSelectors public static SelectorBuilder consumerVersionSelectors() { return new SelectorBuilder() .branch(System.getProperty("pact.consumer.branch")); }``` and acording to the doc, the LATEST *version* from a particular branch of each consumer will be selected. However when the provider test run with this selector, i see it validates against ALL versions from the given branch of each consumer:

lnthai2002
2022-10-13 22:28
is this because the content of the 2 pacts (84a31e06 and c22dca51) are the same? thus the validation result is applied to both consumer versions?

uglyog
2022-10-13 22:43
Yes, the verification is applied to all versions with the same Pact file

naf
2022-10-14 10:55
has joined #pact-jvm

werner.lauterfeld
2022-10-14 11:09
has joined #pact-jvm

lnthai2002
2022-10-14 13:58
Thank you for confirming. I just got another problem: I have one git branch B with both the consumers and the providers (mono repo). My CI/CD runs the consumer test first then the provider verification. When the branch is pushed at commit X, the CI/CD pipeline starts. By the time the consumer test finish and consumer pact at version X is pushed to branch B, another commit Y has been pushed to branch B and thus a 2nd CI/CD pipeline starts. By the time the provider X verification starts, the LATEST consumer pacts in broker are a mix of X and Y, thus the provider X is validates against some consumer pact Y. Is there anyway to prevent this?

jharms
2022-10-14 15:04
has joined #pact-jvm

daniel.cronin
2022-10-14 16:15
has joined #pact-jvm

txomin.sirera
2022-10-14 18:57
has joined #pact-jvm

jr
2022-10-15 20:48
has joined #pact-jvm

sasankdts
2022-10-16 08:48
has joined #pact-jvm

wil.pannell
2022-10-16 16:56
has joined #pact-jvm

sirisha.kunaparaju
2022-10-17 11:01
has joined #pact-jvm

gardeepti
2022-10-17 11:02
has joined #pact-jvm

vedant3620
2022-10-17 11:08
has joined #pact-jvm

priyanka.bbit
2022-10-17 11:11
has joined #pact-jvm

nvourlakis
2022-10-17 11:21
has joined #pact-jvm


oliwia.koch
2022-10-17 13:51
has joined #pact-jvm

bluediamondpc
2022-10-17 14:18
has joined #pact-jvm

nicholas.difelice
2022-10-17 15:16
has joined #pact-jvm

remington.otoole
2022-10-17 15:20
has joined #pact-jvm

matt.lucido
2022-10-17 15:23
has joined #pact-jvm

molly.mccarthy
2022-10-17 15:28
has joined #pact-jvm

slack1211
2022-10-18 07:24
has joined #pact-jvm

slack1211
2022-10-18 09:30
Hello, I have a small problem using pact testing and the junit5 integration, from gradle, testCompile group: 'http://au.com.dius.pact.provider', name: 'junit5', version: '4.2.0'. I have ane endpoint which I'm testing, which returns a content type of application/x-json-stream, the contents of which are like: { "id": 1, "foo": "bar" } { "id": 2, "foo": "baz" } When running context.verifyInteraction(), the JsonParser is throwing an exception, saying that it can't parse the above, because it isn't valid JSON. Which it isn't. If I understand correctly, this comes down to the following code in Ma tchingConfig.kt: val bodyMatchers = mapOf( "application/.*xml" to "http://au.com.dius.pact.core.matchers.XmlBodyMatcher", "text/xml" to "http://au.com.dius.pact.core.matchers.XmlBodyMatcher", ".*json.*" to "http://au.com.dius.pact.core.matchers.JsonBodyMatcher", "text/plain" to "http://au.com.dius.pact.core.matchers.PlainTextBodyMatcher", "multipart/form-data" to "http://au.com.dius.pact.core.matchers.MultipartMessageBodyMatcher", "multipart/mixed" to "http://au.com.dius.pact.core.matchers.MultipartMessageBodyMatcher", "application/x-www-form-urlencoded" to "http://au.com.dius.pact.core.matchers.FormPostBodyMatcher" ) @JvmStatic fun lookupBodyMatcher(contentType: String?): BodyMatcher? { return if (contentType != null) { val matcher = bodyMatchers.entries.find { contentType.matches(Regex(it.key)) }?.value if (matcher != null) { val clazz = Class.forName(matcher).kotlin (clazz.objectInstance ?: clazz.createInstance()) as BodyMatcher? } else { val override = System.getProperty("pact.content_type.override.$contentType") The call to lookupBodyMatcher has contentType == application/x-json-stream, so it is matching the regexp ".*json.*" and trying to parse the expected content as JSON. And the JSON isn't valid. It never will be. It doesn't look like there is any way of overriding this either. My question is this: what is the best approach for this situation? I currently use reflection to insert a new entry in the bodyMatchers map which handles the x-json-stream body matcher correctly. This obviously is quite fragile, but I can't see a way around it for the minute?



mekala.kalyan
2022-10-18 12:49
has joined #pact-jvm

jpullifrone
2022-10-18 17:05
has joined #pact-jvm

jorge.bo
2022-10-18 18:42
has joined #pact-jvm

orhun
2022-10-18 19:42
has joined #pact-jvm

jorge.bo
2022-10-18 20:15
Hi, i?m writing an async consumer test in kotling and having the following error. Not sure what if i am missing something. ```null cannot be cast to non-null type au.com.dius.pact.core.model.BasePact java.lang.NullPointerException: null cannot be cast to non-null type au.com.dius.pact.core.model.BasePact at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.storePactForWrite(PactConsumerTestExt.kt:478) at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.afterTestExecution(PactConsumerTestExt.kt:459) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterTestExecutionCallbacks$9(TestMethodTestDescriptor.java:233) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$13(TestMethodTestDescriptor.java:273) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$14(TestMethodTestDescriptor.java:273) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAllAfterMethodsOrCallbacks(TestMethodTestDescriptor.java:272) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAfterTestExecutionCallbacks(TestMethodTestDescriptor.java:232) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at com.sun.proxy.$Proxy5.stop(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193) at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)```

uglyog
2022-10-19 02:57
Is the level_2 attribute repeated? I don't think Pact can work with that. It expects unique keys.

uglyog
2022-10-19 02:58
It uses the logging config from your project. Just update that to set the appropriate log level for the Pact-JVM classes

uglyog
2022-10-19 03:00
That is not one JSON document, it is multiple. By default, the JSON parser is expecting a single document

uglyog
2022-10-19 03:02
I don't think there is a dynamic way to add new content type handlers, as this has not been required for any before. Can you raise a GitHub issue to add that?

uglyog
2022-10-19 03:03
Are you able to provide the test? The failure is that the Pact object it is trying to store is null

kwo.ding
2022-10-19 08:24
has joined #pact-jvm

soap6gal
2022-10-19 09:50
has joined #pact-jvm

soap6gal
2022-10-19 09:51
Hello, I'd like to pass in dynamic path to PathFolder. Does anyone have any workaround?

ankit.jain
2022-10-19 10:41
has joined #pact-jvm

edeandre
2022-10-19 12:09
has joined #pact-jvm

stanlisaus
2022-10-19 12:11
has joined #pact-jvm

jorge.bo
2022-10-19 12:29
sure,

jorge.bo
2022-10-19 12:29
```@file:OptIn(ExperimentalCoroutinesApi::class) package io.travelx.flights.itineraryreservations.cdc import arrow.core.left import arrow.core.right import au.com.dius.pact.consumer.MessagePactBuilder import au.com.dius.pact.consumer.dsl.LambdaDsl.newJsonBody import au.com.dius.pact.consumer.junit5.PactConsumerTestExt import au.com.dius.pact.consumer.junit5.PactTestFor import au.com.dius.pact.consumer.junit5.ProviderType import au.com.dius.pact.core.model.PactSpecVersion import au.com.dius.pact.core.model.annotations.Pact import au.com.dius.pact.core.model.annotations.PactDirectory import au.com.dius.pact.core.model.messaging.MessagePact import io.kotest.assertions.arrow.core.shouldBeRight import io.ktor.client.engine.okhttp.* import io.mockk.coEvery import io.mockk.mockk import io.travelx.flights.itineraryreservations.TestCalendar import io.travelx.flights.itineraryreservations.core.domain.UnexpectedError import io.travelx.flights.itineraryreservations.core.domain.commands.CreateReservationCommand import io.travelx.flights.itineraryreservations.core.domain.model.CreateReservationData import io.travelx.flights.itineraryreservations.core.usecases.reservation.cancel.CancelPurchaseUseCase import io.travelx.flights.itineraryreservations.core.usecases.reservation.confirm.ConfirmReservationUseCase import io.travelx.flights.itineraryreservations.core.usecases.reservation.create.CreateReservationUseCase import io.travelx.flights.itineraryreservations.infrastructure.messaging.CheckoutSQSMessageProcessor import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import software.amazon.awssdk.services.sqs.model.Message import software.amazon.awssdk.services.sqs.model.MessageAttributeValue @ExtendWith(value = [PactConsumerTestExt::class]) @PactTestFor(providerName = "checkout-service", providerType = ProviderType.ASYNCH, pactVersion = PactSpecVersion.V4) @PactDirectory("pacts") class ReservationConsumerContractTest { private val jsonBody = newJsonBody { o -> o.stringType("purchaseId", "111") o.stringType("name", "PURCHASE_STARTED") o.eachLike("products", 1) { items -> items.stringType("productID", "1") items.stringType("productType", "FLIGHT") items.stringType( "availabilityId", "RkxZfEVaRV9JR1IoRk98Rk98NTEwMClZXzIwMjItMDktMTJfMDc6MjBfS19LT1dfMEBhPTF8TkVU" ) } }.build() @Pact(consumer = "reservation-service", provider = "checkout-service") fun pactForReservationBooking(builder: MessagePactBuilder): MessagePact { return builder .hasPactWith("checkout-service") .expectsToReceive("a purchase started message to book a reservation") .withContent(jsonBody) .toPact() } @Test @PactTestFor(pactMethod = "pactForReservationBooking") fun testPactForReservationBooking() = runTest { val createReservationUseCaseStub = mockk<CreateReservationUseCase>() val confirmReservationUseCaseStub = mockk<ConfirmReservationUseCase>() val cancelPurchaseUseCaseStub = mockk<CancelPurchaseUseCase>() coEvery { confirmReservationUseCaseStub.invoke(any()) } returns UnexpectedError(IllegalStateException("Confirm should not be called")).left() coEvery { cancelPurchaseUseCaseStub.invoke(any()) } returns UnexpectedError(IllegalStateException("Cancel should not be called")).left() coEvery { createReservationUseCaseStub.invoke( CreateReservationCommand( CreateReservationData( "111", "RkxZfEVaRV9JR1IoRk98Rk98NTEwMClZXzIwMjItMDgtMjlfMDY6MzBfS19LT1dfMEBhPTF8TkVU", "Bearer token", ), createdAt = TestCalendar.instant(), ) ) } returns Unit.right() val sut = CheckoutSQSMessageProcessor( createReservationUseCaseStub, confirmReservationUseCaseStub, cancelPurchaseUseCaseStub, TestCalendar, ) val response = sut.invoke( Message.builder() .body( """ {"purchaseId": "111", "name": "PURCHASE_STARTED", "products" : [ { "productId": "1", "availabilityId": "RkxZfEVaRV9JR1IoRk98Rk98NTEwMClZXzIwMjItMDgtMjlfMDY6MzBfS19LT1dfMEBhPTF8TkVU", "productType": "FLIGHT" }]}""" ).messageId("1IoRk98Rk98NTEwMClZ") .messageAttributes( mapOf( "Authorization" to MessageAttributeValue.builder().stringValue("Bearer token").build(), "messageDeduplicationId" to MessageAttributeValue.builder().stringValue("1").build(), "messageGroupId" to MessageAttributeValue.builder().stringValue("10").build() ) ).build() ) response shouldBeRight Unit } }```

nikolaasrondon
2022-10-19 17:29
has joined #pact-jvm

lnthai2002
2022-10-19 18:34
Thank you

fquijada
2022-10-19 21:25
has joined #pact-jvm

kkalan
2022-10-20 03:52
has joined #pact-jvm

dyptorden
2022-10-20 10:24
has joined #pact-jvm

olawale.akande
2022-10-20 11:52
has joined #pact-jvm

olawale92.tech
2022-10-20 11:56
has joined #pact-jvm

calen.pennington
2022-10-20 13:43
has joined #pact-jvm

muhammud.naseeruddin
2022-10-20 16:04
has joined #pact-jvm

xuw
2022-10-20 16:38
has joined #pact-jvm

matt.johnson
2022-10-20 17:25
has joined #pact-jvm

bhavyashree.r
2022-10-22 06:10
has joined #pact-jvm

mosesgwenne
2022-10-24 06:10
has joined #pact-jvm

jorge.bo
2022-10-24 19:48
any tipp?

j.watkins12
2022-10-24 21:13
has joined #pact-jvm

uglyog
2022-10-24 22:17
I can't see anything wrong. I'll need to setup a Kotlin test to see if I can replicate it

tony.odonnell
2022-10-25 07:56
has joined #pact-jvm

martin.schlegel
2022-10-25 11:24
has joined #pact-jvm

stefan.zivkovic
2022-10-25 12:35
has joined #pact-jvm

alexander.friesen
2022-10-25 14:07
has joined #pact-jvm

mspector
2022-10-25 14:45
has joined #pact-jvm

thomas.peyregne
2022-10-25 14:53
has joined #pact-jvm

rachelxelizabethh
2022-10-25 14:58
Hi, we are trying to get Pact JVM's matchQuery() to work with PactFlow's Hosted Stubs. Because matching rules are a requirement for us, we are using Pact v2 contracts. In our efforts to try and get dynamic query parameters working, we are facing the below error: ```Error from Pactflow stub: Pact::Error - Value to generate \"[\"string\"]\" does not match regular expression /[A-Za-z0-9]{1,}/``` For reference, we have tried both of the two ways (one including a custom example, and the other not): ```// Example not included (Pactflow generates randomly) pactDslRequestWithPath = pactDslRequestWithPath.matchQuery(parameter.getName(), "[A-Za-z0-9]{1,}"); // Example included pactDslRequestWithPath = pactDslRequestWithPath.matchQuery(parameter.getName(), "[A-Za-z0-9]{1,}", "string");``` Here is the relevant part of the contract that was generated: ```"request": { "method": "GET", "path": "<path>", "query": "response_type=string&client_id=string&redirect_uri=string&state=string&scope=string", "matchingRules": { <path>, "$.query.response_type": { "match": "regex", "regex": "[A-Za-z0-9]{1,}" }, "$.query.client_id": { "match": "regex", "regex": "[A-Za-z0-9]{1,}" }, ... }``` We were facing similar issues with machPath() when we were *not* including the example, but including the custom example worked in that case. Has anyone got this feature working with v2 contracts? Am I missing something?

anhtvuong
2022-10-25 18:52
level_2 attributes are unique in each message and the message expects at least one appearance of mandatory_cpu or mandatory_memory attribute to be a valid content.

jsirju
2022-10-25 20:22
has joined #pact-jvm

jorge.bo
2022-10-25 20:24
i was able to make it works with pactV3: ```@file:OptIn(ExperimentalCoroutinesApi::class) package io.travelx.flights.itineraryreservations.cdc import arrow.core.left import arrow.core.right import au.com.dius.pact.consumer.MessagePactBuilder import au.com.dius.pact.consumer.dsl.LambdaDsl.newJsonBody import au.com.dius.pact.consumer.junit5.PactConsumerTestExt import au.com.dius.pact.consumer.junit5.PactTestFor import au.com.dius.pact.consumer.junit5.ProviderType import au.com.dius.pact.core.model.PactSpecVersion import au.com.dius.pact.core.model.annotations.Pact import au.com.dius.pact.core.model.annotations.PactDirectory import au.com.dius.pact.core.model.messaging.MessagePact import io.kotest.assertions.arrow.core.shouldBeRight import io.ktor.client.engine.okhttp.* import io.mockk.coEvery import io.mockk.mockk import io.travelx.flights.itineraryreservations.TestCalendar import io.travelx.flights.itineraryreservations.core.domain.UnexpectedError import io.travelx.flights.itineraryreservations.core.domain.commands.CreateReservationCommand import io.travelx.flights.itineraryreservations.core.domain.model.CreateReservationData import io.travelx.flights.itineraryreservations.core.usecases.reservation.cancel.CancelPurchaseUseCase import io.travelx.flights.itineraryreservations.core.usecases.reservation.confirm.ConfirmReservationUseCase import io.travelx.flights.itineraryreservations.core.usecases.reservation.create.CreateReservationUseCase import io.travelx.flights.itineraryreservations.infrastructure.messaging.CheckoutSQSMessageProcessor import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import software.amazon.awssdk.services.sqs.model.Message import software.amazon.awssdk.services.sqs.model.MessageAttributeValue @ExtendWith(value = [PactConsumerTestExt::class]) @PactTestFor(providerName = "checkout-service", providerType = ProviderType.ASYNCH, pactVersion = PactSpecVersion.V3) @PactDirectory("pacts") class ReservationConsumerContractTest { private val checkoutCompletedJsonBody = newJsonBody { o -> o.stringType("purchaseId", "111") o.stringType("name", "PURCHASE_STARTED") o.eachLike("products", 1) { items -> items.stringType( "productId", "29e44fee-66e6-48c9-950e-3d84bbc675d7" ) } }.build() private val purchaseStartedJsonBody = newJsonBody { o -> o.stringType("purchaseId", "111") o.stringType("name", "PURCHASE_STARTED") o.eachLike("products", 1) { items -> items.stringType( "availabilityId", "RkxZfEVaRV9JR1IoRk98Rk98NTEwMClZXzIwMjItMDktMTJfMDc6MjBfS19LT1dfMEBhPTF8TkVU" ) items.stringType( "productId", "" ) items.stringType( "productType", "FLIGHT" ) } }.build() @Pact(consumer = "reservation-service", provider = "checkout-service") fun pactForReservationBooking(builder: MessagePactBuilder): MessagePact { return builder .hasPactWith("checkout-service") .expectsToReceive("a purchase started message to book a reservation") .withContent(purchaseStartedJsonBody) .toPact() } @Test @PactTestFor(pactMethod = "pactForReservationBooking") fun testPactForReservationBooking(messages: List<au.com.dius.pact.core.model.messaging.Message>) = runTest { val createReservationUseCaseStub = mockk<CreateReservationUseCase>() val confirmReservationUseCaseStub = mockk<ConfirmReservationUseCase>() val cancelPurchaseUseCaseStub = mockk<CancelPurchaseUseCase>() coEvery { confirmReservationUseCaseStub.invoke(any()) } returns UnexpectedError(IllegalStateException("Confirm should not be called")).left() coEvery { cancelPurchaseUseCaseStub.invoke(any()) } returns UnexpectedError(IllegalStateException("Cancel should not be called")).left() coEvery { createReservationUseCaseStub.invoke( CreateReservationCommand( CreateReservationData( "111", "RkxZfEVaRV9JR1IoRk98Rk98NTEwMClZXzIwMjItMDktMTJfMDc6MjBfS19LT1dfMEBhPTF8TkVU", "Bearer token", ), createdAt = TestCalendar.instant(), ) ) } returns Unit.right() val sut = CheckoutSQSMessageProcessor( createReservationUseCaseStub, confirmReservationUseCaseStub, cancelPurchaseUseCaseStub, TestCalendar, ) for (message in messages) { val response = sut.invoke( Message.builder() .body(message.contentsAsString()) .messageId("1IoRk98Rk98NTEwMClZ") .messageAttributes( mapOf( "Authorization" to MessageAttributeValue.builder().stringValue("Bearer token").build(), "messageDeduplicationId" to MessageAttributeValue.builder().stringValue("1").build(), "messageGroupId" to MessageAttributeValue.builder().stringValue("10").build() ) ).build() ) response shouldBeRight Unit } } }```

uglyog
2022-10-25 21:49
If you look at your error message, you'll notice something odd: `Value to generate \"[\"string\"]\" does not match regular expression /[A-Za-z0-9]{1,}/`, the value has square brackets and quotes around it. That is why it is not matching the regex

uglyog
2022-10-25 22:56
I think this was the problem: ```@Pact(consumer = "reservation-service", provider = "checkout-service") fun pactForReservationBooking(builder: MessagePactBuilder): MessagePact```

uglyog
2022-10-25 22:57
It is not using the new V4 classes (should return a V4Pact)

rachelxelizabethh
2022-10-25 23:31
Yes that part makes sense ... I'm still curious as to why the brackets and quotes are being added in the first place, though. I am just passing in "string" to the matchQuery() function, and I am getting this same error even when I don't provide a default example. Do you know if maybe there is a workaround? Only thing that I can think of is adding the optional brackets and quotes in the regex itself, but that's probably not ideal

uglyog
2022-10-25 23:37
I think the issue is with PactFlow's Hosted Stubs, as the test code and contract looks ok

uglyog
2022-10-25 23:42
I've raised a Jira ticket for this for the dev team to look into

a.emmanuelmendoza
2022-10-25 23:42
has joined #pact-jvm

anhtvuong
2022-10-26 01:04
I got error when trying to retrieve a consumer pact from local pact broker in provider to verify a pact against its non-http message. I tried few versions including 4.3.14 and 4.2.9 <dependency> <groupId>http://au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.3.14</version> <scope>test</scope> </dependency> <dependency> <groupId>http://au.com.dius.pact.provider</groupId> <artifactId>junit</artifactId> <version>4.3.14</version> <scope>test</scope> </dependency> 17:59:13.737 [main] DEBUG http://au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider - Pact sources on test class: @au.com.dius.pact.provider.junitsupport.loader.PactSource(http://au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.class) java.lang.NoSuchMethodError: 'http://au.com.dius.pact.provider.junitsupport.loader.PactLoader http://au.com.dius.pact.provider.ProviderUtils.instantiatePactLoader(http://au.com.dius.pact.provider.junitsupport.loader.PactSource, java.lang.Class, java.lang.annotation.Annotation)'

uglyog
2022-10-26 01:11
Make sure you are not mixing different versions of Pact-JVM libraries. You need to check all your project dependencies

anhtvuong
2022-10-26 01:36
I fixed one version mismatch and now both consumer and provider use 4.3.14 which goes past that error. I see my consumer is 'null'. How/where do I correct it? Another issue is that it picks up wrong url for PactBroker as localhost:9292 not my pact broker as @PactBroker(url = "${PACT_BROKER_BASE_URL}", providerTags = {"latest", "dev", "prod"}, enablePendingPacts = "true", authentication = @PactBrokerAuth(username = "${PACT_BROKER_USERNAME}", password = "${PACT_BROKER_PASSWORD}")) 18:32:03.004 [main] DEBUG http://au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider - Verifying pacts for provider 'cx-switch-device-health' and consumer 'null' 18:32:03.378 [main] DEBUG http://au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider - Pact sources on test class: @au.com.dius.pact.provider.junitsupport.loader.PactSource(http://au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.class) 18:32:03.379 [main] DEBUG http://au.com.dius.pact.provider.ProviderUtils - Pact source does not have a constructor with one argument of type Class 18:32:03.403 [main] DEBUG http://au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader - Loading pacts from pact broker for provider cx-switch-device-health and consumer version selectors [] 18:32:03.408 [main] DEBUG http://au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader - Authentication: Basic 18:32:03.416 [main] DEBUG http://au.com.dius.pact.core.pactbroker.HalClient - Fetching: / 18:32:03.618 [main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ex-0000000001 preparing request execution 18:32:03.623 [main] DEBUG org.apache.hc.client5.http.protocol.RequestAddCookies - null Cookie spec selected: strict 18:32:03.626 [main] DEBUG org.apache.hc.client5.http.protocol.RequestAuthCache - null Auth cache not set in the context 18:32:03.627 [main] DEBUG org.apache.hc.client5.http.impl.classic.ProtocolExec - ex-0000000001 target auth state: UNCHALLENGED 18:32:03.627 [main] DEBUG org.apache.hc.client5.http.impl.classic.ProtocolExec - ex-0000000001 proxy auth state: UNCHALLENGED 18:32:03.627 [main] DEBUG org.apache.hc.client5.http.impl.classic.ConnectExec - ex-0000000001 acquiring connection with route {}->http://localhost:9292

uglyog
2022-10-26 02:05
Don't worry about the consumer, it will fetch all pacts for the provider by default

uglyog
2022-10-26 02:06
Check the `PACT_BROKER_BASE_URL` environment variable

rachelxelizabethh
2022-10-26 12:57
Sounds great, thank you!

jorge.bo
2022-10-26 13:04
mm.. i have replaced MessagePact with V4Pact, however the result is the same. I? am not sure if ```fun testPactForReservationBooking(messages: List<au.com.dius.pact.core.model.messaging.Message>) ``` is required, i have seen examples written in different ways. Some create the message by itself and other let pact create them. I?m finding a bit difficult to understand the documentation.

emma.colleran
2022-10-26 13:05
has joined #pact-jvm

aaron.swerlein
2022-10-26 15:10
has joined #pact-jvm

stefan.zivkovic
2022-10-26 16:32
@stefan.zivkovic has left the channel

jeronimo
2022-10-26 17:50
has joined #pact-jvm

matthew.beattie
2022-10-26 20:14
has joined #pact-jvm

anhtvuong
2022-10-26 20:52
Thanks to @uglyog all pacts are retrieved despite of consumer 'null'. On env vars, not sure what caused them, I moved them from alias file into .bashrc and they work now, real fix or just coincident?

harrison.le
2022-10-26 21:47
has joined #pact-jvm

amandasstecz
2022-10-26 21:57
has joined #pact-jvm

christianoliver.table
2022-10-27 06:15
has joined #pact-jvm

zehra.lichtenberg
2022-10-27 08:08
has joined #pact-jvm

vzviaruha
2022-10-27 11:29
has joined #pact-jvm

michael.laird
2022-10-27 13:38
has joined #pact-jvm

rachelxelizabethh
2022-10-27 14:23
For traceability purposes, is there a public link for this Jira card and/or would there be an ETA that this will be picked up?

pedropho18
2022-10-27 21:33
has joined #pact-jvm

juancesarvillalba
2022-10-27 21:43
has joined #pact-jvm

uglyog
2022-10-27 22:12
Unfortunately, no. It is the internal Pactflow team backlog. Best to raise to a Github issue with the details above and we can use that to track it

angad.singh
2022-10-28 11:07
has joined #pact-jvm

yousafn
2022-10-28 14:15
Hey @rachelxelizabethh , saw your issue here and dropped you a reply https://github.com/pactflow/example-consumer-java-junit/issues/27

rachelxelizabethh
2022-10-28 16:18
Thanks! Will keep track in there

jeronimo
2022-10-28 18:20
@jeronimo has left the channel

oroceo.ian
2022-10-28 20:04
has joined #pact-jvm

benjamin
2022-10-28 21:09
has joined #pact-jvm

emailpankaj.agarwal
2022-10-29 13:26
has joined #pact-jvm

krishnakanth219
2022-10-30 22:59
has joined #pact-jvm

krishnakanth219
2022-10-30 23:11
Hi Team, Is it possible to hit the provider dev service from the consumer test instead of Mock? we wanted to generate the contract by hitting the provide service instead of mock but pact is throwing error


joshua.mclatchie
2022-10-31 02:21
has joined #pact-jvm

jason.taylor2
2022-10-31 13:55
has joined #pact-jvm

kedar.ghate
2022-10-31 14:02
has joined #pact-jvm

jason.taylor2
2022-10-31 16:38
@jason.taylor2 has left the channel

thomas.fisher
2022-11-02 09:12
hi all! Is it possible to log out the request/response on provider tests? I think so, but I am not quite sure how to go about it. I am using the junit5 version in this instance.

usama.mumtaz
2022-11-02 09:45
has joined #pact-jvm

gsouza
2022-11-02 14:29
has joined #pact-jvm

zhangjingqiang
2022-11-02 23:49
has joined #pact-jvm

bmorton
2022-11-02 23:58
has joined #pact-jvm

andrew.brindle
2022-11-03 10:44
has joined #pact-jvm

vladislav.ledniov
2022-11-03 14:13
has joined #pact-jvm

jonathan
2022-11-03 16:43
has joined #pact-jvm

ldicesaro.scvsoft
2022-11-03 20:55
has joined #pact-jvm

carlosmarange
2022-11-04 06:09
has joined #pact-jvm

stevet
2022-11-04 06:31
has joined #pact-jvm

seikyo.cho
2022-11-04 08:58
has joined #pact-jvm

poornimakrishnarajan
2022-11-04 13:56
has joined #pact-jvm

michalkras
2022-11-05 01:05
has joined #pact-jvm

maria.botnari
2022-11-07 12:07
has joined #pact-jvm

tomasz.sosnowski
2022-11-07 13:52
has joined #pact-jvm

bpadhalni
2022-11-07 15:26
has joined #pact-jvm

ajay.chinnam
2022-11-08 10:08
has joined #pact-jvm

sprengo
2022-11-08 10:57
has joined #pact-jvm

james.ferguson
2022-11-08 12:33
has joined #pact-jvm

gururaghavendrar98
2022-11-08 13:04
has joined #pact-jvm

steven
2022-11-08 23:09
has joined #pact-jvm

alan.barr
2022-11-09 03:14
has joined #pact-jvm

wojciech.bachur
2022-11-09 13:55
has joined #pact-jvm

arek92
2022-11-09 13:58
has joined #pact-jvm

dariusz.duleba
2022-11-09 14:00
has joined #pact-jvm

nathan.deamer
2022-11-09 18:35
Evening everyone, Can I get a sanity check please on webhooks? I have pushed a consumer with a branch to pactflow (all good) This has then triggered a webhook in our CICD to trigger the provider - with some properties such as the pact-url for verification (all good) In the provider I have set the following properties: ```systemProperty "pact.provider.version", getGitHash() systemProperty "pact.provider.branch", getGitBranch() systemProperty "pact.verifier.publishResults", "true" systemProperty "pact.filter.consumers", [nameOfConsumer] systemProperty "pact.filter.pacturl", [pact-url-from-webhook]``` I?d expect given I have set the `pact.filter.pacturl` that it should only run the provider tests for that are in the url provided - but it seems to be running everything and also not verifying the consumer branch I am expecting. It is as though the `pact.filter.pacturl` is being ignored?

nathan.deamer
2022-11-09 18:57
I think I forgot an annotation `@AllowOverridePactUrl`

vieira.jluiz
2022-11-09 22:29
Hello everyone. Searched a lot and was not able to find a solution, so I am asking help here. I am trying to write the code for the provider side of contract in java (`au.com.dius.pact.provider:spring:4.3.16`). A have a few tests working, but when I try to test a controller that has a `Pageable` as a parameter, I get. ``` 1.1) Request processing failed; nested exception is java.lang.IllegalStateException: No primary or single unique constructor found for interface org.springframework.data.domain.Pageable``` I am already using the `messageConverters` of the `MockMvcTarget` but I could not find an argument resolver of sorts. One solution would be to break down the pageable in the values, but I was trying to avoid that. Any ideas on how to fix this error with pageable as a parameter? (code in the first comments of the thread)

vieira.jluiz
2022-11-09 22:30
controller code ``` @GetMapping("/integrations-config/search") public CollectionModel<?> search(@RequestParam String param1, @RequestParam String param2, Pageable pageable) { return //some logic }```

vieira.jluiz
2022-11-09 22:31
controller test ```@RunWith(SpringRestPactRunner.class) @Provider("my-service") @PactBroker(url = "https://pact-brokers.tools.mydomain.com") @PactFilter(value = "^\\/integrations-config\\/.*", filter = InteractionFilter.ByRequestPath.class) public class SampleControllerProviderContractTest { @TestTarget public final MockMvcTarget target = new MockMvcTarget(); @Mock private IntegrationConfigService integrationConfigService; @Mock private IntegrationConfigRepository integrationConfigRepository; @InjectMocks private IntegrationConfigController integrationConfigController = new IntegrationConfigController(integrationConfigRepository); @Before public void before() { MockitoAnnotations.initMocks(this); target.setControllers(integrationConfigController); } @State("my state") public void stateForX() { //my mocks } }```

cgodsey
2022-11-10 19:45
has joined #pact-jvm

saweniger
2022-11-14 17:29
has joined #pact-jvm

miguel.roldan
2022-11-15 11:06
has joined #pact-jvm

marek.czerwinski
2022-11-15 12:05
Hi all! Do you have any examples which show how can I use JUnit `@ParameterizedTest` on a consumer side?

angad.singh
2022-11-15 13:14
Hi All, I am trying to integrate contract testing in Android along with the Instrumentation tests (UI tests). So far we have tried to use `Pact-jvm` (https://github.com/pact-foundation/pact-jvm) and `wiremock-pact-generator` plugin (https://bitbucket.org/atlassian/wiremock-pact-generator) but facing some issues with both of these libraries. With `Pact-jvm`, I am not able to mock the responses and with `wiremock-pact-generator` plugin I am not able to add providerState or a matcher in the pact generated. Has anyone faced/resolved a similar kind of issue?

robin.lungwitz
2022-11-15 13:32
has joined #pact-jvm

laith
2022-11-15 16:15
has joined #pact-jvm

laith
2022-11-15 16:17
Hi! I?m using v4.1.39 of the JUnit5 provider plugin in Java 11, and I?m trying to modify the request sent to the pact broker to include a basic auth header as per https://docs.pact.io/implementation_guides/jvm/provider/junit5#modifying-the-requests-before-they-are-sent. However, when I inspect the packets being sent to the pact broker, I see that the header is not being added, and so the authentication fails. I?m probably missing something obvious, is anyone able to help? See thread for my code etc.

laith
2022-11-15 16:18
My code: ```@TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(PactVerificationContext context, HttpRequest request) { String encodedUsernameAndPassword = Base64.getEncoder().encodeToString("user:password".getBytes()); request.addHeader("Authorization", "Basic " + encodedUsernameAndPassword); context.verifyInteraction(); }``` The headers that are actually sent - note the Authorization header is not present: ```Content-Type: application/json Accept: application/hal+json, application/json Host: localhost:9292 Connection: Keep-Alive User-Agent: Apache-HttpClient/4.5.6 (Java/11.0.16.1) Accept-Encoding: gzip,deflate``` The error I get when I run the test: ```[ERROR] testTemplate{PactVerificationContext, HttpRequest} Time elapsed: 0.989 s <<< ERROR! au.com.dius.pact.core.pactbroker.InvalidNavigationRequest: Failed to fetch the root HAL document Caused by: au.com.dius.pact.core.pactbroker.RequestFailedException: Request to path '/' failed with response 'HTTP/1.1 401 Unauthorized'```

shivam.kumar
2022-11-15 17:08
hey everyone, We have been using Pact-jvm (version 4.1.34) for contract test across our web and microservices (25-30 applications :pact-logo-white:). I was looking to setup some kind of `observability` for our contract test executions to monitor the failures :dart:. Has anyone seen any example implemented where we could read the Verification Results at the end of provider test completion and publish the meaningful info from results as part of AfterAll or end of execution.

elluru.kri.mohan
2022-11-15 18:14
has joined #pact-jvm

rmartine
2022-11-15 20:35
has joined #pact-jvm

matt.fellows
2022-11-15 22:17
what tools do you use for other testing observability? e.g. sonarqube?

matt.fellows
2022-11-15 22:17
> I?m trying to modify the request sent to the pact broker this is not a thing. Do you mean request to the provider? The pact broker just hosts the pact files. No testing happens against the broker

matt.fellows
2022-11-15 22:18
The code above injects a header to the request to the provider during the test phase, not to the broker

matt.fellows
2022-11-15 22:18
I think you want to authenticate to the broker?+


sameena9010
2022-11-16 06:49
has joined #pact-jvm

shivam.kumar
2022-11-16 09:00
@matt.fellows Thanks for your reply. We are using Datadog metrics in this case. But that tool doesn?t matter as such, because i was looking to fetch the pact test result information somehow and then send it via the Datadog apis.

laith
2022-11-16 09:08
Thanks, yes authentication with the broker is what I?m after, looks like I misunderstood the documentation

ryanthomas840310
2022-11-16 20:52
has joined #pact-jvm

mike.hideaki
2022-11-16 21:48
has joined #pact-jvm

vwaters
2022-11-16 22:31
has joined #pact-jvm

rmartine
2022-11-16 22:48
Hi! Really great work from the pact team lately :slightly_smiling_face: I've been encountering this issue: https://github.com/pact-foundation/pact-plugins/issues/9 It's preventing the pact-protobuf-plugin from working from pact-jvm inside a docker container (which is how we run tests in our build system). Does anyone have a workaround?

uglyog
2022-11-16 22:58
Which version of the plugin are you using?

rmartine
2022-11-16 22:59
Latest, 0.1.16.



uglyog
2022-11-16 23:23
As soon as I get a chance, I'll look into this for you

rmartine
2022-11-16 23:23
Thank you so much!

matt.fellows
2022-11-17 03:27
> Hi! Really great work from the pact team lately also thank you, that actually means a lot :pray:

rmartine
2022-11-17 17:02
Thank you for all your hard work!

juergen.unfried
2022-11-17 20:43
has joined #pact-jvm

jose.anastacio
2022-11-18 13:34
has joined #pact-jvm

shawn305
2022-11-18 13:42
has joined #pact-jvm

james.perepiczka
2022-11-18 14:35
Is it possible to set a default state? I?ve currently got some mocks setup when running the provider tests but for those tests I use particular states. There are some consumers that hit endpoints that dont require for us to mock but because the mocks are setup on a service level it is affecting their behaviour? Is there a default state annotation that we can use to tell the mock service to use real methods for the calls it needs to make?

rmartine
2022-11-19 01:14
Fix works like a charm, we're able to run tests + publish from a build pipeline, thank you so much!

tronghuy
2022-11-19 01:38
has joined #pact-jvm

tronghuy
2022-11-19 01:48
hello everybody. i'm not sure if this is the correct place to ask this. i am trying to test a contract against a provider that exposes it's API through an endpoint `/graphql`. the request is done through 2 methods: 1. lambda sdk call by another back end service 2. front end POST through the aws api gateway in both cases, the endpoints are not set up in the application itself but rather through lambda or aws api gateway (and the cdk) when running the test on the provider side, i always get 404 because the endpoint `/graphql` doesn't exist when the test is running locally. any ideas how to get around this? is using a Message Contract rather than an HTTP contract the best use here?

tronghuy
2022-11-19 01:53
i understand there are ideas here: https://docs.pact.io/recipes/apigateway however, i can't figure out how to implement them

uglyog
2022-11-21 06:02
Make a state called default?

uglyog
2022-11-21 06:05
I don't use API Gateway for the verification tests. For our lambda services, we run a node express app that hosts the lambda, and verify against that.

glauco.carvalho
2022-11-21 15:47
has joined #pact-jvm

tronghuy
2022-11-21 16:01
I ended up using WireMock to intercept the `/graphql` and bypass the gateway layer

soner.ay
2022-11-21 16:57
has joined #pact-jvm

matt.fellows
2022-11-21 23:44
Wiremock? can you please elaborate? Hopefully you?re not mocking out the whole endpoint (i.e. testing a mock, and not the real provider)?

tronghuy
2022-11-22 18:18
all of our microservices communicate through graphql via lambda or through a `/graphql` endpoint in a front end. the `/graphql` endpoint is set up in AWS CDK and api gateway. our provider microservices are not aware of the endpoints when testing locally. i used WireMock to listen for the `/graphql` post and pass it along to the logic controller

flafla.mattos
2022-11-22 19:10
has joined #pact-jvm

chrisjburnscg
2022-11-22 22:11
has joined #pact-jvm

matt.fellows
2022-11-22 23:07
oh right. I didn?t realise WireMock could also act as a proxy

matt.fellows
2022-11-23 01:05
FYI I have moved the issue to https://github.com/pact-foundation/pact-mock_service/issues/140, which is where the true source of the problem lies

marcin.grzejszczak
2022-11-23 11:55
hey! I tried pinging @matt.fellows about this but didn't get any response so I'll post the message here. I'm Marcin and I'm the lead of Spring Cloud Contract. I've got a thing I would like to discuss. I tried to upgrade Pact support in Spring Cloud Contract from version 4.1 to 4.3. Unfortunately, there were API breakages (which I've managed to fix) and functionality breakages (which I didn't manage to fix). I often have to spend a lot of time on the upgrades even with minor releases (actually I see breaking changes even between 4.2.7 and 4.2.20). We've decided to move the SCC - Pact integration out of SCC (I've temporarilly moved the whole code here https://github.com/marcingrzejszczak/spring-cloud-contract-pact together with e2e samples) . My question is - would someone (I guess the Pact foundation) be willing to take in the SCC - Pact integration?

yousafn
2022-11-23 13:40
Hey @woojos, Thanks for reaching out! Matt is over is Aus, so is likely to be asleep now. Will have a chat with the team, I was aware of SCC but wasn't aware there was an SCC Pact integration. Is there any insight into ? what issues were seen so far / resolved (changelog)? ? who is using SCC Pact and where if anywhere are they raising issues? ? any documentation to the SCC Pact integrations, example repos etc? Just thinking it would be useful, as if it does come under the Pact Foundation wing, we would need to help find maintainers and contributors to support it.

marcin.grzejszczak
2022-11-23 13:42
Yeah I've pinged Matt a couple of days ago. > what issues were seen so far / resolved (changelog)? I guess you can follow these issues to have an answer to that https://github.com/spring-cloud/spring-cloud-contract/issues?q=is%3Aissue+is%3Aopen+pact > who is using SCC Pact and where if anywhere are they raising issues? Users of SCC are. They are raising issues in SCC issues at Github (as shown above). > any documentation to the SCC Pact integrations, example repos etc? I moved the docs, the code and samples here https://github.com/marcingrzejszczak/spring-cloud-contract-pact

matt.fellows
2022-11-23 21:30
Eeek! Sorry I missed that Marcin - my slack #inboxzero is currently failing

matt.fellows
2022-11-23 21:30
We?ll raise this with the maintainer group to see what options we have

matt.fellows
2022-11-23 21:30
thanks for sharing the link above, very helpful

imer.muhovic
2022-11-24 08:57
has joined #pact-jvm

mohitsoni
2022-11-24 10:19
has joined #pact-jvm

celia
2022-11-24 14:32
has joined #pact-jvm

harald.bittermann
2022-11-25 10:01
has joined #pact-jvm

ad
2022-11-25 13:23
has joined #pact-jvm

sree
2022-11-25 14:22
has joined #pact-jvm

soumya.aithal
2022-11-27 17:15
has joined #pact-jvm

nathan.pine
2022-11-28 09:19
has joined #pact-jvm

sanmicad
2022-11-28 12:20
has joined #pact-jvm

glenn
2022-11-28 21:14
When running the producer tests for a service that has other downstream service dependencies is the approach to mock / stub those downstream dependencies?



glenn
2022-11-29 09:04
:slightly_smiling_face: thanks @matt.fellows

marcin.nawrocki
2022-11-29 09:25
has joined #pact-jvm

glenn
2022-11-29 20:05
Is there a current state of the art pact + springboot example github repo you can recommend. Some of the examples linked in the docs have code from 2015. (ref: https://docs.pact.io/implementation_guides/jvm/readme#links)

uglyog
2022-11-29 22:19
There are some springboot examples around, but they will be very simple


matt.fellows
2022-11-29 23:03
howtoexamples


matt.fellows
2022-11-29 23:04
I think there are some springboot examples there

matt.fellows
2022-11-29 23:04
and the tutorials/workshops (howtolearn) definitely include springboot too

2022-11-29 23:04
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

sergewar
2022-11-30 08:54
has joined #pact-jvm

diego
2022-11-30 09:50
has joined #pact-jvm

surya.sidharthan
2022-11-30 11:13
has joined #pact-jvm

nicolas.chara
2022-11-30 13:16
has joined #pact-jvm

daniel
2022-11-30 18:30
has joined #pact-jvm

denis
2022-11-30 22:07
has joined #pact-jvm

francislainy.campos
2022-12-01 04:43
Hi, how do we tag a contract with the PR branch from the mvn command when publishing it? Can?t find the right syntax for that. Not sure if something like this? ``` ./mvnw -Dpactbroker.auth.token=${pactBrokerToken} pact:publish -Dpact.consumer.version=Aversion -Dpactbroker.tags=ATag```

francislainy.campos
2022-12-01 04:44
This is coming from Jenkins and we would like to tag our contracts with the git commit hash.

uglyog
2022-12-01 05:03
Use `pact.consumer.tags`

francislainy.campos
2022-12-01 05:09
```sh "PACT_CONSUMER=$consumer BROKER_TOKEN=$pactBrokerToken yarn publish:pact:flow --consumer-app-version=`git rev-parse HEAD` --tag=master"``` This is what we have for our javascript contract.

francislainy.campos
2022-12-01 05:10
Okay, so `-Dpact.consumer.tags="myTag"` ?

francislainy.campos
2022-12-01 05:11
Or do we need `{}`

uglyog
2022-12-01 05:12
Use `pact.publish.consumer.version` to set the version, and `pact.consumer.tags` to set any tags

francislainy.campos
2022-12-01 05:15
Cool, let me try that.

francislainy.campos
2022-12-01 05:15
Thank you

francislainy.campos
2022-12-01 05:20
It worked for the tagging but I?m a bit unsure about the versioning.

francislainy.campos
2022-12-01 05:20
It?s showing here 3.1.3

francislainy.campos
2022-12-01 05:21
But the value I tried to add was the hardcoded one

francislainy.campos
2022-12-01 05:21
```./mvnw -Dpactbroker.auth.token=myToken pact:publish -Dpact.consumer.version=Aversion -Dpact.consumer.tags=ATag```

francislainy.campos
2022-12-01 05:21
Ah, sorry, I think I?m missing a word here, right?

francislainy.campos
2022-12-01 05:22
```./mvnw -Dpactbroker.auth.token=myToken pact:publish -Dpact.publish.consumer.version=Aversion -Dpact.consumer.tags=ATag```

francislainy.campos
2022-12-01 05:22
Should it be like this instead?

francislainy.campos
2022-12-01 05:24
Doesn?t seem to be it..

francislainy.campos
2022-12-01 05:26
And we need the branch as well


francislainy.campos
2022-12-01 05:28
Cool, but my command seems correct for the version parameter

francislainy.campos
2022-12-01 05:28
But it?s still not there

francislainy.campos
2022-12-01 05:29
Instead, it?s showing the old 3.1.3 value

uglyog
2022-12-01 05:29
Does it have the same Pact file?

francislainy.campos
2022-12-01 05:29
Yes

francislainy.campos
2022-12-01 05:30
Do I need to delete it and republish it?

francislainy.campos
2022-12-01 05:33
No, I deleted the whole integration and tried again but still came up with the 3.1.3 value and no branch info.

francislainy.campos
2022-12-01 05:33
```./mvnw -Dpactbroker.auth.token=myToken pact:publish -Dpact.publish.consumer.version=Aversion -Dpact.consumer.tags=ATag -Dpact.publish.consumer.branch=Abranch```

uglyog
2022-12-01 05:36
What version are you using?

francislainy.campos
2022-12-01 05:37
for pact?

uglyog
2022-12-01 05:37
Yes, that requires min versions 4.1.33/4.2.19/4.3.4

francislainy.campos
2022-12-01 05:37
Let me check it here.

francislainy.campos
2022-12-01 05:38
```<pact.version>4.3.2</pact.version> <pact.plugin.version>4.0.10</pact.plugin.version>```

uglyog
2022-12-01 05:38
`4.0.10` is too old

francislainy.campos
2022-12-01 05:39
Cool, I?ll find a newer one.

francislainy.campos
2022-12-01 05:44
4.1.28 fine?

francislainy.campos
2022-12-01 05:44
Nah, maven is complaining that doesn?t exist

uglyog
2022-12-01 05:46
Why not `4.3.17`?

uglyog
2022-12-01 05:46
That is the latest 4.3.x version

francislainy.campos
2022-12-01 05:47
Yes, I was looking for this but couldn?t find it.

francislainy.campos
2022-12-01 05:47
I?ll try now.

francislainy.campos
2022-12-01 05:47
Thank you.

francislainy.campos
2022-12-01 05:48
Maven is not finding it

francislainy.campos
2022-12-01 05:49
``` <plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.3.17</version> <configuration> <pactDirectory>target/pacts</pactDirectory> <pactBrokerUrl>https://my.pactflow.io</pactBrokerUrl> <!--suppress UnresolvedMavenProperty --> <pactBrokerToken>${pactbroker.auth.token}</pactBrokerToken> <projectVersion>${project.version}</projectVersion> <trimSnapshot>true</trimSnapshot> </configuration> </plugin>```

uglyog
2022-12-01 05:50
```<groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.3.17</version>```

francislainy.campos
2022-12-01 05:54
Unfortunately, this version didn?t even publish the contract.

francislainy.campos
2022-12-01 05:54
:disappointed:

francislainy.campos
2022-12-01 05:55
weird..

francislainy.campos
2022-12-01 05:55
I get an ok on the terminal

francislainy.campos
2022-12-01 05:55
but the contract is not there.

uglyog
2022-12-01 05:55
You'll need to provide debug logs.

francislainy.campos
2022-12-01 05:56
how do I do that?

francislainy.campos
2022-12-01 05:56
owh, no

francislainy.campos
2022-12-01 05:56
wait, it?s here

francislainy.campos
2022-12-01 05:56
maybe there was a bit of delaying, but I see it here now

francislainy.campos
2022-12-01 05:57
All good, it seems

francislainy.campos
2022-12-01 05:57
both version and branch name are here.

francislainy.campos
2022-12-01 05:57
Thanks so, so much!!

francislainy.campos
2022-12-01 06:00
I?m just investigating now as the branch name got published with the tag instead.

francislainy.campos
2022-12-01 06:00
Let me check a bit.

uglyog
2022-12-01 06:01
The broker does that, sets the branch to the tag if the branch is not set

francislainy.campos
2022-12-01 06:02
But I?m setting it though?

francislainy.campos
2022-12-01 06:02
./mvnw -Dpactbroker.auth.token=myToken pact:publish -Dpact.publish.consumer.version=Aversion -Dpact.consumer.tags=ATag -Dpact.publish.consumer.branch=Abranch

uglyog
2022-12-01 06:02
Try remove the tag

francislainy.campos
2022-12-01 06:03
None of them appear now

francislainy.campos
2022-12-01 06:04
I mean, no branch and no tag info

francislainy.campos
2022-12-01 06:18
I?ll need to step away for 1h30 to leave for the office, but I can get back here as soon as I?m with the computer again.

francislainy.campos
2022-12-01 06:19
I?m a bit short on time as this is actually my last day with the company, so really prioritising getting this done so I can hand it over back to team in working condition.

james.perepiczka
2022-12-01 08:51
Hi, is it possible to do a pact verification based off of the consumer version number? I?m thinking of the scenarios where a webhook is triggered by the broker, there are a number of properties to get the consumer and their version such as `${pactbroker.consumerVersionNumber}` and `${pactbroker.consumerName}` . Is there a way of combining that in order to give a selector such as ```SelectorBuilder().consumer("consumer1").version("1234567")``` I was looking to see if the raw json selectors would do it but I couldn?t find any examples of what can be passed

francislainy.campos
2022-12-01 11:12
Is this how we inject an id dynamically into the body for a consumer? ```@ExtendWith(PactConsumerTestExt.class) class PactConsumerSendScoreIT { private final Map<String, String> headers = new HashMap<>(); private final String path = "/v5/assignmentStatus/update"; @Pact(provider = PACT_PROVIDER, consumer = PACT_CONSUMER) public RequestResponsePact scoreConsumerPact(PactDslWithProvider builder) { headers.put("Content-Type", "application/json"); //Body given and returned DslPart body = new PactDslJsonBody() .valueFromProviderState("assignmentId", "assignmentId", "c1ef3bbf-55a2-4638-8f93-22b2916fe085") .stringType("timestamp", DateTime.now().plusHours(3).toString()) .decimalType("scoreGiven", 75.00) .decimalType("scoreMaximum", 100.00) .stringType("comment", "Good work!") .stringType("status", "IN_PROGRESS") .stringType("userId", "c2ef3bbf-55a2-4638-8f93-22b2916fe085") .close(); return builder .given("Scoring info is passed between ags-tool and assignmentapi") .uponReceiving("Scoring info is passed between ags-tool and assignmentapi") .path(path) .method("POST") .body(body) .headers(headers) .willRespondWith() .status(201) .body(body) .toPact(); } @Test @PactTestFor(pactMethod = "scoreConsumerPact", providerName = PACT_PROVIDER, port = "8080", pactVersion = PactSpecVersion.V3) void runTest(MockServer mockServer) { String updateAssignmentId = "c2ef3bbf-55a2-4638-8f93-22b2916fe085"; HashMap<String, Object> map = new HashMap<>(); map.put("timestamp", DateTime.now().plusHours(3).toString()); map.put("scoreGiven", 75.00); map.put("scoreMaximum", 100.00); map.put("comment", "Good work!"); map.put("status", "IN_PROGRESS"); map.put("userId", "c2ef3bbf-55a2-4638-8f93-22b2916fe085"); map.put("assignmentId", updateAssignmentId); //Mock url RequestSpecification rq = Util.getRequestSpecification().baseUri(mockServer.getUrl()).headers(headers); Response response = rq.body(map) .post(path); assertEquals(201, response.getStatusCode()); }```

francislainy.campos
2022-12-01 11:12
```@State("Scoring info is passed between ags-tool and assignmentapi") Map<String, Object> getScoringInfo() { Map<String, Object> map = new HashMap<>(); map.put("assignmentId",updateAssignmentId); return map; }```

francislainy.campos
2022-12-01 11:13
I think we may need to have sth set inside the runTest code to make sure we?re configuring it to be dynamically generated perhaps?

francislainy.campos
2022-12-01 11:13
As of now, it?s still using the hardcoded id given under the sample part.

dbarne24
2022-12-01 11:35
has joined #pact-jvm

min.zaw.mra
2022-12-01 11:36
has joined #pact-jvm

kevin.lau
2022-12-01 11:41
has joined #pact-jvm


bojanmarjanovic1980
2022-12-01 13:09
has joined #pact-jvm

ivona.sovic
2022-12-01 13:13
has joined #pact-jvm

orbit
2022-12-01 15:45
has joined #pact-jvm

david.dudley
2022-12-01 19:55
has joined #pact-jvm

brian.coan
2022-12-01 20:22
has joined #pact-jvm

manishmitraba
2022-12-02 02:16
has joined #pact-jvm

lepdiana01
2022-12-02 03:53
has joined #pact-jvm

arpan.agr
2022-12-02 08:06
has joined #pact-jvm

goksel00
2022-12-02 17:41
has joined #pact-jvm

aibosun900614
2022-12-04 02:18
has joined #pact-jvm

mayank.mahajan04
2022-12-05 10:51
has joined #pact-jvm

elluru.kri.mohan
2022-12-05 12:42
HI All, https://mvnrepository.com/artifact/au.com.dius/pact-jvm-provider-maven suggests latest version of pact-jvm is 4.0.10 and it is as old as 2 yrs. is this the latest? should I use pact-jvm or http://au.com.dius.pact.provider-maven for my maven builds? I see both are redundant and the examples in https://docs.pact.io/implementation_guides/jvm/provider/maven refer to pact-jvm though.

dyptorden
2022-12-05 16:58
hi guys, Anyone knows if there's a `Pact Junit 5 Extension` compiled in Java 8? It is impossible to move our monolith to Java 11, and I need to make use of the `PactBrokerConsumerVersionSelectors`



mailtoshinu
2022-12-06 07:42
has joined #pact-jvm

dyptorden
2022-12-06 09:39
thank you @matt.fellows

rmartine
2022-12-06 22:29
I feel like I'm missing something obvious -- what's the equivalent of `.given` for a `consumer.dsl.PactBuilder`? I'm trying to set a provider state on a pact, using the plugins framework. Working off of the example https://github.com/pact-foundation/pact-plugins/blob/main/examples/gRPC/area_calculator/consumer-jvm/src/test/java/io/pact/example/grpc/consumer/PactConsumerTest.java.

uglyog
2022-12-06 23:12
You are correct, it is missing. Can you raise an issue for that, please?


youri.thielen
2022-12-07 07:52
has joined #pact-jvm

cpopovici
2022-12-07 09:02
has joined #pact-jvm

hendrik916
2022-12-07 12:07
has joined #pact-jvm

matcheckep
2022-12-07 13:55
has joined #pact-jvm

brendan.j.donegan
2022-12-07 15:05
@francislainy.campos we figured out that the expression needed to include the ${} at least if it's a string - once we updated it to `valueFromProviderState("assignmentId", "${assignmentId}", "c1ef3bbf-55a2-4638-8f93-22b2916fe085")` it seems to work

wesley.nutley
2022-12-07 19:48
has joined #pact-jvm

github2
2022-12-07 20:21
The GitHub user https://github.com/bethesque has signed out. Use the following command/s to recreate subscriptions /github subscribe pact-foundation/pact-jvm

bethskurrie
2022-12-08 00:35
/github subscribe pact-foundation/pact-jvm

2022-12-08 00:35
:white_check_mark: Subscribed to https://github.com/pact-foundation/pact-jvm. This channel will receive notifications for `issues`, `pulls`, `commits`, `releases`, `deployments`

dagmara.krent
2022-12-08 10:19
has joined #pact-jvm

komathypriya
2022-12-08 11:35
has joined #pact-jvm

neethu.santhosh
2022-12-08 14:22
has joined #pact-jvm

janga.nagamallika
2022-12-08 17:49
has joined #pact-jvm

rmartine
2022-12-08 21:18
We have our protobuf files distributed as an artifact that's part of a dependency's JAR, and need to extract the file in order to pass a path to the gRPC plugin. I figured I'd share the snippet I came up with, in case it's of use to others, or anyone has a better method :slightly_smiling_face:

uglyog
2022-12-08 21:43
I'll see if I can add this into the test DSL

yousafn
2022-12-08 22:12
Nice! Thanks for sharing @rmartine :chefkiss: Glad to see you checking out the plugins too, cheers for the kind words on our announcement post

jampala_1988
2022-12-08 23:47
has joined #pact-jvm

krishnaraj.pk
2022-12-09 05:35
has joined #pact-jvm

rajavadootha04
2022-12-09 07:56
has joined #pact-jvm

rajavadootha04
2022-12-09 08:02
We are also facing issues with multipart file upload contract testing. Getting 'Missing start boundary'. Do we have multipart support at consumer side? We are trying with both pact versions 3.0.0 and 4.0.0, both results same error.

tomaszrdzak
2022-12-09 11:54
has joined #pact-jvm

kjayachandra2000
2022-12-10 23:04
Hey All :wave: , is there an automated way to update `repositoryUrl` for the pacticipants? I don?t want to use pact API . I would be keen to know to update the url while publishing pacts or running the tests

uglyog
2022-12-11 22:02
Not with Pact-JVM.

kjayachandra2000
2022-12-12 07:05
thanks uglyog

edouard.lopez
2022-12-12 09:16
Hello, I got the following feedback from a teammate > Hi there! > A small issue we just encounter with PACT. Our PACT consumer is green and was validated by the provider, so all seems good. But then, when we did our first test and we are facing a deserialization issue on the provider side. After investigating, the consumer is not serializing in the right way an enumeration value. The provider is expecting "`customer_order`" and the consumer is sending "`CUSTOMER_ORDER`". > So I did some test on the consumer, to understand why this has not broken the PACT on the consumer side. And it seems that the PACT *consumer will broke if an expected field in the request is missing, but not if the values does not match*... I am a bit sad about this behavior, I was expected the PACT to fully validate the body, field and value. This mean, we need to write additional integration test to validate the serialization of the consumer, not cool :confused:! Or maybe we are missing a configuration somewhere? I haven't found something yet His solution was to implement a matcher on the request field. ``` .stringMatcher( "issuer_type", "^(" + Arrays.stream(IssuerTypeDTO.values()) .map(IssuerTypeDTO::getCode) .collect(Collectors.joining("|")) + ")", IssuerTypeDTO.CUSTOMER_ORDER.getCode())``` I'm aware that Pact is not strict in the response's _value_ but was expecting more control on the request content as per https://docs.pact.io/getting_started/matching/gotchas#pact-follows-postels-law. Should

maxime.raverdy
2022-12-12 09:22
has joined #pact-jvm

matt.fellows
2022-12-12 10:56
No, Pact should detect this situation. There is some other issue going on

matt.fellows
2022-12-12 10:57
> And it seems that the PACT *consumer will broke if an expected field in the request is missing, but not if the values does not match* In the consumer test, it won?t fail when the unit test happens if the response value is incorrect (it?s a mock of the provider at this stage, which has yet to be verified).

matt.fellows
2022-12-12 10:58
At this point, if you are using `can-i-deploy`, this check should not pass, because the provider has yet to validate the contract. When the provider verifies the contract, if it receives `CUSTOMER_ORDER` and that is unexpected, presumably the provider build should fail? If you are using `can-i-deploy`, this check should not pass, because the provider is unable to satisfy the contract

matt.fellows
2022-12-12 11:00
> His solution was to implement a matcher on the request field. This is not a good solution, because it requires knowledge of the provider?s validation rules. In general, you should avoid matchers on the request unless you can?t make the unit test pass (which is usually a sign the code is not very modular)

sambhavi.chinnu
2022-12-13 04:11
has joined #pact-jvm

david.turner
2022-12-13 09:01
has joined #pact-jvm

edouard.lopez
2022-12-13 11:20
> In the consumer test, it won?t fail when the unit test happens if the response value is incorrect (it?s a mock of the provider at this stage, which has yet to be verified). I reckon the use of matchers makes the test fail in a way they expect, the reasoning probably being "it fails for missing field, it should fail for invalid values". And instead of adding a unit test on the DTO serialization, they use a matcher on contract tests :/

mateusz.dudek03
2022-12-13 14:10
has joined #pact-jvm

mateusz.dudek
2022-12-13 14:22
has joined #pact-jvm

dmitrij.bogomyakov
2022-12-13 16:09
has joined #pact-jvm

victor.lau841
2022-12-13 16:30
has joined #pact-jvm

roblesjm
2022-12-14 11:40
has joined #pact-jvm

ahmidat
2022-12-14 12:44
has joined #pact-jvm

sergey.ledniov
2022-12-14 16:46
has joined #pact-jvm

abhimanu.sehgal
2022-12-14 20:40
has joined #pact-jvm

abraham.gonzalez93
2022-12-14 21:38
@abraham.gonzalez93 has left the channel

uglyog
2022-12-14 23:54
/github subscribe pact-foundation/pact-jvm issues, releases

2022-12-14 23:54
This channel will receive notifications from https://github.com/pact-foundation/pact-jvm for: `issues`, `pulls`, `commits`, `releases`, `deployments`

uglyog
2022-12-14 23:56
/github subscribe pact-foundation/pact-jvm commits

2022-12-14 23:56
This channel will receive notifications from https://github.com/pact-foundation/pact-jvm for: `issues`, `pulls`, `commits`, `releases`, `deployments`

uglyog
2022-12-14 23:56
/github unsubscribe pact-foundation/pact-jvm commits

2022-12-14 23:56
This channel will receive notifications from https://github.com/pact-foundation/pact-jvm for: `issues`, `pulls`, `releases`, `deployments`

uglyog
2022-12-14 23:56
/github unsubscribe pact-foundation/pact-jvm issues

2022-12-14 23:56
This channel will receive notifications from https://github.com/pact-foundation/pact-jvm for: `pulls`, `releases`, `deployments`

uglyog
2022-12-14 23:57
/github unsubscribe pact-foundation/pact-jvm pulls

2022-12-14 23:57
This channel will receive notifications from https://github.com/pact-foundation/pact-jvm for: `releases`, `deployments`

enrique.decoss
2022-12-15 02:25
has joined #pact-jvm

kirankishore4
2022-12-15 06:12
has joined #pact-jvm

maxime.raverdy
2022-12-15 09:57
@maxime.raverdy has left the channel

alvaro.navarroiborra
2022-12-15 10:47
has joined #pact-jvm

leelavathi.sundaram
2022-12-15 10:55
has joined #pact-jvm

paula.muldoon
2022-12-15 11:40
has joined #pact-jvm

james.sun
2022-12-15 22:42
has joined #pact-jvm

dominic.matabilas
2022-12-15 22:42
has joined #pact-jvm

myao
2022-12-16 00:21
has joined #pact-jvm

matt.fellows
2022-12-16 01:46
mmm possibly

matt.fellows
2022-12-16 01:47
Did the other answer make sense to the team? Because it?s a unit test, they won?t see just yet if their mock is valid - only once the provider verification takes place do we know this, which is why `can-i-deploy` exists.

tlemmonds
2022-12-16 19:55
has joined #pact-jvm

samuel.woodbridge
2022-12-19 09:44
has joined #pact-jvm

mwojcik
2022-12-19 13:43
has joined #pact-jvm

robinsmit
2022-12-19 15:08
has joined #pact-jvm

jungjae.lim
2022-12-19 16:24
has joined #pact-jvm

saurwein
2022-12-21 14:48
has joined #pact-jvm

ssharma
2022-12-21 15:17
has joined #pact-jvm

laith
2022-12-21 15:24
Hi, I?m using v4.1.39 of the junit5 provider plugin to verify pacts with a pact broker with basic auth enabled. I?m trying to pass in the password to the `@PactBrokerAuth` annotation using a java system property, since https://docs.pact.io/implementation_guides/jvm/provider/junit#using-authentication-with-the-pact-broker, ?the `token`, `username` and `password` values also take Java system property expressions?. A quick google of java system property expressions led me to Spring expression language, so I tried `password = "#{systemProperties['pact.broker.password']}"`, and also `password = "System.getProperty(\"pact.broker.password\")"` (where I?ve defined `pact.broker.password` on the command line), but in both cases the string was interpreted literally. I?m not too familiar with spring, or java for that matter, would you be able to help me get the syntax right? Thanks

alejandro.depablos
2022-12-21 18:56
has joined #pact-jvm

vieira.jluiz
2022-12-21 20:09
For anyone looking for the solution, I found it and posted https://stackoverflow.com/a/74881297/1986022.

uglyog
2022-12-21 22:26
Use the form `password = "${pact.broker.password}"`

tomas.cerkasas
2022-12-21 23:14
has joined #pact-jvm

priyanka.soni
2022-12-22 08:24
has joined #pact-jvm

laith
2022-12-22 10:02
excellent thank you

zijian.wang1
2022-12-22 10:51
has joined #pact-jvm

anyi.huang
2022-12-22 11:02
has joined #pact-jvm

stepik02
2022-12-23 10:36
has joined #pact-jvm

prajwalg
2022-12-25 14:28
has joined #pact-jvm

raksha.baskaran
2022-12-27 06:01
has joined #pact-jvm

venkatesh.madas
2022-12-27 06:36
has joined #pact-jvm

anthony.bennett
2022-12-27 20:15
has joined #pact-jvm

livinglogic.nl
2022-12-28 10:50
has joined #pact-jvm

pawel.szczerbicki
2022-12-29 13:22
has joined #pact-jvm

anandhiemail
2022-12-29 17:37
has joined #pact-jvm

francislainy.campos
2022-12-30 05:56
@matt.fellows @uglyog any plans to bring this in as a feature at some point: https://github.com/pact-foundation/pact-jvm/issues/1507 ?

arika.goyal
2022-12-30 12:18
has joined #pact-jvm

m.marquez
2022-12-31 16:05
has joined #pact-jvm

francislainy.campos
2023-01-02 06:31
Is this perhaps just a matter of using stringValue() instead of stringType()? Which one are you using?

guoxin.rick33
2023-01-03 08:45
has joined #pact-jvm

will
2023-01-03 09:59
has joined #pact-jvm

mario.pires
2023-01-03 11:42
has joined #pact-jvm

vtft1988
2023-01-03 16:38
has joined #pact-jvm

matt.thompson
2023-01-04 10:54
has joined #pact-jvm

rytis.lisauskas
2023-01-04 14:20
has joined #pact-jvm

morin.td
2023-01-04 16:54
has joined #pact-jvm

yanov.alexander
2023-01-04 17:07
Hello #pact-jvm , does anyone had practice writing pacts for services with different programming languages? An example, nodejs service as a consumer and java service as a provider?

jaswanth.ooty
2023-01-04 21:03
Hey @yanov.alexander :wave::skin-tone-2: yup. We have multiple consumers in different languages and have a provider in Kotlin. Is there anything specific that you?re after ? :slightly_smiling_face: Happy to answer any questions you have.

afernandez
2023-01-04 22:22
has joined #pact-jvm

vkaramoff
2023-01-05 10:00
has joined #pact-jvm

morin.td
2023-01-05 10:17
@morin.td has left the channel

vika.karman
2023-01-05 10:32
has joined #pact-jvm

tjones
2023-01-05 10:35
Yes, this is a normal Pact use case. There?s no need to use the same language at consumer and provider.

tjones
2023-01-05 10:35
Pact communicates using a language and platform independent contract file.

nickzakirov
2023-01-05 15:01
has joined #pact-jvm


vkaramoff
2023-01-05 18:27
Hello, In a code taken from https://github.com/zephyrok/blog-code-examples/tree/main/java/pact there are tests: ```@ExtendWith(PactConsumerTestExt.class) @Pact(provider = "order_provider", consumer = "order_consumer") public V4Pact listOfOrdersPact(PactDslWithProvider builder) { .... @Pact(provider = "order_provider", consumer = "order_consumer") public V4Pact noOrdersPact(PactDslWithProvider builder) { ... @Test @PactTestFor(pactMethod = "listOfOrdersPact") void getListOfOrders(MockServer mockServer) throws IOException { ... @Test @PactTestFor(pactMethod = "noOrdersPact") void getEmptyListOfOrders(MockServer mockServer) throws IOException {``` when I run *any* of these 2 tests I got an error: ```The following methods annotated with @Pact were not executed during the test: OrderApiClientPactTest.noOrdersPact If these are currently a work in progress, add a @Disabled annotation to the method``` Commenting out `noOrdersPact` and its test fixes the issue. How to fix that?


vkaramoff
2023-01-06 12:53
Root cause: it?s not possible to run individual tests

nam.nguyen
2023-01-07 04:00
has joined #pact-jvm

francislainy.campos
2023-01-08 07:13
That?s awesome, Brendan. Thank you for letting me know. I?ve added this to my SO question, so it should be there for future reference. https://stackoverflow.com/questions/74641538/how-to-inject-dynamic-id-for-body-of-pact-contract-written-in-java/75046058#75046058

dale.wells
2023-01-08 15:18
has joined #pact-jvm

manohar.adepu
2023-01-09 02:58
has joined #pact-jvm

hsyogesh12
2023-01-09 05:54
has joined #pact-jvm

hsyogesh12
2023-01-09 06:24
Hello, I am one of the PACT consumer, after upgrading to 4.0, It generates random strings (as example) to match the specified pattern and for some reason when it serializes those example string, it generates invalid sequence, It doesn't escape those strings in 4.0.x version that's the reason we don't see this issue before. we are getting below error ```{"error":{"message":"source sequence is illegal/malformed utf-8","reference":"HjPEylMxlF"}}```

matt.fellows
2023-01-09 06:31
Interesting. In most of the matchers that the JVM provides, you can provide an example or have Pact JVM generate ones for you. I suggest you don?t let it generate values, not just because of the issue, but also because it will mean the pact isn?t pre-verified in tools like `can-i-deploy`. That being said, if it is generating an invalid pact file, could you please raise a defect on the Pact JVM github?

hsyogesh12
2023-01-09 06:34
@matt.fellows can I please get the link to raise defect?

uglyog
2023-01-09 06:43
Can you also try a later version than 4.0, that is not a supported version

hsyogesh12
2023-01-09 07:32
sorry i mentioned wrong version earlier, currently we are using 4.1.41

sowmya.bhg
2023-01-09 10:32
has joined #pact-jvm

hsyogesh12
2023-01-09 10:36
@matt.fellows attached is the file which got generated and failed to publish

matt.fellows
2023-01-09 10:47
You?d raise any issue on the Github repo here :point_right: https://github.com/pact-foundation/pact-jvm/issues/new

matt.fellows
2023-01-09 10:47
I?ll let Ron weigh in on whether you should do that though

hsyogesh12
2023-01-09 11:01
@matt.fellows I have created the issue, please find below link for your reference https://github.com/pact-foundation/pact-jvm/issues/1651

ivan.mikhalka
2023-01-09 13:21
has joined #pact-jvm

klaudijus.rulys
2023-01-09 13:32
has joined #pact-jvm

boer.k
2023-01-09 15:10
has joined #pact-jvm

chris.aguirre11
2023-01-09 16:45
has joined #pact-jvm

nicolas.barbey
2023-01-09 17:06
has joined #pact-jvm

simon.petty
2023-01-09 21:11
has joined #pact-jvm

edisonjen13
2023-01-09 22:25
has joined #pact-jvm

hsyogesh12
2023-01-10 06:24
@matt.fellows any update on the issue?

matt.fellows
2023-01-10 07:29
Thanks for raising. I don?t see any comments on the issue, but best to follow that issue for updates

hsyogesh12
2023-01-10 07:51
@matt.fellows its passing sometimes and failing consistently, not sure what exactly the problem is

jeroen.vandijk
2023-01-10 09:07
@jeroen.vandijk has left the channel

boer.k
2023-01-10 10:16
Hi, I have a simple consumer test in which I expect the producer to return a json array as response body. However when we ran the producer test, it turned out that the producer returns the array unordered. All the data is there, but the order is inequal. As the consumer, we don?t care about the order. So I assume I have to edit the pact in the consumer test to somehow specify that the order is irrelevant, but I have no how to do so. I believe this documentation https://github.com/pact-foundation/pact-jvm/tree/master/consumer/junit#dsl-matching-methods is relevant, but its hard to find example usages of it. Am I on the right track here?

matt.fellows
2023-01-10 11:10
I think you want the eachLike matcher from here: https://github.com/pact-foundation/pact-jvm/tree/master/consumer/junit#ensuring-all-items-in-a-list-match-an-example If you need exact value matching, but without the ordering of elements, I'm not sure that's currently possible

matt.fellows
2023-01-10 11:11
Ah, you want `unorderedArray` : https://github.com/pact-foundation/pact-jvm/tree/master/consumer/junit#ignoring-the-list-order-v4-specification (Only if you want value matching. You might just want to be ensuring the shape is correct)

boer.k
2023-01-10 12:20
Yeah I think the unorderedArray and value matching is what we want. However I am unfamiliar with defining the response as a DslPart object. Currently we just define our response as a json string. Do you maybe have any code examples or documentation where unorderedArray is used?

matt.fellows
2023-01-10 12:21
I don?t sorry (I literally only just discovered that new matcher now)


matt.fellows
2023-01-10 12:22
(see also howtoexamples)


boer.k
2023-01-10 12:23
Thanks a lot! I expect this should be enough to get me going

artem.z
2023-01-11 13:18
has joined #pact-jvm

jrede
2023-01-11 17:57
has joined #pact-jvm

vanitha.annamalai
2023-01-12 05:27
has joined #pact-jvm

jessy.li
2023-01-12 17:29
has joined #pact-jvm

aronlmin
2023-01-13 02:13
has joined #pact-jvm

harwin1494
2023-01-13 06:56
Hi, is there any provision to write pact tests for the micronaut framework?

buckley
2023-01-13 20:01
has joined #pact-jvm

sashizen
2023-01-16 09:09
has joined #pact-jvm

richardmccann
2023-01-16 15:37
has joined #pact-jvm

francislainy.campos
2023-01-17 05:28
@phil.endsley maybe you can answer? Thank you.

eugene.malihins
2023-01-17 11:08
has joined #pact-jvm

yusufjamalazam
2023-01-17 12:24
has joined #pact-jvm

jbosca
2023-01-17 13:10
has joined #pact-jvm

hehecx
2023-01-17 22:16
has joined #pact-jvm

jawaharsurapaneni
2023-01-18 00:36
has joined #pact-jvm

kerrypmckeever
2023-01-18 02:12
has joined #pact-jvm

tomknee1
2023-01-18 10:48
hello, does anyone please know how i can do `minArrayLike` for an array of json objects in Kotlin lambda dsl please?

james_fraser
2023-01-18 15:50
Hey folks :wave: does anyone know if it?s possible to write contract tests for Java services that communicate using JSON-RPC?

paul
2023-01-18 16:56
has joined #pact-jvm

matt.fellows
2023-01-19 02:03
Is that over HTTP or sockets I can't remember? You could probably model it with message pact if the latter. If the former you might need to create a content type plugin

basma.eldesouky
2023-01-19 10:24
has joined #pact-jvm

james_fraser
2023-01-19 10:36
I think ours is over HTTP, is there any documentation on writing a plugin?

alex.strizhak
2023-01-19 13:12
has joined #pact-jvm

laura.porpiglia
2023-01-19 13:56
has joined #pact-jvm

chimein.1234
2023-01-19 16:13
has joined #pact-jvm

john295
2023-01-19 23:12
has joined #pact-jvm

hsyogesh12
2023-01-20 07:28
@matt.fellows any luck with the defect

dominik.lukac.96
2023-01-20 10:33
has joined #pact-jvm

julian.alvarezv
2023-01-20 10:38
Hi, we are facing many issues with writing the contracts and making it work because the DSL is quite intuitive when writing the contracts but they dont work straight forward as one would expect and we need to be changing things closeObject(), closeArray() .. and so on ... so the question is .. is there a way to see in a json format what the mock is expecting based on a defined contract? Thanks a lot in advance

matt.fellows
2023-01-20 11:18
Hi Yogesh, your last update was yesterday and as you have seen the ticket has been initiated and had been active. Please follow the ticket there. Please also understand that the team have other priorities and can't just drop what they're doing to focus on the last ticket someone raises. That being said I know Ron will be away for a week, so it will at least be another week before you see an update.

luca.narbone
2023-01-20 16:39
has joined #pact-jvm

ivan.mikhalka
2023-01-21 14:30
Hi, all, I have a question about pact Gradle plugin, 4.1.39 version in use. I am wondering, how can I change some content of pact file that coming from Pactflow broker? We have endpoints, where user id changes instantly, so we decided to keep placeholder in pact file, like `path/to/endpoint/userId/12345` and then replace it on the fly. When storing pact file locally, we used to use `sed` for replacing placeholder with actual id, like `sed s/12345/$ACTUAL_USERID/g` , but it?s not the case when switching to pact broker. Could this be done via `requestFilter` from plugin or somehow else? I know it?s not the best practice, but we need some workaround for now

matt.fellows
2023-01-21 22:41
There is a `fromProviderState` matcher you could use for this, or as you note, request filters could also work


matt.fellows
2023-01-21 22:44
Looks like you want the path variant


bram.hautekiet
2023-01-22 22:32
has joined #pact-jvm

ivan.mikhalka
2023-01-23 00:45
Thank you!

ivan.mikhalka
2023-01-23 00:47
btw, requestFilter in Gradle plugin also can do the trick, with methods `setHeader` , `setURI` etc.


matt.fellows
2023-01-23 01:02
see also #pact-plugins

james_fraser
2023-01-23 09:43
Awesome thanks Matt :sweat_smile:

onur.baskirt
2023-01-23 13:06
Hi all, I hope you all are doing fine. We are currently moving the JDK 17, and we faced a strange problem. We cannot debug tests using pact provider and consumer junit5 dependencies. I tried many versions and faced the same problem. I debugged this problem by excluding each library that pact dependency is using, and in the end, I found the problematic area. If I use the below configuration, the problem disappears. ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.4.4</version> <exclusions> <exclusion> <groupId>io.ktor</groupId> <artifactId>ktor-network-tls-certificates</artifactId> </exclusion> <exclusion> <groupId>io.ktor</groupId> <artifactId>ktor-server-netty</artifactId> </exclusion> <exclusion> <groupId>au.com.dius.pact.core</groupId> <artifactId>model</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>4.4.4</version> <scope>test</scope> <exclusions> <exclusion> <groupId>io.ktor</groupId> <artifactId>ktor-network-tls-certificates</artifactId> </exclusion> <exclusion> <groupId>io.ktor</groupId> <artifactId>ktor-server-netty</artifactId> </exclusion> <exclusion> <groupId>au.com.dius.pact.core</groupId> <artifactId>model</artifactId> </exclusion> </exclusions> </dependency>``` If I do not exclude any of these libraries, I am facing the below problem when I debug the tests in IntelliJ. This happens only for debugging, not running the tests. Connected to the target VM, address: ?127.0.0.1:52632?, transport: ?socket? Internal Error occurred. *org.junit.platform.commons.JUnitException: TestEngine with ID ?junit-jupiter? failed to discover tests* at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160) at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:132) at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:107) at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:78) at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:110) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54) *Caused by: org.junit.platform.commons.JUnitException: MethodSelector [className = ?com.emirates.ocsl.skeleton.ct.tests.SkeletonCT?, methodName = ?iGetResponseSuccessfully?, methodParameterTypes = ??] resolution failed* at org.junit.platform.launcher.listeners.discovery.AbortOnFailureLauncherDiscoveryListener.selectorProcessed(AbortOnFailureLauncherDiscoveryListener.java:39) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:103) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.run(EngineDiscoveryRequestResolution.java:83) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.resolve(EngineDiscoveryRequestResolver.java:113) at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(DiscoverySelectorResolver.java:46) at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:69) at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:152) ... 13 more *Caused by: java.lang.ClassCircularityError: java/lang/WeakPairMap$Pair$Weak* at java.base/java.lang.WeakPairMap$Pair.weak(WeakPairMap.java:201) at java.base/java.lang.WeakPairMap.putIfAbsent(WeakPairMap.java:123) at java.base/java.lang.Module.implAddReads(Module.java:488) at java.base/java.lang.Module.implAddReads(Module.java:449) at java.base/java.lang.System$2.addReads(System.java:2335) at java.base/jdk.internal.module.Modules.addReads(Modules.java:90) at java.base/java.lang.reflect.Proxy$ProxyBuilder.lambda$getDynamicModule$1(Proxy.java:918) at java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:329) at java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:205) at java.base/java.lang.reflect.Proxy$ProxyBuilder.getDynamicModule(Proxy.java:908) at java.base/java.lang.reflect.Proxy$ProxyBuilder.mapToModule(Proxy.java:846) at java.base/java.lang.reflect.Proxy$ProxyBuilder.<init>(Proxy.java:651) at java.base/java.lang.reflect.Proxy$ProxyBuilder.<init>(Proxy.java:656) at java.base/java.lang.reflect.Proxy.lambda$getProxyConstructor$0(Proxy.java:429) at java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:329) at java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:205) at java.base/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:427) at java.base/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1037) at java.base/sun.reflect.annotation.AnnotationParser$1.run(AnnotationParser.java:302) at java.base/sun.reflect.annotation.AnnotationParser$1.run(AnnotationParser.java:300) at java.base/java.security.AccessController.doPrivileged(AccessController.java:318) at java.base/sun.reflect.annotation.AnnotationParser.annotationForMap(AnnotationParser.java:300) at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:289) at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:121) at java.base/sun.reflect.annotation.AnnotationParser.parseSelectAnnotations(AnnotationParser.java:102) at java.base/sun.reflect.annotation.AnnotationType.<init>(AnnotationType.java:146) at java.base/sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:85) at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:262) at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:121) at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:73) at java.base/java.lang.Class.createAnnotationData(Class.java:4068) at java.base/java.lang.Class.annotationData(Class.java:4057) at java.base/java.lang.Class.getAnnotation(Class.java:3940) at java.base/java.lang.reflect.AnnotatedElement.isAnnotationPresent(AnnotatedElement.java:292) at java.base/java.lang.Class.isAnnotationPresent(Class.java:3950) at org.junit.platform.commons.util.AnnotationUtils.findAnnotation(AnnotationUtils.java:136) at org.junit.platform.commons.util.AnnotationUtils.isAnnotated(AnnotationUtils.java:105) at org.junit.jupiter.engine.discovery.predicates.IsTestableMethod.test(IsTestableMethod.java:52) at org.junit.jupiter.engine.discovery.predicates.IsTestMethod.test(IsTestMethod.java:23) at org.junit.jupiter.engine.discovery.predicates.IsTestableMethod.test(IsTestableMethod.java:26) at java.base/java.util.function.Predicate.lambda$or$2(Predicate.java:101) at java.base/java.util.function.Predicate.lambda$or$2(Predicate.java:101) at org.junit.platform.commons.util.ReflectionUtils.findMethod(ReflectionUtils.java:1368) at org.junit.platform.commons.util.ReflectionUtils.isMethodPresent(ReflectionUtils.java:1267) at org.junit.jupiter.engine.discovery.predicates.IsTestClassWithTests.hasTestOrTestFactoryOrTestTemplateMethods(IsTestClassWithTests.java:50) at org.junit.jupiter.engine.discovery.predicates.IsTestClassWithTests.test(IsTestClassWithTests.java:46) at org.junit.jupiter.engine.discovery.predicates.IsTestClassWithTests.test(IsTestClassWithTests.java:27) at java.base/java.util.function.Predicate.lambda$or$2(Predicate.java:101) at org.junit.jupiter.engine.discovery.MethodSelectorResolver.resolve(MethodSelectorResolver.java:87) at org.junit.jupiter.engine.discovery.MethodSelectorResolver.resolve(MethodSelectorResolver.java:75) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:150) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1602) at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129) at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:189) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:126) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:92)

benjamin.hess
2023-01-23 23:55
has joined #pact-jvm

benjamin.hess
2023-01-24 00:00
Hello - we're introducing Pact across several teams. One of the teams is using Pact .NET exclusively, and it's my understanding Pact-net provider tests only work with V3 Pactfiles. Is there a way to make a pact-junit5 consumer test generate V3 pacts?

benjamin.hess
2023-01-24 00:00
I tried setting PactSpecVersion.V3 in the PactTestFor annotation

benjamin.hess
2023-01-24 00:01
and the generated pact file does say that $.metadata.pactSpecification.version is 3.0.0

benjamin.hess
2023-01-24 00:02
but instead of "messages", I see "interactions".

benjamin.hess
2023-01-24 00:02
Am I doing something wrong? Or should I downgrade?

matt.fellows
2023-01-24 00:39
Pact .NET should be able to verify any version of the Pact Specification

matt.fellows
2023-01-24 00:39
Why are you expecting to see ?messages? and not ?interactions??

onur.baskirt
2023-01-24 07:37
As I see the ktor libraries create problems with OpenJDK17, Springboot, Webflux, Junit5 project. I am not sure what is the conflict but below exclusions worked fine. ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>${pact.version}</version> <exclusions> <exclusion> <groupId>io.ktor</groupId> <artifactId>ktor-network-tls-certificates</artifactId> </exclusion> <exclusion> <groupId>io.ktor</groupId> <artifactId>ktor-server-netty</artifactId> </exclusion> <exclusion> <groupId>io.ktor</groupId> <artifactId>ktor-http-jvm</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>${pact.version}</version> <scope>test</scope> <exclusions> <exclusion> <groupId>io.ktor</groupId> <artifactId>ktor-network-tls-certificates</artifactId> </exclusion> <exclusion> <groupId>io.ktor</groupId> <artifactId>ktor-server-netty</artifactId> </exclusion> <exclusion> <groupId>io.ktor</groupId> <artifactId>ktor-http-jvm</artifactId> </exclusion> </exclusions> </dependency>```

steve.jefferies
2023-01-24 09:47
has joined #pact-jvm

benjamin.hess
2023-01-24 12:48
A misunderstanding on my part. Thank you for verifying.

aoife.drury
2023-01-24 14:36
has joined #pact-jvm

perger1984
2023-01-24 21:04
has joined #pact-jvm

thibaut.bodart
2023-01-25 09:23
Hello. I have a question about `arrayContaining` . I need this logic for an array that is not defined as a value of an object property. Instead, the array is returned as the *body* of the response. ```[ {....}, {....} ]``` Ideally, I would need a `newJsonArrayContaining` method in `LambdaDsl`. See an example below. ``` return logAndReturn(builder.given("multiple connections exists") .uponReceiving("request to get all connections") .method("GET") .path("/connections") .headers(headers()) .willRespondWith() .status(200) .headers(headers()) .body(newJsonArrayContaining(arr -> { ...... }); }).build()));``` As I understand it, there is currently no way to use `arrayContaining` in this situation. Is my understanding correct?

james_fraser
2023-01-25 10:36
Someone in my team just pointed me towards https://open-rpc.org/ which seems to be the OpenAPI Spec equivalent for JSON-RPC Do you know if it would be possible to get bi-directional contract testing working using this? I?m happy to try and do some of the additional work if it?s needed

ajaytaneja
2023-01-25 13:18
has joined #pact-jvm

petr.sebek
2023-01-25 14:20
has joined #pact-jvm

sean.mccann
2023-01-25 15:25
has joined #pact-jvm

thibaut.bodart
2023-01-25 23:06
Hello. I am migrating from `4.3.17` to `4.4.4` since I would like to use the V4 Pact specifications. My response is in JSON format and only contains a UUID. See below a valid JSON response. ```"08f7a210-95db-4827-bcc8-d2025ba506cf"``` I am using the following code to define the interaction: ```... .willRespondWith() .status(201) .headers(headers()) .body(PactDslJsonRootValue.uuid(JOB_ID)));``` With `4.3.17`, using a Pact v3 contract, the generated contract looks like: ```"response": { "body": "\"08f7a210-95db-4827-bcc8-d2025ba506cf\"", ..... }``` With `4.4.4`, using a Pact v4 contract, it looks like: ```"response": { "body": { "content": "08f7a210-95db-4827-bcc8-d2025ba506cf", "contentType": "application/json", "encoded": false }, ..... }``` The content value *is not a valid JSON value* in the case of `4.4.4`. For this reason, the contract cannot be verified by the provider (also using pact-jvm `4.4.4`). See the exception below. This is expected since `"08f7a210-95db-4827-bcc8-d2025ba506cf"` is not a valid JSON document whereas `"\"08f7a210-95db-4827-bcc8-d2025ba506cf\""` is. ``` 1.1) Invalid JSON (1:5), found unexpected character '7'``` Am I doing something wrong? If I modify the contract manually as illustrated below, the provider can successfully verify it. *Is there a way to generate the response below using the Pact DSL?* ```"response": { "body": { "content": "\"08f7a210-95db-4827-bcc8-d2025ba506cf\"", "contentType": "application/json", "encoded": false },``` Thanks in advance!

nirob726
2023-01-26 12:25
has joined #pact-jvm

giuseppe.aina
2023-01-26 17:45
has joined #pact-jvm

boris.pogrebitskiy
2023-01-26 23:00
has joined #pact-jvm

rafael.luiz-cavalcant
2023-01-27 00:00
has joined #pact-jvm

matt.fellows
2023-01-27 00:11
Ahh, interesting. We definitely don?t support that in BDCT but it?s not implausible that we could. For that to happen we?d need to do a few things though (high level list): 1. Add support for parsing OpenRPC documents (potentially via https://github.com/pactflow/swagger-mock-validator, but possibly via a different tool, and comparing to pact files 2. Add support in Pactflow for displaying, rendering and handling those document types 3. Add support in Pact for generating client contracts compatible with (1) I?m guessing it can?t be expressed in a standard OAS because it can have multiple requests? I?m wondering if it _could_ be expressed in an AsyncAPI document? (something which we do plan to support)

matt.fellows
2023-01-27 00:11
In the meantime, I think you could just get away with using standard message pact

ivan.mikhalka
2023-01-27 05:10
Hi, I am running pact tests using gradle plugin `4.1.39` , using Pactflow as a pact broker. There is a several consumers for same provider, and I can run verification for all consumers using similar config: ```fromPactBroker { withSelectors { selector('tagConsumer1', true, null, 'Consumer1') selector('tagConsumer2', true, null, 'Consumer2') } }``` via command `./gradlew pactVerify -Ppact.verifier.publishResults=true -Dpact.provider.branch=`git branch --show-current` -Dpact.provider.tag=`git branch --show-current`` How can I run verification for only one specified consumer?

james_fraser
2023-01-27 09:40
That?s awesome to hear, thanks for taking a look Matt :smile: I?ll get cracking with message pact for now but hopefully in the future we can migrate to BDCT :fingerscrossed: thanks again

zkocsihorvath
2023-01-27 13:47
has joined #pact-jvm

jorgen.x.andersson
2023-01-27 14:56
has joined #pact-jvm

matt.fellows
2023-01-28 23:51
I think you can use `pact.filter.pacturl` which is for that use case (e.g. via webhooks) https://docs.pact.io/implementation_guides/jvm/provider/gradle


mlapis
2023-01-29 10:56
has joined #pact-jvm

marko.justinek
2023-01-30 04:49
has joined #pact-jvm

tim.malseed
2023-01-30 04:52
has joined #pact-jvm

matt.corby-eaglen
2023-01-30 11:47
has joined #pact-jvm

ulises.cervino
2023-01-30 12:38
has joined #pact-jvm

m.gruehn
2023-01-30 13:04
has joined #pact-jvm

boer.k
2023-01-30 13:48
Hi, I am learning the pact-jvm framework by rewriting some of our existing wiremock tests. I?ve noticed that in our wiremock tests, multiple services are mocked in a single test. So in pact-jvm terms, that would be a multiprovider test: https://docs.pact.io/implementation_guides/jvm/consumer/junit5#using-multiple-providers-in-a-test-425. Ive followed the instructions and I get the test running, however I?ve ran into problems when defining mock provider ports in case a multiprovider test. I assume that you have to run a different instance of mockserver for each provider, so that each provider will have their own contract. By default a random port is used for each mockserver instance launched during a test. However our application is configured to call the provider by a fixed port. In case of a single provider test, this would be resolved using ?port = 1234? in the @PactTestFor annotation: ```@Test @PactTestFor(providerName = "provider1", port = "1234") public void example(MockServer provider1mock) { ... }``` However, when I do this in a multiprovider test: ```@Test @PactTestFor(pactMethods = {"createProvider1Pact", "createProvider2Pact"}, port = "1234") public void example(@ForProvider("provider1") MockServer provider1mock, @ForProvider("provider2") MockServer provider2mock) { ... }``` I get an ?address already in used? exception. Which is logical since I instantiate 2 instances of mockserver, and only provide 1 port. It tries to launch both on the same port. However I have found no way of specifying which mockserver should use which port. Is there a way to do this? I could not find anything in the documentation or source code, though I am unfamiliar with kotlin, I may have missed something. I tried making a subclass of MockServer and set the port myself, but then I ran into injection/instantiation issues with my new class. Alternatively, i have also not found a way to let the application use whatever random port is chosen for the mock.

martin.ineichen
2023-01-30 15:07
has joined #pact-jvm

ch.pascucci
2023-01-30 15:22
has joined #pact-jvm

grace.tree
2023-01-30 16:03
has joined #pact-jvm

grace.tree
2023-01-30 16:13
Hi, yeah from what I know from working with the jvm is the only way to be able to force it to use a certain port is to explicitly set the lower and upper port values. If the port the APIs use is a variable, it might be possible to override/set this value depending on what your tech stack is. So when you send request to make a provider, it response with the port number. Can use that to then set your variables. Though my experience is with the jdk 8 implementation :slightly_smiling_face:

pryan
2023-01-30 21:25
has joined #pact-jvm

andy.jenness
2023-01-30 21:29
has joined #pact-jvm

onur.baskirt
2023-01-31 06:13
Hi all, Is the JDK 17 (LTS) version supported? https://github.com/pact-foundation/pact-jvm#supported-jdk-and-specification-versions We cannot see the JDK 17 support on this page. We are moving from JDK 11 to JDK 17, and we would like to know if anyone has faced any issues with JDK 17?

uglyog
2023-01-31 08:23
Version 4.4.x build runs on JDK 17

boer.k
2023-01-31 08:31
hmm I did not know you could set port lower and upper values. But I think that wont work either. If I just create a range of 2 ports: 4000-4001, then theres still no guarantee that provider 1 will always get 4000 and provider 2 will get 4001?

ivan.mikhalka
2023-01-31 09:17
Seems like `pact.filter.pacturl` does not support wildcards. What do you think, is it worth feature request to get latest version of pact, if version not specified? Like `provider/ProviderName/consumer/ConsumerName/` instead `/provider/ProviderName/consumer/ConsumerName/version/a34fge` , as it can be hard to obtain version when running on CI/CD

matt.fellows
2023-01-31 09:20
What use case would you have for doing this?

matt.fellows
2023-01-31 09:21
if you want to specify a single pact, the main use case is for the `contract_requiring_verification_published` webhook (https://docs.pact.io/pact_broker/webhooks#the-contract-requiring-verification-published-event).

matt.fellows
2023-01-31 09:22
i.e. when a consumer publishes a new contract, it will trigger a webhook to fire if it hasn?t yet been verified. This is the use case for specifying a specific version of a contract

matt.fellows
2023-01-31 09:22
if you want latest, you can get that (follow the HAL resources to find the `latest` resource, which will be a pointer to the latest version, essentially). This is not particularly useful, because ?latest? can be anything - the latest for the main branch, on a feature branch etc. So when you verify ?latest? at the time of verification, you don?t actually know what you?re verifying. Selectors are a better way of specifying what you need

grace.tree
2023-01-31 09:39
`-l 4000 and -u 4000` will set it to one port. So would have to spin up the jvm 2 times with different ports in order to force it to only give you a pact provider server running on an explicit port.

boer.k
2023-01-31 09:44
Doesnt spinning up 2 jvms (somehow) scream ?there must be or should be a better way to do this?? Is my usecase that unordinary?

grace.tree
2023-01-31 10:34
Again, see if can adapt the code, capture the API response from the jvm when create the server. Then use that value to set the port of your solution :melting_face: If application is too port dependent then I would raise this as a configuration issue. Else, suggestion above will mean you would still be able to set the ports. Otherwise make a PR I guess to make it do what you want.

ivan.mikhalka
2023-01-31 11:45
As I usually have commit hash as version, I would prefer fetch pact by tag, which usually more human readable, like ?master?, ?test? etc. Can I get pact by tag for specified consumer and provider?

chimein.1234
2023-01-31 11:51
Hi, how to hit the actual api and generate contract instead of mock url for testing

onur.baskirt
2023-01-31 12:09
@uglyog Did you face any issue when debugging any Junit tests when you use pact provider and consumer dependencies. We faced this issue and exclude ktor libraries to overcome but I am not sure the pact tests will run with this settings fine. In next weeks I will work on this and update here.

boer.k
2023-01-31 12:19
That would require that you have both the consumer and the provider running at the same time? Isnt that exactly what pact is trying to prevent? By defining contracts between consumer and provider, it ?shouldnt? matter that the provider is a mock?

jcarlos.anast
2023-01-31 12:24
has joined #pact-jvm

leonardo.saragiotto
2023-01-31 12:32
has joined #pact-jvm

sebastianman45
2023-01-31 18:25
Hi team :sunglasses: :spock-hand:, I'm new with pact jvm; one question, the implementation with the local pact broker works for me. Do you know of any guide to publish my contracts in pact flow?

matt.fellows
2023-01-31 22:10
Publishing to Pactflow is the same as locally. You can continue to use the pact CLI


matt.fellows
2023-01-31 22:11
We have a number of workshops and tutorials on the PactFlow docs on using PactFlow

matt.fellows
2023-01-31 22:11
See howtolearn

2023-01-31 22:11
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

matt.fellows
2023-01-31 22:11
Why do you want to do that?

sebastianman45
2023-01-31 22:32
Cool! thanks, Matt :sunglasses:

rholshausen
2023-01-31 22:54
That is an IntelliJ IDEA issue

matt.fellows
2023-02-01 04:36
So back to the above, what?s the use case you?re trying to solve?

ivan.mikhalka
2023-02-01 08:14
run provider verification on Jenkins, and, in most cases, use contract from consumer?s master branch

ivan.mikhalka
2023-02-01 08:15
So, tag and branch name will be known

ivan.mikhalka
2023-02-01 08:15
While version rather unknown as it usually commit hash

matt.fellows
2023-02-01 09:05
So why can't you use the selectors then? That's what they do - dynamically find the contracts based on given criteria


ulises.cervino
2023-02-01 10:33
x-posting from #general because of pact-jvm; tl;dr: I'm writing a consumer test that on retrieval of an entity with ID `ID` it checks that the ID of the returned entity matches

ulises.cervino
2023-02-01 10:34
however it's not quite working for me (code examples in the thread)

ulises.cervino
2023-02-01 10:34
any thoughts/advice much appreciated

ulises.cervino
2023-02-01 10:34
final comment: if I relax the checks in the consumer (e.g. I check that the ID is _any_ UUID) then the pact is verified no bother at all

ivan.mikhalka
2023-02-01 11:27
Because I want to have selectors for all consumers in withSelectors {} block, but have ability to run verification for one of them

matt.fellows
2023-02-01 11:30
When would you want to run the verification for just one of them? Silly question perhaps, but can you not just comment out the selector above which you don?t want?

ivan.mikhalka
2023-02-01 11:46
Yes, it?s possible to comment out, or even add selector in gradle file dynamically at runtime. In most of cases we will run verification for all consumers at once, still, I think of possibility to convenient filtering declared selectors, in some cases, perhaps, we will want to run `pactVerify` for only one (or two etc) specified consumer/s

barry.irvine
2023-02-01 15:52
has joined #pact-jvm

marcin.slowiak.007
2023-02-01 18:28
has joined #pact-jvm

hoon.jung
2023-02-01 23:53
has joined #pact-jvm

andhika.hasiholan06
2023-02-02 03:51
has joined #pact-jvm

jhordies
2023-02-02 09:59
has joined #pact-jvm

amanda.santos
2023-02-02 14:19
has joined #pact-jvm

keith.w
2023-02-02 15:57
has joined #pact-jvm

gazal.gafoor
2023-02-03 00:13
has joined #pact-jvm

pavithz
2023-02-03 03:17
Hi, I am bit new to pact. I have a pact junit5 consumer test using 4.1.7 version and the moment I updrade to latest version - it throws error saying Method (pact method name) does not conform required method signature pact.core.model.V4Pact xxx (PactBuilder builder) Note: until pact junit5 consumer 4.2.21 - test works fine. How can I fix it with later junit5 consumer version ? Thanks

uglyog
2023-02-03 03:39
Set the Pact specification version to V3

pavithz
2023-02-03 03:56
Great thanks .. with the above change - it?s passing now. Also noticed with latest pact junit5 consumer 4.4.4 - port has been deprecated. Should we explicitly use MockServerConfig as in your screenshot (I tried that and it works fine) but the mockserverconfig library is part of junit consumer and not junit5 consumer - though it?s not a big deal ?

uglyog
2023-02-03 03:58
junit5 depends on junit, so it should be available

uglyog
2023-02-03 03:58
Those values will not go away until the next major version, so it should be ok to use the old ones

pavithz
2023-02-03 03:59
Thank you so much for the super quick replies :ok_hand: :clap:

ulises.cervino
2023-02-03 14:16
how does one effectively use `valueFromProviderState` in responses? I'm struggling to figure out how this work. The test I have in mind is a consumer saying "when I GET /entity/1 I expect a response like {id: 1}" for instance, where `1` in the path matches the `1` in the response (I already have `pathFromProviderState` working fine)

ulises.cervino
2023-02-03 14:17
this is the relevant bit in my consumer test: ```body.valueFromProviderState( "basketId", "basketId", existingBasketId.toString())```

ulises.cervino
2023-02-03 14:17
however in my pact file I end up with ``` "matchingRules": { "body": { "$.basketId": { "combine": "AND", "matchers": [ { "match": "type" } ] },```

ulises.cervino
2023-02-03 14:17
and the provider test fails with ``` 1.1) body: $.basketId Expected "698c7e00-1e27-436e-a2e6-f7dd94ea98a7" to be null```

ulises.cervino
2023-02-03 14:18
this is the state method for the provider test: ``` Map liveBasketExists(Map _ignored_params) { Map<String, Object> state = new HashMap<>(); InternalBasket internalBasket = repository.createBasket(TestSupport.Repository.basketWithDefaults()).orElseThrow(); // the key in this state-map corresponds to the variable in the expression in the consumer // test, i.e. in the // example consumer test we have a call like .pathFromProviderState("/${basketId}", ...) state.put("basketId", internalBasket.getBasketId()); return state; }```

ulises.cervino
2023-02-03 14:54
seems like the 2nd `"basketId"` has to be an expression such as `"${basketId}"`

eschroeder
2023-02-03 17:15
has joined #pact-jvm

sebastianman45
2023-02-03 19:26
Hello team :sunglasses:, I am doing some tests from the consumer trying to generate the contract, it works perfectly for me, but when I want to add headers, it seems the mock response with a 500 error, do you have any idea what could be happening? ```package consumer.pact.springboot; import org.junit.jupiter.api.extension.ExtendWith; import au.com.dius.pact.consumer.MockServer; import au.com.dius.pact.core.model.RequestResponsePact; import au.com.dius.pact.core.model.annotations.Pact; import au.com.dius.pact.consumer.dsl.PactDslJsonBody; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.HashMap; import java.util.Map; import static org.hamcrest.MatcherAssert.assertThat; import static http://org.hamcrest.Matchers.is; @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "provider-springboot") class UserPactTest { @Pact(consumer="consumer-springboot") public RequestResponsePact getUser(PactDslWithProvider builder) { PactDslJsonBody body = new PactDslJsonBody(); body.stringType("id", "1"); body.stringType("name", "Sebastian Suarez"); body.stringType("email", ""); body.stringType("phone", "3145289654"); body.stringType("password", "xhzASfe&1"); return builder .given("a user with ID 1 exists") .uponReceiving("a request to get a user") .path("/api/v1/users/1") .method("GET") .headers(headers()) .willRespondWith() .status(200) .body(body) .toPact(); } @Test @PactTestFor(pactMethod = "getUser") void testGetProduct(MockServer mockServer) throws IOException { UserData user = new UserRequest().setUrl(mockServer.getUrl()).getUser(1); assertThat(user.getName(), is("Sebastian Suarez")); } private Map<String, String> headers() { Map<String, String> headers = new HashMap<>(); headers.put("Content-Type", "application/json; charset=utf-8"); return headers; } }``` ```package consumer.pact.springboot; import org.apache.http.client.fluent.Request; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.util.List; public class UserRequest { private String url; public UserRequest setUrl(String url) { this.url = url; return this; } public UserData getUser(int id) throws IOException { return Request.Get(this.url + "/api/v1/users/" + id) .addHeader("Accept", "application/json") .execute().handleResponse(httpResponse -> { try { ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(httpResponse.getEntity().getContent(), UserData.class); } catch (JsonMappingException e) { throw new IOException(e); } }); } }```

sebastianman45
2023-02-03 19:28
I did a short implementation here https://github.com/athan3350/pact-consumer-springboot :face_with_hand_over_mouth:

marunachalam1
2023-02-04 02:16
has joined #pact-jvm

tjones
2023-02-04 04:10
Usually a 500 from the mock server means that the request didn?t match the expectation

tjones
2023-02-04 04:11
Have a look in your log, there?s probably content there that explains it

matt.fellows
2023-02-06 00:01
Yep. Check the junit log file it produces, the error is usually quite explicit there

pavithz
2023-02-06 00:42
hi there, is there a way to define PactDslWithProvided builder with optional arrays ? { "data": { "titles": [ { "titleId": "1234", "parenttitleId": "5678", "titleName": "test", "titleOwner": "xyzb", "titleArchitect": "abcde", "titleLeads": [ //optional array -- how to mention this - if exist - example to be of this type , if not - ignore the verification { "lead1": "xyz", "isEndorsed": true }, { "lead2": "abcd", "isEndorsed": false } ] }, { "titleId": "12345", "parenttitleId": "5678", "titleName": "test", "titleOwner": "xyzba", "titleArchitect": "abcdef" } ] } }

uglyog
2023-02-06 00:44
Use the `eachLike` function

matt.fellows
2023-02-06 00:51
for ?optional?, please also see the below link to properly cover your use case :point_down: (howtooptional)


pavithz
2023-02-06 01:18
this still fails at provider end if the optional array 'titleLeads' not returned: ```.body(new PactDslJsonBody().object("data") .minArrayLike("titles", 1) .stringType("titleId", "abcd01") .stringType("parentTitleId", "abcd01") .stringType("titleName", "ABCD") .stringType("titleOwner", "abcd01") .eachLike("titleLeads") .stringType("employeeId") .booleanType("isEndorsed") .closeObject() .closeArray() .closeObject() .closeArray()) .toPact();```

uglyog
2023-02-06 01:22
Oh, you mean it is not present at all. No, it won't support that. Refer to the link posted above.

pavithz
2023-02-06 01:22
Based on the FAQ, looks like there is no option to set the optional ..

uglyog
2023-02-06 01:22
We don't support optional values.

pavithz
2023-02-06 01:23
got it ! and the reasoning behind that .. however if we check for say retrieve all end point where in the first item might have or might not have the optional array and hence in this case - looks like there is no way to verify it

uglyog
2023-02-06 01:24
You need to create two tests, one with the value and one without. Then define a different provider state for each case.

pavithz
2023-02-06 01:25
yeah got that.. but definitely all microservice will have retrieveall list endpoint where in this specific need arises ! and looks like as of now there is no way to verify in pact ..

pavithz
2023-02-06 01:28
I hope its a valid scenario .. do you guys reckon there would be any future support for this ?

uglyog
2023-02-06 02:21
Pact won't support optional fields, you need to use tests for the different cases

tjones
2023-02-06 03:01
A key point here is that you?re not describing the response schema in your pact test. You are defining a complete example. Pact is contract-by-example, not contract-by-schema. A matcher doesn?t say ?this might be in the response?, it says ?this test covers all responses that pass this matcher?.

tjones
2023-02-06 03:01
So, yes, this is a valid scenario. And the way you cover it in Pact is with two different tests.

matt.fellows
2023-02-06 03:04
I wonder if in this scenario (and possibly many others) we should start using the word ?test? or ?unit test?, instead of ?Pact test? i.e. how do you write a unit test that A is either an X or a Y? You write two tests. You don?t write a single unit test that has one variant and if it passes call it done. You write a second one for the other variant to cover both branches

matt.fellows
2023-02-06 03:05
Pact is no different

tjones
2023-02-06 03:11
I like it.

pavithz
2023-02-06 03:11
thanks for the details.. I completely understand what you mean and pact test is exactly similar to unit test with specific examples .. However, in this case - I don't understand how to write it specifically just for one data (if the end point is to retrieve all lists and it does retrieves for all data. Response : first object is array without optional array and second object is array with optional array and its values .. Note: if I remove the optional array in the builder - it doesnt verify this array at all and the test anyway passes. However, if I do add the optional array - test always fails because the intention of the end point is to retrieve for all data and not just one data (are we expected to write the builder with all array of responses?)

tjones
2023-02-06 03:12
You do this with provider states

pavithz
2023-02-06 03:12
It is a common provider state in this case

tjones
2023-02-06 03:13
test one: ? State ?titles don?t have titleLeads? ? Request ? Response expects no title leads test two: ? State ?titles have titleLeads? ? Request ? Response expects title leads

pavithz
2023-02-06 03:14
whatever you mentioned is applicable for my endpoint - get for titleLead1, get for titleLead2 etc .. (for which I have written two different states)

pavithz
2023-02-06 03:14
however for endpoint getalltitleLeads - above two states cant be separated

tjones
2023-02-06 03:14
Why not?

pavithz
2023-02-06 03:14
as the response can have both

pavithz
2023-02-06 03:14
getallTitleLeads - returns both titles one with and one without

tjones
2023-02-06 03:15
For get all, you could use the arrayContains matcher - one with and one without.

pavithz
2023-02-06 03:15
which means if the response is supposed to return two titles - I should have two array explicitly with arrayContains matcher ?

tjones
2023-02-06 03:16
> getallTitleLeads - returns both titles one with and one without Yes. You could use two states: ? ?No titles have titleLeads? ? ?All titles have titleLeads? Or you could use ?One title with titleLeads, and one title without titleLeads?

pavithz
2023-02-06 03:17
unfortunately getallTitleLeads - doesnt have any input param to return me only titles with titlesLeads and viceversa

tjones
2023-02-06 03:17
No, no

tjones
2023-02-06 03:17
not in the request

tjones
2023-02-06 03:17
in the provider state


pavithz
2023-02-06 03:19
ok got you .. because we use mocking in the provider end - you saying use different provider state and mock the response to return two different states


tjones
2023-02-06 03:20
Or, have a single state that has both response types, and define your expectation explicitly.

tjones
2023-02-06 03:20
`titles: [exampleWithLeads, exampleNoLeads ]`

pavithz
2023-02-06 03:23
hmm... unfortunately in my case - we are not using mocking for now in the provider end (I know its not 100% right, still.. ) as we are implementing contract testing for the existing microservices too - we pointing to live endpoint in the provider instead of mock (which doesnt give me responses for specific state).. and single state with both response types (this end point have got multiple such optional arrays and returns 100s of response with different combination - hence not easy to explicitly define the expectation)

tjones
2023-02-06 03:59
In that case, I would define it with either the specific exact test data that you are setting up, or I would define it with the arrayContains matcher with both types of response object (I?m not familiar with the JVM DSL, so I can?t give you an exact answer there)

pavithz
2023-02-06 04:14
Sure nws ? I got the idea though .. thanks

loc.daot
2023-02-06 07:37
has joined #pact-jvm

ondrej.hajek
2023-02-06 09:45
has joined #pact-jvm

shravan.baira
2023-02-06 11:16
has joined #pact-jvm

cameron.doyle
2023-02-06 11:17
has joined #pact-jvm

ckarlborg45
2023-02-06 11:29
has joined #pact-jvm

itzhak
2023-02-06 11:56
has joined #pact-jvm

itzhak
2023-02-06 12:16
Hi :slightly_smiling_face: When using Pact Juni5 Consumer, is it possible to configure an external mock-server instead of the "in process" one? Thanks

dyptorden
2023-02-06 12:38
hello everyone. It seems that the PactBroker attributes *`scheme`*, *`host`*, *`port`* are deprecated, but the documentation doesn't explicitly say what replaced them. I do see a *`url`*, Can any of you please confirm if *`url`* replaces the other 3?

prashant.singh
2023-02-06 14:05
has joined #pact-jvm

georgina.sallery
2023-02-06 15:18
has joined #pact-jvm

sebastianman45
2023-02-06 15:50
@tjones @matt.fellows :sunglasses: Thank you very much for the support; you are right. I forgot to attach the junit log; it basically shows the same error when debugging as I did to the mocking; the weird thing is that it only throws this error when I add headers to the contract ```java.io.IOException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "error" (class consumer.pact.springboot.UserData), not marked as ignorable (5 known properties: "id", "email", "phone", "name", "password"]) at [Source: (org.apache.http.conn.EofSensorInputStream); line: 1, column: 13] (through reference chain: consumer.pact.springboot.UserData["error"]) at consumer.pact.springboot.UserRequest.lambda$getUser$0(UserRequest.java:30) at org.apache.http.client.fluent.Response.handleResponse(Response.java:90) at consumer.pact.springboot.UserRequest.getUser(UserRequest.java:25) at consumer.pact.springboot.UserPactTest.testGetProduct(UserPactTest.java:49) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74) at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at com.sun.proxy.$Proxy2.stop(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193) at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "error" (class consumer.pact.springboot.UserData), not marked as ignorable (5 known properties: "id", "email", "phone", "name", "password"]) at [Source: (org.apache.http.conn.EofSensorInputStream); line: 1, column: 13] (through reference chain: consumer.pact.springboot.UserData["error"]) at app//com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61) at app//com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:840) at app//com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1192) at app//com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1592) at app//com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1570) at app//com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:294) at app//com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151) at app//com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4202) at app//com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3242) at app//consumer.pact.springboot.UserRequest.lambda$getUser$0(UserRequest.java:28) ... 86 more```

tjones
2023-02-06 16:00
We think there?s an error further up somewhere, before the stack trace. The stack trace is your test trying to decipher the error response from pact

tjones
2023-02-06 16:00
You could test this by not unmarshalling the response

tjones
2023-02-06 16:00
Check your full log

edouard.lopez
2023-02-06 16:10
I'm having trouble running a publishing task via `gradlew`: ``` java.lang.IllegalArgumentException: Invalid pact broker host specified ('${pactbroker.host:}'). Please provide a valid host or specify the system property 'pactbroker.host'. ``` with the command ```./gradlew testContract \ -Ppact.verifier.publishResults=true \ -Ppactbroker.url="http://foo.bar" \ --info```

edouard.lopez
2023-02-06 16:49
Passing `pactbroker.url` using a system property gave the same result: ```./gradlew testContract \ --info \ -Ppact.verifier.publishResults=$PACT_PUBLISH_VERIFICATION_RESULTS \ -Dpactbroker.url=$PACT_BROKER_URL ```


ulises.cervino
2023-02-06 19:17
more specifically the use of `http://miningmadness.com`

ulises.cervino
2023-02-06 19:17
it's triggering all sorts of red flags tbh

guptadaksh56
2023-02-06 20:40
has joined #pact-jvm

uglyog
2023-02-06 22:07
That change is if the reverse lookup results in `http://miningmadness.com`, ignore it and try use the original address. Java uses reverse lookups when resolving the local address (used to get the bound port with HTTPS), and that address being mapped to localhost is just stupid, but was causing tests to fail on Windows trying to access the real site instead of localhost and the certificate does not match. That fix is saying, if the address ever resolves to that site, *don't use it*!

uglyog
2023-02-06 22:08
try setting `pactbroker.host`

uglyog
2023-02-06 22:08
Yes, `url` replaces those

uglyog
2023-02-06 22:09
Why would you want to do that, and how would that work?

brendanmbliss
2023-02-06 23:14
has joined #pact-jvm

helloyuanyuan
2023-02-07 02:25
has joined #pact-jvm

itzhak
2023-02-07 07:53
Hi @uglyog I want the actual consumer tests to match what my app will do so I plan on running my app in a separate machine and triggering the calls to the mockserver indirectly. This way I make sure I actually require the pacts that were described. I do not have the option to run/mock my own app inside the process (like Spring MockMVC or similar solutions) I know that there are mock-server standalone like: https://docs.pact.io/implementation_guides/rust/pact_mock_server_cli https://hub.docker.com/r/pactfoundation/pact-cli https://github.com/pact-foundation/pact-jvm/tree/master/pact-jvm-server That seems to be able to replace the "in process" one Am I missing something?

ulises.cervino
2023-02-07 07:58
that address is mapped to localhost? :confused:

ulises.cervino
2023-02-07 07:59
so this is a fix just for windows, for a particular user(s) of the framework?

edouard.lopez
2023-02-07 08:59
Got the same result with ```./gradlew testContract --info \ -Ppact.verifier.publishResults="true" \ -Dpactbroker.host="http://our.broker.com" ``` or ``` -Dpactbroker.host="http://our.broker.com"```

edouard.lopez
2023-02-07 09:01
My goal is to be able to inject those value from CI so teams don't have to update their code every time we enable or change a feature (e.g. enablePending). So my verifier test code is ```@PactBroker() class ProductControllerContractVerificationTest { ? }``` I would like my `gradle` task to be as light as possible, e.g.: ```val testContract = task<Test>("testContract") { useJUnitPlatform() group = "verification" description = "Verify contracts published by consumers." testClassesDirs = sourceSets["testContract"].output.classesDirs classpath = sourceSets["testContract"].runtimeClasspath outputs.upToDateWhen { false } }``` And my GitLab-CI call job's `script` to be like ``` script: - > ./gradlew testContract \ --info \ -Dpact.provider.branch="${GIT_CURRENT_BRANCH}" \ -Dpact.provider.version="${PACT_PROVIDER_APP_VERSION}" \ -Dpact.verifier.buildUrl="${PACT_CI_PIPELINE_URL}" \ -Dpactbroker.enablePending="${PACT_ENABLE_PENDING_CONTRACT}" \ -Dpactbroker.includeWipPactsSince="${PACT_INCLUDE_WIP_PACT_SINCE}" \ -Dpactbroker.url=$PACT_BROKER_URL \ -Ppact.verifier.publishResults="${PACT_PUBLISH_VERIFICATION_RESULTS}"```

geetika.joshi
2023-02-07 10:25
has joined #pact-jvm

erik.haartmans
2023-02-07 10:31
has joined #pact-jvm

rawisankarn
2023-02-07 12:59
has joined #pact-jvm

hiep.duong
2023-02-07 13:10
has joined #pact-jvm

edouard.lopez
2023-02-07 13:13
The following declaration works: ? mapping all systemProperties in the task ? mapping project property `pact.verifier.publishResults` to system property ```val testContract = task<Test>("testContract") { systemProperties = System.getProperties() as Map<String, Any> systemProperty( "pact.verifier.publishResults", System.getenv("PACT_PUBLISH_VERIFICATION_RESULTS") ?: properties.getOrDefault( "pact.verifier.publishResults", "false" ) as String ) ? }```

michael.branders484
2023-02-07 14:08
has joined #pact-jvm

marcin.grzejszczak
2023-02-07 14:26
hey! 3-4 months ago we started the discussion around migrating the Pact & Spring Cloud Contract integration (https://github.com/spring-cloud/spring-cloud-contract/issues/1845) to the Pact foundation. I've temporarily moved it out to a repo in my org here (https://github.com/marcingrzejszczak/spring-cloud-contract-pact). There was some discussion here over 3 months ago and now it's gone because of Slack's history. Was there any progress done with that? Do you need any help? Is there willingness to move it there?

anda.rozenfelde
2023-02-07 14:33
has joined #pact-jvm

itzhak
2023-02-07 15:43
Hi :slightly_smiling_face: Is it possible to specify a header exists in an HTTP response (without value matching) using `PactBuilder` (V4)?

uglyog
2023-02-07 23:52
Hey @marcin.grzejszczak I think there was some outstanding policy things around who will be responsible for maintenance and responding to user requests or help. We can easily move the repo over, but there will be an implicit expectation from the community that it supported. I don't think any of that got resolved, or if it did, it was not shared with me.

uglyog
2023-02-07 23:53
There is a V4 notEmpty matcher that will do that.

uglyog
2023-02-07 23:54
I don't think any of the current DSLs allow setting that matcher for a header, though.

uglyog
2023-02-07 23:57
Actually, the new request and response builders can set that.

marcin.grzejszczak
2023-02-07 23:57
I mean the very problem is that due to how often breaking changes occur in pact jvm it's impossible for me to maintain it on the spring cloud contract side. That's why it would be great if it gets supported on the pact side. Now the question is what we can do to move this forward?

uglyog
2023-02-08 00:33
Ok, fair enough. The first step would be to get representation with the Pact Foundation maintainers group. I have raised it there.

uglyog
2023-02-08 00:42
This is just of Windows on GitHub action agents

vietanhtran.dev
2023-02-08 04:44
has joined #pact-jvm

ulises.cervino
2023-02-08 07:53
I see, cool, thanks for the explanation :slightly_smiling_face:

itzhak
2023-02-08 08:09
Hi @uglyog thank you for your answer! I am looking at `HttpResponseBuilder.kt` version 4.4.5 and can not see an overload with matcher Am I missing something?

goyal.himanshu
2023-02-08 08:23
has joined #pact-jvm

jeroenlamain
2023-02-08 11:57
has joined #pact-jvm

pallavi.bose
2023-02-08 13:19
has joined #pact-jvm

adi.d
2023-02-08 16:25
has joined #pact-jvm

oriane.rodriguez
2023-02-08 16:59
has joined #pact-jvm

tdickman
2023-02-08 21:36
has joined #pact-jvm

george.croucamp
2023-02-09 05:14
has joined #pact-jvm

gcroucamp
2023-02-09 05:15
has joined #pact-jvm

tonis.ojandu
2023-02-09 09:46
has joined #pact-jvm

justyna
2023-02-09 10:03
has joined #pact-jvm

tomer.ghelber
2023-02-09 12:24
has joined #pact-jvm

goyal.himanshu
2023-02-09 16:05
Hello Team, I am trying to specify Pact broker using annotation @PactBroker but it is only allowing me to provide host, port and scheme. My Pact URL is https://<org-base-url>/pactbroker. If I only define the host, port and scheme then I get error as below which is expected because my pact broker is at "*/pactbroker"* not at *"/"*: http://au.com.dius.pact.core.pactbroker.NotFoundHalResponse: No HAL document found at path '/' And If I specify ```@PactBroker(scheme = "https", host = "<org-base-url>/pactbroker")``` I get error as: ```@PactBroker(scheme = "https", host = "<org-base-url>/pactbroker")``` java.lang.IllegalArgumentException: Invalid pact broker host specified ('<http://<org-base-url>/pactbroker|<org-base-url>/pactbroker>'). Please provide a valid host or specify the system property 'pactbroker.host'. At the same time I am using @PactUrl to specify the pact URL but due to that verification result is not getting published. JDK version: 1.8 http://au.com.dius.pact.provider.junit5 : 4.1.11 Can someone help with this? Maybe I am missing something!! :thinking2:

goyal.himanshu
2023-02-09 16:29
Never mind. I just saw this: https://github.com/pact-foundation/pact-jvm/#supported-jdk-and-specification-versions updated the dependency to 4.1.41 and using the @PactBroker(url="").

tommy.chen
2023-02-10 00:39
has joined #pact-jvm

sayler.b
2023-02-11 03:46
has joined #pact-jvm

rm.bozhko
2023-02-12 16:27
has joined #pact-jvm

moid.abdul
2023-02-13 00:16
has joined #pact-jvm

sugi
2023-02-13 09:59
has joined #pact-jvm

sgeethu21
2023-02-13 11:01
has joined #pact-jvm

werner.lauterfeld
2023-02-13 11:47
Hello guys, out of curiosity is it possible to use pacts based on v2 specification during verification with a jvm based provider, or will it always verify based on v3+ specification using the jvm maven plugin? Greetings Werner

kp1289
2023-02-13 11:59
has joined #pact-jvm

ivan.mikhalka
2023-02-13 14:37
Hi, all. This is a question about `pact-gradle-plugin` . What I want to achieve - two separate gradle tasks for running provider test a) using contracts fetched from broker; b) using contract file on local file system. For now I have one for pact broker: ```pact { broker { pactBrokerUrl = 'url' pactBrokerToken = 'token' } serviceProviders { MyProvider { .... fromPactBroker { withSelectors { // Some selectors } } } } }``` I?ve tried: 1. Add another provider MyProviderLocal under `serviceProviders` with specifying path to local pact file 2. Add new gradle task and put inside `pact` dsl: ```task pactLocal { pact { ...... } }``` Both attempts not working, it recognise `broker` block and always trying to get pacts from broker.

rahul.jalagadugu
2023-02-13 15:37
has joined #pact-jvm

omatuzenko.hse
2023-02-13 18:14
has joined #pact-jvm

tyler.fleurant
2023-02-13 21:56
has joined #pact-jvm

uglyog
2023-02-13 23:06
The `pact` block is global and not task specific. There are two ways you can do it, if you want to have two different verification tasks, you can use different provider names (MyProvider and MyProviderLocal), or if you want only a single provider name, you can setup two different sources and they will both be verified as part of the same task.

uglyog
2023-02-13 23:29
Ah! It's missing. I have added it, it should be available in the next release

ivan.mikhalka
2023-02-14 07:45
@uglyog Adding MyProviderLocal into `serviceProviders` doesn?t work - as `broker` block defined at top level, plugin tries to find provider named `MyProviderLocal` directly in broker, and of course, it not exists. I want to run single option - broker or local contracts, so, do not suppose to have two sources at one place.

ivan.mikhalka
2023-02-14 07:49
Error example: `Caused by: http://au.com.dius.pact.core.pactbroker.NotFoundHalResponse: No HAL document found at path 'https://secretescapes.pactflow.io/pacts/provider/MyProviderLocal/for-verification'`

ivan.mikhalka
2023-02-14 07:56
If I would define `broker` block on the fly in command line, not in `build.gradle` directly, it could resolve my issue. Seems like presence of `broker` block orders to search for all providers in broker

ivan.mikhalka
2023-02-14 07:58
BTW, we use `4.1.39` version of `http://au.com.dius.pact` due to version limitations of Gradle and Java

uglyog
2023-02-14 09:08
Use an if statement based on a project property. Then set the property on the command line

ivan.mikhalka
2023-02-14 09:21
Thank you, I?ll try

ivan.mikhalka
2023-02-14 09:37
@uglyog That helped, thank you. It works in this way: ```if(useBroker="true") { broker { .... } }``` And then run `./graldew pactVerify_FlashsalesLocal -PuseBroker=false`

swilkinson
2023-02-14 09:59
has joined #pact-jvm

itzhak
2023-02-14 12:12
Thank you very much!

itzhak
2023-02-14 16:16
Hi :slightly_smiling_face: Is it possible to specify a body field value is in range using `PactBuilder` and `PactDslJsonBody` (V4)?

brooks
2023-02-14 18:41
has joined #pact-jvm

carlos.lopez
2023-02-14 19:20
has joined #pact-jvm

sam.mirzaee
2023-02-15 02:35
has joined #pact-jvm

uglyog
2023-02-15 06:05
It supports all the specifications back to V1

uglyog
2023-02-15 06:05
4.4.6 released

uglyog
2023-02-15 06:08
Is in what range?

itzhak
2023-02-15 06:54
Hi @uglyog sorry for not being clear :slightly_smiling_face: Is it possible to specify a body field *numeric* value is in a certain range? for example that the field `$.count` is in between `0` and `100` ? I know generators can define a range but I can not find that in the JVM DSL.

uglyog
2023-02-15 06:54
No, there is nothing like that

itzhak
2023-02-15 07:20
Thanks for the answer! is this planned? even only to control the generator?

werner.lauterfeld
2023-02-15 11:15
Ok thank you! :)

kam.sobon
2023-02-15 11:26
has joined #pact-jvm

mail391
2023-02-15 14:59
has joined #pact-jvm

itzhak
2023-02-15 16:20
Hi :slightly_smiling_face: The module `pact-jvm-server` has an endpoint on `/create` that starts a server on a random port. Is there a way to make this port be predictable and not random?

jmoreno
2023-02-15 21:27
has joined #pact-jvm

uglyog
2023-02-15 22:24
No, nobody has request this before. You can raise a request at https://pact.canny.io/feature-requests

uglyog
2023-02-15 22:28
No, it is designed to create multiple servers. But if you give the same lower and upper bound, it may do what you want. But if you then call it a second time, it will fail.

marcio.duarte
2023-02-16 03:38
has joined #pact-jvm

ben.brugman
2023-02-16 09:55
Hi, i got everything running on my kotlin project. I want to change the path where the pacts should be stored. It simple says add to the build.gradle file... The project i am on has quite extensive gradle file(s) On which level should the snippet go? and should it be inside some other gradle task? Tnx in advance

james_fraser
2023-02-16 16:33
Hey there :wave: is there any way to create a `DslPart` from an existing JSON file or object? Or is it only the `PactDslJsonBody` and `newJsonBody` approaches listed https://docs.pact.io/implementation_guides/jvm/consumer#examples? We have existing JSON files used by our tests so it?d be nice to not have to rewrite all of them into this format

bryen.vieira
2023-02-16 16:34
has joined #pact-jvm

jbrauchler
2023-02-16 22:34
Hi, I have a contract that I am working on a provider pact test with junit5. The interesting thing is the consumer test can only be found if I provide a value for `pact.filter.pacturl` It finds contracts for other consumers but not the consumer the test I'm working on is for. Can anyone think of any reason for that?

uglyog
2023-02-16 22:36
`DslPart` classes are for building JSON payloads. If you already have JSON files, why not just use them directly?

ryan319
2023-02-16 22:50
has joined #pact-jvm

jbrauchler
2023-02-16 23:55
never mind figured it out with version selectors.

zhig.ivan
2023-02-17 08:56
has joined #pact-jvm

james_fraser
2023-02-17 09:25
I?m pretty sure that?s what we do for our other contract tests, but it seems to be different for Message Pact We?re using a `MessagePactBuilder`, and its `withContent()` method only accepts a `DslPart` or `PactXmlBuilder` Is there something simple I?m missing that lets us do this?

yerken.tussupbekov
2023-02-17 11:40
has joined #pact-jvm

iamchughmayank
2023-02-17 18:30
has joined #pact-jvm

jake.kline
2023-02-18 04:11
has joined #pact-jvm

culudamar
2023-02-20 08:12
has joined #pact-jvm

culudamar
2023-02-20 08:21
Hi all, I'm having the exception described https://stackoverflow.com/questions/67723125/pact-test-getting-initialization-error-without-details. My case is trying to use pact broker for provider. How can I see what's going wrong? I'm behind a corporate firewall, but consumer can upload the pact using the same broker settings on the same PC.


james_fraser
2023-02-20 16:33
For example, is it possible to do something like this? ```JSONObject jsonObject = loadJsonFromFile(...); return new MessagePactBuilder() .expectsToReceive("a user created message") .withContent(jsonObject) .toPact();```

gawaine.ogilvie
2023-02-20 17:01
has joined #pact-jvm

uglyog
2023-02-20 21:52
Ok, can you raise a GitHub issue for that?

uglyog
2023-02-20 22:06
Your corporate proxy may be blocking the URL. Are you able to try run the test on a different network?

james_fraser
2023-02-21 09:50
Sure thing thanks @uglyog :smile:

james_fraser
2023-02-21 10:42
Raised it here: https://github.com/pact-foundation/pact-jvm/issues/1669 If there?s anything else you need just let me know, cheers!

mail391
2023-02-21 14:53
Hi, I have a frontend application that communicates with a Spring Boot backend microservice through a Kong API gateway. I want to write contract tests using Pact, but I am not sure how to handle the fact that the frontend talks to the backend through the gateway. In particular, the paths used by the frontend (e.g., "/api/v3/users") are different from those used by the backend (e.g., "/users") due to the gateway configuration. I read in the Pact documentation (https://docs.pact.io/recipes/apigateway#use-case-1-basic) that I could use request filters in the provider test to swap out the correct path, but I am not sure how to do this. Could someone provide an example of how to implement this solution, or suggest another way to approach this issue? This is some code snippet of how my provider looks like right now: ``` @BeforeEach void before(PactVerificationContext context, @LocalServerPort int port) { context.setTarget(new HttpTestTarget("localhost", port)); } @TestTemplate @ExtendWith(PactVerificationSpringProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); }``` While I could implement a solution using this approach, I don't think it's the most optimal way to solve the problem. ``` @BeforeEach void before(PactVerificationContext context, @LocalServerPort int port) { context.setTarget(new HttpTestTarget("localhost", port)); Request request = ((RequestResponseInteraction) context.getInteraction()).getRequest(); request.setPath(request.getPath().replace("/api/v3", "")); }```

lepdiana01
2023-02-21 21:15
Hi there! I?m trying to setup pact consumer test. Currently, I have SDK 11.0.18, kotlin version 1.6.0, and utilizing JUnit 5. What version-id would be the most compatible?

uglyog
2023-02-21 22:00
Better to get JUnit to inject the real request into the test method. You can just add an HTTP request object as a parameter to pactVerificationTestTemplate. See https://github.com/pact-foundation/pact-jvm/tree/master/provider/junit5#modifying-the-requests-before-they-are-sent


james414
2023-02-22 10:00
has joined #pact-jvm

alanbos
2023-02-22 12:00
[Originally posted erroneously to the pact-js channel] I'm using pact-jvm version 4.3.7 on a Spring Boot project. Running provider tests with Spring Boot 2.7 works fine, but if I uprev to Spring Boot 3 the test fails with the following stack trace: ```ANTLR Tool version 4.9.2 used for code generation does not match the current runtime version 4.10.1 ANTLR Runtime version 4.9.2 used for parser compilation does not match the current runtime version 4.10.1 ... Caused by: java.lang.ExceptionInInitializerError at au.com.dius.pact.core.support.Version.parse(Version.java:79) at au.com.dius.pact.core.model.DefaultPactReader.pactFromJson(PactReader.kt:219) at au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:214) at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:251) at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:120) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$pactSources$1$pacts$1.invoke(PactJUnit5VerificationProvider.kt:83) at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:39) ... 60 more Caused by: java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 3 (expected 4). at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:56) at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:48) at au.com.dius.pact.core.support.VersionLexer.<clinit>(VersionLexer.java:115) ... 67 more Caused by: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 3 (expected 4). ... 70 more``` I'm guessing that the problem is that an Antlr 4 runtime dependency has been introduced via an uprev from Hibernate 5 to 6 (itself triggered by the uprev from Spring Boot 2 to 3), but pact needs Antlr 3. Is there any way around this? tia

jbrauchler
2023-02-22 17:56
Hello, I have a large monolith system that we are breaking down into microservices. That said in the mean time the monolith is a provider for a large number of consumers and multiple teams are in charge of adding the contracts. One thing I am unsure of is do I actually need to disable can-i-deploy every time a new contract is added before it gets through all environments? And before adding version selectors like `mainBranch: true` and `deployedOrReleased: true` ?

nbolam
2023-02-22 20:26
has joined #pact-jvm

uglyog
2023-02-22 22:30
4.3.x and 4.4.x won't work with Springboot 3. See https://github.com/pact-foundation/pact-jvm/pull/1663

uglyog
2023-02-22 22:30
4.5.0-beta1 has a spring6 module that will work

alanbos
2023-02-23 07:42
Thanks @uglyog - I will try out the beta!

alanbos
2023-02-23 09:38
Good news that seems to have resolved the error - can now run provider verification tests without issue again. Thanks! For anyone else having similar issues it may be worth noting that using Intellij I also had to update my Kotlin plugin version to stop the IDE complaining that it couldn't resolve imports from pact dependencies. Any idea when an official 4.5.0 will be out?

ashish_garg5
2023-02-23 09:54
Hi Team, Can anyone please let me know till which version of dius/pact-broker supports pact specification V2. I am currently using v2.66.0 and wanted to upgrade it to latest I can see v2.102.2 is latest but it doesn't supports pactSpec V2. Not able to find it. Thanks in advance.

matt.fellows
2023-02-23 09:55
What makes you think it doesn?t support V2? It should

matt.fellows
2023-02-23 09:55
It won?t display/render v3 or v4 pacts, but it still can manage them just fine

ashish_garg5
2023-02-23 09:55
I mean parsed json is not coming. Is that fine

matt.fellows
2023-02-23 09:56
can you please share a screen shot of what you mean, and ideally the pact file?

matt.fellows
2023-02-23 09:58
Can you please show the bottom bit that shows the metadata

ashish_garg5
2023-02-23 09:58
Coming like this and also after upgrading it I am not able to do the verifications of contract

matt.fellows
2023-02-23 09:59
it won?t effect the verification process. The broker itself is not really aware of the spec version, other than to render it

matt.fellows
2023-02-23 10:00
can you please share the full pact file? Something might be wrong with it which is why the broker can?t display it

ashish_garg5
2023-02-23 10:19
Is anything wrong in this ?

lambent21
2023-02-23 13:35
has joined #pact-jvm

pach
2023-02-23 17:34
has joined #pact-jvm

uglyog
2023-02-24 05:38
Ideally, we can release the non-beta version when we know that there are no issues impacting people. Unfortunately, most people will avoid the beta versions, so we won't know what issues would be impacting people until we release the non-beta version. :wink:

richard.ruiter
2023-02-24 06:43
has joined #pact-jvm

alanbos
2023-02-24 07:47
Lol :laughing: I must be swimming against that tide, because I currently rely on betas for both pact-js and pact-jvm.

spalle
2023-02-24 10:54
has joined #pact-jvm

alex637
2023-02-24 14:32
has joined #pact-jvm

egrep
2023-02-25 17:32
has joined #pact-jvm

ykamali
2023-02-26 05:10
has joined #pact-jvm

kripa.kurian
2023-02-27 04:35
has joined #pact-jvm

jordan.brooks
2023-02-27 09:46
has joined #pact-jvm

courtel.yann
2023-02-27 10:47
has joined #pact-jvm

nathan.hickson
2023-02-27 13:07
has joined #pact-jvm

mark.simpson
2023-02-27 13:08
has joined #pact-jvm

tomer.ghelber
2023-02-27 13:08
@tomer.ghelber has left the channel

tomer.ghelber
2023-02-27 13:09
has joined #pact-jvm

masykur.sn
2023-02-27 15:21
has joined #pact-jvm

mike.key
2023-02-27 20:56
Getting an error using pact jvm 4.3.19 where the consumer is a 4.0 pact spec version. It seems to want a semver of 4.0.0 but the consumer publishes the contract as 4.0. This error happens when starting the contract verification on the provider: ```Unexpected character 'EOI(null)' at position '3', expecting '[DOT]' at app//com.github.zafarkhaja.semver.VersionParser.consumeNextCharacter(VersionParser.java:516) at app//com.github.zafarkhaja.semver.VersionParser.parseVersionCore(VersionParser.java:288) at app//com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:255) at app//com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:195) at app//com.github.zafarkhaja.semver.Version.valueOf(Version.java:265) at app//au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:203)```

mike.key
2023-02-27 20:57
I noticed all other pact spec versions are definitely semver

mike.key
2023-02-27 22:00
This seems to be a specific issue in `junit5spring` lib for jvm-provider, everything works fine with `junit5` lib.

uglyog
2023-02-27 22:27
The Pact spec versions on not semver. That stack trace is not from pact jvm 4.3.19, but must be from a version prior to 4.2.0-beta.1. In that version the semver parser (shown above in the stack trace) was replaced with a tolerant parser.

uglyog
2023-02-27 22:28
Just upgrade to 4.3.x+ and that error should go away.

makifkus
2023-02-28 03:51
has joined #pact-jvm

sasankdts
2023-02-28 10:14
Cannot cast org.junit.internal.runners.statements.invokeMethod to org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallBacks

sasankdts
2023-02-28 10:14
Any help on this error

yanov.alexander
2023-02-28 11:20
Hello, I?m trying to write pact tests with xmlpactbuilder, and there are difficulties with writing a collection of elemenets as a list, maybe someone has examples of how to use xmlpactbuilder with a collection of elements inside?

jacob.waller
2023-02-28 21:08
has joined #pact-jvm

dipak8959
2023-02-28 21:18
has joined #pact-jvm

sanketh.shanbhag
2023-03-01 03:57
has joined #pact-jvm

adam.cox
2023-03-01 12:34
has joined #pact-jvm

jordan.brooks
2023-03-01 13:25
Are there any examples of writing Provider tests for Asynchronous/Message based providers that don't use Junit? I can't use Junit and have everything working up to this point, struggling to get this working and all the examples I've found are annotation based.

gazal.gafoor
2023-03-01 13:30
@gazal.gafoor has left the channel

steve.short
2023-03-01 15:14
has joined #pact-jvm

edeandre
2023-03-01 18:12
Hi folks! Is there a way that I can have a single JUnit class that has some `@Test` methods that use pact consumer contract tests as well as other `@Test` methods that don?t? I don?t seem to be able to do that. My usecase: I have my business logic tier (a bean) that has lots of business methods. I have a single test class that has lots of tests, some of those tests don?t belong in the Pact consumer contract (i.e. error handling/failure scenarios). Something like this: ``` @Pact(consumer = "rest-fights", provider = "rest-villains") public V4Pact helloVillainsPact(PactDslWithProvider builder) { return builder .uponReceiving("A hello request") .path(VILLAIN_HELLO_URI) .method(HttpMethod.GET) .headers(HttpHeaders.ACCEPT, MediaType.TEXT_PLAIN) .willRespondWith() .headers(Map.of(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN)) .status(Status.OK.getStatusCode()) .body(PactDslRootValue.stringMatcher(".+", DEFAULT_HELLO_VILLAIN_RESPONSE)) .toPact(V4Pact.class); } @Test @PactTestFor(pactMethod = "helloVillainsPact", port = "8081") public void helloVillainsSuccess() { var message = this.fightService.helloVillains() .subscribe().withSubscriber(UniAssertSubscriber.create()) .assertSubscribed() .awaitItem(Duration.ofSeconds(5)) .getItem(); assertThat(message) .isNotNull() .isEqualTo(DEFAULT_HELLO_VILLAIN_RESPONSE); } @Test public void helloVillainsFailure() { doReturn(Uni.createFrom().item("fallback")) .when(this.fightService) .fallbackHelloVillains(); doReturn(Uni.createFrom().failure(InternalServerErrorException::new)) .when(this.villainClient) .helloVillains(); var message = this.fightService.helloVillains() .subscribe().withSubscriber(UniAssertSubscriber.create()) .assertSubscribed() .awaitItem(Duration.ofSeconds(10)) .getItem(); assertThat(message) .isNotNull() .isEqualTo("fallback"); }``` When I try to run this test class the `helloVillainsFailure` method fails with ```13:02:28 WARN [au.co.di.pa.co.ju.PactConsumerTestExt] (main) No @PactTestFor annotation found on test class, using defaults java.lang.UnsupportedOperationException: No method annotated with @Pact was found on test class PactTests for provider '' at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.lookupPact(PactConsumerTestExt.kt:336) at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.setupMockServer(PactConsumerTestExt.kt:230) at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.beforeTestExecution(PactConsumerTestExt.kt:215) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeTestExecutionCallbacks$5(TestMethodTestDescriptor.java:191) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:202) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:202) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeTestExecutionCallbacks(TestMethodTestDescriptor.java:190) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:136) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)```

kgrady
2023-03-01 18:58
has joined #pact-jvm



uglyog
2023-03-01 22:18
You can use the standalone verifier, but you will need to setup an HTTP proxy server to return the messages.

yanov.alexander
2023-03-02 09:22
Hello @uglyog , maybe you know how to fix it?

pratima.patil
2023-03-02 11:13
has joined #pact-jvm

shilpa199350
2023-03-02 12:40
has joined #pact-jvm

syamphaneendrak
2023-03-02 16:21
has joined #pact-jvm

neeraj.sharma
2023-03-02 16:33
has joined #pact-jvm

dominik.chmielarz
2023-03-02 16:55
has joined #pact-jvm

xchen
2023-03-02 18:59
has joined #pact-jvm

uglyog
2023-03-02 21:50
Sorry, I haven't looked at XML support for a very long time. You'll need to provide an example of what is not working.

fdawson
2023-03-03 08:15
has joined #pact-jvm

tom.meldrum
2023-03-03 13:02
has joined #pact-jvm

syamphaneendrak
2023-03-03 13:15
@All, Good Afternoon. Dear Team, I am new to PACT and trying to setup Pact-jvm. I am successfully able to generate pact contracts & publish to pactflow from consumer. But when I am trying to publish the verification results from provider getting the below exception. Could anyone please let me know where I am missing it. ```Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal au.com.dius.pact.provider:maven:4.1.11:verify failed: lateinit property serviceProviders has not been initialized at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:148) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)```

dragos.neagu
2023-03-03 16:44
has joined #pact-jvm

uglyog
2023-03-05 22:12
Try the latest version (4.1.41 I think), also check that serviceProviders have been configured correctly as per the Pact Maven docs.

syamphaneendrak
2023-03-06 10:48
ok @uglyog thanks for your support

syamphaneendrak
2023-03-06 12:04
After upgrading my pact version, getting the below exception @uglyog http://au.com.dius.pact.core.pactbroker.NotFoundHalResponse: No HAL document found at path 'https://xxx.pactflow.io/pacts/provider/packflow/for-verification' Any idea on this ?

facundo.g
2023-03-06 12:13
has joined #pact-jvm

facundo.g
2023-03-06 12:21
Hey there, good morning :sun_with_face: I?m new to Pact, been trying to set up a contract but I can?t find enough info online and idk if I?m missing something I?ve got two services (frontend with React + back with Java), trying to set up a contract test between them (is it possible between different technologies? I imagine so, but every tutorial I?ve found is between the same technologies) I set up a test in the consumer (React), copy pasted the test to the provider (java) and set up a test. The test is testing something that goes green for a unit test. After passing it a string it should return a succesful 204 message. However, I?m seeing it return 502 :thinking_face: It?s driving me insane cause the unit test runs well, so I imagine it?s not the logic. The provider name matches, the url matches (if it doesn?t it just returns 404, so I know I?m pointing to the right one). The only thing that occurs to me is that it may have to be with the metadata since it?s between two different technologies and I haven?t specified that anywhere? Could someone give me a hand?

facundo.g
2023-03-06 12:22
This is what the contract looks like after being generated by the consumer ```{ "consumer": { "name": "verification-ui" }, "interactions": [ { "description": "the email address for a valid guid", "providerStates": [ { "name": "returns a 204" } ], "request": { "body": { "guid": "some-guid" }, "headers": { "Content-Type": "application/json" }, "method": "POST", "path": "/api/v1/verify-email-address" }, "response": { "body": {}, "headers": { "Content-Type": "application/json" }, "status": 204 } } ], "metadata": { "pact-js": { "version": "10.4.1" }, "pactRust": { "ffi": "0.4.0", "models": "1.0.4" }, "pactSpecification": { "version": "3.0.0" } }, "provider": { "name": "account" } }```

tjones
2023-03-06 13:04
> is it possible between different technologies? Yes. This is a major selling point of Pact

tjones
2023-03-06 13:05
> After passing it a string it should return a succesful 204 message. However, I?m seeing it return 502 Pact doesn?t return 502, so this is probably a misconfiguration in your code

tjones
2023-03-06 13:06
> The only thing that occurs to me is that it may have to be with the metadata since it?s between two different technologies and I haven?t specified that anywhere? No, I don?t think this is related.

tjones
2023-03-06 13:06
What happens if you spin up the server like you were about to test it, and then did that POST request via curl?

tjones
2023-03-06 13:07
> This is what the contract looks like after being generated by the consumer Aside - but you should never need to look in the contract file. You can generally treat it as opaque (although in this case it?s helpful, as we can see what you?re trying to do with it)

facundo.g
2023-03-06 13:32
Ah sorry, forgot to say this, but if I spin it up and hit the endpoint I also get a 502, but that?s an SQL error, which I understand happens when the whole flow is run in local, but with the contract test I?m mocking the answer past the controller, so I would expect it not to care :confused:

tjones
2023-03-06 13:33
I reckon signs point to the mock isn?t applying for some reason

tjones
2023-03-06 13:34
This feels like it?s not Pact at fault - (but it might be order of setup / invocation of the Pact verification)

tjones
2023-03-06 13:34
It might be helpful if you can share the way you?re setting up your test - although I don?t do much with the JVM so I personally might not be able to help

facundo.g
2023-03-06 13:40
I can share that, but it?s pretty similar to the one provided in the workshop I think. Only thing I?m not able to add is the @SpringBootTest annotation cause it throws a ?Failed to load ApplicationContext?

michael.bryson
2023-03-06 14:59
has joined #pact-jvm

jordan.brooks
2023-03-06 15:57
Thanks, was able to get what I needed setting the verification type to `RESPONSE_FACTORY`

kingsley
2023-03-06 22:47
has joined #pact-jvm

james_fraser
2023-03-07 13:50
Hey folks :wave: if I?m loading existing JSON into a `MessagePactBuilder` or `ConsumerPactBuilder` is there any way to apply matching rules to them afterwards so this basic type match is added to the contract? ```"matchingRules": { "$.body": { "match": "type" } },```

james_fraser
2023-03-07 13:51
Some sample code for context: ```JSONObject jsonObject = loadJsonFromFile( stubFile ); ConsumerPactBuilder.consumer( "consumer" ) .hasPactWith( "provider" ) .uponReceiving( "aRequest" ) .path( "/" ) .body( "{}" ) .willRespondWith() .body( jsonObject ) .toPact(); new MessagePactBuilder() .expectsToReceive( "aMessage" ) .withContent( jsonObject ) .toPact();```

syamphaneendrak
2023-03-07 15:19
Hey guys, can anyone faced the below issue. If yes, could you please help me. ```au.com.dius.pact.core.pactbroker.NotFoundHalResponse: No HAL document found at path 'https://xxx.pactflow.io/pacts/provider/packflow/for-verification'```

marckpuiu
2023-03-07 15:58
has joined #pact-jvm

hazem
2023-03-07 17:44
is your provider really called `pactflow`? see the second instance in the path

matt.fellows
2023-03-07 22:29
This can also happen if there are intermediate proxies that mess with the response - you can set log level to debug and see what the request/response to PactFlow looks like. If you see HTML or something that looks like a proxy responding, that?s probably the issue

matt.fellows
2023-03-07 22:29
howtoproxy


uglyog
2023-03-07 22:40
There is no DSL support for that, but you could add them yourself to the generated interactions.

james_fraser
2023-03-08 08:51
Thanks for clarifying @uglyog - do you mean just edit the JSON file after its generated?

xchen
2023-03-08 15:36
Hi All. I wonder how do you spin up the provider service before you kick off its verification test? If I treat this provider side test as a kind of unit test, CI pipeline won't start the real provider application when running unit tests. I'm very confused. Please help. Thank you.

duncan3142
2023-03-08 19:42
has joined #pact-jvm

william.stewart
2023-03-08 20:25
has joined #pact-jvm

uglyog
2023-03-08 22:27
There are options, depending on whether you are using Gradle, Maven, Spring or Springboot.

trc229
2023-03-09 01:34
has joined #pact-jvm

xchen
2023-03-09 09:26
Hi @uglyog I am using Gradle/Springboot. Any suggestions please?

zaira.zafar
2023-03-09 10:41
has joined #pact-jvm

itzhak
2023-03-09 13:57
Hi :slightly_smiling_face: Is it possible to define a response with array of objects where the order is not important using `PactBuilder` (V4)?

itzhak
2023-03-09 14:25
Hi @uglyog :slightly_smiling_face: where can I find documentation about this feature? I am using 4.4.7 and can not define the existence of a header using `PactBuilder`

dominik.goltermann
2023-03-09 15:31
has joined #pact-jvm

sharathkonda
2023-03-09 15:37
has joined #pact-jvm

sharathkonda
2023-03-09 15:43
Hi All, I am unable to verify with the provider as the PactFlow is deployed with HTTPS protocol. Itseems the @PactBroker annotation only supports host and port. protocol is deprecated. so when building it is trying to connect http://<pacthostname> and getting denied. Also what is the variable to be refferred for the apitoken. Can I use path.auth.token as a property.

sharathkonda
2023-03-09 15:44
In my application properties, it contains pact.host pact.port pact.auth.token

allen.ayala
2023-03-09 16:33
has joined #pact-jvm

slawomir.pawluk
2023-03-09 18:22
has joined #pact-jvm

casavelha
2023-03-09 19:49
has joined #pact-jvm

uglyog
2023-03-09 22:05
When you say "can not define the existence of a header", what do you mean? By adding a header to a Pact interaction means it has to exist otherwise the verification will fail.

uglyog
2023-03-09 22:13
Springboot tests can start the app as part of the tests. Refer to the Springboot docs and the `@SpringBootTest` annotation



uglyog
2023-03-09 22:18
You must be running an old version, if you upgrade to the latest supported the `@PactBroker` annotation has a `url` attribute. Use that.

nikita.gupta
2023-03-09 22:21
has joined #pact-jvm

pjayakumar
2023-03-10 02:21
has joined #pact-jvm

xchen
2023-03-10 09:21
Thanks @uglyog. For for the provider's dependencies, do I need to stub them and put on @State on provider's verification test class?

sasankdts
2023-03-10 11:36
Any example handling null values in build and generate pact file? I mean attribute value always null

josh.marlow
2023-03-10 15:10
has joined #pact-jvm

josh.marlow
2023-03-10 16:09
can you use `nullValue` ? e.g ```LambdaDsl.newJsonBody(body -> { body.nullValue("fieldName"); }```

patilb
2023-03-11 17:02
has joined #pact-jvm

renan.santos
2023-03-11 18:46
has joined #pact-jvm

keren.eckshtein
2023-03-12 08:57
has joined #pact-jvm

sr
2023-03-12 11:58
has joined #pact-jvm

gokuldot
2023-03-12 17:30
has joined #pact-jvm

ldgaribello
2023-03-13 06:23
has joined #pact-jvm

xchen
2023-03-13 09:16
Problem solved. Now I can treat provider side test as a normal unit test and integrate it with existing CI pipeline.

lidan.liu
2023-03-13 10:45
has joined #pact-jvm

vipin.kumar
2023-03-13 12:29
has joined #pact-jvm

michael.branders484
2023-03-13 12:35
My OAS is inside my code so i dont have a yaml file to upload bi directional contracts. How do i then upload the OAS from a CI perspective?

sasankdts
2023-03-13 13:15
I have 2 pojo classes to generate into 1 pact file any help on this?

yousafn
2023-03-13 13:21
This question would be best asked in #pactflow as it is regarding bi-directional. > My OAS is inside my code What do you mean exactly? You should be able to generate a JSON or YAML representation of your OpenAPI depending on the tooling you are using, I would suggest reading your tools documentation. For uploading contracts, once you have the openapi spec, see the instructions here https://docs.pactflow.io/docs/bi-directional-contract-testing/contracts/oas#publishing-the-provider-contract--results-to-pactflow

bknapik
2023-03-13 17:13
has joined #pact-jvm

ravi0894
2023-03-13 17:38
has joined #pact-jvm

anji.boddupally
2023-03-13 20:37
has joined #pact-jvm

voon.wong
2023-03-14 01:34
has joined #pact-jvm

gigamac
2023-03-14 08:09
has joined #pact-jvm

ivstam
2023-03-14 08:43
has joined #pact-jvm

melikesezin
2023-03-14 14:17
has joined #pact-jvm

gopishankar.haridas
2023-03-14 16:42
has joined #pact-jvm

rajasekaran.parthiban
2023-03-14 20:13
has joined #pact-jvm

sbanerjee
2023-03-15 02:46
has joined #pact-jvm

itzhak
2023-03-15 06:15
Hi @uglyog thank you for your answer :slightly_smiling_face: I want to add a header but do not care about its content. For example, I expect `x-request-id` header to be present but I do not know or care about its value.

uglyog
2023-03-15 06:17
There is a notEmpty matcher, but I have never tested that with headers, and I don't think the DSL lets you supply any matcher for the headers. You could use a simple regex like `.+`

itzhak
2023-03-15 06:31
I did not find a `header` method that accepts a matcher or regex string in the DSL, have I missed something?

kurt_schriefer
2023-03-15 13:21
has joined #pact-jvm

uglyog
2023-03-15 22:05
Use `matchHeader`

andreas530
2023-03-15 22:32
has joined #pact-jvm

santiago.rendong
2023-03-15 23:21
has joined #pact-jvm

itzhak
2023-03-16 07:42
Hi @uglyog I am using version `4.4.7` and can not find that definition in `HttpRequestBuilder.kt` . I could also not find `matchHeader`definition in `4.4.8` https://github.com/pact-foundation/pact-jvm/blob/4_4_8/consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/HttpRequestBuilder.kt... Am I missing something?

soap6gal
2023-03-16 09:03
Hello,

soap6gal
2023-03-16 09:06
I'm using pact-jvm version 3.5.x (an old version due to legacy system), and want to do a Message test that verifies the metadata that my consumer publishes. According to https://docs.pact.io/implementation_guides/jvm/provider/junit#example-of-message-test-that-verifies-metadata, I should be using MessageAndMetadata however it's not available in the library, presumably because it's an older version. What other ways can I use to verify the metadata?

matt.fellows
2023-03-16 09:08
You could perhaps back port the change from a later version?

matt.fellows
2023-03-16 09:08
I'm sure a PR would be welcome

christine.awofeso
2023-03-16 09:58
has joined #pact-jvm

uglyog
2023-03-16 12:56
Oh, sorry, that's right. With the new DSL you can use a matching function with the methods, so you should be able to use the notEmpty matcher

uglyog
2023-03-16 12:57
```builder .header("A", regexp("\\d+", "111"))```

uglyog
2023-03-16 12:58
Or ```builder .header('A', notEmpty('111'))```

uglyog
2023-03-16 12:58
Those functions are found in `http://au.com.dius.pact.consumer.dsl.Matchers`

konstantin.manna
2023-03-16 15:04
has joined #pact-jvm

emgarcia
2023-03-16 15:44
has joined #pact-jvm

john.goodwin
2023-03-16 15:51
has joined #pact-jvm

tomasz.kowalczyk
2023-03-16 15:51
has joined #pact-jvm

samir.ferreira
2023-03-16 16:27
has joined #pact-jvm

kripa.kurian
2023-03-16 19:31
@kripa.kurian has left the channel

raess.simon
2023-03-16 23:02
has joined #pact-jvm

pascal.libenzi
2023-03-17 07:00
Hello guys! I have an issue using branch fallback feature with pact-broker and pact-jvm by PactBrokerConsumerVersionSelectors (I think I am missing something that?s why I didn?t create an issue for now). Here is my configuration: ? Java version: 17 ? pact jvm dependency: ```<dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.5.2</version> </dependency>``` ? PactBrokerConsumerVersionSelectors: ```@PactBrokerConsumerVersionSelectors public static SelectorBuilder consumerVersionSelectors() { return new SelectorBuilder() .branch(System.getProperty("branch"), null, System.getProperty("fallback")); }``` ? Link to the project sources if needed: https://gitlab.com/pascal.libenzi/pact-jvm-provider/-/tree/feature/new-field-publication-date My consumers have a trunk branch. If I put it as a System property ?branch? the test pass. If I pass ?nonexistingbranch? in branch and trunk in fallback I have: ```au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify Provider: BookStore Source: Pact Broker http://localhost:80 consumerVersionSelectors=[Branch(name=test, consumer=null, fallback=trunk)]``` Does somebody have any idea about what I am missing? Thanks!

raess.simon
2023-03-17 09:24
I have strange issues with au.com.dius.pact.provider:spring6:4.5.3 (and older versions as well). When I add the dependency to a plain Gradle build file and run "gradle dependencies" the dependencies are not resolved: \-- au.com.dius.pact.provider:spring6:4.5.3 FAILED the reason I think is the missing version on the dependency to org.apache.groovy:groovy If I include the dependency in our own build, I get NullPointerExceptions or other strange errors. see https://github.com/pact-foundation/pact-jvm/blob/v4.5.x/provider/spring6/build.gradle#L33

sasankdts
2023-03-17 15:41
Can we use java8 and junit5 for pact test?

anshu.ranjan1002
2023-03-17 21:59
has joined #pact-jvm

mptinternational
2023-03-18 18:12
has joined #pact-jvm

16728365
2023-03-19 14:30
has joined #pact-jvm

brick777
2023-03-19 21:47
has joined #pact-jvm

anji.boddupally
2023-03-19 23:07
```Hi, I have a question about BiDirection Contract Testing. Steps I followed 1. I created OAS swagger.json file and published as provider contract with version 1.0.0 2. Ran can-i-deploy tool and recorded the deployment for the version 1.0.0 3. Generated the consumer contract which is compatible with provider contract 4.Published this consumer contract with version 2.0.0 5. Ran can-deploy-tool and it says consumer version 2.0.0 is compatible with provider version 1.0.0 6.Hence proceeded with deployment and recorded the deployment with consumer version 2.0.0 7.Now, I made a breaking change in provider contract (in OAS) and published to pact as version 1.0.1 8.Ran can-i-deploy and it says NO as provider contract 1.0.1 is not compatible with consumer version 2.0.0 9.I updated consumer executions to be inline with new provider change and published the consumer contract with version 2.0.1 http://10.In pact flow UI, I see that consumer version 2.0.1 is compatible with producer version 1.0.1 which is good 11.But when I run "can-i-deploy" it says NO as consumer version 2.0.1 is compared with producer version 1.0.0 instead 1.0.1 How can I proceed with deployment??```

uglyog
2023-03-19 23:56
What version of Gradle are you using?

uglyog
2023-03-19 23:56
Yes, but you need to use 4.1.x pf Pact-JVM

matt.fellows
2023-03-20 01:50
So the critical mistake you are making, is that you?re making a breaking change and now have to coordinate that by synchronising deployments. We want to avoid this at all costs. At step 9, the consumer is not in prod yet. So if the provider is to deploy (step 11) it would temporarily break the consumer, until it releases. Whether you are doing BDCT (PactFlow only) or CDC (Pact), PactFlow won?t allow a situation like this to happen

matt.fellows
2023-03-20 01:51
You should follow an expand and contract approach, where you make a change that allows the consumer to move to that, before removing the behaviour the consumer(s) previously relied on

mark.ingram
2023-03-20 11:31
has joined #pact-jvm

jo.laing
2023-03-20 17:06
has joined #pact-jvm

erich.buri
2023-03-20 22:07
has joined #pact-jvm

xiaorong.ruby
2023-03-21 09:34
has joined #pact-jvm

markcox20
2023-03-21 10:08
has joined #pact-jvm

oloruntobi.ayilara
2023-03-21 14:01
has joined #pact-jvm

pankaj_kumar39
2023-03-21 14:18
has joined #pact-jvm

ravi_shankar_lakkims
2023-03-21 14:18
has joined #pact-jvm

sathish.nilla
2023-03-21 14:19
has joined #pact-jvm

sikandar_kumar.singh
2023-03-21 14:19
has joined #pact-jvm

benjamin.earle
2023-03-21 19:23
has joined #pact-jvm

sanjaysingh99in
2023-03-22 00:57
has joined #pact-jvm

rafalmaciak
2023-03-22 08:03
has joined #pact-jvm

rafalmaciak
2023-03-22 08:07
Hello! I'm looking for a way to test message based communication (with Kafka) using Pact and *groovy/spock*. I already defined the consumer's test using this example (https://docs.pact.io/implementation_guides/jvm/consumer/groovy#consumer-test-for-a-message-consumer). Now I'm struggling how to test provider with groovy/spock. I couldn't find a doc/sample/tutorial. Is there a way to test message communication with groovy?

jyothy18
2023-03-22 09:23
has joined #pact-jvm

haiyang.huang
2023-03-22 10:30
has joined #pact-jvm

tjones
2023-03-22 12:56
I?ve done provider verification with groovy before, so it?s definitely possible. I?m afraid it has been a long time since I?ve used groovy, so I don?t personally have any examples to hand

rafalmaciak
2023-03-22 12:59
Hi @tjones, thanks for you reply. Was this verification for messages or http (e.g. rest API)? I also did verification for REST API in groovy/spock but can't figure out nor find examples how to do it for messages :disappointed:

tjones
2023-03-22 13:02
I misunderstood what you were asking, my apologies. It was for http verification.

denispegan4
2023-03-22 13:14
has joined #pact-jvm

tranghetti
2023-03-22 21:15
has joined #pact-jvm

uglyog
2023-03-22 22:27
There is nothing with groovy/spock that is going to stop you from being able to write a provider verification test.


rafalmaciak
2023-03-23 05:55
Thanks for those examples. Now I need to figure out how to connect it with Pact broker :wink:

amruta_mandavilli
2023-03-23 06:23
has joined #pact-jvm

shubhamshriram.shinde
2023-03-23 06:34
has joined #pact-jvm

juliemarierosok
2023-03-23 08:20
has joined #pact-jvm

colin.aygalinc
2023-03-23 09:23
has joined #pact-jvm

me1685
2023-03-23 10:53
has joined #pact-jvm

gregpovorozniuk
2023-03-23 11:32
has joined #pact-jvm

mpalla553
2023-03-23 14:51
has joined #pact-jvm

sumit.singh
2023-03-23 18:03
has joined #pact-jvm

quinton.miller
2023-03-23 19:18
has joined #pact-jvm

hurdledatrade
2023-03-24 11:24
has joined #pact-jvm

2023-03-24 13:39
This message was deleted.

srijan.c
2023-03-24 15:26
has joined #pact-jvm

praveen.gangasani
2023-03-26 13:19
has joined #pact-jvm

uglyog
2023-03-27 01:07
`verify` does not publish anything, it verifies the provider against a published Pact. `pact:publish` is the command to do that.

yzxu
2023-03-27 07:27
has joined #pact-jvm

1248124408
2023-03-27 08:59
has joined #pact-jvm

daniel.redelberger
2023-03-27 09:07
has joined #pact-jvm

1248124408
2023-03-27 09:40
Hey,guys!I'm using pact framwork(version num:4.1.28) to verify a multipart/form-data interface. This interface will receive a excel and parse to a Workbook. Here is the interface: ```@PostMapping("/pact-test-form-data") public SimpleResultVo<Object> pactTest(SecurityUploadHttpServletRequest request) { List<String> result = new ArrayList<>(); CommonsMultipartFile[] mfs = request.getMultipartFiles(); try(InputStream is = mfs[0].getInputStream(); Workbook workbook = new XSSFWorkbook(is)) { workbook.getSheetAt(0); } catch (IOException e) { e.printStackTrace(); } result.add(request.getParameter("userName")); result.add(request.getParameter("password")); return ResultVoUtil.success(result); }``` Here is the pact I created: ```@Pact(consumer = "FBB") public RequestResponsePact formDataReqTest(PactDslWithProvider builder) throws IOException { File file = new File("C:\\Users\\g00574640\\Desktop\\importProjectList.xlsx"); MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create() .addTextBody("userName", "guojiahui") .addTextBody("password", "123456") .addBinaryBody("file", file, ContentType.create("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), "importProjectList.xlsx"); String expectStr = TestingFileUtils.loadFileAsString("business/service/ResourceServiceTest/expect/formData.json"); Map<String, String> map = new HashMap<>(); map.put("Content-Type", "application/json"); return builder.uponReceiving("query a server info success.") .path("/cloud-platform-service/v1/resource/pact-test-form-data") .method("POST") .body(entityBuilder) .willRespondWith() .status(200) .body(expectStr) .toPact(); } @Test @PactTestFor(providerName = "FormDataAPI", port = "8500", pactMethod = "formDataReqTest") public void runTestformDataReq() throws IOException { File file = new File("C:\\Users\\g00574640\\Desktop\\importProjectList.xlsx"); MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create() .addTextBody("userName", "guojiahui").addTextBody("password", "123456") .addBinaryBody("file", file, ContentType.create("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), "importProjectList.xlsx"); HttpEntity httpEntity = entityBuilder.build(); CloseableHttpClient httpclient = HttpClients.createDefault(); RequestBuilder request = http://RequestBuilder.post("http://localhost:8500/cloud-platform-service/v1/resource/pact-test-form-data") .setEntity(httpEntity); HttpUriRequest httpUriRequest = request.build(); httpclient.execute(httpUriRequest); }``` But when i verified this interface and executed `Workbook workbook = new XSSFWorkbook(is)` ? I received an exception like this:`java.util.zip.DataFormatException: invalid block type` . Did I write the wrong pact? I loaded this file and found that this file is broken. What shoud I do?:heart:

mohammed.a.ezzedine
2023-03-27 15:25
has joined #pact-jvm

kiran.malsetty
2023-03-27 17:20
has joined #pact-jvm

rchild
2023-03-27 18:46
has joined #pact-jvm

asoni
2023-03-27 20:23
has joined #pact-jvm

uglyog
2023-03-27 22:18
I would guess that the content type header is not being set correctly

uglyog
2023-03-27 22:19
Or the other option is that Apache Tika does not support Workbook format

yu.xie
2023-03-28 00:08
has joined #pact-jvm

gamer.fikri
2023-03-28 04:46
has joined #pact-jvm

james_fraser
2023-03-28 08:09
Hey there :wave: I?m having a bit of trouble getting the `pactVerify` Gradle command to run for my message provider - it doesn?t seem to be able to find the methods I?ve annotated even though it should be on the test classpath I?ve commented out the `packagesToScan` section in my Gradle and it still can?t find it, it just gives me an error: ```No annotated methods were found for interaction 'message.interaction.name'. You need to provide a method annotated with @PactVerifyProvider("message.interaction.name") on the classpath that returns the message contents.``` I have a method annotated correctly in my test directory (the test runs and passes if I run it using JUnit): ```@PactVerifyProvider("message.interaction.name") public String verifyInteraction() { ... }``` My build.gradle currently looks like this: ```pact { broker { pactBrokerUrl = "$System.env.PACT_BROKER_BASE_URL" pactBrokerToken = "$System.env.PACT_BROKER_TOKEN" } serviceProviders { providerName { verificationType = 'ANNOTATED_METHOD' // packagesToScan = ['*'] hasPactsFromPactBroker("$System.env.PACT_BROKER_BASE_URL", authentication: ['Bearer', "$System.env.PACT_BROKER_TOKEN"]) } } }``` If you?ve any suggestions on what I could try in order to sort this I?d really appreciate it - thanks :smile:

tjones
2023-03-28 08:30
You could set `packagesToScan` to tell it where your test is

tjones
2023-03-28 08:31
What is your test class annotated with?

james_fraser
2023-03-28 08:31
I tried that originally, then took it out as apparently that should scan the full classpath so thought it might have better success

james_fraser
2023-03-28 08:32
My test class is annotated like this: ```@Provider("providerName") @PactBroker(url = "url", authentication = @PactBrokerAuth(token = "token")) public class ProviderMessageTest { ...```

tjones
2023-03-28 08:35
Hm. Looks right to me, but it has been a while since I worked with the JVM.

james_fraser
2023-03-28 08:40
Thanks for checking, at least I don?t seem to be missing something obvious :+1:

james_fraser
2023-03-28 08:41
For what it?s worth I?m on version `4.3.19`, 4.4+ seems to give me an error due to my Gradle version (which is currently locked for the project I?m working on)

james_fraser
2023-03-28 08:49
Though just for peace of mind, I tried bumping it to `4.5.3` locally and still get the same error

shaun.carmody
2023-03-28 13:23
has joined #pact-jvm

christianschiepe
2023-03-28 13:50
has joined #pact-jvm

aberman
2023-03-28 19:24
has joined #pact-jvm

uglyog
2023-03-28 23:04
What is the package that `ProviderMessageTest` is in? That is what you should set `packagesToScan` to. Where does this test class sit, is it in another module? What JDK are you using?

0xoscario
2023-03-29 03:38
has joined #pact-jvm

james_fraser
2023-03-29 08:37
I?m fairly new to Gradle so apologies if my answers aren?t exactly what you?re looking for The repo I?m working with has two projects inside (`provider_service` and `provider_service_api`, the service is the provider), each with their own `build.gradle`, the Gradle snippet I shared is from the repo?s root `build.gradle` Its package is `com.company.providername.pact`, which is what I had originally set it to The test file is in `provider_service/src/test/unit/java/com/company/providername/pact/` My JDK seems to be set to 17

uglyog
2023-03-29 22:03
Ok, that will explain why the class is not found. You need to add the `provider_service` to the build classpath of the root Gradle project. When the Gradle plugin runs, it uses the build classpath to load classes, not the project compile or test classpaths.

uglyog
2023-03-29 22:03
I would recommend using JUnit to run the test, because the classes will all be available

james_fraser
2023-03-30 08:36
Ok cool thanks for that :smile: I?ll try and update the Gradle then see if I can get it working I was originally using JUnit but it seemed to require adding the broker auth token to every test class (which we?d like to keep secured), and I wasn?t having any luck getting it to pick up system properties I?ll try again as it definitely worked though

paddyhendy94
2023-03-30 12:48
has joined #pact-jvm

haroldrobson11
2023-03-30 13:16
has joined #pact-jvm

jfbosca
2023-03-30 15:26
has joined #pact-jvm

daominhdam
2023-04-01 10:04
has joined #pact-jvm

crazycabo350
2023-04-02 01:55
What?s the best resource with some examples for migrating from V3 to V4 Pacts for Java implementations?

art.ptushkin
2023-04-03 13:19
Hey everyone, I'd like to find/conclude the best practices regarding mocking on the provider side. Once I participated in a Pact meetup and I heard (from Matt I think) that it's recommended *not to mock layers* but prepare the state around the service, i.e. inserting into the database etc. Which I support very much. Though I still see that people are mocking mostly for the reason that writing a mock on the controller level seems easy. As well I see that in the https://github.com/pact-foundation/pact-workshop-jvm-spring/tree/step7#step-7---adding-the-missing-states there is a recommendation/example to *mock results* returned by the repository layer. Q: Do we have somewhere a community conclusion regarding this? If not, let's conclude and I can list my points if it's needed. Just my point is mocking evil and as soon folks start writing this they copy-paste the approach.

joseph.gately
2023-04-03 14:14
has joined #pact-jvm

tjones
2023-04-03 15:12
I personally believe it?s best to mock at the repository layer.

tjones
2023-04-03 15:12
I?ve written this up a bit somewhere, let?s see if it?s still in slack.

tjones
2023-04-03 15:12
Hm. It isn?t.


tjones
2023-04-03 15:17
In quick points - If you mock at the controller, you only know that the service might produce the response you want, not that it actually does in at least one case If you insert into the database, your state setup knows too much about the database structure (which will be a pain to maintain, and you have the reverse problem, where you don?t know if that data ever gets in to the database). If you mock at the repository layer, then your mock is simple as it is expressed in domain concepts `when "user '10' exists" then repo.getUser('10') returns {....}` etc, robust to implementation changes of the repository layer, and also those mocks can be used to check the contract tests for that layer too.

tjones
2023-04-03 15:21
I think the argument for mocking at the controller is so that you don?t start driving functional tests with your contract tests. I agree that functional tests shouldn?t be driven by your contract tests (this is also a maintenance issue, where the consumer knows too much about the provider?s behaviour), but I think it?s an advantage if your contract tests have some functional _coverage_, where they would fail if that specific behaviour broke. This is the main point I made in the video

matt.fellows
2023-04-04 07:05
yep, what Tim Said

matt.fellows
2023-04-04 07:05
I think I remember you from the TestJS Summit maybe? In any case, hello! :wave:

matt.fellows
2023-04-04 07:08
So yes, I would suggest mocking at the repository layer also. It?s a good default for most teams. If you mock elsewhere, that?s totally acceptable, but comes with more caveats - the main one is ensuring you have the testing coverage elsewhere in your code and that all of these tests are properly aligned, otherwise you can end up in a situation where you have mocked the controller, but haven?t considered the actual scenarios downstream of it, and there are gaps.

bram.harmsen
2023-04-04 07:20
has joined #pact-jvm

sarah.al-hawi
2023-04-04 10:55
has joined #pact-jvm

andrei.enache
2023-04-04 10:55
has joined #pact-jvm

sohaib.zahid
2023-04-04 10:55
has joined #pact-jvm

behrouz.pooladrak
2023-04-04 10:55
has joined #pact-jvm

amarpal.amrith
2023-04-04 10:57
has joined #pact-jvm

laszlo.bogardi
2023-04-04 10:57
has joined #pact-jvm

caroline.thom
2023-04-04 13:20
has joined #pact-jvm

jeremy.chao
2023-04-04 14:49
has joined #pact-jvm

bmdk83
2023-04-04 15:51
has joined #pact-jvm

maithree.uppunda
2023-04-05 07:50
has joined #pact-jvm

sivamkumar80
2023-04-05 13:34
has joined #pact-jvm

vanja.ilic
2023-04-05 14:24
has joined #pact-jvm

proydimonoff
2023-04-05 14:30
has joined #pact-jvm

proy
2023-04-05 14:33
has joined #pact-jvm

kevin.moylan
2023-04-05 16:13
has joined #pact-jvm

vijaykumar.patel
2023-04-06 06:36
has joined #pact-jvm

art.ptushkin
2023-04-06 09:46
Thanks, everyone, I think I participated in exactly that conference :slightly_smiling_face: Good to have that presentation reference, I will use that negotiating

art.ptushkin
2023-04-06 09:55
My personal preference was preparing the database for every test by inserts. Because this way makes sure that the provider operates as it will be on any actual environment. This way our state is an example of a state that we could compare with an actual state in any environment. Tests look more isolated from the behavior and rely on the external state. Another personal argument is that I do not trust Java mocks, it makes us think about the Java classes rather than the pure data. Though I agree that mocking on the repository layer looks good to move away from the database structure dependency. I see a good reason here that usually there are fewer _converters_ between the repository layer and the actual database data. If we would have many converters than it would be difficult to match the mock data with the actual database data troubleshooting and using contract tests as _an example_.

tjones
2023-04-06 10:40
How do you know that what you are inserting in the database looks like what you will really have in a real environment?

ankit.kumar
2023-04-06 10:55
has joined #pact-jvm

joye.arbuckle
2023-04-06 14:24
has joined #pact-jvm

allison.stone
2023-04-06 19:36
has joined #pact-jvm

mayank
2023-04-06 22:11
has joined #pact-jvm

ganesh.walunj
2023-04-07 06:05
has joined #pact-jvm

jan.krolikowski
2023-04-07 14:39
has joined #pact-jvm

mragni.majhwar
2023-04-07 17:51
has joined #pact-jvm

dawoud.sheraz
2023-04-09 08:49
Hi. Is there an example project for pact with gradle? I was poking through examples but I only found maven examples.

tjones
2023-04-09 09:14
I don?t remember if there?s an example project, but there are examples of the gradle dsl in the pact jvm documentation

matt.fellows
2023-04-09 09:58
I'm there are several, I think one of the workshops uses gradle also. See howtoexamples


gonzalo.granizo
2023-04-11 10:13
has joined #pact-jvm

theburningmonk
2023-04-11 11:29
has joined #pact-jvm

helenarodcal
2023-04-11 11:31
has joined #pact-jvm

enver.yasar
2023-04-11 13:39
has joined #pact-jvm

christian.ledgard
2023-04-11 13:49
has joined #pact-jvm

ddongre
2023-04-11 15:09
has joined #pact-jvm

prajapati.pravesh
2023-04-12 02:55
has joined #pact-jvm

edwin.raju
2023-04-12 08:13
has joined #pact-jvm

john.hennigan
2023-04-12 08:16
has joined #pact-jvm

donald.robertson
2023-04-12 10:42
has joined #pact-jvm

tam.norris
2023-04-12 10:46
has joined #pact-jvm

gopijaganathan7
2023-04-13 07:27
has joined #pact-jvm

lukaszmalek90
2023-04-13 11:40
has joined #pact-jvm

omri.eyal
2023-04-13 13:23
@omri.eyal has left the channel

nickwilliamsqa
2023-04-13 16:15
has joined #pact-jvm

guozhangliew
2023-04-14 02:03
has joined #pact-jvm

praboo.p
2023-04-14 07:17
has joined #pact-jvm

florenciaaldana.rodri
2023-04-14 08:10
has joined #pact-jvm

taher.kapasi
2023-04-14 15:53
has joined #pact-jvm

michael385
2023-04-14 16:40
has joined #pact-jvm

darrenoc3
2023-04-15 03:46
has joined #pact-jvm

ones.ardo
2023-04-17 07:58
has joined #pact-jvm

deeptiagrawal
2023-04-17 23:31
has joined #pact-jvm

nikita.gupta
2023-04-18 02:50
Hello Guys,I am verifying a request between a Kotlin based consumer and PHP based Provider service that requires authorization token send in request header (that does not change very frequently) so i added token in pact and consumer test which works fine but verifying the pact against provider respond with 401 error code.whats the best way to handle this? Should i add token on provider side(which i could not find way to add in pact-php) or i there a possibility to totally ignore token since we are using mock client to interact with provider and i don?t need to verify token.Please suggest.Thanks!

uglyog
2023-04-18 02:52
Raise this with the Pact PHP project

nikita.gupta
2023-04-18 02:55
Thanks @uglyog,since i already added token in pact which is published on pact flow do i still need to do something on provider side?

uglyog
2023-04-18 02:56
Yes, I would imagine so. But I don't know your provider

nikita.gupta
2023-04-18 02:57
make sense since its i php i will post on php channel but alos curios to know how it will be done between two java/kotlin based application.Can you point me to an example?

uglyog
2023-04-18 02:58
It depends on the application. Any example will be specific to how that application works.

nikita.gupta
2023-04-18 03:00
i am takling about X-Favor-token

madhukar.koratagere
2023-04-18 06:24
has joined #pact-jvm

mahesh.damavarapu
2023-04-18 06:26
has joined #pact-jvm

james_fraser
2023-04-18 10:19
Hey there :wave: I?m looking at https://github.com/pact-foundation/pact-jvm/blob/master/docs/system-properties.md It says that `pact.verifier.publishResults` has an env var equivalent but I?m struggling to find it anywhere, is it possible for these to be listed?

james.perepiczka
2023-04-18 10:51
Hey, Is it possible to use the SelectorBuilder with a specific version number? I notice that version can be sent on a webhook but I don?t see how to take that version to verify against. I know you can filter on environments, consumer, tags etc but it would be nice to be able to pass in specific version numbers. Especially if you have missing verifications you might want to selectively target

paul.caplan
2023-04-18 14:52
has joined #pact-jvm

cars2991
2023-04-19 02:42
has joined #pact-jvm

cars2991
2023-04-19 02:44
Anybody have issues with intellij and Pact? I am trying to follow the guide https://docs.pact.io/implementation_guides/jvm/consumer

cars2991
2023-04-19 02:45
It always complains about not being able to resolve dependencies

tjones
2023-04-19 04:44
I don?t think this is a Pact problem

tjones
2023-04-19 04:45
but if you provide more information, perhaps someone can help

vaidas.sieber
2023-04-19 06:42
has joined #pact-jvm

jonathandelaros
2023-04-19 07:40
has joined #pact-jvm

priyaranjanmudliar
2023-04-19 09:05
has joined #pact-jvm

ch.pascucci
2023-04-19 09:11
Hello all :slightly_smiling_face: My team is looking at a very specific use case and we are trying to figure out if Pact is the right tool for us, so I was wanting to check if someone may have used it successfully in a similar scenario: ? Consumer (written in TS) that is a user facing application (to do with management of user accounts). This sends requests to a backend API when needing to update user details (e.g. update phone number) ? Provider (Java, thus posting here). Accepts requests and interact with the database with user details Consumer tests are implemented in we can generate a Pact file, but we have a couple of sticking point with the provider side ? We cannot run the api locally, thus we are considering running the tests against a deployed version of the API (in a test env) ? The deployed API has an authentication layer, making it very hard to set up the request properly in a test file (as we would need to generate an auth token on the fly, using an OAuth2 auth flow, and then use this to modify the request as set out in the pact file) Anyone has come across a similar use case before? Apologies for the very long post, any help/pointes/thoughts massively appreciated :smile: as a bonus: I have been wondering if there is any way to create a custom class implementing the TestTarget interface, which instead of forwarding requests to a host/port it directly calls handler method in the test base - but unsure if this is even in realm of possibilities

ajaydiwakar.ka
2023-04-19 10:11
has joined #pact-jvm

meghaagr
2023-04-19 10:13
has joined #pact-jvm

jan.krolikowski
2023-04-19 10:30
> We cannot run the api locally, thus we are considering running the tests against a deployed version of the API (in a test env) As long as you trust this environment that should be doable. However, the tradeoff is isolation and control over the environment. Considering contract tests executed as a part of consumer build pipeline, it might get cumbersome when multiple consumer pipelines will act on the same test environment. The state of provider service might change during the test execution and the flakiness might happen, failing the consumer build. > The deployed API has an authentication layer, making it very hard to set up the request properly in a test file read up on https://github.com/pact-foundation/pact-jvm/blob/master/provider/junit5/README.md#modifying-the-requests-before-they-are-sent - it should help

hcummins
2023-04-19 12:58
has joined #pact-jvm

michael.dasilva
2023-04-19 13:13
has joined #pact-jvm

matt.fellows
2023-04-19 13:22
Lovely answer! :taco: for you @jan.krolikowski

ivana.lazic
2023-04-19 14:04
has joined #pact-jvm

vakong13
2023-04-19 16:15
has joined #pact-jvm

bas
2023-04-20 09:40
It might not even be an IntelliJ problem, maybe you're using a company Maven / Gradle repository where Pact isn't available yet? More info would definitely help, @cars2991

ravinder.kadiyan
2023-04-20 09:56
has joined #pact-jvm

alfredo.castro
2023-04-20 13:27
has joined #pact-jvm

lluis.casals
2023-04-20 17:07
has joined #pact-jvm

cars2991
2023-04-20 21:45
I was able to solve it after invalidating cache from intellij. Somehow I updated from spring 2 to 3 and intellij freaked out.

cars2991
2023-04-20 21:45
Thanks for all the help.

dprawatya
2023-04-21 01:11
has joined #pact-jvm

mbutt
2023-04-21 01:11
has joined #pact-jvm

darrenoc3
2023-04-21 12:04
@nikita.gupta for our project, how we handle this is having a test profile for the provider service that allows basic authentication (username + password) in place of a token. Then the username and password is added to the headers of the provider contract test requests. Basic authentication is then disabled in prod environments for obvious reasons

darrenoc3
2023-04-21 12:17
```We cannot run the api locally``` I think I would try to solve this challenge, before I went down any other paths. There are so many development velocity benefits to being able to spin up a reduced version of a service locally, even if you have to mock out the database or mock out the authentication provider to do so.

marcia.meira
2023-04-21 12:43
has joined #pact-jvm

raubreysmith
2023-04-21 12:46
has joined #pact-jvm

ksenia.vasileva
2023-04-21 15:02
has joined #pact-jvm

jack.amico
2023-04-21 15:48
has joined #pact-jvm

cheng.ngai
2023-04-22 00:55
has joined #pact-jvm

aditya.kashyap
2023-04-24 05:13
has joined #pact-jvm

aditya.kashyap
2023-04-24 05:14
Hi Team , I was looking to use PACT For Contract Testing , but I have one query 1. Does it work for Internal APIs also ? 2. Do you guys support gRPC ?

matt.fellows
2023-04-24 05:16
> 1. Does it work for Internal APIs also ? Can you please elaborate on what you mean by this? It?s best suited to internal APIs vs public APIs, if that?s what you?re talking about?


aditya.kashyap
2023-04-24 05:40
It?s best suited to internal APIs vs public APIs, if that?s what you?re talking about? Ya i am talking about this only

aditya.kashyap
2023-04-24 07:07
@matt.fellows can you give me some insights as we have less customer side exposed api , and more internal apis to work on so will pact work for that ?

matt.fellows
2023-04-24 07:15
Pact was designed for internal microservices, so yes, I would think so!

aditya.kashyap
2023-04-24 08:02
Previously we did POC on PACT and we halted because we didn?t find that out . If you could confirm that it works then we would like to use PACT

aditya.kashyap
2023-04-24 09:14
Also do you have support for Bazel Projects ?

iustina.gavrila
2023-04-24 09:15
has joined #pact-jvm

matt.fellows
2023-04-24 11:10
> If you could confirm that it works then we would like to use PACT Didn?t I just do that. Twice?

matt.fellows
2023-04-24 11:10
> Also do you have support for Bazel Projects ? We do anything special for Bazel.

juliemarierosok
2023-04-24 12:50
Hi Everyone. I am having some trouble understanding how to combine matchers with OR/AND. Maybe I have misunderstood, but I was hoping I could use this to specify that we expect either attribute A to be present OR attribute B. Is this possible? If so, how do I specify it? I have tried like this: ```root.stringType("requestedProductionDateFrom", "2024-03-20T00:00:00Z") .or("calculatedProductionDateFrom", "2024-03-20T00:00:00Z"); root.stringType("requestedProductionDateTo", "2024-03-02T17:15:00Z") .or("calculatedProductionDateTo", "2023-03-02T17:15:00Z");``` But, both attributes are filled in the example data generated, and the matching rules does not look correct : ```"$.calculatedProductionDateFrom": { "combine": "OR", "matchers": [ ] }, "$.calculatedProductionDateTo": { "combine": "OR", "matchers": [ ]```

darrenoc3
2023-04-24 13:13
Hey all. Quick one: I was using the DSL for matching but colleague asked for matching document to be provided as JSON resource file instead. Mostly works, but now I can't figure out how to match on type instead of value (e.g. for unique id field): is there any way to add matching rules when using file based approach? e.g: ```.body(FileUtils.readFromResourceFile("pacts/createFtdcDevicePact.json"))```

darrenoc3
2023-04-24 13:15
I guess I need the JVM equivalent of `Pact::SomethingLike`

vandana.aveva
2023-04-24 18:24
has joined #pact-jvm

lucas
2023-04-25 00:01
has joined #pact-jvm

tjones
2023-04-25 02:21
What are you trying to do? See howtooptional


tjones
2023-04-25 02:28
Oh, I see you posted the other thread we replied to as well. Sorry for the double up

szydlakus
2023-04-25 11:19
has joined #pact-jvm

sarah.hutchins
2023-04-25 12:48
has joined #pact-jvm

darrenoc3
2023-04-25 13:12
Since I didn't get any bites, I'll rephrase my question: using Pact JVM can I provide raw JSON to the matcher and have it match on the types instead of the actual values? Or is that only possible using the DSL matchers.

tjones
2023-04-25 13:26
This is a good question, but I don?t know, I?m afraid.

tjones
2023-04-25 13:26
It might be useful if you could provide some information about the use case - why does your colleague want the document to be provided by a JSON resource file? What?s the benefit?

tjones
2023-04-25 13:27
If you did do that, and could provide JSON matchers, I think it would be pretty unmaintainable.

tjones
2023-04-25 13:28
If your colleague is just thinking ?this looks like a lot of hard coded data, it would be more appropriate in a resource file?, I would encourage them to look again and think about the maintenance implications.

tjones
2023-04-25 13:28
But maybe I am missing the use case.

kristoffer
2023-04-25 13:31
has joined #pact-jvm

jack.drake
2023-04-25 15:40
has joined #pact-jvm

mathivanan.kailasam
2023-04-25 16:15
has joined #pact-jvm

hornc
2023-04-25 18:00
has joined #pact-jvm

hulia.suliman
2023-04-25 18:07
has joined #pact-jvm

hornc
2023-04-25 18:07
Hello ! I have a question / issue , essentially my use case is we have an API gateway layer that maps the endpoint the UI calls (eg - /checkout/v2) to the endpoint published by service app (/checkout/v1) which results in contract tests failing with a 404 not found error (/checkout/v2 does not exist on service app). I was sent this to try - https://docs.pact.io/recipes/apigateway#use-case-1-basic To use something like a ?request filter? to change the path in the test at producer verification time. Unfortunately, that document doesn't have an example, so I thought I'd ask here if anyone knows the solution.

yousafn
2023-04-25 22:21
See the request filters section in the pact-jvm docs, linked here https://docs.pact.io/faq#how-do-i-test-oauth-or-other-security-headers


yousafn
2023-04-25 22:23
albeit for use case three

markus.nakhlah
2023-04-26 13:44
has joined #pact-jvm

hornc
2023-04-26 16:15
Thank you ! I will try this and report back

jean-francois.renaud
2023-04-26 21:09
has joined #pact-jvm

jakazzy
2023-04-27 06:16
has joined #pact-jvm

jean-francois.renaud
2023-04-27 19:05
tl dr _Is there a way to merge pact verification results before sending it to the pact broker?_ Hi all, I have a provider multi-modules maven project where I expect some modules to execute parts of the pact verification. The sum of all the module verification would cover all the pacts. I am planning use https://docs.pact.io/implementation_guides/jvm/provider/junit#filtering-the-interactions-that-are-verified , to decide what states a module should be testing. My understanding is that the results are accumulated in memory, and not shared across junit/test jvms. Which means I am not sure how to assemble those results before sending it to the broker. I want each module to verify some pacts since the business logic is replicated across them. This service is an integration service, so for each external system we support we have a dedicated module for this that implements our service api.

matt.fellows
2023-04-27 22:58
hmm I don?t think so, at least a search of the docs suggests it?s not readily available

matt.fellows
2023-04-27 22:59
Could you instead, treat A, B and C as separate providers?

jean-francois.renaud
2023-04-28 00:39
Well it would still boil down to the same problem, I would have more than one module implementing A endpoints

tjones
2023-04-28 03:19
> I would have more than one module implementing A endpoints This is certainly unusual - although it is a leaky part of pact?s abstraction that the consumer needs to know which services it has that are different

tjones
2023-04-28 03:19
I?ve thought for a long time it would be useful to have a tool that can chop and change Pact files - if we had such a tool, things like this could be built easily

matt.fellows
2023-04-28 03:21
> I would have more than one module implementing A endpoints OK I see the problem now. The ?uses {B, C}? was confusing to me. It sounds like ?implements part of {B, C}? is actually what it does.

tjones
2023-04-28 03:23
If I had this situation, I would probably just do contracts between Consumer -> X, Consumer -> Y and Consumer -> Z.

tjones
2023-04-28 03:23
(and then have the Provider verify them all)

tjones
2023-04-28 03:24
Do you need the actual modules to be doing the verification? Why not just spin up the box you?ve marked as Provider, instead?

tjones
2023-04-28 03:25
(as surely that includes the modules)

juliemarierosok
2023-04-28 10:14
Hi, I am posting a follow up from a question I posted in #general the other day. I am having issues with the datetime matcher, that pact is generating the example date in my local time instead of in UTC, which is what is expected. I was able to get the test to run green by setting the run configuration argument -Duser.timezone="UTC", but this is not really the ideal solution ( I could set it in the POM as well, which would be a tad better, but still not what we want). Does anyone know if there is a way to tell Pact which timezone to use? When providing the Instant to the .datetime method, I am also giving the timezone information, but it seems to be overridden.

tjones
2023-04-28 10:39
I don?t know the answer to your question - but, why would it matter as long as the generated timezone is format compliant?

tjones
2023-04-28 10:39
> I am also giving the timezone information, but it seems to be overridden. This sounds like a bug to me

edwin.raju
2023-04-28 11:13
@edwin.raju has left the channel

juliemarierosok
2023-04-28 12:16
It only matters because I have a Mockito.verify in my test where I am providing an expected object, in which the dates then does not match

srinivas.nali
2023-04-28 14:27
has joined #pact-jvm

dmitriy.tarasevich
2023-04-28 16:00
has joined #pact-jvm

jigish.mehta
2023-04-28 16:00
has joined #pact-jvm

juan.felix
2023-04-28 16:01
has joined #pact-jvm

jean-francois.renaud
2023-04-28 16:20
Yes I can test this by spinning up the full provider, but then I would have to control which module receives which request using _states_. Which means I would be pushing this ?implementation detail? to the consumer, and will have to replicate the tests for each Systems. This is something I was trying to avoid, but I guess that will be the way to go.

himesj
2023-04-28 17:25
has joined #pact-jvm

itsforbabu
2023-04-29 14:25
has joined #pact-jvm

tea.trader168
2023-04-30 02:04
has joined #pact-jvm

lori.maurais
2023-05-01 15:27
has joined #pact-jvm

aditya.kashyap
2023-05-02 04:56
Hi Team , Quick Question Can we run pactVerify command in bazel project ? If anyone has run that can you share the same ?

damola.thompson
2023-05-02 07:26
has joined #pact-jvm

james_fraser
2023-05-02 11:42
Hey there :wave: can anyone tell me what the env var equivalent is for `pact.filter.pacturl` or where to find it? https://docs.pact.io/implementation_guides/jvm/docs/system-properties says it has an env var equivalent but it?s not the upper case version of the property

ivan.v.kurlovich
2023-05-02 13:01
has joined #pact-jvm

ckulkarni
2023-05-02 14:22
has joined #pact-jvm

aurel.pintea
2023-05-02 14:55
has joined #pact-jvm

aurel.pintea
2023-05-02 14:58
Hi :wave: Good to be here.

aurel.pintea
2023-05-02 15:12
TL;DR; We are configuring the Pact provider within our Spring Boot 3, Kotlin app. We are currently facing the following error: ```'org.springframework.http.HttpStatus org.springframework.test.web.reactive.server.EntityExchangeResult.getStatus()' java.lang.NoSuchMethodError: 'org.springframework.http.HttpStatus org.springframework.test.web.reactive.server.EntityExchangeResult.getStatus()' at au.com.dius.pact.provider.spring.junit5.WebFluxBasedTestTarget$DefaultImpls.executeInteraction(WebFluxBasedTestTarget.kt:49) at au.com.dius.pact.provider.spring.junit5.WebTestClientTarget.executeInteraction(WebTestClientTarget.kt:9) at au.com.dius.pact.provider.junit5.PactVerificationContext.validateTestExecution(PactVerificationContext.kt:106) at au.com.dius.pact.provider.junit5.PactVerificationContext.verifyInteraction(PactVerificationContext.kt:60)``` The NoSuchMethodError is thrown due to having a misalignment between and older and a newer Spring version, as getStatus might be a newer introduced method. Can anyone provide guidance on how could we rectify this issue, please? Happy to share more info about our dependencies, but we are using the latest versions of all the main stuff I believe.

ariveros142
2023-05-02 20:03
has joined #pact-jvm

uglyog
2023-05-02 23:25
Looks like only when using `@AllowOverridePactUrl` with JUnit can you use an env var, and the case will be the same as the property

cody.jenkins
2023-05-03 04:48
has joined #pact-jvm

ashish.tilara
2023-05-03 06:08
has joined #pact-jvm

james_fraser
2023-05-03 08:03
Thanks for looking into that @uglyog - can I ask where you found that? Just so I know for future digging :smile: Also should the env var be `pact_filter_pacturl`? Even with `@AllowOverridePactUrl` and Junit it doesn?t seem to pick it up

alfred.brose00
2023-05-03 08:17
has joined #pact-jvm

dibya.dhar
2023-05-03 09:04
has joined #pact-jvm

ronnie.kilsbo
2023-05-03 09:28
has joined #pact-jvm

caitriona.gallagher
2023-05-03 15:18
has joined #pact-jvm

raubreysmith
2023-05-03 16:36
hi, I?m not sure if this is a pact jvm thing but we?re just starting out, after doing a verification and publishing the results, I can see the provider version in the broker but the provider branch is NA. In Gradle (Kotlin) ``` systemProperty("pact.provider.version", gitHash) systemProperty("pact.provider.branch", gitBranch) systemProperty("pact.verifier.publishResults", System.getProperty("pact.verifier.publishResults"))```

majhwar.mragni
2023-05-03 17:03
has joined #pact-jvm

michael.fenstermaker
2023-05-03 20:56
has joined #pact-jvm

man.tse
2023-05-03 20:58
has joined #pact-jvm

uglyog
2023-05-03 23:22
I searched for `pact.filter.pacturl` in the code :stuck_out_tongue: and the env var has to be the same


uglyog
2023-05-03 23:26
Just a silly question to get going. What is the value of `gitBranch`? I'm assuming not `N/A`?

tristan
2023-05-04 03:27
has joined #pact-jvm

joseph.joyce
2023-05-04 07:35
Hey, Aurel. I had a chat with @uglyog about this and it looks like there is an open issue for this on the Pact-JVM GitHub repo: https://github.com/pact-foundation/pact-jvm/issues/1660. Unfortunately, you can't use the older Pact-JVM spring support libraries with Spring 6.

raubreysmith
2023-05-04 08:48
yeah sorry those are fed from git commands: ```gitHash -> git rev-parse --verify --short HEAD gitBranch -> git rev-parse --abbrev-ref HEAD ```

raubreysmith
2023-05-04 08:49
however, I still don?t see anything populated even if I just set that as a string e.g. ?test-branch?

james_fraser
2023-05-04 09:02
I did the search but missed the line underneath it :facepalm: Thanks @uglyog :smile: I?ll have another crack at it, see if I?m missing something

raubreysmith
2023-05-04 09:06
my deps: ```testImplementation("au.com.dius.pact.provider:junit5spring:4.5.3")```

raubreysmith
2023-05-04 09:28
~looks like I can set the branch if I leave out the version, version on the broker then shows as 0.0.0. Maybe I?m misunderstanding something. Is it suppose to be one or the other or a combination of version + branch?~

raubreysmith
2023-05-04 09:37
ok, looks like something with how I?m executing the git cmds with gradle :face_palm:

raubreysmith
2023-05-04 10:22
turns out I wasn?t trimming the commit/branch values :face_palm:

michal.kopriva
2023-05-04 11:03
has joined #pact-jvm

ulises.cervino
2023-05-04 15:08
hi all, is there an easy way to have the mock server ignore headers sent by a client? (without rewriting requests)

james.jenks
2023-05-04 19:09
has joined #pact-jvm

abdurrahman.muratt
2023-05-04 20:50
has joined #pact-jvm

uglyog
2023-05-04 23:00
Ah! The old chomp bug. Caught me out many times.

uglyog
2023-05-04 23:08
The mock server does ignore headers that are not specified in the interaction.

ulises.cervino
2023-05-05 07:21
oh, interesting, because I?m debugging a failed test which fails with a `500` + `null` and I thought it?d be the extra headers that the client is sending

ulises.cervino
2023-05-05 07:21
what?s the best way to go about debugging this failing test?

matt.fellows
2023-05-05 11:34
Are you using JUnit, it should print a report with the mismatch info in it Otherwise, you could enable debug logging through the usual java means (SLF4J I think)?

svetoldo444ka
2023-05-05 15:35
has joined #pact-jvm

arjun.gowda
2023-05-08 17:07
has joined #pact-jvm

valencianaad
2023-05-09 15:05
has joined #pact-jvm

marlon.jimenez
2023-05-09 17:53
has joined #pact-jvm

erollins
2023-05-09 18:49
has joined #pact-jvm

marcos.aruj
2023-05-09 23:39
has joined #pact-jvm

meritxell.rodriguez
2023-05-10 06:33
has joined #pact-jvm

ulises.cervino
2023-05-10 07:26
right, that?s what I?ve been trying to do. The mismatch reported by junit5 simply says ?unexpected request?, and dumps everything, though there?s no indication as to what was unexpected about the request itself

ulises.cervino
2023-05-10 07:27
it?s not my codebase, so I?m struggling to increase log levels via slf4j but that?s a diff issue, I was just hopeful I could add a flag/variable here and there (in the annotations for instance) that?d make my life easier

ulises.cervino
2023-05-10 07:27
also slack is not notifying me of these things, apologies for the slow replies and thanks for taking the time to help

yana.kliuch
2023-05-10 08:58
has joined #pact-jvm

james.brown
2023-05-10 14:01
has joined #pact-jvm

mark.bursnall
2023-05-10 14:01
has joined #pact-jvm

alexandru.simion
2023-05-10 14:01
has joined #pact-jvm

giulio.giovannini
2023-05-10 14:01
has joined #pact-jvm

razvan.grigorescu
2023-05-10 14:04
has joined #pact-jvm

henry.rutman
2023-05-10 18:28
has joined #pact-jvm

simondemartini
2023-05-10 19:53
has joined #pact-jvm

matt.fellows
2023-05-11 06:52
Argh, sorry to hear. I can?t help too much as it?s literally been 10 years since I?ve had to write any Java (or JVM based stuff).

matt.fellows
2023-05-11 06:53
no worries on the slow replies - there are already too many ways to be ?notified? these days!

matt.fellows
2023-05-11 06:53
> right, that?s what I?ve been trying to do. The mismatch reported by junit5 simply says ?unexpected request?, and dumps everything, though there?s no indication as to what was unexpected about the request itself hmm. No HTML report written to file anywhere though?

stefan.kemp
2023-05-11 07:42
has joined #pact-jvm

supersmile2009
2023-05-11 12:06
has joined #pact-jvm

ulises.cervino
2023-05-11 14:31
none that I can see :disappointed:

lknaresh2
2023-05-11 18:20
has joined #pact-jvm

2023-05-11 18:22
This message was deleted.

yousafn
2023-05-11 20:36
Hey, Please note the community is not a general helpdesk, take the time to raise a suitable question please, the time of others is valuable, so help them help you https://docs.pact.io/help/how_to_ask_for_help if this is PactFlow specific, please raise in #pactflow

siddharth12345
2023-05-12 09:47
has joined #pact-jvm

siddharth.shetty
2023-05-12 09:51
has joined #pact-jvm

giulio.giovannini
2023-05-12 09:52
Hi all, I am Giulio from Commify. we are starting to use Pact in our tests. I am writing test for the provider to verify the contract. What is the maven dependency for class PactRunner?

yousafn
2023-05-12 10:01
Hey @ulises.cervino, I am also not a Pact JVM'er but happy to rubber ducky with you today for a bit if you want

giulio.giovannini
2023-05-12 10:37
My broader question is: how should I go about to develop verification of consumer published contracts using junit5 and springboot 2? is this a good starting point: https://docs.pact.io/implementation_guides/jvm/provider/junit5spring?

ulises.cervino
2023-05-12 10:56
hi! Thanks for the offer. Today I can?t, next week I?ll give it another go and I?ll reach out to you then if that?s all right?

yousafn
2023-05-12 10:57
sure thing, Jo Laing will be gutted she'll miss you as she is on holidays next week.

ulises.cervino
2023-05-12 10:57
we can do it later too when she?s back

ulises.cervino
2023-05-12 11:33
ok, actually, check this out this is what I get when I run a consumer test: ```ApiException{code=500, endpoint=http://localhost:63004/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee, responseHeaders={access-control-allow-origin=[*], content-length=[762], content-type=[application/json], date=[Fri, 12 May 2023 11:32:45 GMT], x-pact-unexpected-request=[1]}, responseBody='{ "error": "Unexpected request : \tmethod: PUT\n\tpath: \/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\n\tquery: {}\n\theaders: {Accept-encoding=[gzip], X-booking-timeout-ms=[5000], Accept=[application\/json], X-booking-request-max-attempts=[1], Connection=[Keep-Alive], Host=[localhost:63004], X-booking-trace-meta=[caller_persona=\"banana\"], X-booking-request-attempt=[1], User-agent=[http://Booking.com Internal B.Client v6.52.0], X-booking-topic=[b-basket-platform-basket-service], Content-type=[application\/json], Content-length=[77], Tracestate=[evsystem=caller_persona:\"banana\"]}\n\tmatchers: MatchingRules(rules={})\n\tgenerators: Generators(categories={})\n\tbody: PRESENT({\"creator\":\"FLIGHT\",\"booker\":{\"BUID\":\"11111111-2222-3333-4444-555555555555\"}})" }'}```

ulises.cervino
2023-05-12 11:34
I understand that this 500 is because I prepped the mock server to receive a particular request, and in my unit test I?m not sending the exact same request

ulises.cervino
2023-05-12 11:34
that?s fine (if correct), what I need now is a diff of what I?m missing

ulises.cervino
2023-05-12 11:34
is it buried in that message somewhere? (the rest is generic jvm stacktrace)

yousafn
2023-05-12 11:41
do you get a junit xml report that has more detail? I think the last time I used the kotlin example there stdout wasn't much use, but there was detail in a report, memory fades :sweat_smile:

ulises.cervino
2023-05-12 11:42
right, we don?t get that

yousafn
2023-05-12 11:44
Hmm I noted you had you SLF4J issues the docs state https://docs.pact.io/implementation_guides/jvm/consumer/junit#debugging-pact-failures Might be worth seeing if we can shave the SLF4J yaks

ulises.cervino
2023-05-12 11:45
right, I just fixed it

ulises.cervino
2023-05-12 11:45
the issue is that serialisation was including stuff like `field: null` in how I was setting up the mock

yousafn
2023-05-12 11:46
ahhh yeah them pesky nulls!

ulises.cervino
2023-05-12 11:46
which means the mock wanted the field to be there, but the client serialises requests to skip these fields

ulises.cervino
2023-05-12 11:46
:nod-hmm-yes:

yousafn
2023-05-12 11:46
nice, yeah in JS you can set keys to undefined and then when you serialise into json they magically disappear

yousafn
2023-05-12 11:47
Superb! Job jobbed :slightly_smiling_face: Can go get a covfefe, happy testing @ulises.cervino

ulises.cervino
2023-05-12 11:47
right, the thing is that you can set up the mock server manually (very explicit but cumbersome) or do something like `mapper.writeAsString(new RequestThing().withField("blah"))` and use the resulting string for the mock server

ulises.cervino
2023-05-12 11:47
enjoy your coffee and thanks for making me look into this _again_

yousafn
2023-05-12 11:50
There are some nice little helpers some people have posted in this channel to make this less onerous to write, I haven't captured them but a ctrl+f on this page (plus plenty of :ram: for :chrome: ) https://docs.pact.io/slack/pact-jvm.html Or rendered slightly prettier https://www.linen.dev/s/pact-foundation/c/pact-jvm These archive the entirety of slack so helpful resources

yousafn
2023-05-12 11:51
> enjoy your coffee and thanks for making me look into this _again_ My pleasure! on the _again_ - I'm sure there is something we could add maybe into some troubleshooting notes to help others out in the future

yousafn
2023-05-12 11:54
The docs are always a great starting point. You may also enjoy our in browser tutorial https://docs.pactflow.io/docs/tutorials#tutorial and you can clone the repos separately offline to play with after


lukemstorey
2023-05-12 13:52
has joined #pact-jvm

rana
2023-05-13 20:56
has joined #pact-jvm

anatoliy.ganzyuk
2023-05-14 20:15
has joined #pact-jvm

minhajsid
2023-05-15 10:18
has joined #pact-jvm

artur.ashyrov984
2023-05-15 16:01
has joined #pact-jvm

jerson.zuniga
2023-05-15 20:25
has joined #pact-jvm

sekumar
2023-05-15 21:05
has joined #pact-jvm

jzunigacoayla
2023-05-15 21:41
has joined #pact-jvm

matthieu.saleta
2023-05-16 09:31
has joined #pact-jvm

matthieu.saleta
2023-05-16 09:40
Hello, we started to use Pact on our projects and I'm working on a Github Actions to help consumers to upload their contract to Pactflow. I would like to add the `branch` information but it does not work properly. Here is the command that was executed by the action : ```mvn au.com.dius.pact.provider:maven:4.1.11:publish -Dpact.broker.url=https://XXXX.pactflow.io -Dpact.broker.token=*** -Dpact.broker.authenticationScheme=*** -Dpact.publish.consumer.branchName=feat/UTO-706_contract-testing``` But in Pactflow the `branch` has been set with the `93/merge` that is the merge branch generated by Github on Pull Request. Is there a known problem ou am I doing something wrong ? Thanks for your help!

tjones
2023-05-16 09:51
Do you have the `maven-surefire-plugin` in your xml?

tjones
2023-05-16 09:53
Otherwise, what you?re doing looks right to me. Do you have the environment variables `pact.publish.consumer.branchName` or `PACT_PUBLISH_CONSUMER_BRANCHNAME` set to `"93/merge"`? (If no, you could also try setting those environment variable to your desired value, as a workaround)

matthieu.saleta
2023-05-16 09:54
Yes surefire is executed to launch Pact Unit test and produce the pact Json file.

matthieu.saleta
2023-05-16 09:56
That is what i have done ^^ In the command, i've setted the JVM System property : `-Dpact.publish.consumer.branchName=feat/UTO-706_contract-testing` And that is precisely what it does not work.

tjones
2023-05-16 09:59
Yes, I understand. I?m saying that the documentation says you can also specify the branch with the *environment* variable: ```pact.publish.consumer.branchName``` or ```PACT_PUBLISH_CONSUMER_BRANCHNAME```

tjones
2023-05-16 10:00
So, I would: 1) Check that you?re not overriding with either of those environment variables 2) Try setting those environment variables anyway, maybe they work Otherwise it sounds like a bug to me - at least in the documentation, if not in the software.

carls.stfleur
2023-05-16 12:20
has joined #pact-jvm

matthieu.saleta
2023-05-16 13:00
I checked that the environment variable was not set before launching the maven plugin and i did set it manually but the result stay the same :confused:

dale
2023-05-16 16:01
has joined #pact-jvm

uglyog
2023-05-16 23:08
The property is `pact.provider.branch`, you can see all the properties here: https://github.com/pact-foundation/pact-jvm/blob/master/docs/system-properties.md


j3rry.wan9
2023-05-17 03:01
Hi all, how can I debug an "unexpected request" error when running consumer tests?

matt.fellows
2023-05-17 03:07
Check the JUnit report (file) if using it, it should show the expected vs received

curb1968
2023-05-17 03:41
has joined #pact-jvm

j3rry.wan9
2023-05-17 05:58
Thanks, Matt! Yes, I'm using JUnit 4.13.2. However, there is nothing like expected vs. received in the XML report. Also, I'm still on 4.2.4, not sure if that matters.

matt.fellows
2023-05-17 06:01
It?ll probably show up in DEBUG level logging, but I?m sure there is a more obvious place it would be

j3rry.wan9
2023-05-17 07:04
Hmm, I had a try with debug level logging configured in Log4J 2, but still I can't find anything like that in reports

robert.turner
2023-05-17 12:26
has joined #pact-jvm

j3rry.wan9
2023-05-17 15:27
Hi, I came across this thread while searching for solutions for the "unexpected request" I'm facing. Could someone please let me know how to enable debug level logging for `http://au.com.dius.pact.consumer.UnfilteredMockProvider`?

uglyog
2023-05-17 23:04
Pact-JVM uses SLF4J for logging. I would recommend using Logback for logging, unless you are using Spring.

j3rry.wan9
2023-05-17 23:15
@uglyog Thanks for the suggestion! Unfortunately, the project I'm working on is using Log4J 2.


jsanthakumar
2023-05-18 09:47
has joined #pact-jvm

rmodrego
2023-05-18 09:47
has joined #pact-jvm

clm.whyte
2023-05-18 09:48
has joined #pact-jvm

fdonald
2023-05-18 09:52
has joined #pact-jvm

mgarcia
2023-05-18 09:53
has joined #pact-jvm

lsantarelli
2023-05-18 10:26
has joined #pact-jvm

bdocherty
2023-05-18 11:56
has joined #pact-jvm

srikanth_vemuri
2023-05-18 12:08
has joined #pact-jvm

perera.x.roshni
2023-05-18 12:16
has joined #pact-jvm

mohitkrishna.s.s12
2023-05-18 13:23
has joined #pact-jvm

dwayne.sykes
2023-05-18 16:23
has joined #pact-jvm

kancharla.g
2023-05-19 03:31
has joined #pact-jvm

kancharla.g
2023-05-19 03:35
Hello, I'm facing an issue while verifying kafka messages using pact ```[from Pact Broker http://localhost:9292/pacts/provider/jsonKafkaProviderApp/consumer/jsonKafkaConsumerApp/pact-version/cad7af5d7c576d3aa19e56a755683a7e811ee5a1/metadata/c1tdW2xdPXRydWUmc1tdW2N2XT0xMCZzW11bY3ZdPTEwJnA9dHJ1ZQ] A simple message generates a message which Verification Failed - Failed to invoke provider method 'verifySimpleMessageEvent' Pending Failures: 1) A simple message 1.1) Failed to invoke provider method 'verifySimpleMessageEvent'``` I am getting the above error when even i try to verify a kafka message. Below is the function 'verifySimpleMessageEvent' `@PactVerifyProvider("A simple message")` `MessageAndMetadata verifySimpleMessageEvent() {` `Map<String, Object> metadata = new HashMap<String, Object>() {` `{` `put(KEY_CONTENT_TYPE, JSON_CONTENT_TYPE);` `}` `};` `return new MessageAndMetadata(new byte[] {}, metadata);` `}`

kancharla.g
2023-05-19 03:36
I'm using java 8, please help me out, TIA.

matt.fellows
2023-05-19 05:02
Might be worth sharing any relevant logs to help us understand _why_ it couldn?t execute that method


kancharla.g
2023-05-19 09:22
Here you can find the complete log of mvn clean verify

joseantonionmfilho
2023-05-19 17:46
has joined #pact-jvm

anenada
2023-05-20 08:06
has joined #pact-jvm

rabrosimov
2023-05-20 20:11
has joined #pact-jvm

matt.fellows
2023-05-22 03:28
thanks

matt.fellows
2023-05-22 03:28
> 1. 14:51:03.647 [main] WARN http://au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader - Failed to instantiate the value resolver, using the default I don?t know what it means exactly, but it is a warning

matt.fellows
2023-05-22 03:29
There is a stacktrace that follows that seems plausibly related to this - maybe that?s why it can?t invoke the method. Can you share the full class details?


kancharla.g
2023-05-22 03:31
This is the class

arm.arturpetrosyan
2023-05-22 10:37
has joined #pact-jvm

adra_verma
2023-05-22 12:11
has joined #pact-jvm

p.keshav.chainani
2023-05-22 12:13
has joined #pact-jvm

divya.s.parappanavar
2023-05-22 12:13
has joined #pact-jvm

n.duran
2023-05-22 14:38
has joined #pact-jvm

matthieu.saleta
2023-05-23 08:15
@uglyog Thank you but the documentation says : `Branch name for the provider from the version control system to record when publishing verification results.` But I'm not publishing verification result, i'm publishing the pact from the consumer so i don't think it will work with this property :confused:

uglyog
2023-05-23 08:35
Oh, sorry, my mistake

matthieu.saleta
2023-05-23 09:01
This is the code from the `PactBrokerClient`that read the property : ``` private fun branchName(config: PublishConfiguration): JsonValue { return config.branchName.ifNullOrEmpty { lookupEnvironmentValue("pact.publish.consumer.branchName") }.toJson() }``` https://github.com/pact-foundation/pact-jvm/blob/master/core/pactbroker/src/main/kotlin/au/com/dius/pact/core/pactbroker/PactBrokerClient.kt#L721 So it is the good one. It executes : https://github.com/pact-foundation/pact-jvm/blob/master/core/support/src/main/kotlin/au/com/dius/pact/core/support/Utils.kt#L185 ``` /** * Looks up a value from the environment, first by looking for the JVM system property with the key, then * looking for an environment variable with the key, then looking for the snake-cased version of the key as an * environment variable. */ fun lookupEnvironmentValue(key: String): String? { return lookupEnvironmentValue(key, { k: String -> System.getProperty(k) }, { k: String -> System.getenv(k) }) } /** * Looks up a value from the environment, first by looking for the JVM system property with the key, then * looking for an environment variable with the key, then looking for the snake-cased version of the key as an * environment variable. */ fun lookupEnvironmentValue( key: String, sysLookup: (key: String) -> String?, envLookup: (key: String) -> String? ): String? { var value: String? = sysLookup(key) if (value.isNullOrEmpty()) { value = envLookup(key) } if (value.isNullOrEmpty()) { value = envLookup(snakeCase(key)) } return value }``` In my case, it will do :`System.getProperty("pact.publish.consumer.branchName")` so the only way that the value could be wrong, is that the `branchName` field is already set in the Mojo : https://github.com/pact-foundation/pact-jvm/blob/master/provider/maven/src/main/kotlin/au/com/dius/pact/provider/maven/PactPublishMojo.kt#L40

matthieu.saleta
2023-05-23 09:40
Well i finally find out the problem... it is just a version problem... The branchName property is not supported on the `4.1.11` .... :facepalm2: I've just checked the documentation and it says : `Including the consumer branch when publishing [min versions 4.1.33/4.2.19/4.3.4]` I have no excuse, sorry for the inconvenience...

garry.wilson
2023-05-23 12:28
has joined #pact-jvm

verevad
2023-05-23 13:04
has joined #pact-jvm

jon.arambarri
2023-05-24 07:34
has joined #pact-jvm

yonatany
2023-05-24 08:14
has joined #pact-jvm

scoplin
2023-05-24 20:02
has joined #pact-jvm

aemanuelson
2023-05-25 23:41
has joined #pact-jvm

sreenivas.chaitanya
2023-05-26 08:29
has joined #pact-jvm

tigrandza
2023-05-26 08:46
has joined #pact-jvm

tle
2023-05-26 09:56
has joined #pact-jvm

adam699
2023-05-26 13:35
has joined #pact-jvm

mariusz.kapczynski
2023-05-29 12:10
has joined #pact-jvm

kazimierz.zarychta
2023-05-29 12:10
has joined #pact-jvm

pierre.zeidan
2023-05-30 13:10
has joined #pact-jvm

shkothari
2023-05-30 14:55
has joined #pact-jvm

bwang
2023-05-30 16:55
has joined #pact-jvm

dev.talha.akbar
2023-05-31 09:45
has joined #pact-jvm

msiles
2023-05-31 13:50
has joined #pact-jvm

eli.thorkelson
2023-05-31 18:14
has joined #pact-jvm

jegadeesan.ponnusamy8
2023-06-02 16:19
has joined #pact-jvm

siyuanshen1993
2023-06-03 10:36
has joined #pact-jvm

pawar.s
2023-06-05 05:15
has joined #pact-jvm

pawar.s
2023-06-05 06:30
HI Guys, suppose 1.there is contract signed between consumer and provider (for data type and attribute values) 2. I need to do the pact verification by giving all the mandatory values(for data type and attribute values) as positive scenario(200) 3. and again I need to do the pact verification between same counsumer and provider by missing some mandatory values(for data type and attribute values) as negative scenario(400) so i am currently able to do the verification for statement 2nd and 3rd by using seperate pact class. but i don't want diffrent classes for pact file creation. i want this verification for positive and negative under the single class. so is this possible to do validation of positive and negative under single pact class?

matt.fellows
2023-06-05 06:32
thanks for raising here. What is currently stopping you from doing this in a single pact class?

matt.fellows
2023-06-05 06:32
(the answer is yes)

bas
2023-06-05 06:42
Hey @pawar.s, here's an example, maybe that helps. https://github.com/basdijkstra/introduction-to-contract-testing/tree/main/customer-consumer/src/test/java/customer If you checkout the entire repository and run the tests for any of the consumers through `mvn clean test` in the correct subfolder, you'll see that all interactions, from both test classes, end up in the same contract. Off topic: both 'positive' and 'negative' are included, although I'd suggest reframing your thinking around this, it is all behaviour :slightly_smiling_face:. See https://www.ontestautomation.com/lets-talk-about-behaviour-instead/ for my thoughts on this.

pawar.s
2023-06-05 07:17
I am trying below code for generating pact file but only one detest() is getting passed that is for negative one and for another one which is positive that is failing. but when i try to run the positive one by commenting negative it is getting passed what could be the reason ? public class XYZ_PostTest extends CommonModules { static CommonModules common = new CommonModules(); public static final String providerServiceName = "XYZ_provider"; public static final String consumerServiceName = "XYZ_Consumer"; public static int providerServicePort = 8110; public static String providerUrl = "http://localhost:" + providerServicePort + "/xyzbasepath"; public String postbody1positive = new String(Files.readAllBytes(Paths.get("src/Resources/XYZ.txt")), StandardCharsets.UTF_8); public String postbody2negative = new String(Files.readAllBytes(Paths.get("src/Resources/LMN.txt")), StandardCharsets.UTF_8); public XYZ_PostTest() throws IOException { } @Rule public PactProviderRuleMk2 provider = new PactProviderRuleMk2(providerServiceName, "localhost", providerServicePort, this); @Pact(consumer = consumerServiceName) public RequestResponsePact createPact(PactDslWithProvider builder) { Map<String, String> reqheaders = new HashMap(); reqheaders.put("Content-Type", "application/json"); // adding required headers under this Map<String, String> resheaders = new HashMap(); resheaders.put("Content-Type", "application/json"); //adding required response headers under this DslPart reqBodywithoutmandatoryfiels = new PactDslJsonBody() .stringType("Uuid", common.randomUUID()) // adding reqBody under this without mandatory fields for negative validation with error code 400 DslPart resBody = new PactDslJsonBody() // adding responsebody for the 400 error code .asBody(); return builder .given("publishe sevent details without mandatory fields") .uponReceiving("sends acknowledgement for bad request") .method("POST") .headers(reqheaders) .body(reqBodywithoutmandatoryfiels) .path("/xyzbasepath") .willRespondWith() .status(400) .headers(resheaders) .body(resBody) .toPact(); } @Pact(consumer = consumerServiceName) public RequestResponsePact createPactpositivescenario(PactDslWithProvider builder) { System.out.println("JWT Token: "+JWTtoken); Map<String, String> reqheaders1 = new HashMap(); reqheaders1.put("Content-Type", "application/json"); // adding required headers under this Map<String, String> resheaders1 = new HashMap(); resheaders1.put("Content-Type", "application/json"); //adding required response headers under this DslPart reqBodyWithmandatoryFields1 = new PactDslJsonBody() .stringType("locationTypeCode","COUNTRY") //adding reqBody under this with mandatory fields for positive validation with success code 200 .asBody(); DslPart resBody1 = new PactDslJsonBody() // adding responsebody for the 202 success code return builder .given("publishesevent details with mandatory fields") .uponReceiving("sends acknowledgement for success") .method("POST") .headers(reqheaders1) .body(reqBodyWithmandatoryFields1) .path("/xyzbasepath") .willRespondWith() .status(202) .headers(resheaders1) .body(resBody1) .toPact(); } @Test @Category(Create_Location_C_ORS_Consumer.class) @PactVerification() public void doTest1() throws IOException { HttpPost httpPost = null; HttpClient httpClient = new DefaultHttpClient(); String url=String.format(providerUrl); HttpEntity httpEntity = new StringEntity((postbody2negative), "utf-8"); httpPost = new HttpPost(url); httpPost.setHeader("Content-type", "application/json"); // added required headers httpPost.setEntity(httpEntity); HttpResponse httpResponse = httpClient.execute(httpPost); } @Test @Category(Create_Location_C_ORS_Consumer.class) @PactVerification() public void doTest2() throws IOException { HttpPost httpPost = null; HttpClient httpClient = new DefaultHttpClient(); String url=String.format(providerUrl); HttpEntity httpEntity = new StringEntity((postbody1positive), "utf-8"); httpPost = new HttpPost(url); httpPost.setHeader("Content-type", "application/json"); //added required headers httpPost.setEntity(httpEntity); HttpResponse httpResponse = httpClient.execute(httpPost); } }

abubics
2023-06-05 07:33
There's a lot going on here, but afaict, this doesn't even compile.

abubics
2023-06-05 07:34
It also looks like you're blending consumer and provider DSLs.

abubics
2023-06-05 07:35
On your builder chains, it looks like you're trying to set multiple batches of headers and bodies, which probably won't work as you expect.

abubics
2023-06-05 07:37
I've not seen pact-jvm tests that really look like this before. Do you have a link to an article or course content that gives examples like this?

abubics
2023-06-05 07:38
Another aside: you can format your code (using triple backticks), which will make it easier for everyone to read :slightly_smiling_face:

matt.fellows
2023-06-05 07:48
You would normally have one set of tests for your Consumer tests, which would reside in the API client?s project / code base. You would have an entirely separate set of Provider Verification, which would reside in the API proider?s project/code base. Having them in the same code base is not strictly uncommon (e.g. in the case of a monorepo) but having them in the same class is definitely not a good idea

rohitkrishnan
2023-06-05 20:37
has joined #pact-jvm

payal.chainani
2023-06-06 06:32
has joined #pact-jvm

divya.parappanavar
2023-06-06 07:23
has joined #pact-jvm

mrudula.patil
2023-06-06 08:19
has joined #pact-jvm

asjad.baig.ind
2023-06-06 11:12
has joined #pact-jvm

rajat.chouhan
2023-06-06 12:16
has joined #pact-jvm

yanov.alexander
2023-06-06 15:17
Hello team, I have a question regarding pact provider async tests. For tests I need to mock one of services, tried to use the @ExtendWith(MockitoExtension.class) but doesn?t work, tests skipped when I run the maven command with verifying pacts. An example: @Provider(provider-name) @ExtendWith(MockitoExtension.class) @Pactbroker(url =?brokerUrl?) class pactTest { @BeforeEach void setupTestTarget(PactVerificationContext context) { context.setTarget(new MessageTestTarget()); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @State(?state?) @PactVerifyPtovider(??) MessageAndMetadata test() { } }

david.stothers
2023-06-07 07:25
has joined #pact-jvm

dominic.gara
2023-06-07 08:45
Morning folks! I've been tasked to look into event based contract testing for the team, and have a few questions that would be invaluable to know. 1. Does Pact-JVM support it? If so, a. Is there a link to an example(s)? https://docs.pact.io/implementation_guides/javascript/docs/messages is handy, but need a little more help with the java implementation b. We're working on SNS, SQS and AWS Lambdas is bi-directional contract testing supported for these? c. AsyncAPI is on our radar, and appreciate it's on your roadmap for directional support. Is this supported via traditional means (consumer driven?) and if we were to integrate the AsyncAPI with swagger would that then enable bi-directional contract testing? Huge thanks in advance!

rafaela.azevedosouza
2023-06-07 08:52
has joined #pact-jvm

matt.fellows
2023-06-07 09:24
> a. Is there a link to an example(s)? https://docs.pact.io/implementation_guides/javascript/docs/messages is handy, but need a little more help with the java implementation Yes, here?s an example: https://docs.pactflow.io/docs/examples/kafka/java/consumer + https://docs.pactflow.io/docs/examples/kafka/java/provider The principles are the same for SNS/SQS (see also the Node examples for AWS) > 1. We?re working on SNS, SQS and AWS Lambdas is bi-directional contract testing supported for these? bi-directional contract testing (if by that you mean https://docs.pactflow.io/docs/bi-directional-contract-testing/) does not support this, it currently only supports HTTP > 1. AsyncAPI is on our radar, and appreciate it?s on your roadmap for directional support. Is this supported via traditional means (consumer driven?) and if we were to integrate the AsyncAPI with swagger would that then enable bi-directional contract testing? could you elaborate here? How would you integrate AsyncAPI with Swagger? You can do message based testing with Pact, yes, but it doesn?t have any AsyncAPI integration.

dominic.gara
2023-06-07 09:35
Thanks Matt for the prompt replies! Really appreciate it :bow: Regarding the AsyncAPI, that stemmed from this blog: https://swagger.io/blog/using-event-driven-asyncapi-specifications-with-sw/

dominic.gara
2023-06-07 09:36
Where this info is presented, but was asked to follow up; _http://pactflow.io/, the leading contract testing tool, makes it simple to catch breaking changes relating to your AsyncAPIs before they cause issues later in the SDLC ? you can use contract testing for your Async services. Currently, http://pactflow.io/ does not support AsyncAPI but work to create this capability is on the https://github.com/pactflow/roadmap/projects/1._

newmolti
2023-06-07 10:14
has joined #pact-jvm

danut.turta
2023-06-07 11:35
has joined #pact-jvm

dev664
2023-06-07 11:53
has joined #pact-jvm

matt.fellows
2023-06-07 12:28
> _http://pactflow.io/, the leading contract testing tool, makes it simple to catch breaking changes relating to your AsyncAPIs before they cause issues later in the SDLC ? you can use contract testing for your Async services. Currently, http://pactflow.io/ does not support AsyncAPI but work to create this capability is on the https://github.com/pactflow/roadmap/projects/1._ the wording of that is unfortunate, to say the least given the context. But it is true - it?s on the roadmap and you can test services documented by AsyncAPI - we just don?t care about the _AsyncAPI document_. It?s unfortunate because AsyncAPI is used both as a noun to denote the AsyncAPI document (and presumably also the open source initiative), and also as an adjective to describe a type of API that is asynchronous

matt.fellows
2023-06-07 12:29
Pact supports the adjective version.

matt.fellows
2023-06-07 12:29
All of that is to say - you can test async (and sync) services now with Pact, and support for AsyncAPI in our BDCT feature is something we would like to support in the future :slightly_smiling_face:

dominic.gara
2023-06-07 12:30
Yeah, probably why i'm getting confused by it. Again, much appreciated! Truly invaluable insights and direction :bow:

matt.fellows
2023-06-07 12:33
I reckon! You?re welcome, hopefully that gets you going :+1:

thomas.fisher
2023-06-07 13:02
Hi team! Are multiValueHeaders supported in jvm and if so how should I handle them? My response is returning header values in an array, which is then failing the test on the consumer side (I have to get the first entry from the array to assert on it). I am wondering if it is related to the inclusion of a multiValueHeader in the response. The "content-type" header appears in both headers and multiValueHeaders. It's possible for me to not have this assertion in my consumer tests, but then it fails on the provider side with an error along the lines of: ```header: Expected 'application/json' to match 'application/json'```

david.blanco
2023-06-07 18:08
has joined #pact-jvm

jonathan.fisher
2023-06-07 19:30
has joined #pact-jvm

dev.pactslack
2023-06-07 20:17
has joined #pact-jvm

uglyog
2023-06-07 23:28
What do you mean by `multiValueHeaders`? Is this a header with multiple values as defined by HTTP2?

dan.nichols52
2023-06-08 04:30
has joined #pact-jvm

s.lohmeier
2023-06-08 08:08
has joined #pact-jvm

dev.pactslack
2023-06-08 13:01
Hi I am trying to understand the expected behaviour and use cases for provider state parameters. I've read through: ? https://docs.pact.io/getting_started/provider_states ? https://docs.pact.io/implementation_guides/jvm/consumer (Having values injected from provider state callbacks) ? https://docs.pact.io/implementation_guides/jvm/provider/junit#provider-state-callback-methods and some of our own usages of this functionality and I still have some questions about both the concept and potentially the pact-jvm implementation. Questions: 1. The consumer docs above suggest the use case of the params is where the provider actually generates some identifiers that appear in the interaction. a. Since the consumer in pact-jvm always must specify an example when using the xxxFromProviderState() methods and the provider must always return those parameters from a state method as a populated map, what is the use case for the consumer to define concrete values in the pact itself if the provider won't read them and the consumer can't read them? b. Shouldn't those concrete values just be used instead of the examples when calling xxxFromProviderState() methods? c. What is the use case for the provider to accept an incoming map of params in their implementation of the state methods if the provider is expected to generate these values and return them? 2. I have started to see some pacts define many identifiers and interesting values in the provider state params that are then expected to populate all the fields in a json response body. The expectation here is these values are then taken by the provider in their state method to prime test data. a. Is this a valid use case of provider state params or is this too much coupling between pacticipants? b. Specifically with the pact-jvm implementation, it seems unnecessary in such a use case for the provider to need to return a new map of provider state params if its just going to prime using all the incoming params. The API however requires you to effectively return the incoming map otherwise the params used in the test will be an empty map. 3. Are there any documentation/talks that discuss the use of provider state parameters in more detail outside the links above? I can't seem to find any discussion of why they were being introduced in the pact v3 spec. I realise there is quite a lot here, but I would like to understand how I should be using this functionality. Cheers

radek.stolarczyk
2023-06-08 13:32
has joined #pact-jvm

radek.stolarczyk
2023-06-08 13:51
Hello ! I'm trying to setup my consumer and provider using these two examples: ? https://github.com/pactflow/example-consumer-java-kafka ? https://github.com/pactflow/example-provider-java-kafka I'm having issues with my contract generation. I don't see it locally and its not getting published to my http://packflow.io page. Make start / make test-events, localhost its all fine on the consumer project but I'm getting the following error on provider: java.lang.RuntimeException: Could not resolve property "PACT_BROKER_HOST" in the system properties or environment variables and no default value is supplied. Has anyone experienced these issues before? Thanks for your help!

zeeshankhan0330
2023-06-08 16:36
has joined #pact-jvm

marek
2023-06-09 07:57
has joined #pact-jvm

matt.fellows
2023-06-09 09:32
Have you set that environment variable?

matt.fellows
2023-06-09 09:33
You can see how it should be set by reviewing the GitHub actions build setup

michael.lawrence
2023-06-09 09:57
has joined #pact-jvm

radek.stolarczyk
2023-06-09 12:15
thank you @matt.fellows for the information! The env variables were set in my terminal with the following commands: PACT_BROKER_BASE_URL="https://mypacthere.pactflow.io" PACT_BROKER_TOKEN="mytockenhere" I'm getting this error :confused: rstolarc@xxxx example-consumer-java-kafka % GIT_BRANCH=${GIT_REF:11} make publish_pacts Unable to find image 'pactfoundation/pact-cli:latest' locally latest: Pulling from pactfoundation/pact-cli docker: no matching manifest for linux/arm64/v8 in the manifest list entries. See 'docker run --help'. make: *** [publish_pacts] Error 125

matt.fellows
2023-06-10 12:08
I think it's arm64 that's the issue. I don't think we currently support or build that target

matt.fellows
2023-06-10 12:08
I know @yousafn had done a heap of work to support X platform builds so hopefully not too far away

matt.fellows
2023-06-10 12:09
You might be able to emulate another combo using the --platform docker arg


yousafn
2023-06-10 12:11
you can use the vanilla image with platform=linux/amd64 otherwise you can append -multi to the tag and get a platform specific image

rana
2023-06-11 14:33
Hi guys :slightly_smiling_face: I am implementing a Provider verification tests class. This provider does not have any consumers yet, and I am receiving the `NoPactsFoundException: No Pact files were found to verify` exception. I have added the `@IgnoreNoPactsToVerify` annotation, and added a null check to the `PactVerificationContext` Here is the class: ```@Provider("${PACT_PROVIDER_NAME:}") @PactBroker(url = "${PACT_BROKER_URL:}") @IgnoreNoPactsToVerify @RequiredArgsConstructor @Slf4j public class PactVerificationTests { @State("HAS_USERS") public void hasUsersState(Map<String, Object> params) throws URISyntaxException, IOException { ... } @BeforeEach void beforeEachInteraction(PactVerificationContext ctx) throws MalformedURLException { if(ctx == null){ log.debug("Null PactVerificationContext received, no pacts to verify"); return; } var interaction = ctx.getInteraction(); var states = interaction.getProviderStates(); if (states.size() > 1) { throw new AssertionError("Only 0 or 1 states are currently supported per interaction"); } var targetUrl = Config.testedAppURL(); ctx.setTarget(HttpTestTarget.fromUrl(new URL(targetUrl))); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext ctx) { if(ctx == null){ log.debug("Null PactVerificationContext received, no pacts to verify"); return; } ctx.verifyInteraction(); } }``` The only selector I am using is `{"mainBranch": true}`, but as I said - this provider does not have any consumers yet. How could I overcome this exception? Thanks :)

abubics
2023-06-12 03:12
What are you expecting to see when the provider has nothing to verify?

abubics
2023-06-12 03:14
(e.g. Just no exception?)

rana
2023-06-12 06:04
@abubics Yes, for the exception to be caught, maybe logged, or even not thrown at all if possible, but ultimately for the verification to pass. I consider a provider with no consumers a valid state

abubics
2023-06-12 06:31
Mmm yeah, you'll probably need a maintainer to answer that.

mssachin
2023-06-12 08:06
has joined #pact-jvm

rana
2023-06-12 11:14
Hi again :slightly_smiling_face: What would be the right way to go about using `can-i-deploy` for a provider, who has no consumers and therefore no verifications were made yet? I receive the `No pacts or verifications have been published for service-A` error. If there are no instances of `service-A` in the pact-matrix, shouldn't it be as if it is safe to deploy? Important to point out that the verification tests do pass, as there is no pacts to verify. Thanks :)

rana
2023-06-12 11:16
I'm not really sure how, but the issue has been resolved. Thanks :slightly_smiling_face:

yousafn
2023-06-12 11:19
hey, technically consumer driven contract testing with Pact doesn?t support using can-i-deploy with no registered consumers. therefore in order for the check to pass, the consumer must have at least one successful verification for the version you wish to deploy

yousafn
2023-06-12 11:19
ie, it doesn?t make sense to call can-i-deploy for a provider who has not verified any contracts

yousafn
2023-06-12 11:22
you can dry run flags, to skip the can-i-deploy check, or in this case, if your provided is deployed, mark that version as deployed in an environment. When a consumer comes along and registers a contract test, it should verify against the deployed version of the provider and the HEAD of the defined main branch. at that point, if the contract is successfully verified the consumer would be able to proceed, otherwise it would be a communication point with the provider to ascertain which side the misunderstanding lays, and work a path forward

yousafn
2023-06-12 11:24
Bi-Directional contracts via PactFlow support an alternative flow, whereby a provider can publish a contract advertising their capabilities (currently described in an OpenAPI definition), the user self tests their implementation against the OpenAPI definition, and if successful, can use the can-i-deploy tool, and then record a deployment. As in your case, no verifications within Pact have taken place with the provider, Pact can offer no guarantees at can-i-deploy time

yousafn
2023-06-12 11:24
> I consider a provider with no consumers a valid state Pact doesn?t

yousafn
2023-06-12 11:25
Therefore this would be a be a new feature request :slightly_smiling_face:

yousafn
2023-06-12 11:25
We have a public feature roadmap where users can search for existing and vote for their own https://pact.canny.io/

yousafn
2023-06-12 11:30
Does the provider even exist in your Pact Broker? ```> pact-broker can-i-deploy --pacticipant provider-foo --version foo Pacticipant provider-foo not found```

rana
2023-06-12 12:09
Sure does. As you replied in the thread below, can-i-deploy is not a good fit for a new service since it has no record deployed at all.

yousafn
2023-06-12 12:09
How do they exist in your pact broker?

yousafn
2023-06-12 12:09
Please don?t invite me to huddles thank you

rana
2023-06-12 12:14
@yousafn `ie, it doesn't make sense to call can-i-deploy for a provider who has not verified any contracts` As a platform engineer, it makes perfect sense :slightly_smiling_face: I would like to provide my company's developers the best UX possible, a part of that is providing a whole solution out of the box. If there are no instances of a service in the Pact Matrix, I would expect the `can-i-deploy` call to succeed, sense there is nothing blocking me from recording a new deployment (no contract has been broken). Instead of having it succeed in such case as stated above, I would have to ask them to do a manual `record-deployment` for each new service, and for a company that is transitioning from a monolith to microservices - this will occur many times.

rana
2023-06-12 12:17
@yousafn Sorry about that - clicked by mistake. They exist in my pact-broker since I defined a step in our service's pipeline that registers a service before any function/verification tests take place using the `create-or-update-pacticipant` call.

matt.fellows
2023-06-12 12:18
:point_right: the answer you are looking for is here: https://docs.pact.io/pact_nirvana/notes_1

yousafn
2023-06-12 12:25
Ahh great, you have read the docs well then :slightly_smiling_face: that is why you see the pacticipant as a first class item which returns a result, rather than the 404 on the pacticipant being found. Thanks for confirming and raising the feature req :+1:

yousafn
2023-06-12 12:27
So I believe Ran has added that Matt, which is why the provider exists but doesn?t return a valid can-i-deploy as there are no verifications associated with it

yousafn
2023-06-12 12:29
would a `--pass-if-no-consumers` flag or something similar work on a `can-i-deploy` rather than it being a default behaviour. The premise being that `can-i-deploy` offers guarantees about the compat of an application prior to deployment. As the Pact framework does nothing, in Consumer driven contract testing (with zero consumers), we have zero guarantee or basis to tell you your application is safe to deploy. At least that is my take on the current behaviour.

andy.frith
2023-06-12 12:31
has joined #pact-jvm

andy.frith
2023-06-12 12:35
Hello :wave: we?re currently looking to upgrade from pact-jvm 3.6.15 to 4.0.0 (for now, then will bump to latest v4) - are there any docs on doing this? Looks like there are quite a few changes but hard to get a good overview of them. Thanks!

yousafn
2023-06-12 12:35
Personally from experience, this hasn?t been an issue for us, as we traditionally at the start of an applications lifecycle we might not opt in for being gated by can-i-deploy but rather using it as an additional check. As confidence builds up, it can be brought into the estate as a first class tool that does indeed gate your deployments. Also being aware of the break glass mechanisms, for if you need to skip can-i-deploy is useful too, for those times you just need to get something out the door pronto. Also as consumer driven contract testing uses provider states and matchers, the provider tests aren?t usually written in isolation from the consumers. Having the boilerplate their when you spin up a new provider service is good, but hooking it up with your pipelines, prior to having a consumer doesn?t seem sensible. It?s like trying to automate the conversation away

rana
2023-06-12 12:41
Thanks for the assistance.

rana
2023-06-12 13:14
`--pass-if-no-consumers` would absolutely work. I get what you are saying, but if you look at it from an infrastructural point of view, meaning the platform is my product and the developers are my clients - I need to provide a fluent way for their CI to pass for each service, regardless of their rule (provider/consumer). Every new provider needs to perform a `record-deployment` for the first time, that does not mean that the provider does not have any consumers. It only means that it does not have a deployed version in which the consumers could push that pacts and verify against. The notion that a provider must have consumers that have already published pacts is a bit problematic.. I guess I would have to call `list-pacticipants` and check whether the service is listed or not. In case it is not I would need to use the `can-i-deploy dry-run`

radek.stolarczyk
2023-06-12 14:12
I was able to fix the issue with updating the make file ```PACTICIPANT := "pactflow-example-consumer-java-kafka" GITHUB_WEBHOOK_UUID := "654aff47-0269-4b9f-aaca-2f83ff3cd772" PACT_CLI="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli:latest-multi"```

radek.stolarczyk
2023-06-12 14:13
I'm still looking how to generate the pacts. Getting this error now: rstolarc@xxxx example-consumer-java-kafka % make publish_pacts No value provided for option '--consumer-app-version' make: *** [publish_pacts] Error 1

yousafn
2023-06-12 14:22
you are trying to run a script that is setup for CI, and the env vars GIT_COMMIT and GIT_BRANCH set


yousafn
2023-06-12 14:23
or you can set them yourself in your shell

yousafn
2023-06-12 14:23
the error message is very clear

radek.stolarczyk
2023-06-12 15:22
Thank you Yousaf ! I have the consumer working. When I try to run the tests or fake_ci for provider, I get the following error; java.lang.RuntimeException: Could not resolve property "PACT_BROKER_HOST" in the system properties or environment variables and no default value is supplied. Looking for where its missing.

radek.stolarczyk
2023-06-12 15:44
I did the following and still are seeing the issue: export PACT_BROKER_HOST="https://mytest.pactflow.io" export PACT_BROKER_TOKEN="testtoken" PACT_BROKER_HOST and PACT_BROKER_TOKEN (Provider Variables) are the same variables as PACT_BROKER_BASE_URL and PACT_BROKER_TOKEN (Consumer Variables)?

alejandro.pena
2023-06-12 17:49
Good evening community, Anyone knows about a library with similar functionality to this one? To try to automate the Dsl body generation using Java objects. https://github.com/remondis-it/pact-consumer-builder We're having compatibility issues with this one due to be outdated

ajay_886
2023-06-12 22:38
has joined #pact-jvm

tjones
2023-06-12 23:08
Hmmm. I don?t know about this. Wouldn?t this approach mean you?re not sure if the code actually does what you think it does?

tjones
2023-06-12 23:09
I think the explicit nature of Pact is a feature

tjones
2023-06-12 23:09
(also, sorry, I don?t know if there is another library like that)

matt.fellows
2023-06-12 23:54
> So I believe Ran has added that Matt, which is why the provider exists but doesn?t return a valid can-i-deploy as there are no verifications associated with it It should work without that. You need to both create the application _and_ create an application version

steven.wang06
2023-06-13 05:06
has joined #pact-jvm

matt.fellows
2023-06-13 06:29
I know a client here in Melbourne when I was still consulting, created an Intellij plugin to do something similar to this. The idea is that you would get an IDE action that would take a JSON file and then a ?create test? from it. The customer already had a large suite of fixture files for use in other tests, so being able to go back from them into code was helpful. The tests would need to be manually reviewed, but it just prevented a bunch of painful manual work to get large or complex data structures mapped into the appropriate JVM DSL.

tjones
2023-06-13 06:51
Yeah. I have wondered about "trust me mode" for Pact - where you go "look, just match whatever I send" for the request. This would avoid the problem where clients emit headers that break the provider, but don't declare them in the Pact (so they don't end up in the test)

navanesyan
2023-06-13 07:05
has joined #pact-jvm

alejandro.pena
2023-06-13 14:24
I wasn't very excited about the idea of using/creating a library like this, but the client has insisted and... it really does make sense after all. They have some teams with HUGE bodies of work to be defined, and 95% of those bodies consist of pretty standard validations. Of course, you would need to review the BodyDSL generated, and sometimes include specific type mappings, but it could potentially save a lot of time for the teams (and even avoid scaring them, sometimes when they see the amount of code to write they start freaking out :joy:)

ran.tao
2023-06-13 21:46
has joined #pact-jvm

matt.fellows
2023-06-13 23:16
It would be a great addition to the ecosystem Alejandro, if you could OSS it :wink:

matt.fellows
2023-06-13 23:16
But yes, it?s a common question and I see value in it. If you could make the test fail by default, so it had to be reviewed, that could be a simple way to prevent it from being auto-generated without review

prakhar.roy371
2023-06-14 05:21
has joined #pact-jvm

john.joel.thetla
2023-06-14 10:16
has joined #pact-jvm

alejandro.pena
2023-06-14 14:03
That's a good point, yes. I'll talk with our folks and let's see if we can do something :slightly_smiling_face:

drew.bowman
2023-06-14 18:05
has joined #pact-jvm

devwenzel
2023-06-15 08:26
has joined #pact-jvm

ronen.yurik
2023-06-15 13:34
has joined #pact-jvm

matthew.finbury
2023-06-15 13:39
has joined #pact-jvm

anthony.sharp
2023-06-15 13:43
has joined #pact-jvm

mariane.leite
2023-06-15 15:25
has joined #pact-jvm

wvkehoe
2023-06-16 10:27
has joined #pact-jvm

rost.khanyukov
2023-06-16 22:59
has joined #pact-jvm

mich.krzyzanowski
2023-06-17 15:22
has joined #pact-jvm

f.barril
2023-06-18 16:58
has joined #pact-jvm

delboy1978uk
2023-06-20 07:46
has joined #pact-jvm

hammid.funsho
2023-06-20 22:18
has joined #pact-jvm

benjamine.nidhin
2023-06-21 12:15
has joined #pact-jvm

kuksa.vladyslav
2023-06-22 12:47
has joined #pact-jvm

suryasaharan
2023-06-22 15:41
has joined #pact-jvm

gabriel
2023-06-22 21:22
has joined #pact-jvm

bgrgincic
2023-06-26 11:00
has joined #pact-jvm

sandy.mechie
2023-06-26 12:02
Hello, I am trying to set-up Pact-JVM using the GRPC plugin. Since I am running it in a restricted environment, I had to manually download the plugins and place them in appropriate directory as suggested in the documentation. I am using the same test defined the pact-plugin project area_calculator. While running the tests, I am getting the following error `Failed to set the interaction: Failed to process protobuf: Failed to invoke protoc binary: exit code exit code: 1` `http://au.com.dius.pact.consumer.dsl.InteractionConfigurationError: Failed to set the interaction: Failed to process protobuf: Failed to invoke protoc binary: exit code exit code 1` `at app<//au.com>.dius.pact.consumer.dsl.PactBuilder.setUpMessageContents(PactBuilder.kt:276)` `....` I have placed the protoc inside the plugins directory. Not sure why it's failing to invoke the protoc Any suggestions on this?

sandy.mechie
2023-06-26 12:15
Ignore above. The proto filepath was incorrect

svilen.popov
2023-06-27 09:44
has joined #pact-jvm

matt982
2023-06-27 16:02
has joined #pact-jvm

matt.fellows
2023-06-28 12:27
Is there any other log context with that? It should be showing somewhere that the protobuf file was not able to be found

eltonlinconl07
2023-06-28 17:30
has joined #pact-jvm

eltonlinconl07
2023-06-28 18:04
Hello, I'm having a problem with pact when I run a test that validate the body content. Anyone see this problem before ? I'm using this dependencies on my pom.xml ``` <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.4.6</version> </dependency> <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.3.7</version> <scope>test</scope> </dependency>``` I don't know if this help, but the project uses spring boot and it's a modularized project

uglyog
2023-06-28 23:08
Update `junit5spring` to also be version 4.4.6

carlosmmelo
2023-06-29 07:00
has joined #pact-jvm

prerit.jain849
2023-06-29 09:40
has joined #pact-jvm

sssona09
2023-06-29 11:12
has joined #pact-jvm

antonio.blandon
2023-06-29 20:40
has joined #pact-jvm

arjun
2023-07-02 04:23
has joined #pact-jvm

adwait.damle
2023-07-03 06:39
has joined #pact-jvm

stan.amsellem
2023-07-03 14:00
has joined #pact-jvm

cobookman
2023-07-03 21:14
has joined #pact-jvm

anshu.behera.02
2023-07-04 07:01
has joined #pact-jvm

adam.strawson
2023-07-04 13:24
has joined #pact-jvm

mathewsa
2023-07-04 15:20
has joined #pact-jvm

olopezs
2023-07-04 16:03
has joined #pact-jvm

ajay_886
2023-07-04 23:29
Hi. My pact broker is exposed using a self signed certificate. How do I mark my broker as insecure in my Junit5 provider tests to work around the SSLHandshakeException? ```PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target```

2023-07-04 23:29
Please see these instructions on running and accessing a Pact Broker over TLS https://docs.pact.io/pact_broker/advanced_topics/using-tls/

uglyog
2023-07-05 00:31
You can set `enableInsecureTls` on the `@PactBroker` annotation

ajay_886
2023-07-05 01:04
Hi @uglyog - How do I specify this? I don?t see this field available in the PactBroker

uglyog
2023-07-05 01:11
You need to upgrade to a version that supports that (4.4.0+)

nithesh
2023-07-05 08:14
has joined #pact-jvm

ajay_886
2023-07-05 09:06
ok. thanks

ajay_886
2023-07-05 10:38
With `enableInsecureTLs` set to `true` I get a different exception. Somewhere towards the bottom it says ``` unable to find valid certification path to requested target``` ``` Failed to fetch the root HAL document au.com.dius.pact.core.pactbroker.InvalidNavigationRequest: Failed to fetch the root HAL document at app//au.com.dius.pact.core.pactbroker.HalClient.navigate(HalClient.kt:253) at app//au.com.dius.pact.core.pactbroker.PactBrokerClient$fetchConsumersWithSelectorsV2$halClient$navigateResult$1.invoke(PactBrokerClient.kt:494) at app//au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:35) at app//au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchConsumersWithSelectorsV2(PactBrokerClient.kt:494) at app//au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:248) at app//au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:128) at app//au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$pactSources$1$pacts$1.invoke(PactJUnit5VerificationProvider.kt:78) at app//au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:35) at app//au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.resolvePactSources(PactJUnit5VerificationProvider.kt:78) at app//au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:45) at app//org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:106) at java.base@17.0.2/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:273) at java.base@17.0.2/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) at java.base@17.0.2/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base@17.0.2/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base@17.0.2/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base@17.0.2/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base@17.0.2/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base@17.0.2/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) at app//org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:110) at app//org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:44) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base@17.0.2/java.util.ArrayList.forEach(ArrayList.java:1511) at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base@17.0.2/java.util.ArrayList.forEach(ArrayList.java:1511) at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) at app//org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at app//org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:62) at java.base@17.0.2/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base@17.0.2/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base@17.0.2/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base@17.0.2/java.lang.reflect.Method.invoke(Method.java:568) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at jdk.proxy2/jdk.proxy2.$Proxy5.stop(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193) at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65) at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:371) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:314) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:309) at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1357) at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(CertificateMessage.java:1232) at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(CertificateMessage.java:1175) at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396) at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480) at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:458) at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:201) at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:172) at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1500) at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1415) at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:450) at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:421) at org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.executeHandshake(SSLConnectionSocketFactory.java:303) at org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:275) at org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:251) at ... 82 more Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:439) at java.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:306) at java.base/sun.security.validator.Validator.validate(Validator.java:264) ```

andre.tartarelli
2023-07-05 11:26
has joined #pact-jvm

laura.huysamen
2023-07-05 12:38
has joined #pact-jvm

goatleyj11
2023-07-05 12:43
has joined #pact-jvm

lily.oconnell
2023-07-05 15:32
has joined #pact-jvm

mohanraj.r
2023-07-05 19:53
has joined #pact-jvm

uglyog
2023-07-05 23:01
Please see these instructions on running and accessing a Pact Broker over TLS https://docs.pact.io/pact_broker/advanced_topics/using-tls/

ajay_886
2023-07-05 23:04
ok. thank you

ianlutz
2023-07-06 01:34
has joined #pact-jvm

rohit.m.patil27
2023-07-06 03:51
has joined #pact-jvm

timo.schwarzer
2023-07-06 06:18
has joined #pact-jvm

kuntol.banerjee
2023-07-06 06:54
has joined #pact-jvm

ianlutz
2023-07-06 07:22
Hi, i am struggling to get pact libs to behave in my project, I have a java 11 app. I have tried using the deps ```testImplementation("au.com.dius.pact.core:model:4.4.9") testImplementation("au.com.dius.pact.consumer:junit5:4.4.9")``` I manage to write some sort of PACT test (doesnt work); The problem is this kills debugging (adding these deps). It kills debugging for the entire project. I try to run any test in debug mode (intellij) and i get the following error: ```Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/Result at kotlinx.coroutines.debug.AgentPremain.<clinit>(AgentPremain.kt:24) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513) at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525) *** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422 FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed Disconnected from the target VM, address: '127.0.0.1:58784', transport: 'socket'``` Something to do with kotlin. ? What is the issue here, and how do i fix ? :stuck_out_tongue: ? Do i actually need both of those deps ? Thanks!!

ianlutz
2023-07-06 07:36
lo and behold...adding this gradle plugin seems to have fixed debugging... "id 'org.jetbrains.kotlin.jvm' version '1.5.31'" :shrug: .

ianlutz
2023-07-06 07:37
is this the actual way i am supposed to fix this hmmm

uglyog
2023-07-06 07:41
There is something wrong with your project, as your classpath is not correct. Do you use Kotlin in your project?

ianlutz
2023-07-06 07:42
Nope we dont use kotlin in this project

uglyog
2023-07-06 07:43
That stacktrace is in native code, not Pact-JVM. But the `java.lang.NoClassDefFoundError: kotlin/Result` means the Kotlin stdlib is missing

uglyog
2023-07-06 07:43
You can try adding `org.jetbrains.kotlin:kotlin-stdlib:1.6.21` to your project.

ianlutz
2023-07-06 07:44
hmm, i added the plugin and it worked. Before adding the plugin i had a problem

ianlutz
2023-07-06 07:44
if these are transitive dependencies, shouldn't they be added in by gradle automagically ?

uglyog
2023-07-06 07:44
Yes, they should

ianlutz
2023-07-06 07:49
stdlib still seems to be there, but i still need the plugin

ianlutz
2023-07-06 07:50
my other question, am i supposed to need both deps "au.com.dius.pact.core:model:4.4.9"" and "au.com.dius.pact.consumer:junit5:4.4.9" or just the latter ?

ianlutz
2023-07-06 07:57
So i am concluding, that in order to use pact-jvm, in a pure java11 app, i must add 'id 'org.jetbrains.kotlin.jvm' version '1.5.31'' plugin that is if i want to be able to continue to debug the app, because the library, pact-jvm, is written in kotlin. Is that a fair conclusion ? I find this surprising.

shaun.mendham
2023-07-06 11:06
Hi, I have a question regarding the lambda DSL. There is a particular JSON structure which I?m struggling to match a contract for. A simplified example of which is: ```{ "id": "3293bf46-050c-424d-b29f-4dd1de7300f7", "offerRankings": { "default": [ "dcc513d2-ffe2-41a4-9b21-0371eb8d120c", "b3f360d1-d632-406d-83b5-5b27ae029099", ] } }``` In the above the offerRankings object can have arbitrary keys. Having looked through the docs found this section, https://docs.pact.io/implementation_guides/jvm/consumer#matching-any-key-in-a-map Based on my understanding: ? `eachKeyLike` can represent an arbitrary key to a string, number, boolean, object ect. ? `eachKeyMappedToAnArrayLike` can represent an arbitrary key to an array of objects. Is there anything in the current version which supports an arbitrary key to an array of strings? (or other non object types) Currently we have this, which works: ```var body = newJsonBody(b -> { b.stringType("id", "c4b86559-1082-4041-a8f5-0175d3f391c9"); b.object("rankings", rankings -> { rankings.array("default", array -> array.stringType("3fa85f64-5717-4562-b3fc-2c963f66afa5")); }); }).build();``` But this requires a provider to specifically reference the default key. It feels like this is an edge case, but any feedback on the above is greatly appreciated.

adebakre
2023-07-06 11:28
has joined #pact-jvm

rajkumarbapuvrs
2023-07-06 17:35
has joined #pact-jvm

uglyog
2023-07-06 23:04
No, this problem is unique to your app. Pact-JVM works just fine in lots of other pure Java apps.

uglyog
2023-07-06 23:24
Looks like you need a function something like `eachKeyMappedToPrimitiveArray`

ianlutz
2023-07-06 23:39
okies cool, thanks :slightly_smiling_face:

ianlutz
2023-07-06 23:59
Yep, just created a shell java 11 app + pact-jvm, and adding debugger works fine.

ianlutz
2023-07-06 23:59
//me enters dependency hell

jorge.carneiro
2023-07-07 09:43
has joined #pact-jvm

carlleferink
2023-07-07 12:01
has joined #pact-jvm

anju.ashk
2023-07-10 07:39
has joined #pact-jvm

rmahadeorathod
2023-07-10 09:48
has joined #pact-jvm

ekaterina.essina
2023-07-10 09:59
has joined #pact-jvm

arca.artem
2023-07-10 10:00
has joined #pact-jvm

connor.stevens
2023-07-10 11:35
has joined #pact-jvm

connor.stevens
2023-07-10 11:43
Hi all:blobwave:, I am a data engineer looking to implement pact for our Apache Beam ingestion component, but after considerable searching I have not found any examples or even mention of pact with Beam. I searched this Slack and did not see anything (I saw a #pact-beam channel, but that appears to be relating to something else). Is anyone able to perhaps point me in the right direction or let me know if this is a pointless mission? Any assistance would be appreciated!

matt.fellows
2023-07-10 11:50
Pact can be used with a myriad of technologies, you're best searching for use cases than technology

matt.fellows
2023-07-10 11:51
Is it an HTTP based system or message based? My guess would be the latter

connor.stevens
2023-07-10 12:12
Yes indeed, it is message based.

matt.fellows
2023-07-10 22:35
I?d suggest taking a look at the kafka or message based examples.

matt.fellows
2023-07-10 22:35
howtoexamples


pgeurtsen
2023-07-11 07:30
has joined #pact-jvm

shaun.mendham
2023-07-11 08:11
Is this something that would be considered for adding to the library? As above we have a work around, but might be useful for others in future too. Is there a process for proposal of this?

rjurca
2023-07-11 08:22
has joined #pact-jvm

connor.stevens
2023-07-11 09:31
Thanks for the pointer @matt.fellows

frederic.vaugeois
2023-07-11 14:12
has joined #pact-jvm

marko.lamberg
2023-07-11 15:27
has joined #pact-jvm

uglyog
2023-07-11 22:49
The best thing to due is raise a GitHub issue for this

lshilling
2023-07-12 09:31
has joined #pact-jvm

lshilling
2023-07-12 09:46
Hi, I?m currently stuck with how pact is populating a provider state parameter. Its converting an Integer to a String. In my consumer everything works and contract generated correctly: I have the following line in my request body ``accountId: fromProviderState('${accountId}', accountId)`` In the debug logs I can see it populating correctly with correct type Calling match_values for path $.accountId `Comparing '1686819389' to '1686819389' using Type -> Ok(())` `Comparing 'Number()' to 'Number()' at path '$.accountId' -> Ok(())` `body: '{??.. ,"accountId":1686819389}'` In my provider: `int accountId = 2;` `providerStateParameters.put(_ACCOUNT_ID_, accountId);` In the debug logs: `****I set my account id as: 1689080143238***` `body: PRESENT({???..,"accountId":"1689080143238"})` Both consumer (pact-js) and provider (pact-jvm) are on the latest version

matt.fellows
2023-07-12 10:36
hmm it looks to be a similar bug to https://github.com/pact-foundation/pact-reference/issues/298 (that?s a different reference implementation, but perhaps it copied/has the same problem as the JVM or vice versa)

lshilling
2023-07-12 12:29
any idea of if there would be a way to override it? my test will always fail because the API requires type number

matt.fellows
2023-07-12 12:58
Unfortunately not, sorry. Mind raising a defect on Pact JVM?

rudydc
2023-07-12 17:53
has joined #pact-jvm

wesley.newcomb
2023-07-13 15:54
has joined #pact-jvm

joris.vaneijden
2023-07-14 10:56
has joined #pact-jvm

joris.vaneijden
2023-07-14 10:58
@joris.vaneijden has left the channel

tushar.adsul223
2023-07-14 15:29
has joined #pact-jvm

francisco.almeida
2023-07-17 11:35
has joined #pact-jvm

mike.lovely
2023-07-17 12:12
has joined #pact-jvm

kyam.harris_pact
2023-07-17 12:51
has joined #pact-jvm

drettie
2023-07-17 13:23
has joined #pact-jvm

mburns
2023-07-17 13:24
has joined #pact-jvm

amit.jadhav
2023-07-18 06:19
has joined #pact-jvm

aljaz.klanecek
2023-07-18 08:58
has joined #pact-jvm

amitw
2023-07-18 15:15
has joined #pact-jvm

fkelly
2023-07-18 17:28
has joined #pact-jvm

fkelly
2023-07-18 17:30
Hi folks - am pretty new to Pact so probably am doing something silly - but when upgrading Spring Boot 2 --> 3 and upgrading the Pact Jars I am now hitting the following during Pact Verification ```java.lang.IllegalArgumentException: URI path begins with multiple slashes at org.apache.hc.core5.util.Args.check(Args.java:41) at org.apache.hc.core5.http.message.BasicHttpRequest.setUri(BasicHttpRequest.java:281) at org.apache.hc.core5.http.message.BasicHttpRequest.<init>(BasicHttpRequest.java:123) at org.apache.hc.core5.http.message.BasicClassicHttpRequest.<init>(BasicClassicHttpRequest.java:91) at org.apache.hc.client5.http.classic.methods.HttpUriRequestBase.<init>(HttpUriRequestBase.java:45) at org.apache.hc.client5.http.classic.methods.HttpGet.<init>(HttpGet.java:50) at au.com.dius.pact.core.pactbroker.HalClient$getJson$1.invoke(HalClient.kt:311) at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:35) at au.com.dius.pact.core.pactbroker.HalClient.getJson(HalClient.kt:310) at au.com.dius.pact.core.pactbroker.HalClient.fetch(HalClient.kt:274) at au.com.dius.pact.core.pactbroker.HalClient.fetchLink(HalClient.kt:354) at au.com.dius.pact.core.pactbroker.HalClient.navigate(HalClient.kt:261) at au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchConsumers(PactBrokerClient.kt:443) at au.com.dius.pact.core.pactbroker.PactBrokerClient$fetchConsumersWithSelectorsV2$1.invoke(PactBrokerClient.kt:520) at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:35) at au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchConsumersWithSelectorsV2(PactBrokerClient.kt:514) at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:248) at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:128) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$pactSources$1$pacts$1.invoke(PactJUnit5VerificationProvider.kt:78) at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:35) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.resolvePactSources(PactJUnit5VerificationProvider.kt:78) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:45) at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:106)``` Please see https://github.com/pact-foundation/pact-jvm/issues/1701 Any advice or pointers appreciated.

phananhdung104
2023-07-18 18:28
has joined #pact-jvm

gurubabu.jampala
2023-07-19 01:02
has joined #pact-jvm

a.kravchenko357
2023-07-19 11:03
has joined #pact-jvm

thiagotrinta
2023-07-19 20:00
has joined #pact-jvm

lotem.dagan
2023-07-20 10:48
has joined #pact-jvm

lotem.dagan
2023-07-20 10:49
@lotem.dagan has left the channel

cmesyngi
2023-07-20 20:56
has joined #pact-jvm

alan.barker
2023-07-21 09:47
has joined #pact-jvm

vijaya.balla.external
2023-07-21 15:06
has joined #pact-jvm

dennis1125dennis
2023-07-22 02:30
has joined #pact-jvm

muhammedalimutlu
2023-07-23 18:40
has joined #pact-jvm

doug.hanke
2023-07-24 17:53
has joined #pact-jvm

sameswar.khuntia
2023-07-25 10:17
has joined #pact-jvm

sameswar.khuntia
2023-07-25 10:24
Hi All, I am pretty new to Pact and may be I am doing something wrong . I have created a Pact like this @Pact(consumer = "AddressClient") public RequestResponsePact PactFetchAddressCheck(PactDslWithProvider builder) { return builder.given("address exist") .uponReceiving("getting all address details") .path("/getAddress") .method("GET") .willRespondWith() .status(200) .body(new PactDslJsonBody() .stringType("name","Jon Doe1") .stringType("address","Ynglingavagen 10, jarfalla") .stringType("zipCode","17757") ) .toPact(); } but I am getting an out put json as "{\"address\":\"Ynglingavagen 10, jarfalla\",\"name\":\"Jon Doe1\",\"zipCode\":\"17757\"}". My question is why I am getting Address as first attribute in the json object ?

michal.mirecki
2023-07-25 10:28
has joined #pact-jvm

matt.fellows
2023-07-25 10:36
Why does the order matter?

sameswar.khuntia
2023-07-25 10:42
I want to compare with a response from my provider API. junit assertions fails when there is mismatch in order

matt.fellows
2023-07-25 10:50
Pact will already assert the body is correct when it verifies a provider, you don't need to do that in the unit test.

matt.fellows
2023-07-25 10:50
The unit test should be asserting the behaviour of your API client.

jeremyjpark
2023-07-25 15:30
has joined #pact-jvm

chetana.mahangare
2023-07-25 15:58
has joined #pact-jvm

fkelly
2023-07-25 17:38
Hello folks - another newbie question here. I have a Pact JVM consumer and I am getting 500 responses from the Mock Server. I found this documentation https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit/README.md#debugging-pact-failures but it's not clear to me 1. Where to set the log level? I tried something like the following without luck ```./gradlew contractTest --debug``` 2. Is there a log file as opposed to StdOut? Thanks in advance

fkelly
2023-07-25 17:53
(BTW I am using version `4.1.9` )

kwan
2023-07-25 18:49
has joined #pact-jvm

matt.fellows
2023-07-25 22:27
Most Java projects use SLF4j or logback or whatever right, so there should be an XML file or something where you can specify which packages can log at a given level

matt.fellows
2023-07-25 22:27
`http://au.com.dius.pact.consumer.UnfilteredMockProvider` is the package you want to set to `DEBUG`.

matt.fellows
2023-07-25 22:28
I think if you?re using the spring packages, it should show up in the stdout of the HTML file it spits out

uglyog
2023-07-25 23:11
Huh! UnfilteredMockProvider is the old Scala implementation, which was replaced years ago. Setting the package `http://au.com.dius.pact.consumer` as DEBUG will work

sameswar.khuntia
2023-07-26 07:51
@matt.fellows How can I verify the structure of the response(Json) using the Pact ?

matt.fellows
2023-07-26 07:52
what have you tried so far?

matt.fellows
2023-07-26 07:52
The consumer Pact test job is to unit test your API client, and capture its needs of the provider API (you need not assert in the consumer tests anything about the provider, as pact captures that in the contract and will verify the provider when those tests run)

matt.fellows
2023-07-26 07:53
To ensure the API does what it should do, you run a provider verification step. It will read the contract and stand in for the API consumer(s) and hit your API, checking the API behaves as needed

matt.fellows
2023-07-26 07:53
which part are you wanting to do?

sameswar.khuntia
2023-07-26 07:57
To ensure API does it should do

matt.fellows
2023-07-26 08:05
That?s what Pact does

matt.fellows
2023-07-26 08:05
I?d recommend running through a basic tutorial here: https://docs.pactflow.io/docs/tutorials

matt.fellows
2023-07-26 08:06
We have a Java one that might be helpful for you. You can do it in the browser, and takes 15-30 minutes to run through

yanov.alexander
2023-07-26 08:39
Hello pact community, are there any possibility to show pact run reports, something like allure reports? To visualize the pact executions?

matt.fellows
2023-07-26 09:35
I believe the JUnit adapter produces reports

matt.fellows
2023-07-26 09:35
What kind of details are you after?

venkatesh.civic
2023-07-26 16:49
has joined #pact-jvm

bartlomiej
2023-07-26 18:06
has joined #pact-jvm

amitw
2023-07-26 18:08
@amitw has left the channel

wongkoonwai
2023-07-27 03:14
has joined #pact-jvm

yanov.alexander
2023-07-27 05:04
How many tests executed.

yanov.alexander
2023-07-27 05:04
any info which can visualize pact executions)

conrad.john
2023-07-27 08:37
has joined #pact-jvm

dale.wells
2023-07-27 11:24
@dale.wells has left the channel

ajit.kumar
2023-07-27 11:37
has joined #pact-jvm

marekurbanowicz
2023-07-27 12:40
has joined #pact-jvm

maciej.krakowiak
2023-07-27 13:28
has joined #pact-jvm

mateusz.luty
2023-07-27 13:29
has joined #pact-jvm

fkelly
2023-07-27 17:07
Thanks everyone - in the end I found I had to 1. Add the following logback dependencies ``` contractImplementation('ch.qos.logback:logback-classic') contractImplementation('ch.qos.logback:logback-core')``` 2. Add a `logback-test.xml`file to lhe classpath to log to std out 3. And add the following to my contract test task in the gradle file ```testLogging.showStandardStreams = true```

pact259
2023-07-27 23:19
has joined #pact-jvm

hetal.patel
2023-07-28 14:04
has joined #pact-jvm

thatrandybrown
2023-07-28 16:49
has joined #pact-jvm

michael072
2023-07-29 03:08
has joined #pact-jvm

selniumtrainer
2023-07-29 08:10
has joined #pact-jvm

selniumtrainer
2023-07-29 08:11
I am trying to create a Stub server using PACT + JAVA. My requirement is the Stub server which I create will be either running locally or on some server. When any service ( say API ) sends request it should hit this STUB Server and return response Thanks I did go through lot of resources but could not find starter. Any help would be appreciated.


matt.fellows
2023-07-29 22:49
Stubs are based on the pact files generated by pact tests

matt.fellows
2023-07-29 22:50
Once you have a contract, you can use that in the stub server

matt.fellows
2023-07-29 22:50
Pactflow also automatically hosts them (up to spec v2)

raylincontact
2023-07-31 01:51
has joined #pact-jvm

ext-damian.rudzinski
2023-07-31 10:01
has joined #pact-jvm

rostas.laszlo.dev
2023-07-31 11:27
has joined #pact-jvm

allen.ayala
2023-07-31 17:28
In https://docs.pact.io/implementation_guides/javascript/docs/matching, there is an ability to match a body field by field by type against an entire json object with somethingLike `will_respond_with(` `status: 200,` `headers: {"Content-Type" => "application/json"},` `body: Pact.like(` `name: "Mary",` `age: 73)` `)` Is somethingLike or anything similar implemented for pact-jvm (specifically Junit5) ?

anubhuti.shrivastava
2023-08-01 07:35
has joined #pact-jvm

pavikrish
2023-08-01 07:45
has joined #pact-jvm

pavikrish
2023-08-01 07:58
Hi I'm writing pact contract tests for Spring boot provider service. My provider test is a SpringBootTest. With the gradle test task in the CI/CD pipeline, I'm able to verify and publish the test results to my pact broker. Would like to know how gradle pactVerify task is different from the above process and which one is recommended for verifying and publishing provider test results.

pavikrish
2023-08-01 08:00
Can someone help here?

matt.fellows
2023-08-01 08:09
from _what_ above process, sorry?

matt.fellows
2023-08-01 08:09
the `SpringBootTest` vs `gradleTest` you mean?

pavikrish
2023-08-01 09:00
Verifying provider using gradle test vs gradle pactVerify?

matt.fellows
2023-08-01 09:26
One executes the test framework which gives you access to all of the usual features of a test tool like JUnit, whereas gradle verify does not

pavikrish
2023-08-01 11:14
Thank you!

fkelly
2023-08-01 13:01
Hello again - seeking some advice or suggestions. We are using the OpenAPI Generator to create our Client and Server side code but they've had a number of bugs lately where sometimes they indicate a JSON array as null and sometimes as empty `[]`. This is causing some havoc with our Contract tests. Personally I don't really care about the distinction from a contract / pact perspective. Is there any feature or workaround or setting I can use to tell Pact to ignore the distinction between `null` and "empty" for any containers e.g. objects, arrays etc. Thanks in advance.

fkelly
2023-08-01 13:05
In regards to the above I did come across https://docs.pact.io/faq#why-is-there-no-support-for-specifying-optional-attributes - so I understand but the constraint we face is being driven by a third-party library we do not control

pavikrish
2023-08-01 13:08
Hello - Does pact gradle plugin supports record-deployment and create-environment? We are currently using gradle plugin for publishing and verifying contracts and to invoke can-i-deploy.

arnoldsi
2023-08-01 15:09
has joined #pact-jvm

matt.fellows
2023-08-01 23:27
I?d suggest using the CLI tools

matt.fellows
2023-08-01 23:27
howtocli


pavikrish
2023-08-02 04:48
Thanks Matt for your response. We are currently using gradle tasks for publishing, pact verification and can-i-deploy. Is it recommended to migrate to pact cli commands for those as well?

matt.fellows
2023-08-02 06:12
you don?t have to, but personally, I would use the CLI for those things, all other things being equal

tjones
2023-08-02 06:29
If you don't care about a field, you can leave it out of the expectation

stefan.waldhauser
2023-08-02 13:45
has joined #pact-jvm

sharathkonda
2023-08-02 18:08
Can someone point to me a basic GitHub java maven consumer junit5 example project? My implementation is working fine and able to publish the consumer contract but using the plugin https://mvnrepository.com/artifact/au.com.dius.pact.provider/junit5/4.1.11 - In this case I am able to express pactflow url and the token. I have seen some example projects using the consumer http://au.com.dius.pact.consumer (https://docs.pact.io/implementation_guides/jvm/consumer/junit5) where we can provide the information about the pactflow url and token in the pom.xml and I was not able to find the proper example on it. I am not sure which one is correct.

shadman.equebal140
2023-08-02 19:20
has joined #pact-jvm

matt.fellows
2023-08-02 20:59
It doesn?t really matter where you source the values from, if it works and your team is happy with it then that?s probably all that matters


aravind.pai
2023-08-03 07:06
has joined #pact-jvm

ganeshacse01
2023-08-03 08:10
has joined #pact-jvm

br.holanda15
2023-08-03 14:35
has joined #pact-jvm

allen.ayala
2023-08-03 15:26
Could I get some guidance on this?

yousafn
2023-08-03 15:41
the docs you link to show your answer https://docs.pact.io/implementation_guides/javascript/docs/matching#match-based-on-type just provide `like` a json object

yousafn
2023-08-03 15:41
oh sorry! you are after it for JVM!



yousafn
2023-08-03 15:46
There is a thread I believe on some things that might make it easier ( I assume you don?t have primitive json objects but some class that gets serialised as json) https://pact-foundation.slack.com/archives/C9UN99H24/p1686592166541669 you can search back through our entire history as we are currently on a slack pro trial

abarkha1
2023-08-03 22:34
has joined #pact-jvm

abarkha1
2023-08-04 00:03
when do we generally see status response 500 with pact verification?

abarkha1
2023-08-04 00:08
```"error": { 19:30:45 M4ih5Vd0ib6F7jGnYdS6xlc0 | + "id": "-1354814997-1", 19:30:45 M4ih5Vd0ib6F7jGnYdS6xlc0 | + "severity": "ERROR", 19:30:45 M4ih5Vd0ib6F7jGnYdS6xlc0 | + "httpStatusCode": 500, 19:30:45 M4ih5Vd0ib6F7jGnYdS6xlc0 | + "message": "System encountered an unexpected error.", 19:30:45 M4ih5Vd0ib6F7jGnYdS6xlc0 | + "messageParam": null, 19:30:45 M4ih5Vd0ib6F7jGnYdS6xlc0 | + "created": 1691105445092 19:30:45 M4ih5Vd0ib6F7jGnYdS6xlc0 | + }```

matt.fellows
2023-08-04 00:45
this looks to be an error with your provider API, so we can?t answer that

matt.fellows
2023-08-04 00:45
It doesn?t look like an error eminating from Pact.

boreyuk
2023-08-04 07:22
has joined #pact-jvm

evan196
2023-08-04 14:33
has joined #pact-jvm

evan196
2023-08-04 15:00
Hi All, I have a provider state question. I'm testing a Java Provider and using `mvn pact:verify` for the Consumer contracts. I supply Provider mocks via https://microcks.io/ (a mock server) loaded with mocks from OpenAPI Examples that are lint validated with https://stoplight.io/open-source/spectral. Because the OpenAPI schema and the Java Provider endpoint as always in sync I feel confident my mocks will not go out of sync with the Provider endpoint. However I do worry about the Provider response after any business logic might be executed (State). At present I'm considering using Microcks's response behaviour features https://microcks.io/documentation/using/advanced/dispatching/ to inject Provider State, but feel this can go out of sync with the real Provider. I see you can use https://docs.pact.io/implementation_guides/jvm/provider/junit to inject Provider states as well, but I don't see how this will also stop the endpoint's business logic going out of the sync. Any advice appreciated! Thanks.

marek.fexa
2023-08-06 08:36
has joined #pact-jvm

acemilyalcin
2023-08-06 16:55
has joined #pact-jvm

acemilyalcin
2023-08-06 17:10
Hello, I am wondering something about pact testing. I am new in pact testing. I can verify the pact using the pact plugin and also I can test it using the junit dependency. What is the difference between them? Thanks.

uglyog
2023-08-06 23:13
If the business logic was out of sync, would the tests not fail?

uglyog
2023-08-07 00:55
Sorry, I don't understand the question. Which plugin are you using?

uglyog
2023-08-07 00:55
Also, please refer to the docs at http://docs.pact.io

aniket.rane
2023-08-07 02:55
has joined #pact-jvm

antony
2023-08-07 08:11
has joined #pact-jvm

andreas.marcec.extern
2023-08-07 14:35
has joined #pact-jvm

ajit.kumar
2023-08-07 15:09
Hi My consumer publishes pacts with version 1.0, 1.1, 1.2( All have same branch name(or tags) ex. abc). From Provider side, using @PactBrokerConsumerVersionSelectors I have option to set consumer name and branch name against which I want to run provider verification. I have set branch name as abc(above exmaple). But everytime it picks the latest consumer version(1.2). What if I need to run against older version like 1.1? How do I configure that? Could anyone help me out?

jeffreykey
2023-08-07 17:44
has joined #pact-jvm


matt.fellows
2023-08-07 20:59
Why do you need to test multiple versions of the consumer for a given branch? Usually the latest version is all you care about

sandy.mechie
2023-08-08 08:22
Hello, I am trying to set-up consumer test for our grpc service. This is how proto message looks like ```service OMCalc { rpc handleBatchRequest(ActionRequest) return (ActionResponse); } message ActionRequest { string action =1; map<string, string> param =2; repeated string ids =3; } message ActionResponse{ bool responseStatus =1; }``` And This is how I am setting the request and response ```"request", Map.of( "action", "Dummy", "param", Map.of( "apply", "Skip_holiday" ), "ids", List.of("ID1", "ID2") ), "response", Map.of( "responseStatus", "true" )``` After running the test, I am getting the following error message 'Failed to set interaction: Failed to process protobuf: For the message fields, you need to define a Map of expected fields, got String("Skip_holiday")' Could someone please suggest what I am doing wrong here? Many Thanks

uglyog
2023-08-08 08:51
What version of the gRPC plugin are you using, and what version of Pact-JVM?

sandy.mechie
2023-08-08 11:01
Grpc plugin version is 0.1.5 and pact-jvm (au.com.dius.pact.consumer.junit5) is 4.4.1

vaishali.rastogi
2023-08-08 12:29
has joined #pact-jvm

michael.knoll
2023-08-08 14:02
has joined #pact-jvm

sandy.mechie
2023-08-08 16:13
Sorry the plugin version is 0.3.2

evan196
2023-08-08 17:21
I was hoping to keep my mock responses in a Mock Server, and use maven PACT verify, but there does not seem to be a way to make sure the Mock Server's dispatcher rules and the Producer's business logic stay in sync, as the server has no access to run tests against the Producer. It just responds to maven pact:verify's requests. PACT JUnit runner can call Producer business logic in the Unit test to process Mocks responses while verifying the PACT, but I loose the usefulness of a Mock Server to keeping responses for multiple teams to use. I'll end up creating two sets of Mocks: those in the Unit tests, and those in the Mock Server. It would be nice to have Mocks that are verified in one place, and accessible by all.

michelle.he
2023-08-08 19:02
has joined #pact-jvm

uglyog
2023-08-09 05:12
Protobuf plugin 0.3.5 has been released with a fix for this

sandy.mechie
2023-08-09 05:23
Thank you. Will update the plugin

mohammed.a.ezzedin501
2023-08-09 11:17
has joined #pact-jvm

jacopo
2023-08-09 15:34
has joined #pact-jvm

enrique519
2023-08-09 23:57
has joined #pact-jvm

sheyanr
2023-08-10 02:55
has joined #pact-jvm

rcalvo
2023-08-10 08:28
has joined #pact-jvm

rcalvo
2023-08-10 08:36
Hello, I am having one problem when deploying a consumer with a new contract in an specific environment with bamboo. The first task is to run can-i-deploy, but it fails because there is still no contract in the pact broker. This is the error i get: `There is no verified pact between version 1.1676-706b8189 of consumer-service and the version of provider-service currently deployed to dev-environent (2.2569-b9b30e5d4)` To fix it, what I do is to disable the can-i-do-deploy task the first time I deploy a consumer with a new contract, and after that everything works normally. Is that the correct way to do it or I am missing something? Thanks

endikaposadas
2023-08-10 08:40
has joined #pact-jvm

endikaposadas
2023-08-10 09:00
Hi all. We have around 20 projects, some of them being provider, some consumer, some both, using Pact V3. We are now looking into migrating everything to Pact V4 but we have noticed that as soon as we migrate the provider to V4, it will only understand V4 contracts, making it incompatible with existing ones. Is there a way to run the V3 to V4 transition in a seamless way that doesn?t require deleting existing contracts? Otherwise, is there a migration guide we can follow? Thanks!

chinmaya.mishra
2023-08-10 10:05
has joined #pact-jvm

matt.fellows
2023-08-10 10:34
My understanding is that a v4 provider should be able to understand all of the previous specs. What errors are you getting?

endikaposadas
2023-08-10 11:30
Hi, I think I might have written it the wrong way. Our problem is when the consumer has migrated to v4 but the provider is still in v3. Then, we get this error: ```16:26:30.174 [main] DEBUG au.com.dius.pact.provider.ProviderUtils - Pact source does not have a constructor with one argument of type Class Unexpected character 'EOI(null)' at position '3', expecting '[DOT]' at com.github.zafarkhaja.semver.VersionParser.consumeNextCharacter(VersionParser.java:516) at com.github.zafarkhaja.semver.VersionParser.parseVersionCore(VersionParser.java:288) at com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:255) at com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:195) at com.github.zafarkhaja.semver.Version.valueOf(Version.java:265) at au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:203) at au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:198) at au.com.dius.pact.provider.junitsupport.loader.PactFolderLoader.load(PactFolderLoader.kt:29) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$$inlined$flatMap$lambda$1.invoke(PactJUnit5VerificationProvider.kt:82) at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$$inlined$flatMap$lambda$1.invoke(PactJUnit5VerificationProvider.kt:39) xa at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.resolvePactSources(PactJUnit5Verif```

matt.fellows
2023-08-10 11:43
that could be it, albeit that error isn?t too helpful

matt.fellows
2023-08-10 11:44
Is there a V4 feature you?re after? If you?re on the latest version of the library (Pact-JVM) you need not use V4 of the pact spec (serialisation format and some additional features). If you want to use Plugins, some of the newer matchers or have Message Pact and HTTP Pacts in the same file, then they are decent reasons to move

anderson.aeb
2023-08-10 12:37
has joined #pact-jvm

sameswar.khuntia
2023-08-10 14:05
Hi all,

sameswar.khuntia
2023-08-10 14:05
we are getting this error from provider side when we try to run the tests. we are using version 4.6.1. any pointers could help.*Invalid JSON (1:4), found unexpected character 'm'* http://au.com.dius.pact.core.support.json.JsonException: Invalid JSON (1:4), found unexpected character 'm'

poojarylatika1
2023-08-10 14:17
has joined #pact-jvm

sebastianmsandri
2023-08-10 16:01
has joined #pact-jvm

endikaposadas
2023-08-10 16:26
Thanks for replying. We were looking into using the new Kotlin DSL for consumers, as it provides an easier to read syntax

matt.fellows
2023-08-10 22:28
that makes sense too :slightly_smiling_face:

uglyog
2023-08-11 00:02
You have invalid formatted JSON. Look at your logs, you should be able to see what was received from your provider

sameswar.khuntia
2023-08-11 07:01
thanks for your reply. here are the logs . The logs does not show much information .I am getting this error when I am running the tests on provider side . provider try to connect to pact broker and download the contract file . Test are failing as initialization error ....... Invalid JSON (1:4), found unexpected character 'm' http://au.com.dius.pact.core.support.json.JsonException: Invalid JSON (1:4), found unexpected character 'm' at app<//au.com>.dius.pact.core.support.json.JsonLexer.unexpectedCharacter(JsonParser.kt:87) at app<//au.com>.dius.pact.core.support.json.JsonLexer.nextToken(JsonParser.kt:78) at app<//au.com>.dius.pact.core.support.json.JsonParser.nextTokenOrThrow(JsonParser.kt:278) at app<//au.com>.dius.pact.core.support.json.JsonParser.parseObject(JsonParser.kt:183) at app<//au.com>.dius.pact.core.support.json.JsonParser.parseArray(JsonParser.kt:254) at app<//au.com>.dius.pact.core.support.json.JsonParser.parse(JsonParser.kt:158) at app<//au.com>.dius.pact.core.support.json.JsonParser.parseString(JsonParser.kt:130) at app<//au.com>.dius.pact.core.pactbroker.PactBrokerClient.fetchPactsUsingNewEndpointRaw(PactBrokerClient.kt:560) at app<//au.com>.dius.pact.core.pactbroker.PactBrokerClient.fetchConsumersWithSelectorsV2(PactBrokerClient.kt:507) at app<//au.com>.dius.pact.provider.junitsupport.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:248) at app<//au.com>.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:128) at app<//au.com>.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$pactSources$1$pacts$1.invoke(PactJUnit5VerificationProvider.kt:78) at app<//au.com>.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:35) at app<//au.com>.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.resolvePactSources(PactJUnit5VerificationProvider.kt:78) at app<//au.com>.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:45) at app//org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:106) at java.base@17.0.5/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:273) at java.base@17.0.5/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) at java.base@17.0.5/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base@17.0.5/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base@17.0.5/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base@17.0.5/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base@17.0.5/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base@17.0.5/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) at app//org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:110) at app//org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:44) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base@17.0.5/java.util.ArrayList.forEach(ArrayList.java:1511) at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base@17.0.5/java.util.ArrayList.forEach(ArrayList.java:1511) at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) at app//org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at app//org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147) at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127) at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90) at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55) at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102) at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54) at app//org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) at app//org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at app//org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at app//org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:62) at java.base@17.0.5/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base@17.0.5/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base@17.0.5/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base@17.0.5/java.lang.reflect.Method.invoke(Method.java:568) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at jdk.proxy1/jdk.proxy1.$Proxy2.stop(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193) at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65) at app<//worker.org>.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) at app<//worker.org>.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74).

matt.fellows
2023-08-11 09:06
That's a stack trace, not the logs

biancoc
2023-08-11 14:27
has joined #pact-jvm

svarakantham
2023-08-14 00:19
has joined #pact-jvm

sameswar.khuntia
2023-08-14 11:53
@matt.fellows i have uploaded the logs , could you please have a look . it would be helpful if could show us some pointers

carrm
2023-08-14 13:22
has joined #pact-jvm

acemilyalcin
2023-08-14 14:35
Hello, I have a problem with test in pact classes. When I trigger the pipeline, it is failing because provider tests are running before consumer tests. There is no contract because consumer tests haven?t ran yet. What should I do? Are there any solution?

jd.courtoy
2023-08-14 16:25
has joined #pact-jvm

elenadoty
2023-08-14 20:01
has joined #pact-jvm

matt.fellows
2023-08-14 21:35
Haven't run ever or just in your pipeline, why are they linked?


sameswar.khuntia
2023-08-15 07:34
Hi , we have taken these https://github.com/pactflow/example-provider-springboot & https://github.com/pactflow/example-consumer-java-junit demo code and we have upgraded the Spring to 3.1.2 & Pact to 4.6.1. We are able to generate the contract and verify it from provider side using PactFolder but when we are trying to use PactBroker we are getting this error " Invalid JSON (1:4), found unexpected character 'm'. This blocking use to proceed further! if anyone has faced similar issues please show us some pointer ! ```au.com.dius.pact.core.support.json.JsonException: Invalid JSON (1:4), found unexpected character 'm'" ```

matt.fellows
2023-08-15 07:36
```2023-08-14T08:58:26.656+0200 [DEBUG] [TestEventLogger] ProductsPactTest > pactVerificationTestTemplate(PactVerificationContext) > initializationError FAILED 2023-08-14T08:58:26.656+0200 [DEBUG] [TestEventLogger] au.com.dius.pact.core.support.json.JsonException: Invalid JSON (1:4), found unexpected character 'm' 2023-08-14T08:58:26.656+0200 [DEBUG] [TestEventLogger] at app//au.com.dius.pact.core.support.json.JsonLexer.unexpectedCharacter(JsonParser.kt:87) 2023-08-14T08:58:26.656+0200 [DEBUG] [TestEventLogger] at app//au.com.dius.pact.core.support.json.JsonLexer.nextToken(JsonParser.kt:78) 2023-08-14T08:58:26.656+0200 [DEBUG] [TestEventLogger] at app//au.com.dius.pact.core.support.json.JsonParser.nextTokenOrThrow(JsonParser.kt:278) 2023-08-14T08:58:26.656+0200 [DEBUG] [TestEventLogger] at app//au.com.dius.pact.core.support.json.JsonParser.parseObject(JsonParser.kt:183) 2023-08-14T08:58:26.656+0200 [DEBUG] [TestEventLogger] at app//au.com.dius.pact.core.support.json.JsonParser.parseArray(JsonParser.kt:254) 2023-08-14T08:58:26.656+0200 [DEBUG] [TestEventLogger] at app//au.com.dius.pact.core.support.json.JsonParser.parse(JsonParser.kt:158) 2023-08-14T08:58:26.656+0200 [DEBUG] [TestEventLogger] at app//au.com.dius.pact.core.support.json.JsonParser.parseString(JsonParser.kt:130) 2023-08-14T08:58:26.656+0200 [DEBUG] [TestEventLogger] at app//au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchPactsUsingNewEndpointRaw(PactBrokerClient.kt:560) 2023-08-14T08:58:26.656+0200 [DEBUG] [TestEventLogger] at app//au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchConsumersWithSelectorsV2(PactBrokerClient.kt:507) 2023-08-14T08:58:26.656+0200 [DEBUG] [TestEventLogger] at app//au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:248) 2023-08-14T08:58:26.656+0200 [DEBUG] [TestEventLogger] at app//au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:128)``` This error looks to be the problem

matt.fellows
2023-08-15 07:36
when it?s trying to connect to the Pact Broker, it?s not getting a JSON response, but something else. I suspect you would see the actual body at `trace` level, sadly `debug` seems not to print that

matt.fellows
2023-08-15 07:36
My suspicion would be proxy or networking rules


matt.fellows
2023-08-15 07:38
@uglyog I wonder if we should print a better error message in this case, with additional info (e.g. we were expecting a JSON body, but we got a non-JSON body and print out what we received). I think it?s likely network related, and probably proxy

sameswar.khuntia
2023-08-15 07:51
It seems like the Gradle does not support the logging level trace and I have also set the logging.level.root= trace but it deos not print the logs

uglyog
2023-08-15 08:07
Because ProductsPactTest is a JUnit test, you need to set the logging in your test configuration. Setting the logging with Gradle only sets the logs for the Gradle process.


a.adeyeye.gr
2023-08-15 08:49
has joined #pact-jvm

bas.plijnaer
2023-08-15 12:32
has joined #pact-jvm

sameswar.khuntia
2023-08-15 12:43
we have solve the issues by commenting out this "`systemProperty("pactbroker.consumerversionselectors.rawjson", "[{\"mainBranch\":true}]")`"

matt.fellows
2023-08-15 12:46
Ha! Perhaps the escaping was incorrect then? Given it seems to be tripping up on the `m`

matt.fellows
2023-08-15 12:47
Thanks for confirming

liam.butler
2023-08-15 15:20
has joined #pact-jvm

sandy.mechie
2023-08-15 18:17
Hi , is there a way I can change the grpc request path. By default the plugin picks up the path as /packagename.Servicename/methodName?

marcocbarbieri
2023-08-15 22:47
has joined #pact-jvm

uglyog
2023-08-15 23:02
That's the standard form that gRPC uses. Why would you need to change this?

juandiegopalacio
2023-08-16 09:00
has joined #pact-jvm

sandy.mechie
2023-08-16 10:56
One of the server side implementation is in c++ and they haven't set the package name in the proto and this is causing the issue

uglyog
2023-08-16 23:17
Ok, so with the package name removed, the paths would be /Servicename/methodName?

sandy.mechie
2023-08-17 06:09
Yes

sandy.mechie
2023-08-17 06:10
Is this something which can be added?

t.vandenberk
2023-08-17 09:12
has joined #pact-jvm

jianbin.lin
2023-08-17 15:07
has joined #pact-jvm

simondemartini
2023-08-17 16:57
Kinda related to https://pact-foundation.slack.com/archives/C5F4KFKR8/p1692135539338469, but does pact-jvm have a modern way to select multiple consumers for a given provider test? i.e. if a provider has a known set of consumers (rather than just one) we would like to run all tests for those on the same class if possible. Using `@Consumer` only allows one consumer per test class. I see that `@PactBroker` annotation has the `consumerVersionSelectors` field, but that is apparently deprecated. The `@PactBrokerConsumerVersionSelectors` method with `SelectorBuilder` doesn't appear to have any way to select multiple consumer names. Is there a better approach?

yousafn
2023-08-17 17:12
You can provide raw json with `rawSelectorJson(json: String)` and pass the consumer name selectors https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors#advanced it takes an array of selectors, so you can provide scope your selector with the consumer name

yousafn
2023-08-17 17:13
note: I?ve not tested it, but that is why we allow the raw selectors to be passed through, because the core impl should support that fetching mechanism

simondemartini
2023-08-17 17:13
Is this something that will be officially supported for a while? Just a little hesitant to use the raw JSON since we lose some of that first class support


yousafn
2023-08-17 17:15
the client language provide little decorators but tie the client impls with the core impl. having raw json selectors, means you can always use the latest your broker supports without having to worry about your language keeping up to date

yousafn
2023-08-17 17:15
obviously we want all the nice named selectors in the DSL, I am sure a PR wouldn?t go amiss to add a consumer name property as a first class thing :slightly_smiling_face:

simondemartini
2023-08-17 17:17
Yeah I'm not opposed to submitting a PR upstream if thats something you all would support :slightly_smiling_face:

yousafn
2023-08-17 17:17
ps. I don?t live in the pact-jvm world much, @uglyog is our jvm dude, you can always raise an issue on the repo and we can see if there would be support for it :+1:

simondemartini
2023-08-17 17:18
Thanks! On a side note, do you have any thoughts on the linked thread above?

artur.suhaniaka
2023-08-17 20:34
has joined #pact-jvm

uglyog
2023-08-17 23:17
No, it needs a code change to support dropping the package

uglyog
2023-08-17 23:20
By default, a provider test will verify the pacts for all consumers. This is by design. You shouldn't need to specify the consumers.

simondemartini
2023-08-17 23:25
In our case though we were running into an issue where we just split up provider tests to different classes. So we had something like: `ProviderATest` (consumed by `consumer-a` ) and `ProviderBTest` (consumed by `consumer-b`) in the same monolithic project, each with their own states since they're pretty disjoint features. Pact was then complaining that `ProviderATest` didn't have the states that `ProviderBTest` verified and vice versa

simondemartini
2023-08-17 23:26
Are we just going about this all wrong? Or are there better guides for using Pact in a chonky monolith provider?

yousafn
2023-08-17 23:33
I'll be honest Si, I work better with visuals once there are more than a few hops in our scenario and a big thread. I also haven't had time to dip into that other thread yet. How artsy are you feeling? Do you think you could roughly draw up the chonkie boi. It might give us a better working base to get in the head space. If your crayolas are a bit blunt, you could whip up a sample repo? I don't mind diving into code.

aniruddhasingh.kushwa
2023-08-18 01:40
has joined #pact-jvm

sandy.mechie
2023-08-18 06:50
Yes I know:-) what I meant is a feature request? Should I go ahead and raise a feature request?


parthiban.rajasekaran
2023-08-18 08:32
has joined #pact-jvm

gowthamgopal24
2023-08-18 09:52
has joined #pact-jvm

yanov.alexander
2023-08-18 10:05
Hello #pact-jvm , are there any way to skip from the validation new fields from the provider contract as it breaks all consumers. we use pact broker version 2.107.1 and the pact library version 4.1.40

juandiegopalacio
2023-08-18 10:07
Hello #pact-jvm. I'm trying to figure it out if is there any way to dynamically create the matching rules (match variable type) based on a pact generated using https://github.com/pact-foundation/pact-provider-proxy project.

matt.fellows
2023-08-18 10:58
What do you mean, sorry?

matt.fellows
2023-08-18 10:58
You might want pending pacts


matt.fellows
2023-08-18 11:00
Have a search of this forum for auto-generated tests and the pros/cona of it

matt.fellows
2023-08-18 11:00
I think @alejandro.pena was looking at some options there too

yanov.alexander
2023-08-18 11:07
Thanks Matt, let me take a look

yanov.alexander
2023-08-18 11:08
The main issue that we use the xml as a payload, and it constantly and a new field as an empty xml element, so verification is fails for consumer

yanov.alexander
2023-08-18 11:08
let me try the pending pact functionality

matt.fellows
2023-08-18 11:12
What's adding a new field - the consumer?

yanov.alexander
2023-08-18 11:31
The provider xml contract, and all consumers just fails with validation

matt.fellows
2023-08-18 11:57
That sounds like a problem with the consumer test

sandy.mechie
2023-08-18 12:54
Thanks have raised a feature request. Also what is the plan to support grpc streaming. Because in the readme it just says grpc streaming might be supported.

sandy.mechie
2023-08-18 12:54
We have a lot of services which are bidirectional

phillip.lo
2023-08-18 16:34
Does this bad drawing help at all @yousafn :laughing: All of the provider tests within the same monolith are separate classes with their own unique set set states since they are all for different consumers but they all have the same `@Provider(Monolith)` annotation

simondemartini
2023-08-18 16:38
(@phillip.lo and I are working on the same project btw)

naimun.siraj
2023-08-18 16:50
has joined #pact-jvm

yousafn
2023-08-18 16:59
perfect! could you consider the three providers in the monolith to be of separate concerns, they just live in the same home, say name them by convention monolith-provider-a. assume they all deploy together so they would share the same version number. at the point of deployment for the monolith you would check can i deploy with repeated arguments for each names monolith-provider-x

yousafn
2023-08-18 17:01
consumer side they would just call can i deploy with thier own name, they don?t appear to be relayed to anything else. but effectively if they made a contract with 2nd micro service in the monolith, this would be picked up at both ends. the only pain point i see if when you want to deploy the mono but one of the services inside isn?t compat. hopefully they are ironed out pre deploy and on the provider verification side you have enable pending pacts and include wip pacts since date set

yousafn
2023-08-18 17:02
that diagram is spot on @phillip.lo and :ralph-wave:

yousafn
2023-08-18 17:03
also my choice of verbiage confused my colleagues so i am glad you guys got it :joy:

phillip.lo
2023-08-18 17:08
can you explain this line `the only pain point i see if when you want to deploy the mono but one of the services inside isn't compat.`

yousafn
2023-08-18 17:14
so monorepo is made up of say 3 micro providers. they each talk to one, different consumer. the monorepo has a single version number of which you wish to deploy into an environment. that version number would be shared around the 3 micro providers ( as the version number relates to the code you are releasing and they all comprise in a single repo ) if one of the micro providers in the mono repo isn?t compatible with its consumer, none of your monorepo can be deployed, blocking the other micro providers. i am using a term micro provider here loosely, to represent your provider test class a, b and c in your diagram. i assume these aren?t that related and are effective distinct providers from each consumers perspective?

yousafn
2023-08-18 17:15
it?s probably far more nuanced, but that is my simplistic view based on the diagram

phillip.lo
2023-08-18 17:16
yea, unfortunately they could be distinctive but are also many times related and could actually be the exact same "microprovider"

phillip.lo
2023-08-18 17:18
I think thats where in the other thread the sharing states came into play. ie. What do we do if it is actually the same set of endpoints in each Provider test class but they are used by different consumer microservices? Do we have to tell every consumer to write their contracts with the same states? We were hoping that they could be independent with their own set of provider tests but seems not

yousafn
2023-08-18 17:19
hmm. so there is the idea of provider states with params in v3 and v4. could this allow the idea of some kind of shared state and then a permutation based on a particular clients needs ( as informed by the state params )

yousafn
2023-08-18 17:23
then in the provider verification you can match on the state description and then do actionable items based on the param conditions. that way you aren?t filtering contacts, but processing the states potentially for different consumers needs or some kind of shared state default

yousafn
2023-08-18 17:26
provider states should be discussed with provider team by the team generating the contracts, otherwise it?s fair game imo to have a process where as this new pact is now validated and say fails on state because consumers hadn?t collaborated, that they are forced to now collab and potentially update the generated states in their test. the onus is on the consumer to get a successful verification in order to deploy, the provider will be happy enough without any consumers. that doesn?t mean they can yolo a contract over the fence and hope for the best

eugeniosaulo
2023-08-18 21:28
has joined #pact-jvm

yanov.alexander
2023-08-19 06:14
Hello, does anyone experienced an issue when the contract from a consumer published to the pact broker but the provider when run verification said there is no pact contracts for current consumer? The contract itself available on the pact broker from the ui.

matt.fellows
2023-08-19 10:15
It's probably the selectors you use. What's your set-up?

yanov.alexander
2023-08-20 15:12
Hello @matt.fellows , the selectors on the broker side or I can manage it from the consumer or provider service configuration? Do we have any pages about selectors?

pere.villega
2023-08-20 17:49
has joined #pact-jvm

navin.dhanaraj
2023-08-21 00:10
has joined #pact-jvm

simondemartini
2023-08-21 18:37
Has anyone here had experience with consumer contracts with Bazel?


matt.fellows
2023-08-21 21:31
You specify them during provider verification

eduardo.rodrigues
2023-08-22 08:05
has joined #pact-jvm

nickkeers
2023-08-22 08:35
has joined #pact-jvm

stan.amsellem
2023-08-22 09:35
@stan.amsellem has left the channel

radek.stolarczyk
2023-08-22 13:35
Hello, I'm doing consumer driven contract testing. I have finished the consumer class and now I am working on the provider. My provider is able to verify that the message is correct or what is missing but when I try to Publish the Verification results I get 403. So it can access Pactflow to verify the contract/message but it cannot punish the results, weird. :disappointed: ```@Provider("myProvider") @Consumer("myConsumer") @PactBroker(scheme = "https", host = "http://mypactflow.pactflow.io", authentication = @PactBrokerAuth(token = "mytoken")) public class ProviderUCDLambdaTest { private final ObjectMapper objectMapper = new ObjectMapper(); @BeforeEach public void setUp(PactVerificationContext context) { context.setTarget(new MessageTestTarget(List.of("com.myPackage"))); System.setProperty("pact.provider.version", System.getenv("GIT_COMMIT") == null ? "" : System.getenv("GIT_COMMIT")); System.setProperty("pact.provider.tag", System.getenv("GIT_BRANCH") == null ? "" : System.getenv("GIT_BRANCH")); System.setProperty("pact.provider.branch", System.getenv("GIT_BRANCH") == null ? "" : System.getenv("GIT_BRANCH")); System.setProperty("pact.verifier.publishResults", System.getenv("PACT_BROKER_PUBLISH_VERIFICATION_RESULTS") == null ? "true" : "true"); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(PactVerificationContext context) { context.verifyInteraction(); } @PactVerifyProvider("a message with user signal information") public MessageAndMetadata provideMessage() throws Exception { // Main Message Simplified For Example Map<String, Object> mainMessage = new HashMap<>(); mainMessage.put("messageId", "test"); mainMessage.put("receiptHandle", "MessageReceiptHandle"); Map<String, Object> metadata = new HashMap<>(); return new MessageAndMetadata(objectMapper.writeValueAsBytes(mainMessage), metadata); } }``` I'm using "http://au.com.dius.pact" version "4.3.15" ```testImplementation("au.com.dius.pact.consumer:junit5:${project.pactVersion}") testImplementation("au.com.dius.pact.provider:junit5:${project.pactVersion}")``` Messager I get: > Task :user-changed-details-lambda:providerContractTest Verifying a pact between payments-fraud-risk-lambda (fce57cb70c7fe8b9a40ab47787aaef10f4b4dddc) and user-change-details-signal Notices: 1) The pact at https://xxxxxxx being verified because the pact content belongs to the consumer version matching the following criterion: * latest version of awslambdaxxx from the main branch 'main' (fce57cb70c7fe8) [from Pact Broker https://xxxxxxxx a message with user signal information 2023-08-22 14:29:45 WARN Metrics - Please note: we are tracking events anonymously to gather important usage statistics like JVM version and operating system. To disable tracking, set the 'pact_do_not_track' system property or environment variable to 'true'. generates a message which has a matching body (OK) has matching metadata (OK) 2023-08-22 14:29:45 WARN ProviderVersion - Provider version not set, defaulting to '0.0.0' 2023-08-22 14:29:47 ERROR HalClient - PUT JSON request failed with status 403 Forbidden 2023-08-22 14:29:47 ERROR PactBrokerClient - Publishing verification results failed with an exception http://au.com.dius.pact.core.pactbroker.RequestFailedException: Request failed with 403

yousafn
2023-08-22 13:38
are you using a token that doesn?t have write perms (ie read only will allow you to retrieve, but you wouldn?t be expected to publish results from your local machine)

yousafn
2023-08-22 13:51
Hey @simondemartini I caught up with Olivier last month who has been playing around with Bazel and our Pact tooling https://docs.pact.io/blog/2023/07/28/pact-open-source-update-july-2023#community-corner---olivier-picaud

yousafn
2023-08-22 13:51
Bar that I?ve had a brief foray into bazel whilst learning about gRPC but nothing of great substance.

simondemartini
2023-08-22 16:47
Oh interesting thank you!

christophe.laranjo
2023-08-22 17:34
has joined #pact-jvm

tjones
2023-08-23 01:08
When there is a programmer error inside your service

huthayfa
2023-08-23 08:10
has joined #pact-jvm

dsherwin
2023-08-23 09:20
has joined #pact-jvm

radek.stolarczyk
2023-08-23 12:27
Yes it was read only.

yousafn
2023-08-23 12:33
that is the expected behaviour then

marcel.novak
2023-08-23 13:53
has joined #pact-jvm

radek.stolarczyk
2023-08-23 14:17
Is it possible to run my class without: ```@PactBroker(scheme = "https", host = "http://mypactflow.pactflow.io", authentication = @PactBrokerAuth(token = "mytoken"))``` and perhaps use like a command like here: ```- label: ":pact: Publish Consumer Contract" key: pact-publish-consumer-contract depends_on: - gradle:build agents: queue: java-build plugins: - seek-oss/aws-sm#v2.3.1: json-to-env: - secret-id: "/buildkite/common/pactflow" json-key: ".Variables" - docker#v3.5.0: volumes: - "/shared/data:/shared/data" image: ${ECR_REGISTRY}pactfoundation/pact-cli:0.50.0.31 command: - pact-broker - publish - /shared/data/mypact.json - --consumer-app-version=$BUILDKITE_COMMIT - --branch=$BUILDKITE_BRANCH - --tag=${PACT_TAG} - --tag=PR-${BUILDKITE_PULL_REQUEST} environment: - "PACT_BROKER_BASE_URL" - "PACT_BROKER_TOKEN" - "BUILDKITE_BRANCH" - "BUILDKITE_COMMIT" - "SERVICE"``` I'm trying to get the environment variables (Base_Url and Token) to the @PactBroker annotation but no luck :disappointed:

yousafn
2023-08-23 14:26
If all you want to do is not publish verification results with a read only token, set this as default to false that will allow you to pull down contracts for local verification and then publish them back. ``` System.setProperty("pact.verifier.publishResults", System.getenv("PACT_BROKER_PUBLISH_VERIFICATION_RESULTS") == null ? "true" : "true");``` :point_up_2: this is saying always publish results, which probably isn?t what you want, if you are going to run verifications locally the above snippet you?ve shown is for publishing pacts, and the first snippet is for verifying. Pact-JVM uses its own core for consumer/provider testing, whereas the pact cli tooling contains the ruby command line implementation of a verifier. There is also a rust one, which supports v3/v4 features. https://docs.pact.io/implementation_guides/cli#provider-verifier you would probably want the native verifier from that list, if you are going to try and verify pacts in a language agnostic fashion via a cli. I suspect you don?t need this at all tho

davidm
2023-08-23 15:57
has joined #pact-jvm

radek.stolarczyk
2023-08-24 08:43
Is there a way to pass the token from env variables to this annotation? ```@PactBroker(scheme = "https", host = "http://myTest.pactflow.io", authentication = @PactBrokerAuth(token = "myToken")) @Provider("user-change-details-signal") @Consumer("payments-fraud-risk-lambda")``` _______ ```@PactBroker(scheme = "https", host = "http://myTest.pactflow.io", authentication = @PactBrokerAuth(token = "myToken")) @Provider("user-change-details-signal") @Consumer("payments-fraud-risk-lambda") public class ProviderUCDLambdaTest { private final ObjectMapper objectMapper = new ObjectMapper(); @BeforeEach public void setUp(PactVerificationContext context) { context.setTarget(new MessageTestTarget(List.of("com.myTest.payments.user_change_details"))); System.setProperty("pact.provider.version", System.getenv("GIT_COMMIT") == null ? "" : System.getenv("GIT_COMMIT")); System.setProperty("pact.provider.tag", System.getenv("GIT_BRANCH") == null ? "" : System.getenv("GIT_BRANCH")); System.setProperty("pact.provider.branch", System.getenv("GIT_BRANCH") == null ? "" : System.getenv("GIT_BRANCH")); System.setProperty("pact.verifier.publishResults", System.getenv("PACT_BROKER_PUBLISH_VERIFICATION_RESULTS") == null ? "true" : "true"); System.setProperty("pact.broker.url", "https://fanduel.pactflow.io"); System.setProperty("pact.broker.token", System.getenv("Pact_Broker_Token")); }```

svmanikantakumar
2023-08-24 08:50
has joined #pact-jvm

eomeroff
2023-08-24 13:49
has joined #pact-jvm

marcin.slowiak.007
2023-08-24 17:42
wouldn?t be better to prepare your Maven/Gradle to inject that credentials? ex gradle: ```test { useJUnitPlatform() if (System.getenv("CI") != null) { println("[contract-tests] CI run") systemProperty 'pact.verifier.publishResults', 'true' } else { println("[contract-tests] Local run") systemProperty 'pact.verifier.publishResults', 'false' } environment 'pactbroker.enablePending', 'true' environment 'pactbroker.url', 'your-url' environment 'pactbroker.auth.token', 'token' }``` then you do not need to pass any token to annotation at all

riley.marzka
2023-08-24 17:47
has joined #pact-jvm

jared.anderson
2023-08-24 18:15
has joined #pact-jvm

timofeev1valeriy
2023-08-25 08:32
has joined #pact-jvm

kastala.nirosha
2023-08-25 09:17
has joined #pact-jvm

kkanova
2023-08-25 12:55
has joined #pact-jvm

theteea
2023-08-25 13:18
has joined #pact-jvm

theteea
2023-08-25 13:25
@theteea has left the channel

bas
2023-08-25 14:02
Hey! I'm probably overlooking something simple here, but when I run this test: ```package customer; import static http://org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; import au.com.dius.pact.consumer.MockServer; import au.com.dius.pact.consumer.dsl.DslPart; import au.com.dius.pact.consumer.dsl.LambdaDsl; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; import au.com.dius.pact.core.model.RequestResponsePact; import au.com.dius.pact.core.model.annotations.Pact; import org.apache.http.HttpResponse; import org.apache.http.client.fluent.Request; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import java.io.IOException; import java.util.UUID; @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "address_provider") public class AddressServiceGetContractTest { private static final UUID ID = UUID.fromString("8aed8fad-d554-4af8-abf5-a65830b49a5f"); private static final String ADDRESS_TYPE = "billing"; private static final String STREET = "Main Street"; private static final int NUMBER = 123; private static final String CITY = "Nothingville"; private static final int ZIP_CODE = 54321; private static final String STATE = "Tennessee"; private static final String COUNTRY = "United States"; @Pact(provider = "address_provider", consumer = "customer_consumer") public RequestResponsePact pactForGetExistingAddressId(PactDslWithProvider builder) { DslPart body = LambdaDsl.newJsonBody((o) -> o .uuid("id", ID) .stringType("addressType", ADDRESS_TYPE) .stringType("street", STREET) .integerType("number", NUMBER) .stringType("city", CITY) .integerType("zipCode", ZIP_CODE) .stringType("state", STATE) .stringType("country", COUNTRY) ).build(); return builder.given( "Customer GET: the address ID matches an existing address") .uponReceiving("A request for address data") .path(String.format("/address/%s", ID)) .method("GET") .willRespondWith() .status(200) .body(body) .toPact(); } @Test public void testFor_GET_existingAddressId_shouldYieldExpectedAddressData(MockServer mockServer) throws IOException { HttpResponse httpResponse = Request.Get(mockServer.getUrl() + "/address/" + ID).execute().returnResponse(); assertThat(httpResponse.getStatusLine().getStatusCode(), is(equalTo(200))); } }``` I get the following error message: ```[ERROR] Failures: [ERROR] AddressServiceGetContractTest The following methods annotated with @Pact were not executed during the test: AddressServiceGetContractTest.pactForGetExistingAddressI d If these are currently a work in progress, add a @Disabled annotation to the method [ERROR] Errors: [ERROR] AddressServiceGetContractTest.testFor_GET_existingAddressId_shouldYieldExpectedAddressData(MockServer) » UnsupportedOperation Method pactForGetExistingAddressId doe s not conform required method signature 'public au.com.dius.pact.core.model.V4Pact xxx(PactBuilder builder)'``` Any ideas? I'm upgrading my Pact Java workshop material to finally use the latest Pact versions and JUnit 5, and until this point the docs helped out well, but I'm stuck now.

charlan.bettiol
2023-08-25 16:32
has joined #pact-jvm

charlan.bettiol
2023-08-25 16:37
Hello everyone, good afternoon, how are you? recently here at our company we bought pact-flow and we are implementing and assembling the flows and we faced some problems and I would like to know if we can help us? The first moment would be, what is the ideal flow for using and creating contract tests? The second would be: today we have the problem of being able to develop pacts locally using pact-flow but we have the following issue, the api tokens cannot be exposed in the code since we do not know how to do it at this point so that the local development is available using the online broker.

simondemartini
2023-08-25 17:30
Hi all, we have pending/WIP pacts enabled and ran into an interesting case with Mockito and JUnit 5: A consumer contributed a failing WIP pact to provider A but Provider A wrote their test with Mockito in their `@State` method. Because the consumers contract failed early, mockito's `UnnecessaryStubbingException` was thrown because the `@State` method wasn't called and it wasn't using lenient stubbing. It looks like the way this failed, actually failed the build. Unlike "normal" pending/WIP pact failures. Is this expected?

david.tu
2023-08-25 17:51
has joined #pact-jvm

bas
2023-08-25 18:42
Hi @charlan.bettiol, 1: I don?t think there?s one ideal flow, really. You might want to have a look at this, though: https://docs.pact.io/pact_nirvana 2: if you only run tests locally a simple environment variable should do the trick. Or am I misunderstanding your question?

charlan.bettiol
2023-08-25 18:44
Yes, you understand, but in this case, I didn't want this token to be available to more than one person, in this case, to avoid leaking this token

bas
2023-08-25 18:46
So, why not create one token per user in PactFlow and have everybody store them using the same environment variable?

charlan.bettiol
2023-08-25 18:47
because of the number of licenses, we have more devs than licenses we wanted to keep it centralized

bas
2023-08-25 18:55
So you don?t want tokens to be available to more than one developer but also do not want to pay for more users? (By ?you? I mean your team/company, not you personally) If that?s the case I?m sorry man, I can?t (and don?t want to) help as that doesn?t sound right to me.

charlan.bettiol
2023-08-25 18:57
I think I expressed myself wrong in the translation communication, even with individual tokens there is a risk of it being exposed and the pacts becoming available, we wanted some means in which authentication was not through an environment variable or key exposed on the developer's machine

bas
2023-08-25 19:00
Gotcha! No worries :) Have you seen the options here? https://docs.pactflow.io/docs/authentication/main/

bas
2023-08-25 19:02
Although I _think_ you still need a token anyway to authenticate when uploading and downloading contracts and uploading verification results, but I?ve never used any of these options.

charlan.bettiol
2023-08-25 19:06
Thank you very much, I will read the links you passed, the one on the flow gave a great light, now I will study how to send and collect the pacts, we are trying to develop as much as possible without human interaction, just to write the pacts.

riley.marzka
2023-08-25 20:38
@bas Add the annotation to your test method `@PactTestFor(pactMethod = "pactForGetExistingAddressId")` . You should also keep the `@Test` annotation. So your test method should be like this ```@Test @PactTestFor(pactMethod = "pactForGetExistingAddressId") public void testFor_GET_existingAddressId_shouldYieldExpectedAddressData(MockServer mockServer) throws IOException { HttpResponse httpResponse = Request.Get(mockServer.getUrl() + "/address/" + ID).execute().returnResponse(); assertThat(httpResponse.getStatusLine().getStatusCode(), is(equalTo(200))); }```

bas
2023-08-25 20:48
Awesome, I?ll try that right away tomorrow morning, thank you @riley.marzka !

bas
2023-08-26 06:25
I've added that annotation but unfortunately, the error message remains. Does anybody have any other ideas?

bas
2023-08-26 06:36
Fixed it! The solution was to explicitly specify that the Pact version should be V3, i.e. the class-level annotation should be ` ```@PactTestFor(providerName = "address_provider", pactVersion = PactSpecVersion.V3)``` What was causing the confusion was this docs page: https://docs.pact.io/implementation_guides/jvm/consumer/junit5, where it gives the example I followed but that argument to the annotation isn't there. Seems like this method signature `public RequestResponsePact pactForGetExistingAddressId(PactDslWithProvider builder)` is compatible with Pact specification V3 only, but not with V4. Good to know!

bas
2023-08-26 06:49
@riley.marzka thank you for your suggestion anyway, I noticed that I _do_ also need to add that annotation at the test level once I have more than one `@Pact` method and associated test in my test class, otherwise Pact has no idea how to match the two.

bas
2023-08-26 07:43
Another question, now that my consumer tests for the workshop are updated, I want to upgrade the provider side, too. I've got a simple Spring service there that I'd like to reuse, so I've upgraded my dependencies to: ``` <dependency> <groupId>au.com.dius.pact</groupId> <artifactId>provider</artifactId> <version>4.6.2</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5spring</artifactId> <version>4.6.2</version> <scope>test</scope> </dependency>``` and I'm following the example here: https://docs.pact.io/implementation_guides/jvm/provider/junit5spring However, I'm probably missing one or more dependencies here: ```@ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @Provider("address_provider") @PactFolder("src/test/pacts") public class ContractTest { @TestTemplate @ExtendWith(PactVerificationSpringProvider.class) public void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } }``` as it can't find the `@Provider`, `PactVerificationSpringProvider` and `PactVerificationContext` classes. Again, probably something pretty obvious but I've been stuck on this for a while now. I know that page references Pact v 4.4.x so that might be the problem but I'd really like to use the latest versions.


matt.fellows
2023-08-28 03:33
Any chance you could help Bas @uglyog?

matt.fellows
2023-08-28 03:34
> Thank you very much, I will read the links you passed, the one on the flow gave a great light, now I will study how to send and collect the pacts, we are trying to develop as much as possible without human interaction, just to write the pacts. you?ll still need them for local provider verification. Each developer that verifies the contract should have their own unique token (read-only) to verify pacts locally without compromising security by sharing credentials - I think this is what Bas was alluding to.

matt.fellows
2023-08-28 03:35
I understand the want to automate as much as possible - of course we recommend this also. For CI, you would use system accounts with their respective tokens.

matt.fellows
2023-08-28 03:35
As for ideal flow - the Nirvana guide Bas linked is great, and this is the corresponding workshop ICYMI: https://docs.pactflow.io/docs/workshops/ci-cd/

uglyog
2023-08-28 06:01
No idea, those classes and annotations haven't changed. 4.6.2 requires min JDK 17, so check that you have that.

matt.fellows
2023-08-28 06:22
How are you running it Bas - command line? Mind sharing the logs/console?

bas
2023-08-28 06:39
There's not a lot to run as the code doesn't compile :slightly_smiling_face: I've now 'downgraded' (or rather upgraded less) to `4.4.6` and that resolves these issues. I _am_ running on Java 17, by the way.

matt.fellows
2023-08-28 06:46
:raised_hands:

bas
2023-08-28 06:50
Quick test shows that upgrading to 4.5.3 also breaks the project as these classes I mentioned cannot be found. Really weird. For now I'm happy to stick with 4.4.6 but I'd love to hear what causes this behaviour.



bas
2023-08-28 07:22
To what, exactly? 4.0.10 seems to be the latest version


bas
2023-08-28 07:51
Hmmm, still no success when using `4.6.2` for all dependencies, but `4.4.6` works. Again, happy to use that, but I'm really curious to see what causes this. Would love consumer and provider sides to be on the same (latest) Pact version for the workshop.

bas
2023-08-28 07:52
Also, I see this in the console output. Doesn't impact the outcome, though: ``` Given Customer GET: the address ID matches an existing address A request for address data Exception in thread "Thread-6" java.lang.NoClassDefFoundError: org/apache/commons/codec/digest/DigestUtils at au.com.dius.pact.core.support.Metrics.hostnameHash(Metrics.kt:152) at au.com.dius.pact.core.support.Metrics.sendMetrics$lambda-2(Metrics.kt:106) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.digest.DigestUtils ... 3 more returns a response which has status code 200 (OK) has a matching body (OK)``` Not sure if that's related. I've pushed the latest code to the branch I linked to just earlier.

charlan.bettiol
2023-08-28 11:24
@matt.fellows Good morning Thank you very much for these links, would you have something in java?

matt.fellows
2023-08-28 11:39
I don't think so, but the principles are the same. All of our example projects use the principles also

matt.fellows
2023-08-28 11:39
Howtoexamples


viktor.stephanyk
2023-08-28 12:46
has joined #pact-jvm

arpit.gawande
2023-08-28 12:58
has joined #pact-jvm

riley.marzka
2023-08-28 15:14
Glad you got it figured out and glad I could help (even if tangentially)!

alexander.doppelbauer
2023-08-28 17:52
has joined #pact-jvm

jayapriya.m
2023-08-29 00:22
has joined #pact-jvm

grnmeadow7
2023-08-29 03:27
has joined #pact-jvm

kuntol.banerjee
2023-08-29 07:34
hello everyone After successfully running the test, pact json for the provider side doesn't gets generated. It just create a empty folder below is my pom.xml ``` <dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit5</artifactId> <version>4.2.17</version> <scope>test</scope> </dependency>```

matt.fellows
2023-08-29 08:42
you will need to provide some more information Kuntol.

matt.fellows
2023-08-29 08:42
see howtorepro


kuntol.banerjee
2023-08-29 08:44
@matt.fellows Kindly let me know what other information are required

matt.fellows
2023-08-29 08:45
1. Ideally, a project that we can clone that demonstrates the problem 2. What other relevant dependencies are you using 3. DEBUG level console output / logs is always a good start 4. What does your consumer test look like? 5. What have you tried already? Have you looked at working examples to create your test? Did it ever work?

kuntol.banerjee
2023-08-29 08:46
My test are working but the pact json is not getting generated

matt.fellows
2023-08-29 08:46
Think about it from our end. You have told us one dependency you use and that pact files aren?t being generated. Maybe they are, and they are in a different folder. Maybe your pact tests aren?t executing

matt.fellows
2023-08-29 08:46
that?s a start - how do you know they are working?

kuntol.banerjee
2023-08-29 08:46
on executing them no errors are observed also the assertion is not getting failed

matt.fellows
2023-08-29 08:47
how do you know they are running?

kuntol.banerjee
2023-08-29 08:47
while executing the test using the option run as junit in eclipse

matt.fellows
2023-08-29 08:48
ok, so the tests are running (we think)

kuntol.banerjee
2023-08-29 08:48
also the assertion condition is set to check the expected and actual json

kuntol.banerjee
2023-08-29 08:48
which is not getting failed

matt.fellows
2023-08-29 08:48
are you sure the file is not getting generated elsewhere? Have you tried from the command line?

matt.fellows
2023-08-29 08:49
In any case, please share logs, that will help us see if it got written and where it got written to

kuntol.banerjee
2023-08-29 08:49
```14:19:36.206 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate] 14:19:36.222 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)] 14:19:36.263 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.rahulshettyacademy.PactConsumerTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper] 14:19:36.278 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.rahulshettyacademy.PactConsumerTest], using SpringBootContextLoader 14:19:36.283 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.rahulshettyacademy.PactConsumerTest]: class path resource [com/rahulshettyacademy/PactConsumerTest-context.xml] does not exist 14:19:36.284 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.rahulshettyacademy.PactConsumerTest]: class path resource [com/rahulshettyacademy/PactConsumerTestContext.groovy] does not exist 14:19:36.284 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.rahulshettyacademy.PactConsumerTest]: no resource found for suffixes {-context.xml, Context.groovy}. 14:19:36.285 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.rahulshettyacademy.PactConsumerTest]: PactConsumerTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration. 14:19:36.338 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.rahulshettyacademy.PactConsumerTest] 14:19:36.413 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [C:\Users\inkbane\Test\Pact_Testing_demo\Code Projects\SpringBootRestService\target\classes\com\rahulshettyacademy\SpringBootRestServiceApplication.class] 14:19:36.415 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.rahulshettyacademy.SpringBootRestServiceApplication for test class com.rahulshettyacademy.PactConsumerTest 14:19:36.535 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.rahulshettyacademy.PactConsumerTest]: using defaults. 14:19:36.535 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener] 14:19:36.556 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@6bab2585, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@74bdc168, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@644c78d4, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@532a02d9, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@611f8234, org.springframework.test.context.support.DirtiesContextTestExecutionListener@7bb3a9fe, org.springframework.test.context.transaction.TransactionalTestExecutionListener@7cbee484, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@7f811d00, org.springframework.test.context.event.EventPublishingTestExecutionListener@62923ee6, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@4089713, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@f19c9d2, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@7807ac2c, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@b91d8c4, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@4b6166aa, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@a77614d] 14:19:36.561 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@66ea1466 testClass = PactConsumerTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@1601e47 testClass = PactConsumerTest, locations = '{}', classes = '{class com.rahulshettyacademy.SpringBootRestServiceApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@6179e425, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@67304a40, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@69653e16, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@550a1967, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@10b9db7b, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@43195e57], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null]. 14:19:36.607 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true} . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.5.2) 2023-08-29 14:19:36.901 WARN 8020 --- [ main] ory$DuplicateJsonObjectContextCustomizer : Found multiple occurrences of org.json.JSONObject on the class path: jar:file:/C:/Users/inkbane/.m2/repository/org/json/json/20160212/json-20160212.jar!/org/json/JSONObject.class jar:file:/C:/Users/inkbane/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar!/org/json/JSONObject.class You may wish to exclude one of them to ensure predictable runtime behavior 2023-08-29 14:19:36.923 INFO 8020 --- [ main] com.rahulshettyacademy.PactConsumerTest : Starting PactConsumerTest using Java 17.0.8 on VI219488 with PID 8020 (started by inkbane in C:\Users\inkbane\Test\Pact_Testing_demo\Code Projects\SpringBootRestService) 2023-08-29 14:19:36.925 INFO 8020 --- [ main] com.rahulshettyacademy.PactConsumerTest : No active profile set, falling back to default profiles: default 2023-08-29 14:19:37.611 INFO 8020 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2023-08-29 14:19:37.692 INFO 8020 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 70 ms. Found 1 JPA repository interfaces. 2023-08-29 14:19:38.357 INFO 8020 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2023-08-29 14:19:38.644 INFO 8020 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2023-08-29 14:19:38.719 INFO 8020 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2023-08-29 14:19:38.794 INFO 8020 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.32.Final 2023-08-29 14:19:39.017 INFO 8020 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} 2023-08-29 14:19:39.205 INFO 8020 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect 2023-08-29 14:19:39.828 INFO 8020 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] 2023-08-29 14:19:39.837 INFO 8020 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2023-08-29 14:19:40.464 WARN 8020 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning```

kuntol.banerjee
2023-08-29 08:50
2023-08-29 14:19:42.796 INFO 8020 --- [ main] a.c.d.p.c.junit5.PactConsumerTestExt : Writing pacts out to default directory 2023-08-29 14:19:43.348 INFO 8020 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 2023-08-29 14:19:43.348 INFO 8020 --- [ionShutdownHook] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down' 2023-08-29 14:19:43.357 INFO 8020 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2023-08-29 14:19:43.360 INFO 8020 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.

kuntol.banerjee
2023-08-29 08:51
how to check using command line?

grnmeadow7
2023-08-29 08:53
as a consumer, it can generate the json file then publish to pact broker server. as a producer, it will only validate the contract in the pact broker server.

matt.fellows
2023-08-29 08:59
> Writing pacts out to default directory so it thinks it?s writing the pacts. Where have you checked for the pact files?

grnmeadow7
2023-08-29 09:00
to check using command line... 1. go to the root of your project 2. for maven : mvnw test for gradle : gradlew test

matt.fellows
2023-08-29 09:03
it should be in something like `build/pacts` but I?ve seen it in the `target` directory. Search for `pacts` in the root of your project

kuntol.banerjee
2023-08-29 09:05
It's creating a pacts folder but it's empty

matt.fellows
2023-08-29 09:22
What is this? It looks like the pact file, but rendered as a folder

matt.fellows
2023-08-29 09:23
are you sure it?s not the pact file, and Eclipse is just showing it funny?

matt.fellows
2023-08-29 09:23
Can you please try running from the command line (both the tests, and checking if the file is written).

matt.fellows
2023-08-29 09:23
It could be some other process clearing the pacts

grnmeadow7
2023-08-29 09:28
i think he added/modified @PactFolder

kuntol.banerjee
2023-08-29 09:28
issue sorted the issue is with eclipse

matt.fellows
2023-08-29 09:31
What was the issue?

kuntol.banerjee
2023-08-29 09:31
the issue is with eclipse, the json file is getting hidden

sayantini.basak
2023-08-29 10:02
has joined #pact-jvm

shayanadc
2023-08-29 18:19
has joined #pact-jvm

charlan.bettiol
2023-08-29 19:36
good afternoon everyone how are you? I have a doubt, when I run my tests via Junit5 with ``` @PactBroker( host = "http://myhost.com", authentication = @PactBrokerAuth(token = "${PACT_BROKER_TOKEN}") )``` it automatically does the verify and publishes the results, but with maven this does not happen, I wanted the behavior of JUNIT to be the same as MAVEN is there any specific parameter for me to put so that it does not publish the results by JUNIT?

matt.fellows
2023-08-29 22:21
In our examples, we use Gradle and set the system property based on an environment variable: ```systemProperty("pact.verifier.publishResults", System.getenv("PACT_BROKER_PUBLISH_VERIFICATION_RESULTS") == null ? "false" : "true")```



bas
2023-08-30 09:12
Any ideas on this? I?ve got a working workshop codebase now so that?s good, but the provider project is still on 4.4.6 instead of the latest version. My OCD does not agree with this.

matt.fellows
2023-08-30 10:52
Hi Bas, I?ll see if we can take a look tomorrow. Hopefully something simple!

matt.fellows
2023-08-30 10:52
I? understand the compulsion :stuck_out_tongue:

ksawery.karwacki
2023-08-30 14:31
Hi is there any sample how to instrument Consumer Selector in junit to work also with webhooks? I know I have to add `@AllowOverridePactUrl` and pass something to my gradle task but I have no idea what exactly that should be.

jack.jones9512
2023-08-30 15:49
has joined #pact-jvm

craftyqa
2023-08-30 16:54
has joined #pact-jvm

yousafn
2023-08-30 17:09
Just having a look now, on a mac m1, openjdk 17 and maven both installed via homebrew. managed to run all the tests out the box, and then upgraded to 4.6.2 on the provider and that passed too. Just added some local ci runs to replicate and then will push up a fork.

bas
2023-08-30 17:11
Cheers Saf! Really curious to see what I?ve done wrong, the only thing I haven?t tried is completely wiping and repopulating my local Maven repo.

yousafn
2023-08-30 17:12
I just dropped into the repo, updated the pom.xml and did a `mvn test` again. Just did a `mvn clean` and then `mvn test` just incase it didn?t rebuild after changing the pom

yousafn
2023-08-30 17:12
could just be an environmental / transient thing :elmo_shrug: sometimes resetting my pc works for reasons I wish we could fathom in this modern day

bas
2023-08-30 17:13
Thanks! I?ll check first thing tomorrow morning as I CBA to fire up my laptop again tonight

yousafn
2023-08-30 17:14
also just tested against a docker image. `maven:3-eclipse-temurin-17` linux arm and amd64. I?ll just up some repros so you can have a nose tomorrow. enjoy the feet up :+1:

bas
2023-08-30 17:18
I?m on Windows so that might just be a factor here too :laughing:


bas
2023-08-30 17:37
Legend! Again, I?ll check this out first thing tomorrow morning


jean-baptiste.bronisz
2023-08-31 15:48
has joined #pact-jvm

razorangel
2023-08-31 18:41
has joined #pact-jvm

dsharma
2023-08-31 19:11
has joined #pact-jvm

eytan.hanig
2023-08-31 22:10
has joined #pact-jvm

eytan.hanig
2023-09-01 03:07
@eytan.hanig has left the channel

gowthamgopal24
2023-09-01 07:18
Hi All, I am new to PACT and I have completed the publishing pacts to the pact broker from the consumer and I also verified the pacts against the running Provider. This works awesome. All the requests I have should have an active token to verify the pact against the provider. Is there a way to modify the auth token before triggering verification tasks? I need this to be done when I am doing the verification when I provider makes a change. I am using mvn pact:verify to verify the contracts. Can someone help me with this? Is there a sample to check?

matt.fellows
2023-09-01 08:33
See :point_down: (howtoauth)

2023-09-01 08:33
Approaches to handling authentication in Pact tests: https://docs.pact.io/provider/handling_auth

matt.fellows
2023-09-01 08:33
There's some general guidelines there.

matt.fellows
2023-09-01 08:34
To see an example, check out the java workshops authorisation step (howtolearn)

2023-09-01 08:34
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

gowthamgopal24
2023-09-01 10:25
Thanks @matt.fellows, I will check this out and let you know if I have any issues

gowthamgopal24
2023-09-01 11:11
Hi @matt.fellows, I made the changes like this I am using Provider version 4.5.6, but still I am not able to replace the token. I run *mvn pact:verify* to verify my test cases. Am I missing something ?

gowthamgopal24
2023-09-01 11:12
I hard-coded both valid and invalid token, but still I don't see it gets applied during provider verification

gowthamgopal24
2023-09-01 12:14
This is the place where I am stuck and want to find a way to replace the valid token when the provider tries to verify the contracts when a new version is deployed. Your Help is much appreciated. @matt.fellows Java Version 17 Pact Provider Version 4.5.6 I am running the test using "mvn pact:verify" command. I tried adding the Auth token in verifyPact method but still this is not getting updated.

munitheja91
2023-09-01 13:14
has joined #pact-jvm

munitheja91
2023-09-01 13:25
Hi All, Is there a way to replace the authorization token while running the mvn pact:verify command. *Problem Statement:* When Consumer sent a Pact file, it has one auth token and Pact file will be verified immediately. But when i want to check the same pact file again, the consumer token would have expired.so in order to solve this problem i am trying to replace the token in the consumer pact file and run against the provider. Could you please let me know is there any way to solve this problem? Thanks in Advance

yousafn
2023-09-01 13:32
Hey, See handling auth, sections 3 and 4 are relevant, https://docs.pact.io/provider/handling_auth provider states or request filters

yousafn
2023-09-01 13:32
storing valid tokens in a consumer pact file, isn?t scalable

gowthamgopal24
2023-09-02 05:21
@yousafn, Do you have any suggestions for this? I can try replacing the token while running the verification, but I am not able to replace the token while doing provider verification. Is there a sample which tells how to replace an active token during "mvn pact:verify" ?

matt.fellows
2023-09-02 11:37
Do you know if that method is being invoked?

matt.fellows
2023-09-02 11:39
If you set log level to DEBUG, we should be able to see the request/response from the verifier to the actual provider.

alvarado.kelvin
2023-09-02 12:48
has joined #pact-jvm

sautade
2023-09-04 01:23
has joined #pact-jvm

gowthamgopal24
2023-09-04 04:23
Hi @matt.fellows, The method is not being called when I run mvn pact:verify Can we use requestFilter in pom.xml?

joshua.ellis
2023-09-04 04:51
has joined #pact-jvm

ianlutz
2023-09-04 05:34
cccccctbbnvfejrrjtnfelldbfvfdlffuhhvvrfinvrl

gowthamgopal24
2023-09-04 06:32
Hi All, I am working on PACT Provider Verification using Pact JVM. I am stuck reading the request headers. Has anyone worked on writing Groovy scripts in pom.xml to modify the auth token during provider verification? When I add the groovy scripts in pom.xml, I am getting h Thanks in Advance !! Your help is much appreciated. !




abubics
2023-09-04 07:40
I only used Maven once a few years ago, usually I use Gradle for JVM projects. But I've never tried to put scripts in the build files like this.

abubics
2023-09-04 07:41
I've done 2 & 3 & 4 from these suggestions: https://docs.pact.io/provider/handling_auth

abubics
2023-09-04 07:44
But that's always in app (test) code, not in build code.

gowthamgopal24
2023-09-04 09:01
Thanks @abubics, Do you have any samples for 4th option? I have a unique scenario to handle, so this one might be helpful for me

bbodoque.atsistemas
2023-09-04 10:21
has joined #pact-jvm

gowthamgopal24
2023-09-05 04:50
Hi @matt.fellows, I tried writing groovy scripts with <requestFilters> but I am getting error *A required class was missing while executing au.com.dius.pact.provider:maven:4.6.2:verify: org/apache/ivy/util/MessageLogger* *But the dependencies are downloaded but it in not included in pact verify step. Does this needs any fix?*

gowthamgopal24
2023-09-05 04:57
@matt.fellows, The below code works perfect <requestFilter> request.setHeader('Authorization', 'Bearer eyJhbGciOiJS***') </requestFilter> I am able to replace the header 'Authorization' but I want to dynamically change the token. Is there any way to do that?

gowthamgopal24
2023-09-05 04:58
Hi All, The below code works perfectly *<requestFilter>* *request.setHeader('Authorization', 'Bearer eyJhbGciOiJS***')* *</requestFilter>* I am able to replace the header 'Authorization' but I want to dynamically change the token. Is there any way to do that? Has anyone tried this?

rholshausen
2023-09-05 05:05
That executes script code between the *<requestFilter>* tags. You need to update the script to dynamically change the token.

rholshausen
2023-09-05 05:06
Are you asking how to change that code, or are you asking how to dynamically generate a token? We can't answer the latter because it depends on your systems that produce the tokens.

avanlent
2023-09-05 05:56
has joined #pact-jvm

gowthamgopal24
2023-09-05 10:57
Thanks for the reply @rholshausen, I am asking how to change the code. I am a complete alien to Groovy. What I want to achieve is, I wanted to connect to Secrets Manager and get the creds in groovy script. So it should be something like below <requestFilter> #To make a call to secrets manager I would require libs to import. But I am not able to do that here. If I do that then I can do what I want to achieve request.setHeader('Authorization', "<Token>"); </requestFilter>

abubics
2023-09-05 12:17
It kinda depends where your token comes from. If it's available to your groovy script, you just need to put it in the string like `request.setHeader('Authorization', "Bearer $token")`

gowthamgopal24
2023-09-05 12:20
Actually, I wanted to grab a token using groovy script but when I add inline groovy script in pom.xml I get the error "*A required class was missing while executing au.com.dius.pact.provider:maven:4.6.2:verify: org/apache/ivy/util/MessageLogger*"

gowthamgopal24
2023-09-05 12:21
I can grab a token by hitting my endpoint but to make a http call, I need to write a groovy script, which i am not able to do as I face dependency issues while writing groovy scripts @abubics

abubics
2023-09-05 12:27
https://groups.google.com/g/pact-support/c/s4Kijwwd2_E?pli=1 has a Gradle example, looks similar to your code sample

gowthamgopal24
2023-09-05 12:27
Thanks @abubics, Let me check this

abubics
2023-09-05 12:27
Feels like this is getting out of the scope of Pact, and you need to understand better how Maven & Groovy scripts work

abubics
2023-09-05 12:28
I've only used Maven a little, so I can't give you a direct example

abubics
2023-09-05 12:28
I'd need to go through some old computers to find examples of #4 that you asked for earlier

gowthamgopal24
2023-09-05 12:33
Okay, @abubics, That thread has the same thing that we already discussed. I will check how the groovy works. But Pact should come up with a Feature to replace the token dynamically.


matt.fellows
2023-09-05 12:44
Thanks for raising, but I really think that?s a mistake - there are already ways to do it. EIther there is a misunderstanding in how to do it, or it?s a bug. Either way, Canny isn?t the best place for it If it?s a bug, it should go to https://github.com/pact-foundation/pact-jvm/ with a reproducible example so it can be fixed.

matt.fellows
2023-09-05 12:46
Unfortunately I don?t know groovy/maven enough either to help you. But perhaps there is somebody in your team/company that does you can pair with? If you have a small reproducible example, perhaps we can try and help you make it work. But if it?s in your project, there are many variables that can make it hard for us to pinpoint the problem. Sometimes it?s just running from an IDE instead of the CLI that executes an entirely different code path. Or it?s a parent POM that overrides/conflicts with dependencies. If you can start from scratch and build up an example, i?d start there

gowthamgopal24
2023-09-05 12:49
Hi @matt.fellows, Actually, the pact maven plugin has only the Groovy dependency, but it doesn't have dependencies for external custom libraries like AWS. If we are allowed to add external libraries to pact maven plugin that would help us to creatively use external libraries to support our requirement

gowthamgopal24
2023-09-05 12:51
Sorry, I will try some ways to add the external dependencies to the PACT maven plugin and update you the progress @matt.fellows

matt.fellows
2023-09-05 12:52
Honestly, in your case, I would remove auth from the contracts - it sounds really messy. I?d stub the authentication layer in your provider tests and move on.

matt.fellows
2023-09-05 12:54
Having to go to an external system during your Pact tests is a bit of a smell - the point of Pact tests is that they should be deterministic and reliable etc. You might find that running the AWS service locally would be a better use of your time - the tests will run faster, you?ll be able to test it locally, and the work to make it modular will make it more testable

yousafn
2023-09-05 12:58
Are you able to pair with your developers on this? You might find they will have a much easier time, co-ercing the code into a testable state. It is a good suggestion to consider mocking out the aws service locally, so you are isolating the provider under test from its own external deps. You can utilise tools such as localstack for this purpose

gowthamgopal24
2023-09-05 13:47
Hi @matt.fellows, Yeah, you are right We wanted to remove the auth part from the contract and populate it on the provider side, but our use case is that the same API. So wanted to test all the exact cases. So we will use an identifier from the client to mimic the same token on the provider side. So the flow goes like this 1. The client sends a header with the token identifier 2. During Verification, we will generate the token using the token identifier on the provider side I am using groovy script to populate the header with new fresh token. |

gowthamgopal24
2023-09-05 14:00
Hi @matt.fellows / @abubics / @rholshausen, Thanks for the help, I found the way to add external dependencies to the pact plugin I am able to import libraries in groovy script. I will complete my testing and will keep you guys posted.

alejandro.pena
2023-09-05 14:34
Yeah, we have people working on a library to automate the generation of the body validations. I'll keep you posted.

callum.atkinson
2023-09-05 17:00
has joined #pact-jvm

emilie.bline
2023-09-05 22:27
has joined #pact-jvm

me1414
2023-09-06 12:37
has joined #pact-jvm

juantamosaitis2015
2023-09-06 13:24
has joined #pact-jvm

boer.k
2023-09-06 13:56
Hi, we are setting up consumer driven testing in our pipelines, and we are trying to replicate a scenario where the provider test fails. I do this by simply asserting 1 equals 2 in the test function. But I dont understand why there is still an OK result being sent to the broker.

boer.k
2023-09-06 14:04
Strangely enough, if the test fails through an exception thrown by context.verifyInteraction(), we get a proper Failed result sent to the broker. However, if an exception is thrown by the assertion below it, we get an OK result sent to the broker...?

ali.tariq
2023-09-06 14:51
has joined #pact-jvm

anas.zakarneh
2023-09-06 15:04
has joined #pact-jvm

jvillars
2023-09-06 17:53
has joined #pact-jvm

uglyog
2023-09-06 23:14
Can you raise a GitHub issue for this?

gowthamgopal24
2023-09-07 01:55
Hi @matt.fellows / @abubics / @rholshausen, I am able to do what we needed. Everything was done in groovy script. Dynamically added auth token to the request based on certain criteria in Headers.

matt.fellows
2023-09-07 02:02
Thanks for getting back to us! Did you update your answer to your SO question?

boer.k
2023-09-07 07:42
Alright

gowthamgopal24
2023-09-07 08:41
Yeah @matt.fellows


jorge.nunez
2023-09-07 23:30
Exactly the same problem here, @bas what did you do to fix? Thank you

kwongs
2023-09-08 01:45
has joined #pact-jvm

bas
2023-09-08 05:44
@jorge.nunez I?m still using Pact 4.4.x for the provider. Not the solution I prefer but as it?s for a workshop I?m running in just over a week it?ll do.

alicankarayelli
2023-09-08 10:43
has joined #pact-jvm

sgregory875
2023-09-08 12:23
has joined #pact-jvm

jorge.nunez
2023-09-08 12:23
oh... :pensive:

amagana
2023-09-08 22:40
has joined #pact-jvm

heverson.amorim
2023-09-09 10:43
has joined #pact-jvm

vdlre1994
2023-09-11 05:55
has joined #pact-jvm

rware4
2023-09-11 10:16
has joined #pact-jvm

hdjikine
2023-09-11 13:55
has joined #pact-jvm

andrea.paschal
2023-09-11 16:48
has joined #pact-jvm

tigrandza
2023-09-12 03:14
@tigrandza has left the channel

olof.stalnacke
2023-09-12 05:31
has joined #pact-jvm

nvangari
2023-09-12 05:39
has joined #pact-jvm

rksekar5
2023-09-12 12:30
has joined #pact-jvm

rohitkrishnan
2023-09-12 19:21
Could someone explain how the `key` of an interaction is determined? We're having an issue where running the same test twice creates _another_ interaction with the same JSON except the key is different.

rohitkrishnan
2023-09-12 20:04
I've narrowed it down to only happening when we have multiple parameters passed to the providerStates section. Seems eerily similar to https://github.com/pact-foundation/pact-reference/issues/264#issuecomment-1527472595

matt.fellows
2023-09-12 23:46
Could be. Perhaps related to non-deterministic ordering of such data structures?

rohitkrishnan
2023-09-12 23:47
Yeah could this be a Pact-GRPC plugin bug or in the JVM?

matt.fellows
2023-09-13 00:06
good question. Probably in JVM, but can?t be sure

matt.fellows
2023-09-13 00:07
I?d say JVM given it?s in the provider states though. Mind raising an issue please on the Pact JVM repo?

ying.li
2023-09-13 02:54
has joined #pact-jvm

rohitkrishnan
2023-09-13 11:38
Yep, will do! Thanks

nathan.deamer
2023-09-13 15:06
Hi All, I?m having problems with the gradle plugin and setting the `pact.filter.pacturl` property. I can?t see if its working. Using the junit5 style tests: ```@ExtendWith(SpringExtension.class) @Provider("provider-name-here") @SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT}) @PactBroker(url = "${PACT_BROKER_BASE_URL}", authentication = @PactBrokerAuth(token = "${PACT_BROKER_TOKEN}")) @IgnoreNoPactsToVerify public class ProviderPactTests { ... }``` And then my CICD pipeline rungs the provider pact tests using gradle plugin ```./gradlew test -Ppact.filter.pacturl=url-from-webhook -Ppact.filter.consumers=consumer-name --tests "*Provider*"``` I?d expect in the output for it to tell me it has applied the filter, but instead I get: ```Verifying a pact between ecom-booking-portal (b21f4285ced5cb513a3bddf579a3d54c2c2c419f) and ecom-booking-portal-service Notices: 1) The pact at https://xxx.pactflow.io/pacts/provider/ecom-booking-portal-service/consumer/ecom-booking-portal/pact-version/2aa8bcb012d1c007a5f867f3bed41a68f2688e56 is being verified because the pact content belongs to the consumer versions matching the following criteria: * consumer version(s) currently deployed to dev (b21f4285ced5cb513a3bddf579a3d54c2c2c419f), ext (b21f4285ced5cb513a3bddf579a3d54c2c2c419f) and production (b21f4285ced5cb513a3bddf579a3d54c2c2c419f) * latest version of ecom-booking-portal from the main branch 'main' (b21f4285ced5cb513a3bddf579a3d54c2c2c419f) [from Pact Broker https://xxx.pactflow.io/pacts/provider/ecom-booking-portal-service/consumer/ecom-booking-portal/pact-version/2aa8bcb012d1c007a5f867f3bed41a68f2688e56/metadata/c1tdW2N2XT0xMjUwMCZzW11bY3ZdPTEyNTAwJnNbXVtjdl09MTI1MDAmc1tdW2N2XT0xMjUwMA]``` Where I can see it is checking the deployed versions and latest main.

nathan.deamer
2023-09-13 15:36
``` 16:35:24.477 [Test worker] DEBUG au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$Companion - Verifying pacts for provider 'ecom-booking-portal-service' and consumer 'null'``` Consumer `null` from the debug lines looks like it is ignoring the properties: ```pact.filter.consumers=ecom-booking-portal```

nathan.deamer
2023-09-13 15:59
``` [Test worker] DEBUG au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader$Companion - Loading pacts from pact broker for provider ecom-booking-portal-service and consumer version selectors []```

nathan.deamer
2023-09-13 16:04
My theory is should now be using these instead: https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors ?

nathan.deamer
2023-09-13 16:30
Or maybe it is as easy as adding `@AllowOverridePactUrl` to my provider test! :see_no_evil:

rholshausen
2023-09-14 06:35
This won't work `./gradlew test -Ppact.filter.pacturl=url-from-webhook -Ppact.filter.consumers=consumer-name --tests "*Provider*"` as it sets the property in the Gradle build but not in the tests


rholshausen
2023-09-14 06:42
You need to pass the project property though to the test JVM by doing something like: ```test {```

rholshausen
2023-09-14 06:42
```test { systemPropety 'pact.filter.pacturl', project.property('pact.filter.pacturl') }```

matt.fellows
2023-09-14 06:51
Thanks Ron!

nathan.deamer
2023-09-14 07:12
I made it work by: ```test { useJUnitPlatform() systemProperties System.properties }``` And then setting the properties with the `-D` flag

nathan.deamer
2023-09-14 07:13
Is there another way I can allow override pact url - without having to go into every project and add the annotation to my provider tests?

edeandre
2023-09-14 12:35
Question - when I?m building my consumer contract test I specify a json body in an HTTP `POST` operation. The actual json that gets sent has some extra fields in it that the server shouldn?t care about, but the mock server does not match it (I?m getting a `PartialRequestMatch`). Is there a way I can tell the request body matcher to allow extra keys in the json?

david.hodnett
2023-09-14 18:06
has joined #pact-jvm

matt.fellows
2023-09-14 22:19
Just include them and let the provider deal with it. If the server ignores them then no problem, if it causes an issue then you've found a bug. If you really don't need them there, I guess you could post process the JSON and remove them?

matt.fellows
2023-09-14 22:21
But to my knowledge, I don't think such a thing exists

abubics
2023-09-15 00:06
also, the mock should be matching on method & path & query?not body

jonatan.bjork
2023-09-15 13:30
has joined #pact-jvm

jonatan.bjork_test1
2023-09-15 13:41
has joined #pact-jvm

you1
2023-09-15 13:41
has joined #pact-jvm

jonatan.bjork_test2
2023-09-15 13:42
has joined #pact-jvm

you1634
2023-09-15 13:43
has joined #pact-jvm

edeandre
2023-09-15 19:55
what i?m saying though is that it does not match

edeandre
2023-09-15 19:55
if i send extra fields in the request the matcher does not match and the test fails

m_testnewinvite
2023-09-17 22:43
has joined #pact-jvm

abubics
2023-09-17 23:36
By default, it does allow extra fields. Maybe can you paste the test code, so we can see what might be wrong?

matt.fellows
2023-09-18 01:40
Are you sending extra fields, but not specifying those extra fields in the test? If so, that will cause a consumer test failure, yes. If you could share the test/setup that would definitely help

georg.duemlein
2023-09-18 04:09
has joined #pact-jvm

georg.duemlein
2023-09-18 04:10
@georg.duemlein has left the channel

sam647
2023-09-18 14:37
has joined #pact-jvm

rohitkrishnan
2023-09-18 15:10
How does one enable trace logging for pact-jvm (or pass a custom logger)? I noticed `DefaultPluginManager.logger.underlyingLogger` is set to `NoOpLogger` .

uglyog
2023-09-18 23:16
Pact-JVM uses SLF4J. Any complaint SLF4J implementation can be used. Logback is the recommended one.

edward
2023-09-19 07:24
has joined #pact-jvm

dbc216
2023-09-19 14:17
has joined #pact-jvm

harwin1494
2023-09-19 15:14
Hi Team, I have a json response which contains an array object and I am trying to validate it using `eachLike`, but once the interaction.json file is created, it shows the entire response inside of that array object.

tan.k.h.usa
2023-09-20 00:31
has joined #pact-jvm

rholshausen
2023-09-20 00:31
Can you provide your test code to show what you are doing?

harwin1494
2023-09-20 05:57
@rholshausen ```PactDslJsonBody body = new PactDslJsonBody() .stringType("id") .stringType("summary") .eachLike("arrayData") .stringType("id") .stringType("formatCode") .booleanType("Price") .booleanType("permissionsAvailable")```

harwin1494
2023-09-20 05:58
the contract file considers even the `booleanType` parameters as a part of `arrayData` object, which they are not.

rholshausen
2023-09-20 06:24
You're missing a `.closeArray()` after `.stringType("formatCode")`

harwin1494
2023-09-20 06:26
when I add `.closeArray()`, intellij starts throwing error from the next line, i.e. `booleanType("Price")`


harwin1494
2023-09-20 06:33
can you share the link of the api response for which this is written?

uglyog
2023-09-20 06:58
Sorry, no

uglyog
2023-09-20 06:58
We don't have an api response for that

harwin1494
2023-09-20 06:59
okay, I am struggling a bit to write consumer test for a response containing an array, not sure exactly which matcher to use.

daniel.hyun.chae
2023-09-20 13:19
has joined #pact-jvm

harwin1494
2023-09-21 06:31
Hi team, I am getting the following error while trying to use this array matcher in the consumer test :- `JSON parse error: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`)` `"sample": [` `"sample1",` `"sample2"` `],`

uglyog
2023-09-21 06:36
Why have you got maxArrayLike inside another array?

harwin1494
2023-09-21 06:37
It is just one of the tries to get it working!

harwin1494
2023-09-21 06:38
because `eachLike("sample")` does not seem to work

uglyog
2023-09-21 06:51
Is this not what you need? ```> import au.com.dius.pact.consumer.dsl.PactDslJsonBody > > new PactDslJsonBody('$', "test", null) > .eachLike("sample", 2) > .stringType("name", "sample1") > .closeObject() > .closeArray() Result: {"sample":[{"name":"sample1"},{"name":"sample1"}]}```

harwin1494
2023-09-21 06:56
:point_up_2:not working at my end

harwin1494
2023-09-21 06:57
the array in my case only has values, as you can see in the code that I have shared, it doesnt have a key-value pair inside `sample`

uglyog
2023-09-21 07:03
```> import au.com.dius.pact.consumer.dsl.PactDslJsonBody > import au.com.dius.pact.consumer.dsl.PactDslJsonRootValue > > new PactDslJsonBody('$', "test", null) > .eachLike("sample", PactDslJsonRootValue.stringType("sample1"), 2) Result: {"sample":["sample1","sample1"]}```

harwin1494
2023-09-21 07:16
@uglyog this one worked, thank you:pray:! what if we dont want to specify the number of values , since the response is dynamic?

uglyog
2023-09-21 07:18
eachLike uses a fixed number of values in the consumer test, but can match any number of values

harwin1494
2023-09-21 07:19
okay got it, thank you for saving the day:pray:

harwin1494
2023-09-21 07:31
@uglyog getting another issue now, since there is an array of objects just above this array, which I am trying to validate and I am getting this error Do I need to use `.object()` here?

uglyog
2023-09-21 07:33
Missing bracket

harwin1494
2023-09-21 07:34
added, but the error is still here

harwin1494
2023-09-21 08:09
its working now, placed it above the array of objects, thanks!

jake.corn
2023-09-21 14:01
has joined #pact-jvm

karl980
2023-09-21 16:44
has joined #pact-jvm

doctormiguel
2023-09-22 14:31
has joined #pact-jvm

felipe.simoes702
2023-09-22 17:37
has joined #pact-jvm

suat.kose
2023-09-22 22:13
has joined #pact-jvm

marius.grigoriu
2023-09-23 15:33
has joined #pact-jvm

noahmcivor
2023-09-24 06:54
has joined #pact-jvm

matt.fellows
2023-09-24 23:26
Anybody know how to answer https://stackoverflow.com/questions/77161717/how-to-verify-field-of-type-byte-array-byte-through-pact-jvm. If the entire body is binary, we can use the `withBinaryData` method, but not sure how to represent a field.

rholshausen
2023-09-25 00:51
JSON does not have a type for byte arrays, so there is no way we can know how it is encoded

matt.fellows
2023-09-25 01:55
LOL Monday morning brain on my side :laughing:

matt.fellows
2023-09-25 01:56
One long weekend and I forget how the Internet works.

marek19922209
2023-09-25 08:09
has joined #pact-jvm

corey_maynard
2023-09-25 20:07
has joined #pact-jvm

rammohan_mididoddi
2023-09-25 20:12
has joined #pact-jvm

kevin
2023-09-26 02:31
has joined #pact-jvm

michael.lemos1
2023-09-26 12:36
has joined #pact-jvm

michael.lemos1
2023-09-26 12:40
Hello all, I need some help with an issue I am having after upgrading a few libs on a project including pact and I started getting this on our pipeline ```n plugin 'au.com.dius.pact' type 'au.com.dius.pact.provider.gradle.PactPublishTask' property 'pactPublish' doesn't have a configured value.```

michael.lemos1
2023-09-26 12:42
build.gradle looks like this

uglyog
2023-09-26 23:10
Try move the pact block before `runAndPublishConsumerPactTests`

sliu
2023-09-27 00:00
has joined #pact-jvm

michael.lemos1
2023-09-27 06:40
downgrading the version to 4.1.x fixed it, no idea why

ankush.hasani
2023-09-27 10:01
has joined #pact-jvm

pavikrish
2023-09-27 12:22
Hi I'm using gradle plugin to verify pact. Instead of configuring version property under serviceProviders in build.gradle, I would like to set pact.provider.version in runtime while invoking the gradle task. I'm trying with ./gradlew pactVerify -Dpact.provider.version=<PROVIDER_VERSION> But this is not working. Can someone help?

kai
2023-09-27 15:31
has joined #pact-jvm

rholshausen
2023-09-27 23:52
What version of Pact-JVM and Gradle are you using?

a.monteiro
2023-09-28 09:59
has joined #pact-jvm

ml210993
2023-09-29 05:12
has joined #pact-jvm

ml210993
2023-09-29 05:14
Hey, maybe someone can help me.. when upgrading pact from 44.9 to 4.6.3 I suddenly get Groovyc: While compiling [tests of java-backend-blueprint.test]: java.lang.NoClassDefFoundError: io.pact.plugins.jvm.core.PactPlugin. Tried clearing, rebuilding etc

prempooon.hc
2023-09-29 11:35
has joined #pact-jvm

jaishankar.nedunchezh
2023-09-29 17:07
has joined #pact-jvm

devin.woods
2023-09-29 19:28
has joined #pact-jvm

devin.woods
2023-09-29 19:32
Is it expected that a NoPactsFoundException would be thrown when the only Pacts available in the Pact-broker are already verified? I am seeing strange, seemingly sporadic behavior when running Pact tests from my provider side. Sometimes it works, but most of the time when I run the provider tests I get the following error: ```au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify Provider: MY-PROVIDER Consumer: MY-CONSUMER``` I've spent a few days on this, and now I am wondering if the issue isn't actually a failure to find Pacts, but a failure of finding Pacts that need to be verified by the provider. After I publish Pacts to the broker from my consumer, I trigger a pipeline in the consumer repo, which seems to always pass 100% of the time. But, when my provider repo initiates the job to verify the Pacts, I will see this exception. If this is expected, I think that adding the `IgnoreNoPactsToVerify` annotation would fix this. Wondering if this is by design, or if I have a bug somewhere. Thanks for the help!

andrevdrodrigues
2023-09-29 19:56
Hey folks! Im trying to use some matcher for v4 specification to check if one value is greater than other. I checked the documentation but I didn?t find references for that? Does anyone knows if is there some available matcher for this in java? Thanks guys.

bas
2023-09-29 21:54
As in ?I?m expecting the provider to include a field ?numberOfBananas? in the response with a value greater than 5?? That sounds an awful lot like something that the provider team should verify in their own tests, not something that should be part of a contract test. I?m sure a matcher like that could be added if it isn?t there already, but I?m not sure it?s a good idea..

vittorio.gue
2023-09-30 10:51
has joined #pact-jvm

matt.fellows
2023-10-01 02:12
If it can't find pacts to verify it could be one of a few things. If it's intermittent that sounds like the selectors you are using aren't finding anything. It would help to understand your setup - what selectors you're using and how your consumers are publishing and adding branch info etc

matt.fellows
2023-10-01 02:13
Also have you read the CI/CD setup guide? (howtolearn)

2023-10-01 02:13
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

matt.fellows
2023-10-01 02:20
It's a bit of a grey area between contract and functional testing. The question to ask here is "must this value be greater than a certain number to ensure the consumer works". If the answer is no then the check is too restrictive of the provider and belongs in a functional provide test as Bas mentions

honglu11
2023-10-01 16:47
has joined #pact-jvm

andrevdrodrigues
2023-10-02 06:17
Yes, exactly? Its a grey area. Thanks for the tips, guys :slightly_smiling_face:

idd90i
2023-10-02 10:37
has joined #pact-jvm

jamie.weatherby
2023-10-02 13:12
@jamie.weatherby has left the channel

devin.woods
2023-10-02 16:43
Thanks for the reply, Matt. Here is a little more context on our setup: From reading the documentation, I believe we have achieved https://docs.pact.io/pact_nirvana/step_5 :slightly_smiling_face: Repo A is the consumer. We write and publish Pacts to our Pactbroker (not self hosted) on merge requests. After we publish, we trigger a multi-project pipeline in Gitlab to Repo B, which is a provider. Repo B, in the same commit for the pipeline, will bring up their service and run the Pact tests. We pass them a variable which tells them which branch we are working on, so they can fill this into a ConsumerVersionSelector. From our testing, we see that this pipeline will always find Pacts to verify (no NoPactsFoundException), and verify them successfully. When we merge to our main branch, this runs, and updates the latest branch selector for `mainline`. We are hitting the issue I described above when Repo B runs their Pacts as a part of their normal pipeline flow. When they are running their Pact verify job (which stands up the service and runs the pacts), they always point at our `mainline` branch.

matt.fellows
2023-10-02 23:18
Thanks, can you please confirm the selectors you?re using in the ?normal? pipeline? That?s probably the issue.

nathan
2023-10-03 00:43
has joined #pact-jvm

honglu11
2023-10-03 04:37
Hi when I play around pact-workshop project, I see this error when run test, any clue how to fix it?

honglu11
2023-10-03 04:38
```$ ./gradlew provider:test --tests *Pact*Test > Task :provider:test au.com.dius.pactworkshop.provider.ProductPactProviderTest > FrontendApplication - get all products FAILED java.lang.AssertionError at PactJUnit5VerificationProvider.kt:332 Caused by: au.com.dius.pact.provider.junitsupport.MissingStateChangeMethod at PactJUnit5VerificationProvider.kt:392 2023-10-02 17:36:19.260 INFO 39068 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' 5 tests completed, 1 failed > Task :provider:test FAILED```

matt.fellows
2023-10-03 04:38
Is that a command used in the workshop?

jonathan.ryding
2023-10-03 12:02
has joined #pact-jvm

pavikrish
2023-10-03 13:28
Thanks for your response @rholshausen. I'm using gradle pact plugin version 4.3.10 and my gradle version is 7.6

devin.woods
2023-10-03 16:23
In Repo A (consumer), we always trigger the multi-project pipeline against Repo B's `develop` branch (this is the main branch for their repo) and pass in a variable which gets passed into their selector code: ``` @PactBrokerConsumerVersionSelectors fun consumerVersionSelectors(): SelectorBuilder { val selectorBuilder: SelectorBuilder = SelectorBuilder() return selectorBuilder.branch(System.getProperty("consumer.branch", "mainline"), "SOS") }``` In Repo B (provider), as a part of their MR pipeline, they always point to Repo A's `mainline` branch (this is the main branch for our repo). This is what makes me wonder if I have my mental image of the flow wrong. Whenever Repo A has an MR, we publish the new pacts and immediately ask Repo B to verify.

devin.woods
2023-10-03 18:06
The code sample posted above is in our Provider repo

sashi.kandru
2023-10-03 19:46
Hi Team, In contract testing (using Pact-JVM for a Java project), is there a way to leverage/reuse existing model classes in pacts?For example, there might already be model classes to represent the request/response. With the Pact https://docs.pact.io/implementation_guides/jvm/consumer#dsl-usage, it seems you would have to maintain the pact in parallel to the model classes you already have

corey_maynard
2023-10-03 20:24
@corey_maynard has left the channel

matt.fellows
2023-10-03 23:05
You may want to register / attend the event in week 4 of Pactober: https://pact.io/pactober#schedule

matt.fellows
2023-10-03 23:10
Thanks. Hard to say without seeing the branch/tag information associated with the consumer pacts. I?m assuming you?ve read https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors? You could probably just use `mainBranch` (that way the provider need not hard code the consumer?s branch). You probably also want `deployedOrReleased` (see https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors#recommended). If that?s not catching the right stuff, then: 1. there is no branch information on the consumers and they aren?t deployed to any environment 2. there is a bug somewhere To identify (2), we?d need at least some view of the matrix - are you using the OSS Pact Broker or PactFlow?

gabe.hollombe
2023-10-04 03:17
has joined #pact-jvm

pratyusha.boyapati
2023-10-04 08:35
has joined #pact-jvm

mateusz.socha
2023-10-04 10:41
has joined #pact-jvm

pavikrish
2023-10-04 15:24
Can anyone help on this?

maja.vitaz
2023-10-05 10:37
has joined #pact-jvm

martindjk92
2023-10-05 13:05
has joined #pact-jvm

james814
2023-10-05 20:24
has joined #pact-jvm

craig.kilpatrick
2023-10-06 00:33
has joined #pact-jvm

prabakaranplaced
2023-10-06 08:00
has joined #pact-jvm

likekeys
2023-10-06 14:22
has joined #pact-jvm

chris.odryna
2023-10-06 16:51
has joined #pact-jvm

rezaur.rahman
2023-10-06 17:39
has joined #pact-jvm

julie.laursen
2023-10-06 17:43
has joined #pact-jvm

pratibha.kachi
2023-10-06 20:02
has joined #pact-jvm

robert579
2023-10-06 20:22
has joined #pact-jvm

rana
2023-10-08 07:54
Hi guys, sorry if this is not the right channel - Is there a best practice/formal way to test provider states? I mean the state functions themselves, that receive input and set up the required data. Thanks!

matt.fellows
2023-10-08 09:00
Are you asking how to _test_ the provider states or best practice using them?

rana
2023-10-08 12:03
@matt.fellows Hi, yes I am asking how to test them, meaning without going through a full cycle of developing a consumer that will use and send pacts with these states.

matt.fellows
2023-10-08 12:18
That's a good question. I mean, one strategy is to have the provider define the states they support and then the consumer can use them.

bas
2023-10-08 15:52
Wouldn?t this be covered by the tests that the provider runs on their implementation anyway? I mean, your provider _is_ testing their implementation, right? Right? Example: if a specific provider state requires a data entity (an order, an address, whatever) to be present in the database, I?m hoping that there?s already: ? a method or route in the provider implementation that takes care of this ? at least one test that verifies that this method or route actually does what it says on the tin If you then call that method or invoke that route in your provider state method, does it really need additional testing? Or am I thinking too simple / missing something here?

matt.fellows
2023-10-09 01:16
> Wouldn?t this be covered by the tests that the provider runs on their implementation anyway? I mean, your provider _is_ testing their implementation, right? Right? :laughing: I hope so! I was confused by the question also. My suspicion is that the issue is that a consumer can come along and define a new state the provider hasn?t seen before, and Ran is looking for a better way to approach this to avoid the additional communication overhead. That?s an issue we are looking to improve (e.g. via https://pact.canny.io/feature-requests/p/list-provider-states-for-a-provider) There is no real need to test a provider state though - the end goal is to have the provider test work, it?s somewhat irrelevant if the provider state handlers themselves work or not

sbalaranganathan
2023-10-09 12:10
has joined #pact-jvm

honglu11
2023-10-09 17:28
yes

henrik
2023-10-09 18:15
has joined #pact-jvm

johnkavadias
2023-10-10 09:37
has joined #pact-jvm

jose-antonio.cano
2023-10-10 16:21
has joined #pact-jvm

gowthamgopal24
2023-10-11 04:29
Hi Team, We have created a standalone service for contract testing. This helps the consumer to verify the contracts against different providers. Now I also wanted to verify the provider when a new code is deployed by Provider service. What is the best way to verify the contracts when provider deploys? I wanted to keep the code changes minimal at provider side or no code change at all. We have multiple providers so implementing at every provider side is too costly process. Can someone help on this? Thanks in Advance !!

bas
2023-10-11 04:45
What do you mean when you say ?this helps the consumer to verify the contract?? In consumer-driven contract testing, consumers generate a contract, they don?t verify it. One potential downside of CDCT is indeed that it can be difficult to get providers on board. Have you looked at bidirectional contract testing as a potential solution to this problem? https://pactflow.io/bi-directional-contract-testing/

gowthamgopal24
2023-10-11 04:48
Hi @bas, What I meant was, they create the contracts and Broker helps us to verify it. The Service which we created help the consumer to check the contracts. I need to use PactFlow to do bidirectional testing. But I am trying to achieve this through PACT Broker. Is that possible?

bas
2023-10-11 04:50
No, that?s a Pactflow only feature.

gowthamgopal24
2023-10-11 05:05
okay @bas Thank you !! :slightly_smiling_face:

matt.fellows
2023-10-11 06:35
> We have created a standalone service for contract testing. can you please elaborate on this - what is it, exactly?

prerit.jain849
2023-10-11 06:56
Hey team, we are setting up contract testing for a messaging service using Kafka. It's using Avro schema registry. We are following this https://docs.pact.io/recipes/kafka for the implementation & Its failing right now when it tries to deserialize the message on provider side with some unknown characters in actual deserialized message. Do you have any examples for avro schemas or anyone aware of such issue and how we set a deserializer for provider message.

matt.fellows
2023-10-11 06:58
You will need to use a plugin for this. @ali.ustek from the community has created https://github.com/austek/pact-avro-plugin/ for just this purpose

gowthamgopal24
2023-10-11 08:42
Hi @matt.fellows, This is nothing but the service which has information about all the providers, so this will run the verification command, We took the verification functionality out from the Provider and running it as a standalone one.

gowthamgopal24
2023-10-11 08:44
It would be really helpful if you the Pact broker allows provider side verification as well. We will be ready to buy a licensed version of it and use it in our own Server.

matt.fellows
2023-10-11 09:17
> It would be really helpful if you the Pact broker allows provider side verification as well. We will be ready to buy a licensed version of it and use it in our own Server. I?m confused by this. > What I meant was, they create the contracts and Broker helps us to verify it. The Service which we created help the consumer to check the contracts. If I understand correctly, are you using this service to be trigger if a consumer contract is published, which then runs the provider verifier (CLI or docker) against a live system? And further, you?re requesting that PactFlow (or otherwise) build this feature as a commercial capability you?re willing to pay for? > I need to use PactFlow to do bidirectional testing. But I am trying to achieve this through PACT Broker. Is that possible? as Bas said, no this is a commercial feature (available on SaaS and on-prem)

matt.fellows
2023-10-11 09:17
> We took the verification functionality out from the Provider and running it as a standalone one. what problem are you trying to solve?

panagiotis.liaros
2023-10-11 10:15
has joined #pact-jvm

ananya
2023-10-11 10:38
has joined #pact-jvm

omar.sakka
2023-10-11 14:38
has joined #pact-jvm

brandon.king
2023-10-11 18:35
has joined #pact-jvm

sridhar.nayakwadi
2023-10-11 20:56
has joined #pact-jvm

saroja.bhogadhi
2023-10-11 20:58
has joined #pact-jvm

magesh.nagamani
2023-10-12 08:46
Hello Community does PACT has built-in reporting support? I use pact-jvm junit5

bas
2023-10-12 08:59
What kind of reporting are you looking for? The Pact Broker / Pactflow contains all the information you need around contract verification, for 'plain' test results you can get these from your test runner (JUnit or TestNG).

matt.fellows
2023-10-12 09:01
Yep.

magesh.nagamani
2023-10-12 09:05
Thanks for your reply. I just wanted to know do we have any other way of viewing the test results apart from pact broker dashboard. I'm good now.

chris.paul
2023-10-12 15:54
has joined #pact-jvm

chris.paul
2023-10-12 16:03
hi, was there ever an answer on this? I?m interested in generating pact matchers from a POJO. `pact-consumer-builder` doesn?t support kotlin data classes and I think the project is quite old.

yousafn
2023-10-12 16:04
Hey @chris.paul, You may want to tune into this https://pact.io/pactober/2023/pact-jvm-dsl as the OP of the linked thread will be hosting

chris.paul
2023-10-12 16:05
ah great so it sounds like there?s something in the works? I?ve been getting to grips with pact. I think it?s great in principle but I?m going to struggle if I have to maintain pact matchers by hand as well as POJOs for tests

ryan.standley
2023-10-12 17:34
has joined #pact-jvm

joseph
2023-10-12 20:58
has joined #pact-jvm

laurie.green
2023-10-12 22:46
has joined #pact-jvm

stephen.taylor
2023-10-13 09:00
Hey folks, hope this is the right place for advice. I'm trying to set up two interactions in a single PACT (I think - unless I've misunderstoood the terminology). One is the success response, and one is 400 if headers are missing. I thought I'd be able to do this in one builder, but it doesn't work. ```builder .given("default state") .uponReceiving("A request for GET limits") .path(URL_PAYMENTS_SERVICE_LIMITS) .method(HttpGet.METHOD_NAME) .headers( HEADER_X_INFO, getIdentifier( id = FAKE_ID, firstName = FAKE_FIRST_NUMBER, lastName = FAKE_LAST_NAME ) ) .willRespondWith() .status(200) .body(PactDslJsonBody().apply { integerType("limits", 111111L) }) .uponReceiving("A request for GET limits with no headers") .path(URL_PAYMENTS_SERVICE_LIMITS) .method(HttpGet.METHOD_NAME) .willRespondWith() .status(400) .body(PactDslJsonBody().apply { stringType("errorMessage", "error in request") }) .toPact()``` I can get my tests to work when I split this into two separate pacts. However, there's something about that that doesn't make sense to me. I basically just want an 'else' case should the request be missing the vital header info... Can anyone advise?

matt.fellows
2023-10-13 09:05
each request should be tested in isolation (think of it as closer to a unit test, rather than a test that checks multiple scenarios at one).

stephen.taylor
2023-10-13 09:11
Thanks Matt. So I need to specify a specify a separate builder for each?

matt.fellows
2023-10-13 09:21
Each request ideally should be tested in isolation, yes

nikesh1123
2023-10-13 10:32
has joined #pact-jvm

imthu55
2023-10-13 11:05
has joined #pact-jvm

bas
2023-10-13 11:15
As Matt already said, it's better to put those in separate `@Pact` methods. Don't think of them as an 'else' to your happy path, think of them as a separate interaction instead. Having them separated also makes finding the root cause of an error much easier, because you can see exactly which interaction is defined where and which ones passes and fails. Tests should ideally fail for one reason only, and having if-then-else in your tests (either explicit or more implicit like here) is somewhat of an antipattern, at least to me

dzianis_frydliand
2023-10-13 12:36
has joined #pact-jvm

john.maynard
2023-10-13 14:35
has joined #pact-jvm

ashish_garg5
2023-10-13 16:58
Hi All, I have added a header in my request now wanted to verify this in provider test. How do I make sure that response from the provider should be in "en-US" only ? "headers": { "Accept-Language": "en-US" } Thanks in advance. Getting the below error when trying to add in provider test - ```org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [org.apache.http.HttpRequest request] in method [...pactVerificationTestTemplate(au.com.dius.pact.provider.junit5.PactVerificationContext,org.apache.http.HttpRequest)].```

bas
2023-10-13 17:11
So, the Accept header is a consumer header, you don?t exactly verify that at the provider. If you want to be sure that the provider responds in a certain way when the Accept header doesn?t have the right value, make that an interaction. Or better, test that in the provider team, not with a contract test.

ashish_garg5
2023-10-13 17:12
Ok got it. Thanks for the explanation.

bas
2023-10-13 17:13
Sorry, I said Accept, but the same applies to the Accept-Language header. My bad.

ashish_garg5
2023-10-13 17:15
Yeah np thanks :slightly_smiling_face:

magesh.nagamani
2023-10-14 07:16
Hello Community I was exploring PACT with pact-jvm and junit5 Just playing around with free api's to build contract tests - https://reqres.in/ I've successfully wrote consumer test for one interaction, pact contract generated successfully (attached pact file) I've also setup the provider side test. When I run the provider side tests, I'm getting error (Refer image-providerError) Need help to understand what went wrong here.

vittorio.gue
2023-10-14 08:47
Hey @magesh.nagamani it looks like your provider is returning 522! It seems to be a problem related to the provider server! Did you check that the server is running correctly?

magesh.nagamani
2023-10-15 04:42
Yes, The server is up

cmuddam.testing
2023-10-15 06:46
has joined #pact-jvm

magesh.nagamani
2023-10-15 07:36
I resolved the error by setting up the target pointing to the URL directly. Got this info from PACT official documentation

rholshausen
2023-10-15 21:33
Think of the test as setup there as an AND. You are saying you expect to make a request to the URL_PAYMENTS_SERVICE_LIMITS and get a 200 and a 400 response.

rholshausen
2023-10-15 21:34
That is why two different tests are needed, because they are two different responses to the same request

ali.ustek
2023-10-15 22:20
Hi matchers have changed in version 4.6.1 `MatchingRuleDefinition.parseMatchingRuleDefinition("matching(equalTo, '\u0000\u0001\u0002\u0003')")` produces in 4.6.0 `Ok(value=MatchingRuleDefinition(value=\u0000\u0001\u0002\u0003, valueType=Unknown, rules=[A(value=http://au.com.dius.pact.core.model.matchingrules.EqualsMatcher@192d74fb)], generator=null))` and in 4.6.1 `Ok(value=MatchingRuleDefinition(value=, valueType=Unknown, rules=[A(value=http://au.com.dius.pact.core.model.matchingrules.EqualsMatcher@295eaa7c)], generator=null))` is the change intentional?

ali.ustek
2023-10-15 22:22
Sorry non-printable chars

rholshausen
2023-10-15 22:23
Yes, in 4.6.0 the string escaped where not processed correctly, so the value was set verbatim. For instance, `'\''` would fail

matt.fellows
2023-10-15 22:56
Has this caused a break to the plugin, or failing an assertion in a test that checked the defined matcher?

rana
2023-10-16 06:19
Thanks for the reply guys. I really did not explain myself properly :slightly_smiling_face: My goal is to run verification tests, locally - one of the reasons is I want any function with @State to be tested. If I can run my verification tests locally, I could provide pacts and catch any logical mistakes I might have there. My question is - using your libraries, given a static pact file and a running service (locally), is there a way I could load the pact and manually trigger verification tests using this pact?

matt.fellows
2023-10-16 06:29
Yes, you can pass a file to a local verification

matt.fellows
2023-10-16 06:30
> ? have the broker trigger the provider > the broker (running in the cloud or somewhere else) is not going to trigger the verification on your machine, no

rana
2023-10-16 06:35
> Yes, you can pass a file to a local verification How?


matt.fellows
2023-10-16 06:44
(I have shared the JUnit ones, but perhaps you need another)

rana
2023-10-16 06:50
will read again, thanks!

ali.ustek
2023-10-16 08:43
The tests for the plugin are failing for Avro FIXED fields

magesh.nagamani
2023-10-16 09:19
In addition to @bas answer, we can generate additional report using @`VerificationReports` @VerificationReports({"console", "markdown","json"}) _public_ _class_ MyPactTest {...} More info - https://docs.pact.io/implementation_guides/jvm/provider/junit

ali.ustek
2023-10-16 11:04
Also, for the BYTES fields

ali.ustek
2023-10-16 11:05
As I was using ```"\u0000\u0001\u0002\u0003\u0004\u0005"``` notation to workaround passing bytes to protobuf using strings and storing that in the pact file

ianlutz
2023-10-16 23:34
Hi, i am trying to understand the meaning of these warnings, and what deleterious effects i should expect ```2023-10-17 06:35:39 [XNIO-1 task-1] INFO o.s.web.servlet.DispatcherServlet - Initializing Servlet 'dispatcherServlet' 2023-10-17 06:35:39 [XNIO-1 task-1] INFO o.s.web.servlet.DispatcherServlet - Completed initialization in 1 ms returns a response which has status code 200 (OK) has a matching body (OK) 2023-10-17 06:35:39 [Test worker] WARN a.c.d.p.p.DefaultTestResultAccumulator - Not all of the 4 were verified. The following were missing: 2023-10-17 06:35:39 [Test worker] WARN a.c.d.p.p.DefaultTestResultAccumulator - Some pot report 2023-10-17 06:35:39 [Test worker] WARN a.c.d.p.p.DefaultTestResultAccumulator - Some provider-finder report 2023-10-17 06:35:39 [Test worker] WARN a.c.d.p.p.DefaultTestResultAccumulator - some-icsd-report-that-throws-an-exception 2023-10-17 06:35:39 [Test worker] INFO a.c.d.p.p.j.PactVerificationStateChangeExtension - Invoking state change method 'pot-report-exists':SETUP``` I have 4 interactions. They all seem to run. As in I can see they actually hit the http endpoint and the the endpoints return data. I can make the test fail by changing the provider to return stuff it shouldn't; thats expected. So why do i get these warnings, they are verified ? The warning repeats with 1 less interaction until all 4 are done. Is this expected ?

rholshausen
2023-10-16 23:47
You can ignore those, unless your test fails, then you would want to look at those messages to understand the sequence of events

ianlutz
2023-10-16 23:51
Okies, thanks :slightly_smiling_face: tho, I do like to eliminate warnings :disappointed:

david.vadkerti.toth
2023-10-17 08:28
has joined #pact-jvm

shirley.houter
2023-10-17 08:52
has joined #pact-jvm

ruth.kurniawati
2023-10-17 20:02
has joined #pact-jvm

balaaji196
2023-10-18 10:46
has joined #pact-jvm

mpokala
2023-10-18 20:37
has joined #pact-jvm

hiroki.gota
2023-10-18 22:26
has joined #pact-jvm

mattisrobin
2023-10-18 22:37
has joined #pact-jvm

silvimasss
2023-10-18 23:43
has joined #pact-jvm

wanghedi88
2023-10-19 11:16
has joined #pact-jvm

sarah.diendorfer
2023-10-19 12:34
has joined #pact-jvm

ahmed.elakour
2023-10-19 12:35
has joined #pact-jvm

parmin.rock
2023-10-19 14:57
has joined #pact-jvm

victor.yusuf
2023-10-19 14:58
has joined #pact-jvm

luke.dove
2023-10-19 15:46
has joined #pact-jvm

lee.andrews
2023-10-19 15:52
has joined #pact-jvm

mitchellp
2023-10-19 16:06
has joined #pact-jvm

mickelback00
2023-10-19 22:25
has joined #pact-jvm

philip.buttinger
2023-10-20 10:36
has joined #pact-jvm

adrian.kosyra
2023-10-20 11:58
has joined #pact-jvm

andrevdrodrigues
2023-10-20 13:00
Hi team. I have one contract very big with many endpoints and my test class to the define the pact file is becoming huge. Does anyone know if is possible to generate the same contract using different test classes? Thanks.

bas
2023-10-20 13:12
Hey Andre, if you keep the consumer identification consistent, you should be able to break up the tests into separate classes. Here?s an example: https://github.com/basdijkstra/introduction-to-contract-testing/tree/main/customer-consumer/src/test/java/customer If I run the tests in this project using Maven, all interactions end up in a single contract file, even though they?re split into two separate classes.

andrevdrodrigues
2023-10-20 13:13
ok, thanks!

dave.hooson
2023-10-20 15:13
has joined #pact-jvm

pavankumar.cse88
2023-10-20 17:58
has joined #pact-jvm

pavankumar.cse88
2023-10-20 17:59
Hi Team I am trying to write test for one of the service using Junit, I am able to generate contract but when I hit the atual end point from pom.xml I am getting below This is my contract ```{ "provider": { "name": "GetTokenServiceProvider" }, "consumer": { "name": "GetTokenServicePConsumer" }, "interactions": [ { "description": "Pact JVM example Pact interaction", "request": { "method": "GET", "path": "/v1/orders/stickerId", "headers": { "Content-Type": "application/json" } }, "response": { "status": 200, "headers": { "Content-Type": "application/json; charset=UTF-8" }, "body": { "stickerId": "string" }, "matchingRules": { "body": { "$.stickerId": { "matchers": [ { "match": "type" } ], "combine": "AND" } }, "header": { "Content-Type": { "matchers": [ { "match": "regex", "regex": "application/json(;\\s?charset=[\\w\\-]+)?" } ], "combine": "AND" } } }, "generators": { "body": { "$.stickerId": { "type": "RandomString", "size": 20 } } } }, "providerStates": [ { "name": "" } ] } ], "metadata": { "pactSpecification": { "version": "3.0.0" }, "pact-jvm": { "version": "4.0.10" } } }```

pavankumar.cse88
2023-10-20 19:08
POM.xml

pavankumar.cse88
2023-10-21 08:08
Hi Team, Can anyone suggest on how to fix this issue please

bas
2023-10-21 12:06
@pavankumar.cse88 can you show the part of your code where you set / determine the provider port number? Judging from the output, that?s some sort of complex object, but it should be an integer.

pavankumar.cse88
2023-10-21 12:19
And now I am getting different error as below

bas
2023-10-21 12:21
It defaults to port 8080 as you can see. I doubt your live service is running on that port (more likely 80 or maybe 443). Consult the docs to find out how to set a custom port number in your provider POM, I don?t know how to do that off the top of my head.

pavankumar.cse88
2023-10-21 12:30
okay @bas I will check about port, thanks for input

the.m.bjorklund
2023-10-21 21:05
has joined #pact-jvm

pavankumar.cse88
2023-10-22 09:19
Hi Team, My test is failing with date mismatch, how can write DSLbody with date type match And here is my DSL Can I get suggestion how match date with time stamp

thepiesaresquared
2023-10-22 09:58
has joined #pact-jvm

vasile.vetisan
2023-10-22 17:50
has joined #pact-jvm

sartom1994
2023-10-22 18:52
has joined #pact-jvm

rholshausen
2023-10-22 22:16
Use datetime instead of date.

matt.fellows
2023-10-23 01:09
Pavan just a minor comment, if you could please copy/paste the code snippets that would be really helpful. Personally, I find screenshots of code much harder to read than copy/pasting. It also makes it hard to search slack for similar messages because they?re hidden within the image

matt.fellows
2023-10-23 01:09
It is also hard for those on mobile to respond

bas
2023-10-23 06:50
Nice! Thank you for mentioning that, @magesh.nagamani.

rebecca.fulton
2023-10-23 09:27
has joined #pact-jvm

joao.jesus
2023-10-23 10:20
has joined #pact-jvm

kai.moseley
2023-10-23 10:47
has joined #pact-jvm

gunarajs
2023-10-23 19:23
has joined #pact-jvm

ctrando
2023-10-23 21:14
has joined #pact-jvm

thibault.alix
2023-10-23 22:29
has joined #pact-jvm

gurubabu.jampala
2023-10-24 08:07
Hi All, I am using the below command for my provider verification details. `mvn clean install -Dpactbroker.url=<> -Dpact.provider.version=uv4f2d3 -Dpact.provider.branch=main -Dpact.verifier.publishResults=true -Dpactbroker.auth.username=user-Dpactbroker.auth.password=password` I couldn't find how the broker receiving the `Authorization token` here, I checked in the request header, but I am not seeing any auth token present there. Can someone help me how `pact-jvm` is passing the `basic auth` info to `pact-broker` when it's calling to the verification apis? #pact-jvm #pact-broker @uglyog

kwapisz.bartosz
2023-10-24 08:38
has joined #pact-jvm

matt.fellows
2023-10-24 09:34
Please don?t `@` maintainers, we monitor this channel and will respond when we can

matt.fellows
2023-10-24 09:34
the properties above are user/passwords (basic auth) not for takens

matt.fellows
2023-10-24 09:34

btacca
2023-10-24 12:02
has joined #pact-jvm

anton.l.petersson
2023-10-24 13:54
has joined #pact-jvm

jowhalen13
2023-10-24 16:27
has joined #pact-jvm

gurubabu.jampala
2023-10-25 00:17
Thanks for your reply Matt. Sure I won't `@` maintainers in future. My question is how or in which format the pact broker server is receiving the auth details if we set in token/username-password? In normal cases, the basic auth is receiving in server end as Authorization token, but here in pact broker I couldn't see any request header having auth token present. #pact-jvm #pact-broker

gurubabu.jampala
2023-10-25 03:01
I got it, it's my mistake, haven't given proper environment variable for pact broker token. Thank you very much.

tanyagorn.benjaprompa
2023-10-25 08:09
has joined #pact-jvm

benguizat
2023-10-25 14:04
has joined #pact-jvm

edeandre
2023-10-25 19:20
Hey folks! I was starting to play around with Pact and gRPC and came across the protobuf plugin (https://github.com/pactflow/pact-protobuf-plugin). Is there a way to automate the install of the plugin via maven/gradle? I want to use this plugin for an open source sample project, but I can?t have any user who forks/clones the project have to go through setting it up so that they can build the application. It would also make it much easier to set up in CI servers (GitHub actions, etc).

rholshausen
2023-10-25 22:05
the latest version of Pact-JVM can auto-install the plugin as needed.

stan196
2023-10-25 23:42
has joined #pact-jvm

manalikhanna92
2023-10-26 07:09
has joined #pact-jvm

aaron_carey
2023-10-26 09:26
has joined #pact-jvm

ms.maheshhwari
2023-10-26 09:54
has joined #pact-jvm

ohisproperties2
2023-10-26 16:34
has joined #pact-jvm

anupama_enakula
2023-10-26 21:45
has joined #pact-jvm

edeandre
2023-10-26 21:51
Is there any configuration I need to do? Or just to use the plugin and it should just ?work??

pavankumar.cse88
2023-10-27 06:57
HI @rholshausen Actually I dint find datetime

roger.liu
2023-10-27 07:15
has joined #pact-jvm

francislainy.campos
2023-10-27 14:00
Hi, I have this pact java file import static com.example.desafiostone.constants.Constants.*; import static com.example.desafiostone.utils.Util._getMockRequest_; import static org.junit.jupiter.api.Assertions._assertEquals_; import static org.springframework.http.HttpMethod._POST_; @ExtendWith(PactConsumerTestExt.class) class CreateProductIT { Map headers = new HashMap<>(); String path = ?/starstore/product/?; @Pact(provider = _PACT_PROVIDER_, consumer = _PACT_CONSUMER_) public RequestResponsePact createPact(PactDslWithProvider builder) { headers.put(?Content-Type?, ?application/json?); headers.put(?Accept?, ?application/json?); DslPart bodyReceived = new PactDslJsonBody() .numberType(?price?, 7990) .close(); return builder .given(?A request to create a product?) .uponReceiving(?A request to create a product?) .body(bodyReceived) .path(path) .method(String._valueOf_(_POST_)) .headers(headers) .willRespondWith() .status(201) .toPact(); } @Test @PactTestFor(providerName = _PACT_PROVIDER_, port = _MOCK_PACT_PORT_, pactVersion = PactSpecVersion._V3_) void runTest() { Response response = _getMockRequest_(headers).body(new Product()).post(path); _assertEquals_(201, response.getStatusCode()); } } It passes when my product class has the price variable as the primitive double @Data @Builder @NoArgsConstructor @AllArgsConstructor public class Product { private double price; } However, it fails with a 500 when it uses a Double (object) instead. I?m wondering why that is?

abubics
2023-10-27 14:39
Without seeing the outputs, it'll be hard to know :) but a few things: ? What are you using to serialise your objects to JSON? (Maybe it's configurable) ? Using floating point values for money with maths is error-prone. ? I always use something like BigDecimal (or cents rather than dollars) to avoid floating point errors, and Jackson (for example) has good support for serialisation options :innocent:

senbaga.kumarsigamani
2023-10-27 16:12
has joined #pact-jvm

alejandro.ignacio
2023-10-27 17:42
has joined #pact-jvm

devendra.patil
2023-10-27 21:40
has joined #pact-jvm

matt.fellows
2023-10-28 11:51
logs would help, the `500` usually means it got a request it didn?t expect, and the test output should say why

matt.fellows
2023-10-28 11:51
also, welcome back - haven?t seen you around for a wihel!

pavankumar.cse88
2023-10-28 18:02
Hi Team, My contract generation test was working fine, but now i am seeing this error Can anyone please help here

bas
2023-10-28 18:16
What did you change? What happens when you roll back those changes? The chances that Pact magically stops working is pretty much zero, so it must be something else.

pavankumar.cse88
2023-10-28 18:53
I tried to add provider test but that is in different class, now I reverted that too, but still its not working


pavankumar.cse88
2023-10-29 05:09
Yes PactTestFor is present

pavankumar.cse88
2023-10-29 06:20
It worked after updating "http://au.com.dius.pact.consumer" dependency to 4.4.9. Thanks

francislainy.campos
2023-10-29 09:00
@abubics I?m using Jackson. Yes, I changed it later to BigDecimal, but I was just curious about how the library works with double vs Double.

francislainy.campos
2023-10-29 09:02
@matt.fellows haha, thank you. I changed companies, and my current employer does not use pact, so currently I?m just using it for personal project.

abubics
2023-10-29 09:03
Yarr, wb, hope you can get traction easily enough :pray:

francislainy.campos
2023-10-29 09:04
Just wondering how the library handles camel case vs snake case, as I have a contract generated with snake case, but even though my api returns camel case, the tests still passed. ```"response": { "body": [ { "19/08/2016": "29/10/2023", "card_number": "**** **** **** 1234", "client_id": "f0652d7b-1fb4-490d-9fbf-adc23c65b2df", "purchase_id": "e7cd8ac0-0df3-404f-b505-10ea2201f059", "value": 1234 }, { "19/08/2016": "29/10/2023", "card_number": "**** **** **** 1234", "client_id": "f0652d7b-1fb4-490d-9fbf-adc23c65b2df", "purchase_id": "e7cd8ac0-0df3-404f-b505-10ea2201f059", "value": 1234 } ],``` [ { ?clientId?: ?f0652d7b-1fb4-490d-9fbf-adc23c65b2df?, ?purchaseId?: ?f1598770-f7d0-43fc-ae47-62370e0aea03", ?value?: 1234.00, ?date?: ?2023-10-29?, ?cardNumber?: ?? } ]

francislainy.campos
2023-10-29 09:06
Yes, it would be nice to have pact here too, but sometimes introducing new ideas and tools is not as straightforward.

francislainy.campos
2023-10-29 09:06
Maybe someday..

matt.fellows
2023-10-30 02:27
:blobwave: Ever wanted to autogenerate Pact tests from existing code/models? Check out Sngular?s new open source tool, unveiled in our final Pactober event here: :point_right: https://www.youtube.com/watch?v=whXaNti7PSg Thanks to the team who have found a problem, and created an innovating solution to it, whilst still preserving the benefits of Pact consumer tests :clap:

francislainy.campos
2023-10-30 06:24
Similarly to my question above, I have the case where I need my date to be returned in the format dd/MM/yyyy, but the test still pass even when the format is not specified in my model class.

francislainy.campos
2023-10-30 06:24
So I was expecting this to fail:

francislainy.campos
2023-10-30 06:24
```DslPart bodyReturned = PactDslJsonArray.arrayEachLike(2) .uuid("client_id", clientId) .uuid("purchase_id", randomUUID()) .numberType("value", 1234) .date("19/08/2016", "dd/MM/YYYY", new Date()) .stringType("card_number", "**** **** **** 1234") .close();```

francislainy.campos
2023-10-30 06:25
When my variable is defined like this:

francislainy.campos
2023-10-30 06:25
```private LocalDate date;```

francislainy.campos
2023-10-30 06:25
And only pass once I define the format to match the one I?m expecting.

francislainy.campos
2023-10-30 06:25
```@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy") private LocalDate date;```

francislainy.campos
2023-10-30 06:26
@matt.fellows am I misunderstanding something on how pact does these matcher verification, perhaps? :thinking_face:

francislainy.campos
2023-10-30 06:30
This. :point_up_2::raised_hands::clap::eyes:

shenkesi.shiva
2023-10-30 06:57
has joined #pact-jvm


matt.fellows
2023-10-30 09:45
_(I was trying to promote people watch your video, but I think it does make sense to just post the link - thanks!_ :laughing: _)_

matt.fellows
2023-10-30 09:46
So for clarity, your local Pact consumer test expects a format `dd/MM/yyyy` and the consumer test works, and you?re expecting it to fail on the provider side because the format doesn?t match?

matt.fellows
2023-10-30 09:47
I?d need to see the debug logs from the provider test to assert this, probably also the serialised pact file

guido.lenacota
2023-10-30 09:48
has joined #pact-jvm

yihong.wang
2023-10-30 10:01
has joined #pact-jvm

chris.paul
2023-10-30 11:23
@yousafn did this talk happen? The link on that site is for a video from earlier in october

yousafn
2023-10-30 11:30
:blobwave: Hiya, thanks for the heads up, have updated the link to the event now, but to help you out, it is here https://www.youtube.com/watch?v=whXaNti7PSg

chris.paul
2023-10-30 11:30
ah brill, thank you

chris.paul
2023-10-30 11:42
I was pretty excited for this but the library seems strange to me. I?m not sure why they have chosen to generate a separate class to then generate the pact contract. The previous implementation seems more intuitive as it simply maps a pojo to a pact contract - https://github.com/remondis-it/pact-consumer-builder With this library I have to map from a sourcing pojo to a pact generator. I?m not sure if the authors wlil read this but perhaps I?m missing something?

chris.paul
2023-10-30 11:43
My issue was that the older library did not support kotlin data classes or java records. I was hoping this implementation would simply fix that but they appear to be taking it in a different direction?

pavankumar.cse88
2023-10-30 11:54
Hi Team, I am trying to validate the generated contracts through "context.verifyInteraction()" but I am getting "400" error code , can you please check if I am missing something here

pavankumar.cse88
2023-10-30 11:57
I am not able to debug to see what end point is taking during execution from "context"

bas
2023-10-30 16:21
Why are you pulling pacts from the target/pacts folder? I highly doubt your code will find them there

pavankumar.cse88
2023-10-30 16:25
Thanks for response @bas So it should be from PactBroker directly? Reason of trying to pull from folder is , want to try option where I will not use Pact Broker and just share my contract files with Provider manually and provider run provider test at provider side.

bas
2023-10-30 16:41
Yes I get that, but the target folder is a really weird choice for a location as it will get wiped every time you run ?mvn clean?

pavankumar.cse88
2023-10-30 17:44
okay understood, I can move it to resources folder. Any other things which I am doing incorrect?

bas
2023-10-30 18:27
Since the response content type you?re getting is text/html I suspect you?re hitting some kind of proxy / gateway that requires authentication or something else. I?ve not really run tests against AWS hosted APIs so I can?t help in more detail here.

ruth.bassindale
2023-10-30 20:54
has joined #pact-jvm

ruth.bassindale
2023-10-30 20:56
Hi, I was trying to update our pact version, but then I ran into a problem with `.datetim()` (see the https://github.com/pact-foundation/pact-jvm/issues/1726). Is there maybe someone here who can help me? this is currently preventing us from updating pact :disappointed:

rholshausen
2023-10-30 22:56
That is probably the default format for dates in your locale

rholshausen
2023-10-30 23:02
There must be something wrong with your test, or your API is automatically converting the attribute names.

francislainy.campos
2023-10-31 07:08
This is the piece that generates this contract: ```@Pact(provider = PACT_PROVIDER, consumer = PACT_CONSUMER) public RequestResponsePact createPact(PactDslWithProvider builder) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); DslPart bodyReturned = PactDslJsonArray.arrayEachLike(2) .uuid("client_id", clientId) .uuid("purchase_id", randomUUID()) .numberType("value", 1234) .date("19/08/2016", "dd/MM/YYYY", new Date()) .stringType("card_number", "**** **** **** 1234") .close(); return builder .given("A request to retrieve the history of transactions for a client") .uponReceiving("A request to retrieve the history of transactions for a client") .pathFromProviderState(path + "${clientId}", path + clientId) .method(String.valueOf(GET)) .headers(headers) .willRespondWith() .body(bodyReturned) .status(200) .toPact(); }```

francislainy.campos
2023-10-31 07:08
The api is correct, as it returns the fields with camelcase, which is the default.

francislainy.campos
2023-10-31 07:09
However, I was expecting Pact to fail since these are not the exact keys as specified in the contract, as there we use snake case.

francislainy.campos
2023-10-31 07:13
For the moment of my contract generation, I don?t have any specific assertion for the date type, however this is specified in the expected body with ``` .date("19/08/2016", "dd/MM/YYYY", new Date())``` ```@Pact(provider = PACT_PROVIDER, consumer = PACT_CONSUMER) public RequestResponsePact createPact(PactDslWithProvider builder) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); DslPart bodyReturned = PactDslJsonArray.arrayEachLike(2) .uuid("client_id", clientId) .uuid("purchase_id", randomUUID()) .numberType("value", 1234) .date("19/08/2016", "dd/MM/YYYY", new Date()) .stringType("card_number", "**** **** **** 1234") .close(); return builder .given("A request to retrieve the history of transactions for a client") .uponReceiving("A request to retrieve the history of transactions for a client") .pathFromProviderState(path + "${clientId}", path + clientId) .method(String.valueOf(GET)) .headers(headers) .willRespondWith() .body(bodyReturned) .status(200) .toPact(); }```

francislainy.campos
2023-10-31 07:13
However, when my api returns the default 2023-03-04 format, the tests still pass.

francislainy.campos
2023-10-31 07:16
Not sure if that?s the cause for the issue, but perhaps you may want to add the line that asks for the V3 syntax.

francislainy.campos
2023-10-31 07:16
```@Test @PactTestFor(providerName = PACT_PROVIDER, port = MOCK_PACT_PORT, pactVersion = PactSpecVersion.V3) void runTest() { Response response = getMockRequest(headers).get(path + clientId); assertEquals(200, response.getStatusCode()); }```

francislainy.campos
2023-10-31 07:16
As in

francislainy.campos
2023-10-31 07:17
```import au.com.dius.pact.consumer.dsl.DslPart; import au.com.dius.pact.consumer.dsl.PactDslJsonArray; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; import au.com.dius.pact.core.model.PactSpecVersion; import au.com.dius.pact.core.model.RequestResponsePact; import au.com.dius.pact.core.model.annotations.Pact; import au.com.dius.pact.provider.junitsupport.VerificationReports; import io.restassured.response.Response; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.UUID; import static com.example.desafiostone.constants.Constants.*; import static com.example.desafiostone.utils.Util.getMockRequest; import static java.util.UUID.fromString; import static java.util.UUID.randomUUID; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.springframework.http.HttpMethod.GET; @ExtendWith(PactConsumerTestExt.class) @VerificationReports(value = {"markdown"}, reportDir = "target/pacts") class GetHistoryForClientIT { Map<String, String> headers = new HashMap<>(); String path = "/starstore/history/"; UUID clientId = fromString("f0652d7b-1fb4-490d-9fbf-adc23c65b2df"); @Pact(provider = PACT_PROVIDER, consumer = PACT_CONSUMER) public RequestResponsePact createPact(PactDslWithProvider builder) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); DslPart bodyReturned = PactDslJsonArray.arrayEachLike(2) .uuid("client_id", clientId) .uuid("purchase_id", randomUUID()) .numberType("value", 1234) .date("19/08/2016", "dd/MM/YYYY", new Date()) .stringType("card_number", "**** **** **** 1234") .close(); return builder .given("A request to retrieve the history of transactions for a client") .uponReceiving("A request to retrieve the history of transactions for a client") .pathFromProviderState(path + "${clientId}", path + clientId) .method(String.valueOf(GET)) .headers(headers) .willRespondWith() .body(bodyReturned) .status(200) .toPact(); } @Test @PactTestFor(providerName = PACT_PROVIDER, port = MOCK_PACT_PORT, pactVersion = PactSpecVersion.V3) void runTest() { Response response = getMockRequest(headers).get(path + clientId); assertEquals(200, response.getStatusCode()); } }```

francislainy.campos
2023-10-31 07:24
I?m not sure the suggestion to move to contract out of the target folder would make a difference here. Also, I don?t see this as incorrect since it can be used for locally debugging your contracts before publishing them to an online broker.

francislainy.campos
2023-10-31 07:26
All my contracts have always been pulled from that folder and that has never been an issue.

francislainy.campos
2023-10-31 07:26
```@Provider(PACT_PROVIDER) /* Uncomment this and comment @PactBroker instead to test locally by pasting a .json file for the contract under the target/pacts folder */ @PactFolder("target/pacts") // @PactBroker(host = BROKER_PACT_URL, consumers = {"MY_CONSUMER"}) @VerificationReports(value = {"markdown"}, reportDir = "target/pacts") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @Sql(scripts = {"classpath:clean-up.sql", "classpath:init.sql"}, executionPhase = BEFORE_TEST_METHOD) @TestInstance(TestInstance.Lifecycle.PER_CLASS) class ProviderIT extends BasePostgresConfig { @LocalServerPort int port; RequestSpecification rq; @BeforeAll void setUp() { Map<String, String> headers = new HashMap<>(); rq = getRequestSpecification().baseUri("http://localhost:" + port) .contentType(ContentType.JSON) .headers(headers); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactTestTemplate(PactVerificationContext context, HttpRequest request) { logCurlFromPact(context, request, "http://localhost:" + port); context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", port, "")); } @State("A request to retrieve a product") Map<String, Object> getProduct() { Map<String, Object> map = new HashMap<>(); map.put("productId", "d3256c76-62d7-4481-9d1c-a0ccc4da380f"); return map; }``` }

francislainy.campos
2023-10-31 07:27
The target folder is the default location for where the contracts go once they are generated.

francislainy.campos
2023-10-31 07:32
Now, in answer to the original question: 400 normally indicates a request error, and the body returned as html probably indicates an error message is being returned by the api instead of a valid successful json.

francislainy.campos
2023-10-31 07:33
Pact can be hard to debug sometimes, so for this I?ve created a helper code that I use, which gives me the curl for the request printed back to the terminal.

francislainy.campos
2023-10-31 07:33
Perhaps it may be useful to you also.

francislainy.campos
2023-10-31 07:34
```public static void logCurlFromPact(PactVerificationContext context, HttpRequest request, String baseUri) { String bodyParam = ((RequestResponseInteraction) context.getInteraction()).getRequest().getBody().valueAsString(); String bodyResponse = ((RequestResponseInteraction) context.getInteraction()).getResponse().getBody().valueAsString(); String method = ((RequestResponseInteraction) context.getInteraction()).getRequest().getMethod(); String url = baseUri + request.getPath(); Header[] headers = request.getHeaders(); String headersString = ""; for (Header s : headers) { headersString = headersString + "--header " + "'" + s.getName() + ": " + s.getValue() + "'" + "\\" + "\n"; } String curl = """ curl --request %s '%s' \ %s --data-binary '%s' \ --compressed --insecure --verbose """.formatted(method, url, headersString, bodyParam); log.debug(curl + "\n\n " + bodyResponse + "\n ---- \n\n"); }```

francislainy.campos
2023-10-31 07:35
Log can be replaced by System.out if not using a logger library.

francislainy.campos
2023-10-31 07:35
Then you should be able to see your request as per the below screenshot, which may help you compare why it?s different from a valid request.

bas
2023-10-31 07:49
Thanks @francislainy.campos!

ruth.bassindale
2023-10-31 12:08
Yes I already did that, but that didn't change anything. I was assuming that this pactVersion means, that the pact itself does not change with dependency updates, but it seems to change after all. Do I have to put it somewhere else than the test as well for it to work?

pavankumar.cse88
2023-10-31 14:14
Thanks @francislainy.campos and @bas I will check above example and see if I am missing something

francislainy.campos
2023-10-31 16:20
Not sure. This is an article I?ve written before about how to do Pact. Perhaps something there may be useful to you. https://hmh.engineering/how-to-write-and-validate-pact-contracts-using-junit5-and-restassured-72b578e7dd65

ruth.bassindale
2023-10-31 18:59
@francislainy.campos thanks for the hint, you are using date there instead of datetime, even though your date includes a time. Do you remember why that is? :slightly_smiling_face:

sgavathe
2023-10-31 22:00
has joined #pact-jvm

rholshausen
2023-10-31 22:06
Is this correct? `.date("19/08/2016", "dd/MM/YYYY", new Date())` The attribute key is `"19/08/2016"` and the value is the current date?

rholshausen
2023-10-31 22:07
As in, your JSON would look like: ```{"19/08/2016": "01/11/2023"}```

cody.jenkins
2023-11-01 02:39
@cody.jenkins has left the channel

ntthaibk
2023-11-01 04:36
has joined #pact-jvm

francislainy.campos
2023-11-01 06:01
Wow, yes, that?s definitely wrong.

francislainy.campos
2023-11-01 06:01
However, my tests still pass. :joy:

francislainy.campos
2023-11-01 06:01
Not sure what?s going here.

francislainy.campos
2023-11-01 06:21
Sorry, I don?t. Perhaps it was an oversight, or maybe the Pact api accepts both date and dateTime for that field. I?m not sure. That would need to be checked.

francislainy.campos
2023-11-01 06:23
@matt.fellows I think I?m getting a bit confused now. :slightly_smiling_face:

francislainy.campos
2023-11-01 06:23
Can you rescue me, please?


francislainy.campos
2023-11-01 06:23
This is my project.

francislainy.campos
2023-11-01 06:24
My api returns this:

francislainy.campos
2023-11-01 06:25
But my contract keeps passing, even if I have camel case vs snake_case, date value instead of date key, completely wrong keys, such as if I spell centId instead of clientId..


rskilling
2023-11-01 10:23
has joined #pact-jvm

victor_do_val
2023-11-01 19:08
has joined #pact-jvm

james.corry
2023-11-01 19:23
has joined #pact-jvm

gowthamgopal24
2023-11-02 04:48
Hi Everyone, Consumer 1 Provider A Consumer 2 Provider A Consumer 3 Provider A In the above example you could see 3 consumers for 1 provider. Is there a way to verify against only one consumer instead of all three consumers? I am using mvn pact:verify to verify the contracts


vasile.vetisan
2023-11-02 07:03
hi all, could you have a look at the following pact-jvm issue? https://github.com/pact-foundation/pact-jvm/issues/1727 I am interested just in your view about the situation. I am doing something wrong or is a genuine issue?

2023-11-02 08:16
This message was deleted.

nicolas.cote-nolin
2023-11-02 12:30
has joined #pact-jvm

matt.fellows
2023-11-02 12:42
Tried debug level logging?

matt.fellows
2023-11-02 12:42
You should be able to see what it thinks you've set and any requests sent to the broker

sivaganesh.sivakumar
2023-11-02 13:18
has joined #pact-jvm

james.perepiczka
2023-11-02 13:43
Hi, are there any upgrade guides for migrating from Pact V3 to V4. We are looking at adopting V4 to use the synchronous message functionality but then have concerns about how it would affect current HTTP contracts that are using V3. Is there a suggestion on how we could migrate in stages over to V4? We have a lot of contracts so big bang isn?t really an option

rholshausen
2023-11-02 22:20
V4 is backwardly compatible with V3. I would start on your provider side, upgrade those so they can verify either V3 or V4. Then set the consumer tests to use V4. You shouldn't have to make many changes if you are using the standard DSLs.

james.perepiczka
2023-11-03 08:47
Thanks!

id.akanksha26
2023-11-03 11:38
has joined #pact-jvm

id.akanksha26
2023-11-03 11:44
Hi Team..Can somebody please confirm, if pact supports JSON RPC Integration type or not ?

yousafn
2023-11-03 12:09
Hey, It doesn?t but pact-jvm supports the pact-plugin framework, so it would be possible to create your own json-rpc aware pact-plugin.

id.akanksha26
2023-11-03 12:58
Thanks for your response !!

yousafn
2023-11-03 13:12
No worries, how are you using json rpc? Over http, websockets or ipc? If its http, is there any reason why you couldn?t use regular pact? if it just a particular body format and headers? One of our community members @adam.cox has created a websockets plugin which communicates over json-rpc with his employer, they wrote about it here. It isn?t open source but shows that it is possible. https://docs.pact.io/users/community_corner/adam_cox_interview_may2023 There is a feature req for websockets here https://pact.canny.io/feature-requests/p/plugin-websockets

prasant.iragavarapu
2023-11-03 15:06
has joined #pact-jvm

yagocre
2023-11-03 22:46
has joined #pact-jvm

munitheja91
2023-11-04 13:21
Hi All, is there way to run specific consumer pact verification ? I mean if we have 3 consumers C1,C2,C3 for Provider P, I want to run pact Verification between only C1 and Provider P...Please let me know if there is a way to do it ?

ruth.bassindale
2023-11-06 08:51
Hi, are the pact-jvm issues looked at at all? Or is there another way to repord bugs/weird behaviour?


matt.fellows
2023-11-06 08:52
The issues are looked into, why do you ask?

ruth.bassindale
2023-11-06 08:53
Because I added 2 issues 2 weeks ago and haven't received any comment at all so far. If that takes a while maybe a bot would be good to automated write a reply with the time we need to expect to get an answer or something?

yousafn
2023-11-06 10:19
it?s an open source project and there are many other open issues so the maintainer probably hasn?t had the time to look at it. i?ve added some comments to your issue posts. you can also repost in here for community support where other pact-jvm users could help

steve.blomeley
2023-11-06 14:50
has joined #pact-jvm

rana
2023-11-07 07:40
Starting a new thread because I messed the last one up. Pact broker retrieves the wrong provider version - meaning it retrieves not the latest version. Here is my issue: The consumer, which pushed-pacts, got verified by a provider with version `1.0.0`. The provider has made some application changes and performed a `record-deployment` with version `1.0.1`. The consumer has also made some changes, pushed-pacts, and triggered a provider verification pipeline. The provider verification pipeline has finished successfully, but no indication of verification results are present in the broker, unless I hard-code the previous provider version (`1.0.0` - not latest) in the verification pipeline, that was used to verify the previous consumer version and retrigger the verification process - then the pact broker does receive the results. When I set the log level to DEBUG, I am can see the pact broker client's logs only if I use version `1.0.0`! When I use `1.0.1` I don't see any pact broker client logs:exploding_head: I am using pact-broker version `2.105.0`. Other then `record-deployment` , is there any other action I should be taking in order to update a provider's contract version? Thanks

ruth.bassindale
2023-11-07 08:09
@yousafn thanks for the help. I tried that https://pact-foundation.slack.com/archives/C9UN99H24/p1698699396942539 with one of the questions, but unfortunately did not receive an answer that helped me. As you wrote my next step is to create a small project reflecting the problem

ndomingues10
2023-11-07 10:14
has joined #pact-jvm

charlan.bettiol
2023-11-07 13:00
Hello everyone, everything good? Is there an example of contract versioning anywhere? because I'm having the following problem, there are developers making contracts in different branches and when trying to publish I'm getting the error below, I would like to know how to get around this: `Cannot change the content of the pact for subscription version 1.0 and provider subscription, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number. Some Pact libraries generate random data when a concrete value for a type matcher is not specified, and this can cause the contract to mutate - ensure you have given example values for all type matchers. For more information see https://docs.pact.io/go/versioning`

rana
2023-11-07 13:48
I think I might of misunderstood the usage of `record-deployment` , and the https://docs.pact.io/pact_broker/recording_deployments_and_releases#recording-deployments explains only *when* to perform the action (_should be called at the very end of the deployment process_), but does not mention *why*, meaning - in which cases should I `record-deployment`. Any explanation regarding that would be great.

yousafn
2023-11-07 15:40
See https://docs.pact.io/getting_started/versioning_in_the_pact_broker#best-practices if you are using a static value for your consumer version (1.0 in your example), and the data is not changing due to random data, it is changing because you are changing the contents on the pact, and thusly must change the version number. This is normally taken care of, by the Pact broker by utilising commit hashes which uniquely identify a contract to the code that produced that contract. if the published contract content has not changed, and it has already been verified, it will be preverified.

yousafn
2023-11-07 15:41
the link in the error message provides additional information as well > 1. Have the application version number include something that identifies the point in your version control repository that will build this application. For git, it is ideal if you either use the git commit sha (short or long), or include the git commit sha in your version number (for example 0.0.10+76a39e5). This has several advantages: > ? The consumer version will definitely change whenever the pact contract changes (satisfying rule 1 above) > ? Feature branches will automatically have different versions to master branch versions (satisfying rule 2 above) > ? Versions can always be known at deploy time (satisfying rule 3 above) > ? You can also identify and checkout the production version of the provider. >

yousafn
2023-11-07 15:42
> The Pact Broker needs to know which versions of each application are in each environment so it can return the correct pacts for verification and determine whether a pacticular application version is https://docs.pact.io/pact_broker/can_i_deploy.

yousafn
2023-11-07 15:42
> ? `record-deployment` is used to model the real life scenario where a deployment causes the previous version of an application to be replaced by a new version. It is used for APIs and consumer applications that are deployed to known instances. When called, it automatically marks the previously deployed version as undeployed. >

yousafn
2023-11-07 15:43
> The provider verification pipeline has finished successfully, but no indication of verification results are present in the broker, unless I hard-code the previous provider version (`1.0.0` - not latest) in the verification pipeline, that was used to verify the previous consumer version and retrigger the verification process - then the pact broker does receive the results. Without knowing the details on your verification setup, it?s hard to determine. > The provider has made some application changes and performed a `record-deployment` with version `1.0.1`. Did the provider run a verification task, verifying consumer contracts against 1.0.1 prior to calling can-i-deploy and subsequently record-deployment. I would recommend running through the ci/cd workshop to get a handle on how a real world scenario plays out

charlan.bettiol
2023-11-07 16:52
I understant, Thank you for the explanation.

rana
2023-11-07 17:20
Apparently your `http://au.com.dius.pact.consumer` lib clashed with `provider` lib and caused the verification tests to not run. I appreciate your help, thanks.

nswetha.reddy
2023-11-07 19:21
has joined #pact-jvm

nswetha.reddy
2023-11-07 19:25
Hi, I am exploring Pact for our reactJS to springboot/Java application. Can someone please help me with this issue.Some problems were found with the configuration of task ':pactVerify_test_provider' (type 'PactVerificationTask'). - In plugin 'http://au.com.dius.pact' type 'http://au.com.dius.pact.provider.gradle.PactVerificationTask' property 'providerToVerify' is missing an input or output annotation.

matt.fellows
2023-11-07 22:13
perhaps you could share your setup so that we can understand what you might have done differently?

matt.fellows
2023-11-07 22:13
also, what docs are you you using as a guide to setup your test?

yousafn
2023-11-08 11:39
Thanks for the additional context Ruth! You?ve done a good job so far of reaching out via the various areas, as you can see, there was some community support although it didn?t manage to solve your issue this time, it was nice to see. the library author has replied this morning on your original issue here https://github.com/pact-foundation/pact-jvm/issues/1726#issuecomment-1801200011 Hope that helps, and let us know what issues you are seeing after trying the steps in the above issue. Appreciate it can be a bit frustrating when you are stuck and you aren?t getting the answer, sometimes just pinging up like you have done, we will definitely take your points on board here > If that takes a while maybe a bot would be good to automated write a reply with the time we need to expect to get an answer or something? In our weekly maintainers meeting, held via #maintainers - Triage is high on our agenda at the moment, because we are aware most are doing this as a hobby, very very few as full time jobs, but want to make sure that people don?t feel stuck and lost, so the automated bot is something we have considered.

ruth.bassindale
2023-11-08 12:06
I totally apprechiate that time is scares especially in open source projects. So maybe a bot just answering something like "please keep in mind it can take a while to answer" would be helpful, as it is more transparent that the issue is not missed, but maybe just in a queue of too much work for too little time :slightly_smiling_face:

nswetha.reddy
2023-11-08 13:22
I am referring - https://docs.pact.io/

nswetha.reddy
2023-11-08 13:24
```buildscript { repositories { mavenCentral() } dependencies { classpath 'au.com.dius.pact.provider:gradle:4.1.7' } } plugins { id 'java' id 'org.springframework.boot' version '2.7.17' id 'io.spring.dependency-management' version '1.0.15.RELEASE' id 'au.com.dius.pact' version '4.1.7' } group = 'com.pact.example' version = '0.0.1-SNAPSHOT' java { sourceCompatibility = '11' } apply plugin: 'au.com.dius.pact' apply plugin: 'groovy' repositories { mavenCentral() } test { useJUnitPlatform() systemProperty 'pact.verifier.publishResults', 'true' } dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' developmentOnly 'org.springframework.boot:spring-boot-devtools' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'au.com.dius.pact.provider:junit5:4.1.7' } pact { reports { defaultReports() } broker { pactBrokerUrl = 'https://swethatest.pactflow.io/' pactBrokerToken = '<token ..>' } serviceProviders { test_provider { fromPactBroker { hasPactsFromPactBroker('https://swethatest.pactflow.io/', authentication: ['Bearer', '<token ....>']) } } } }```

munitheja91
2023-11-08 13:56
Hi All, We are using PACT maven plugin to run our pact verification, my pom.xml looks like below When I ran pact verify, verification results are getting skipped with below error, Could you please let me know how can i resolve this error? *Error:* Skipping publishing verification results for source UrlSource(url=https://pactbroker.platform.dev.com/pacts/provider/Testprovider/consumer/Testconsumer/latest, pact=null)

munitheja91
2023-11-08 13:59
```<plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.5.2</version> <configuration> <serviceProviders> <serviceProvider> <name>Testprovider</name> <pactBrokerUrl>https://pactbroker.platform.dev.com/</pactBrokerUrl> <protocol>https</protocol> <port>443</port> <host>http://services-dev.com</host> <consumers> <consumer> <name>Testconsumer</name> <pactUrl>https://pactbroker.platform.dev.com/pacts/provider/Testprovider/consumer/Testconsumer/latest</pactUrl> </consumer> </consumers> </serviceProvider> </serviceProviders> <systemPropertyVariables> <pact.verifier.publishResults>true</pact.verifier.publishResults> <pact_do_not_track>true</pact_do_not_track> <pact.filter.consumers>Testconsumer</pact.filter.consumers> </systemPropertyVariables> </configuration>```

yousafn
2023-11-08 14:04
You need a url to an explicit versioned pact, not the `latest` pact

yousafn
2023-11-08 14:17
I can see the same issue reported on the pact-jvm repo. https://github.com/pact-foundation/pact-jvm/issues/1429 what version of gradle are you using

nswetha.reddy
2023-11-08 14:25
```gradle-8.4-bi```

yousafn
2023-11-08 14:35
https://github.com/pact-foundation/pact-jvm/issues/1429#issuecomment-913875893 sounds like you need to update the package version of Pact to support your version of Gradle

yousafn
2023-11-08 14:35
That comment is 2 years old, ideally use that latest Pact library that supports your targeted Java version ( I see you have 11 in your file)

aparnakrishna1115
2023-11-08 14:55
has joined #pact-jvm

munitheja91
2023-11-08 14:58
our requirement is to run only the latest available pact from a specific consumer ...that's why we have chosen latest...is there any other option apart from giving the versioned pact ?

yousafn
2023-11-08 14:58
use consumer version selectors, see the docs

yousafn
2023-11-08 14:59
pact url is for a single url, when a consumer pact changes

yousafn
2023-11-08 14:59
you want the provider verification which can select multiple pacts, so a consumer version selector of latest, (which really isn?t recommended, as it?s non deterministic )


harry.talbot
2023-11-08 15:05
has joined #pact-jvm

munitheja91
2023-11-08 16:34
Thanks for the quick info...but there were no examples for version selector in case of pact maven plugin...(we are not using any code,we are just using a pom.xml with required dependencies and plugins, then running the mvn pact:verify command)


munitheja91
2023-11-08 16:50
Sorry for troubling you much...Can you please help me on how to give consumer alone in the selectors?

munitheja91
2023-11-08 16:51
https://pactbroker.platform.com Consumer

munitheja91
2023-11-08 16:51
i am using like above but it says no pact files found

yousafn
2023-11-08 17:15
not sure on the specifics but you can pass consumer versions selectors as raw json as per those docs. If the combination you provide doesn?t return results you can check the pacts for verfication endpoint via the hal browser and check if you have pacts to verify with your given selectors.

daniel.phillips
2023-11-08 17:18
has joined #pact-jvm

munitheja91
2023-11-08 17:49
hi @matt.fellows, Can you please help me how can i select only consumer in pact maven plug in consumer version selectors. My intension is to select one particular consumer to run using pact maven plugin

yuliya.rahalski
2023-11-08 20:15
has joined #pact-jvm

olivier.picaud
2023-11-08 21:51
has joined #pact-jvm

matt.fellows
2023-11-08 22:50
> our requirement is to run only the latest available pact from a specific consumer why?


ruth.bassindale
2023-11-09 10:14
Hi, I am trying https://github.com/huehnerlady/demo-pact-v3 to build a sample project for an error I have, but now I run into another error I do not understand. It has to do with LocalDateTime. In my sample Project theoretically it should all work fine (shown as it is at the moment), but I run into the error: ```1) Verifying a pact between Consumer-Working and provider - consumer-test has a matching body 1.1) body: $.lastResponse Expected [2021,5,10,16,40,55] to match a datetime of 'yyyy-MM-dd'T'HH:mm:ss': Unable to parse the date: [2021,5,10,16,40,55]``` I did try to reproduce a local closed source project, so maybe I forgot to copy something over? At least the LocalDateTime String method here looks very odd (`[2021,5,10,16,40,55]`) In my other error message with our service it shows up as `2021-05-10T16:40:55` Anybody an idea what I am missing? :slightly_smiling_face:

joseenrique.garcia
2023-11-09 12:56
has joined #pact-jvm

ashish.patel5
2023-11-09 15:20
has joined #pact-jvm

cnguyen
2023-11-10 08:31
has joined #pact-jvm

nam.nguyen414
2023-11-10 12:35
has joined #pact-jvm

yousafn
2023-11-10 15:42
Hey @ruth.bassindale, I converted this return a string in the returned message, rather than a `LocalDateTime` and that at least allowed me to get to your original issue state. I assume your own project will serialise these values into strings when sending them over the wire. Added comments to your original post here https://github.com/pact-foundation/pact-jvm/issues/1726#issuecomment-1805958698 with hopefully a workaround to get you out a bind for the moment

lewis
2023-11-10 16:33
has joined #pact-jvm

vasile.vetisan
2023-11-10 16:54
For http://au.com.dius.pact.consumer-junit5 version 4.6.3 is anyone aware of any float/long matching methods? like intergerMatching or decimalMatching?

ruth.bassindale
2023-11-10 17:17
thank you so much for all your effort, I will look at that directly on Monday :slightly_smiling_face:

anna.lorenzi
2023-11-10 17:42
has joined #pact-jvm

nathan334
2023-11-10 18:34
has joined #pact-jvm

rholshausen
2023-11-12 22:40
The DSL methods are the same with 4.6.3

vasile.vetisan
2023-11-13 06:29
oky I will take this answer as a no :)

vasile.vetisan
2023-11-14 07:00
@rholshausen could this functionality be part of a feature for a future version?

rholshausen
2023-11-14 22:06
There is no need for that. intergerMatching and decimalMatching work on the shape of the numbers, and the matching functions are overloaded for all number types.

banghung859
2023-11-15 08:38
has joined #pact-jvm

vasile.vetisan
2023-11-15 09:59
thanks, I figured it out. .numberMatching("filedName", "regex", 99999L)

pavikrish
2023-11-15 11:36
Hi, I'm using gradle pactVerify plugin to verify pact and publish the results on the provider side. Plugin version is 4.3.10. Using Java 17 and Gradle 7.6. I'm able to verify and publish the results normally. But if I try to publish the results along with provider branch property (pact.provider.branch), I'm getting 403 forbidden error PUT JSON request failed with status 403 Forbidden Failed to push branch develop for provider PromoCredits and version 0a84947 http://au.com.dius.pact.core.pactbroker.RequestFailedException: Request failed with 403 at http://au.com.dius.pact.core.pactbroker.HalClient$putJson$1.invoke$lambda-0(HalClient.kt:482) at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:247) at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:188) at http://au.com.dius.pact.core.pactbroker.HalClient$putJson$1.invoke(HalClient.kt:477) at http://au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:39) at http://au.com.dius.pact.core.pactbroker.HalClient.putJson(HalClient.kt:476) at http://au.com.dius.pact.core.pactbroker.PactBrokerClient.publishProviderBranch(PactBrokerClient.kt:964) at http://au.com.dius.pact.provider.DefaultVerificationReporter.publishResult(VerificationReporter.kt:109) at http://au.com.dius.pact.provider.DefaultVerificationReporter.reportResults(VerificationReporter.kt:90) at http://au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer(ProviderVerifier.kt:852) at http://au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer$default(ProviderVerifier.kt:825) at http://au.com.dius.pact.provider.ProviderVerifier.verifyProvider(ProviderVerifier.kt:809) Can someone help?

rholshausen
2023-11-15 22:06
What is the value of the branch you are trying to set? And is this with Pactflow or the open-source Pact Broker?

pavikrish
2023-11-16 04:37
@rholshausen I'm trying to set develop($GIT_BRANCH) as the value. Using pactbroker.

ali
2023-11-16 04:50
has joined #pact-jvm

rholshausen
2023-11-16 05:00
what does `develop($GIT_BRANCH)` resolve to?

pavikrish
2023-11-16 05:00
@rholshausen Thanks for your immediate response. develop is the value

pavikrish
2023-11-16 05:01
Meant to say $GIT_BRANCH resolves to develop

emmanuel
2023-11-16 09:40
has joined #pact-jvm

pavikrish
2023-11-16 10:56
We have missed to add PUT support in the pact broker. After updating the pact broker, this is working. Thanks @rholshausen

dan.corder
2023-11-16 11:37
has joined #pact-jvm

oswald.quek
2023-11-16 12:32
Hello, I've got a https://github.com/alphagov/pay-adminusers/pull/2255 where I'm trying to run a messaging pact test `ConnectorQueueMessageContractTest`. When I run it I get ```Verifying a pact between connector and adminusers a service archived event Verification Failed - No annotated methods were found for interaction 'a service archived event'. You need to provide a method annotated with @PactVerifyProvider("a service archived event") that returns the message contents.``` But the `@PactVerifyProvider` is https://github.com/alphagov/pay-adminusers/pull/2255/files#diff-19620c191037ccbef53c0d682aa48de76b92088e527cc4d0df5e09f6bae3d8e6R19! :disappointed: I know I'm not on the latest pact-jvm version but hopefully someone here will know what's happening. I've followed the guide at https://github.com/pact-foundation/pact-jvm/tree/master/provider/junit#example-of-message-test

oswald.quek
2023-11-16 14:29
Ah, I solved it. Looks like I need this dependency in my pom.xml: ``` <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit</artifactId> <version>4.0.10</version> <scope>test</scope> <exclusions> <exclusion> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> </exclusion> </exclusions> </dependency>``` I previously had ``` <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit_2.12</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-junit_2.12</artifactId> <version>${pact.version}</version> <scope>test</scope> </dependency>```

matt.fellows
2023-11-16 22:13
> We have missed to add PUT support in the pact broker. After updating the pact broker, this is working. Thanks ?are you adding some layer around the pact broker?

vikash.kumar.singh
2023-11-16 22:58
has joined #pact-jvm

barbara.szczygiel
2023-11-17 14:08
has joined #pact-jvm

maria.olivero
2023-11-17 16:57
has joined #pact-jvm

yanov.alexander
2023-11-20 09:02
Hello team, does anyone have instructions on how to use WIP Pact functionality? I didn?t find enough information in the net.

matt.fellows
2023-11-20 09:29
I'm assuming you've read https://docs.pact.io/blog/2020/02/24/introducing-wip-pacts and the linked docs?

matt.fellows
2023-11-20 09:30
And also the CI/CD workshop (see :point_down: howtolearn)

2023-11-20 09:30
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

yanov.alexander
2023-11-20 09:45
Regarding the provider, looks like I understand how to do it with attributes IncludeWipPactsSince, but on the consumer side, are there any specific annotations/attributes or settings? How does pact broker will know that this is WIP pact?

yousafn
2023-11-20 14:55
From the docs https://docs.pact.io/pact_broker/advanced_topics/wip_pacts > A ?work in progress? pact is a pact that: > 1. is the latest for its branch (or tags) > 2. does not have a successful verification result from the current provider branch (or tags) - that is, the pact is in ?pending? state. > 3. was not explicitly specified in the consumer version selectors

yanov.alexander
2023-11-20 15:59
Thanks! I will try!

honglu11
2023-11-20 23:33
Hello, I encounter a problem when I try to apply request body ( Multipart/form-data entity, Content - Type ) in pact ( consumer side ), when I debug I see MimeMultipart.class get boundary, but when read the file line in parsebm(), outside while loop, line becomes null, thus it won't be able to proceed to the next line of code in parsebm(), the pact failed. Not sure anybody knows how to fix it?

honglu11
2023-11-20 23:40
notice that line in 1028 has value, while in line 1036 it becomes null

honglu11
2023-11-20 23:46
So that eventually it will throw miss start boundary error

honglu11
2023-11-20 23:47
```2023-11-20 23:45:24,526 [HTTP-Dispatcher] ERROR BaseJdkMockServer$Companion - Failed to generate response javax.mail.MessagingException: Missing start boundary at javax.mail.internet.MimeMultipart.parsebm(MimeMultipart.java:1579) ~[mail-1.4.2.gr19.jar:1.4.2.gr19] at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:532) ~[mail-1.4.2.gr19.jar:1.4.2.gr19] at javax.mail.internet.MimeMultipart.getCount(MimeMultipart.java:259) ~[mail-1.4.2.gr19.jar:1.4.2.gr19] at au.com.dius.pact.core.matchers.MultipartMessageContentMatcher.compareParts(MultipartMessageContentMatcher.kt:50) ~[matchers-4.6.3.jar:4.6.3] at au.com.dius.pact.core.matchers.MultipartMessageContentMatcher.matchBody(MultipartMessageContentMatcher.kt:35) ~[matchers-4.6.3.jar:4.6.3] at au.com.dius.pact.core.matchers.Matching.matchBody(Matching.kt:243) ~[matchers-4.6.3.jar:4.6.3] at au.com.dius.pact.core.matchers.RequestMatching$Companion.requestMismatches(RequestMatching.kt:137) ~[matchers-4.6.3.jar:4.6.3] at au.com.dius.pact.core.matchers.RequestMatching$Companion.compareRequest(RequestMatching.kt:112) ~[matchers-4.6.3.jar:4.6.3] at au.com.dius.pact.core.matchers.RequestMatching.matchInteraction(RequestMatching.kt:74) ~[matchers-4.6.3.jar:4.6.3] at au.com.dius.pact.consumer.BaseMockServer.generatePactResponse(MockHttpServer.kt:200) ~[consumer-4.6.3.jar:4.6.3] at au.com.dius.pact.consumer.BaseJdkMockServer.handle(MockHttpServer.kt:258) [consumer-4.6.3.jar:4.6.3] at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:95) [jdk.httpserver:?] at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:82) [jdk.httpserver:?] at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:98) [jdk.httpserver:?] at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:851) [jdk.httpserver:?] at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:95) [jdk.httpserver:?] at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:818) [jdk.httpserver:?] at sun.net.httpserver.ServerImpl$DefaultExecutor.execute(ServerImpl.java:201) [jdk.httpserver:?] at sun.net.httpserver.ServerImpl$Dispatcher.handle(ServerImpl.java:561) [jdk.httpserver:?] at sun.net.httpserver.ServerImpl$Dispatcher.run(ServerImpl.java:527) [jdk.httpserver:?] at java.lang.Thread.run(Thread.java:840) [?:?]```

madhawa
2023-11-21 04:59
has joined #pact-jvm

pascal
2023-11-21 05:25
has joined #pact-jvm

honglu11
2023-11-21 06:57
For the problem I encounter, I have already found out the reason: the MultipartEntityBuilder we used in our project is not the same as pact lib's MultipartEntityBuilder, I use pact's MultipartEntityBuilder to make a builder, then the debug passed

srinu.innovatus
2023-11-21 08:09
has joined #pact-jvm

somya.khandelwal
2023-11-21 08:39
has joined #pact-jvm

somya.khandelwal
2023-11-21 08:42
@oswald.quek I am getting this error while running by tests ```1) createPactTopologyUplinkPort 1.1) Failed to invoke provider method 'verifyMessageForTopologyUplinkPort'```

srinu.innovatus
2023-11-21 08:43
Hello Everyone :slightly_smiling_face: I'm getting the below error while trying to automate pact consumer test

srinu.innovatus
2023-11-21 08:43
java.lang.NullPointerException: null cannot be cast to non-null type http://au.com.dius.pact.core.model.BasePact

srinu.innovatus
2023-11-21 08:44
any idea on it?

ndruzhinina
2023-11-22 14:25
has joined #pact-jvm

jaspal.puri
2023-11-23 10:05
has joined #pact-jvm

ogbofjnr
2023-11-23 12:25
has joined #pact-jvm

patricio.dossantos_sl
2023-11-23 20:08
has joined #pact-jvm

adam.cox
2023-11-24 09:40
Hi, Sorry for the delay in response, I have been away. The plan is still for us to Open Source the plugin but as it was done as part of a Corporate project the process for doing so is quite slow. Unfortunately I have moved on from the team that are responsible for the code, but I believe they are looking to prepare to release the plugin in the near future. I think the one thing to be wary of/or that is slightly niggly with JSON-RPC and contract testing is the `id` field. The value of it is really not relevant for the contract, however the id on the responsemust much the one on the request. You can't easily use the example field in the matching functions to make sure that it is always correct as you might not have control of the id value being set in the request. It will depend on how your client works. If you can create a new JSON-RPC client for each test though the id is normally 0 or 1 and this is easy to encode in the contracts

martin.gallauner
2023-11-24 10:40
has joined #pact-jvm

martin.gallauner
2023-11-24 10:42
Hi, do you want to share some of the concerned code?

juliemarierosok
2023-11-24 11:29
Hey everyone! Pasting my question from the general channel, as I was told this is more of a syntax question. I hope someone can help! I have a consumer contract test where I want to reflect that we expect an array with at least one element containing a boolean with value true. From the forums and docs, I understand I can use "*arrayContaining*" to reflect this. I have two questions regarding this: ? I actually want to say we want only one element to have this boolean true, all other elements must have it as false. But I believe this is not possible to reflect? ? The bigger problem, is that I don't know how to use this "arrayContaining" in the DSL, while it seems to only be possible on arrays contained within an object. The event structure we are consuming is however containing an array on top level, so no parent object. And it is this array which has this requirement.

martin.gallauner
2023-11-24 12:54
Hi Julie, I will try to reproduce that case as soon as I get my pact tests running :slightly_smiling_face:

aschaff
2023-11-24 15:27
has joined #pact-jvm

bruno.petkovic99
2023-11-25 13:55
has joined #pact-jvm

rholshausen
2023-11-26 22:57
> I actually want to say we want only one element to have this boolean true, all other elements must have it as false. But I believe this is not possible to reflect? Yes, this matcher can only determine the presence of something that matches the definition, not that all the other elements are the opposite.

carlrconn
2023-11-27 02:22
has joined #pact-jvm

juliemarierosok
2023-11-27 07:43
Thanks! I will for now just say we expect an array with at least 1 element, with the attribute as mandatory with any boolean value. If you figure out how to do it with arrayContaining, please let me know!

yi.wu
2023-11-27 08:10
has joined #pact-jvm

martin.gallauner
2023-11-27 14:20
Hi! Do yo know if there is any example available about how to test the receiving of error messages on the consumer side? Thanks!

brian_worsham
2023-11-27 14:30
has joined #pact-jvm

jessie.eteng
2023-11-27 15:25
has joined #pact-jvm

allen.ayala
2023-11-27 15:47
Good morning, what is the selector criteria when no consumer selectors are passed from a java provider?

crisciano.botelho
2023-11-27 18:57
has joined #pact-jvm

ajg.public
2023-11-27 21:44
has joined #pact-jvm

matt.fellows
2023-11-27 22:06
in what sense? a `40x` or `50x` type thing? Just?put those in the expectations? What problem are you having?

matt.fellows
2023-11-27 23:08
It would be whatever the broker?s default is, which I believe is the latest contract for each of its consumers



lukasz.lawicki
2023-11-28 10:06
has joined #pact-jvm

martin.gallauner
2023-11-28 13:24
Okay, thanks @matt.fellows, that makes sense. I'm very new to Pact and still have to figure out what's the best way to make use of it. What is the primary purpose of the Consumer tests (annotated with @PactTestFor())? Is it mostly about deserializing the response? For example, when I defined only the types and names of the attributes of the response.

martin.gallauner
2023-11-28 13:26
Sorry to interrupt you. May I ask you about what consumer selector you are writing about? I'm not aware of any consumer selector passed by a provider

jawad.sefiani
2023-11-28 14:08
has joined #pact-jvm

rana
2023-11-28 17:18
Hi team, I had an issue with a service that was both a provider and consumer, verification tests would not get called once pact broker triggered them. Once I had removed the consumer dependency it got back to work. Is this something known? Should I exclude anything to avoid this behaviour? Thanks

elaine.silva
2023-11-28 17:50
has joined #pact-jvm

martin.gallauner
2023-11-28 20:38
okay, by now I understand how stupid my question is.

matt.fellows
2023-11-28 21:24
no stupid questions Martin! Glad you?re back on track :slightly_smiling_face:

matt.fellows
2023-11-28 23:07
This doesn?t make sense to me, so I suspect it was a configuration issue. Could you please explain the setup in more detail and/or share code?


matt.fellows
2023-11-28 23:08
These are the ways that your provider ?selects? which pacts to verify

lukasz.lawicki
2023-11-29 06:54
@lukasz.lawicki has left the channel

tomasz.myszka
2023-11-29 14:21
has joined #pact-jvm

allen.ayala
2023-11-29 14:29
Thanks for the info!

tom.willmott944
2023-11-29 14:44
has joined #pact-jvm

anna.nava
2023-11-29 20:56
has joined #pact-jvm

pasc.ther
2023-11-29 22:19
has joined #pact-jvm

awade
2023-11-30 13:49
has joined #pact-jvm

mohammed.a.ezzedin501
2023-11-30 15:39
Hello! I was looking into this page https://docs.pact.io/implementation_guides/jvm/provider/gradle#using-consumer-version-selectors-4310, but couldn't get my configurations to work. Here is a sample of my configurations: ```plugins { java id("org.springframework.boot") version "2.7.14" id("io.spring.dependency-management") version "1.0.15.RELEASE" id("au.com.dius.pact") version "4.6.3" } buildscript { repositories { maven { url = uri("https://plugins.gradle.org/m2/") } } dependencies { classpath("au.com.dius.pact.provider:gradle:4.6.3") } } pact { serviceProviders { myProvider { fromPactBroker { withSelectors { branch("test") } } } } }``` However, it is failing to recognize the tokens `myProvider`, `fromPactBroker`, `withSelectors`, and `branch` , eventhough it is the exact example from the docs. Can you please help pointing out the issue?

ulises.cervino
2023-11-30 17:22
I have a question about grpc/protobuf consumer tests and headers. I tried adding them via the `metadata` key in the map representing the request but that didn?t have any effect. If I don?t specify any headers, then the headers sent by the client don?t get recorded in the pact, and then this one can?t be verified. These are mostly for auth purposes, and I understand we should leave auth out of it, but I?m also curious: with grpc tests, is it possible to set/record headers in the pacts?

rholshausen
2023-11-30 22:27
What version of Gradle are you using?

mohammed.a.ezzedin501
2023-12-01 06:53
8.2.1

martin.gallauner
2023-12-01 08:32
Hi there, are there any best practices about how to structure your contract test files? Initially I started by creating one class having all `@Pacts` and `@Test` for the client class but that appears a bit untidy by now. Any second thoughts about having a class for each pact?

aniket.rane
2023-12-01 20:03
Hello! We are trying to implement contract testing with a Java + Springboot + Gradle service as our consumer. While trying to run the tests, I ran into this error: ```http://localhost:56992 Exception in thread "Thread-2" java.lang.NoSuchMethodError: kotlin.io.ByteStreamsKt.readBytes(Ljava/io/InputStream;)[B at au.com.dius.pact.consumer.BaseJdkMockServer.toPactRequest(MockHttpServer.kt:247) at au.com.dius.pact.consumer.BaseJdkMockServer.handle(MockHttpServer.kt:214) at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79) at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83) at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82) at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:822) at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79) at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:794) at sun.net.httpserver.ServerImpl$DefaultExecutor.execute(ServerImpl.java:199) at sun.net.httpserver.ServerImpl$Dispatcher.handle(ServerImpl.java:544) at sun.net.httpserver.ServerImpl$Dispatcher.run(ServerImpl.java:509) at java.lang.Thread.run(Thread.java:750) Disconnected from the target VM, address: '127.0.0.1:56982', transport: 'socket'``` Upon googling I found this solution: https://github.com/pact-foundation/pact-jvm/issues/1102 Where @uglyog you suggested that we may need to include the correct version of Kotlin in the build classpath. ```buildscript { //repositories & dependencies for the build script ext { springBootVersion = '2.1.1.RELEASE' sparkplugVersion = "${springBootVersion}.1" jacocoExcludedFiles = [ "**/model*", "**/config*", "**/exception*", "com/{redacted}/Application*" ] } repositories { maven { url "http://artifacts.{redacted}.com/artifactory/plugins-release" } maven { url "https://artifacts.{redacted}.com/artifactory/remote-repos" } maven { url "http://artifacts.{redacted}.com/artifactory/plugins-release-local" } } dependencies { classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}" classpath "com.{redacted}:gradle-sparkplug-plugin:0.+" classpath "com.{redacted}:gradle-servicetests-plugin:1.0.0" classpath "com.{redacted}:gradle-codequality-plugin:1.1.+" classpath 'au.com.dius:pact-jvm-consumer:4.0.10' classpath 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72' classpath 'com.google.code.gson:gson:2.8.6' } .... plugins { id "java" id "groovy" id "eclipse" id "idea" id "application" id "jacoco" id 'au.com.dius.pact' version '4.1.7' } .... dependencies { .... testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } testImplementation 'com.github.tomakehurst:wiremock:2.27.2' testImplementation 'au.com.dius.pact.consumer:java8:4.1.7' testImplementation 'au.com.dius.pact.consumer:junit5:4.1.7' implementation 'org.apache.httpcomponents.client5:httpclient5:5.1.3' implementation 'org.apache.httpcomponents.client5:httpclient5-fluent:5.1.3' }``` I still get the above error. Am I doing it wrong?

tonis.ojandu
2023-12-02 03:41
You seem to be selecting `kotlin-stdlib-jdk8` in the buildscipt levels which influences it for Gradle plugins, but looking at the exception, you probably need to select it down in the main application dependency level.

aniket.rane
2023-12-02 03:42
Will try

vspallas
2023-12-03 10:18
has joined #pact-jvm

mohammed.a.ezzedin501
2023-12-04 07:45
@rholshausen any idea?

nicholaspatrickshaw
2023-12-04 10:32
has joined #pact-jvm

malvine.logina
2023-12-04 11:52
has joined #pact-jvm

aniket.rane
2023-12-04 15:55
Fixed it. Just in case someone else runs into same issue. Edit your build.gradle dependecies section so: ```testImplementation('au.com.dius.pact.consumer:java8:4.1.7') { exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib' exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7' exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8' exclude group: 'org.jetbrains.kotlin', module: 'kotlin-reflect' } testImplementation('au.com.dius.pact.consumer:junit5:4.1.7') { exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib' exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7' exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8' exclude group: 'org.jetbrains.kotlin', module: 'kotlin-reflect' } implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.71' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.71' implementation 'org.jetbrains.kotlin:kotlin-reflect:1.3.71' implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.71'```

aniket.rane
2023-12-04 15:57
PS: Remove the entries from buildscript -> dependencies: ``` classpath 'au.com.dius:pact-jvm-consumer:4.0.10' classpath 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72' classpath 'com.google.code.gson:gson:2.8.6'``` You don't need them

anna.nava
2023-12-04 16:53
:pray: would anyone have any suggestion or where can I see examples on how to build a protobuf matcher that checks that a property in the protobuf message is either of type UUID4 ..... or that it simply matches the regex :pray: from my kotlin code below :point_down: you can clearly see I don't know what to pass in and I don't want to serialize from JSON, but from protobuf or maybe I am doing it all wrong and can't be done like this as there isn't a direct equivalent to `http://au.com.dius.pact.consumer.dsl.DslPart` for protobuf.... so I wonder if Protobuf requires a different approach to what I am attempting here :questionmario: ```@Pact(consumer = "my-service") fun createPact(builder: PactBuilder): V4Pact { val messageFile = loadFileFromJarResource("/events/pub/a/v1/a_event.proto") return builder .usingPlugin("protobuf") .expectsToReceive("an AEvent ", "core/interaction/message") .with( mapOf( "message.contents" to mapOf( "pact:proto" to messageFile.path, "pact:message-type" to "AlertEvent", "pact:content-type" to "application/protobuf", "pact:protobuf-config" to mapOf("additionalIncludes" to listOf("/Users/anna.nava/dev/protobuf/proto")), "this_amazing_property" to mapOf( //this compiles, but passes empty string: "id" to regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$") //this doesn't compile:"id" to matchRegex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$") //this compiles, but ends up passing in an empty string: "id" to regex("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}") //"id" to mapOf("matchers" to mapOf("match" to "regex", "regex" to "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}\$" )) "id" to regexp("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$", "123e4567-e89b-12d3-a456-426614174000") ),``` (apologies if this is not the right channel for, very appreciated if anyone can redirect me where is best for me to ask this, thanks!)

rholshausen
2023-12-04 22:41
No, sorry, I can't see anything wrong with that. Maybe Springboot 2.7.14 won't work with that version of Gradle? Try with Springboot 3 ot maybe an older version of Gradle

abubics
2023-12-05 00:49
Just a Slack-hygiene tip, instead of copying the message to multiple channels, you can share the original to another channel ? then you won't get replies in different places :innocent:

anna.nava
2023-12-05 13:00
you are absolutely right, ignore my message above, if anyone has comments I'd appreciate them in https://pact-foundation.slack.com/archives/CEQBDD5U4/p1701708708926059

vinicius.gabriel
2023-12-05 13:59
has joined #pact-jvm

stasiekps
2023-12-05 15:13
has joined #pact-jvm

antal.tettinger
2023-12-05 15:50
has joined #pact-jvm

archaanaaa8
2023-12-06 07:19
has joined #pact-jvm

archaanaaa8
2023-12-06 07:20
Verifying a pact between abc and xyz - A request to get something 1.1) Connect to http://localhost:8081 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: no further information

bas
2023-12-06 07:22
It looks like your provider service isn?t running. Is it? If so, is it running on port 8081?

archaanaaa8
2023-12-06 07:23
Not unless I start my service using SpringApplication.run(service.Class);

archaanaaa8
2023-12-06 07:24
How to make it start automatically as starting my service requires me to pass secrets which I cannot

bas
2023-12-06 07:29
I have no idea, but that?s also more of a Spring question than a Pact question I guess. Here?s how I start my service automatically when I verify contracts: https://github.com/basdijkstra/introduction-to-contract-testing/blob/main/address-provider/src/test/java/provider/ContractTest.java But that doesn?t require secrets

anna.nava
2023-12-06 09:54
does anyone know if there is any alternative to ```au.com.dius.pact.consumer.dsl.PactDslJsonBody``` for protobuf?

visaliparimi
2023-12-06 10:03
has joined #pact-jvm

indrani.r
2023-12-06 10:06
has joined #pact-jvm

frank.weitmann
2023-12-06 10:23
has joined #pact-jvm

venketeshvenky
2023-12-06 10:40
has joined #pact-jvm

rholshausen
2023-12-06 21:59
No, not yet

abubics
2023-12-06 22:55
Also, needing to pass secrets might (but also might not) be a warning sign that you have unwanted dependencies in test.

kyle.r.shrader
2023-12-07 01:33
has joined #pact-jvm

ajay991610
2023-12-07 05:27
has joined #pact-jvm

marko.stevanovic
2023-12-07 10:01
has joined #pact-jvm

mahesh.manglani
2023-12-07 16:49
has joined #pact-jvm

gerard.molina
2023-12-07 17:00
has joined #pact-jvm

gerard.molina
2023-12-07 17:05
Hello there! :wave: Do you know if there?s a way to configure the communication with the pact broker to use x509 certificates in the http requests? We have a self-hosted pact broker that needs a x509 to validate incoming requests. So when downloading pacts and uploading results we need to include custom x509 certificate. Thanks in advance :raised_hands:

boyd.social
2023-12-07 17:52
has joined #pact-jvm

gjourdanweil
2023-12-07 18:44
Hello folks, is there (still) a need to define tags on provider when using the "pending pacts" feature?

gjourdanweil
2023-12-07 18:45
I'm using pact4s (Scala wrapper) that forces me to use tags to use the pending pacts. But AFAIK tags are deprecated for some time.

gjourdanweil
2023-12-07 18:45
Thus, wondering if I'm right to say this doesn't make sense anymore.


rholshausen
2023-12-07 22:02
No, it won't support that without modification

matt.fellows
2023-12-07 22:12
Pending Pacts work for branches, yes. You?re right, that restriction should be lifted

muhd_syamil.dzulkafta
2023-12-08 05:47
has joined #pact-jvm

gjourdanweil
2023-12-08 07:08
Thanks @matt.fellows

omer.sucu
2023-12-08 10:04
has joined #pact-jvm

hermoine807
2023-12-08 12:04
has joined #pact-jvm

blake.norrish
2023-12-08 17:05
has joined #pact-jvm

robert.jelic
2023-12-10 23:02
has joined #pact-jvm

pragna.reddy
2023-12-11 11:32
has joined #pact-jvm

oguzhannvarol
2023-12-11 14:13
has joined #pact-jvm

aniket.rane
2023-12-11 17:17
Looking for guidance here in terms of best practices for writing Consumer side pact tests. We setup POCs recently for some of our microservices.. Different team members took different approaches for implementing the tests on the consumer side. Some team members used the actual service code from the consumer to write the tests, for eg: `@Test` `@PactTestFor(pactMethod = "getAllProducts")` `void getAllProducts_whenProductsExist(MockServer mockServer) {` `Product product = new Product();` `product.setId("09");` `product.setType("CREDIT_CARD");` `product.setName("Gem Visa");` `List expected = Arrays.asList(product, product);` `RestTemplate restTemplate = new RestTemplateBuilder()` `.rootUri(mockServer.getUrl())` `.build();` `List products = new *ProductService(restTemplate).getAllProducts();*` `assertEquals(expected, products);` `}` Where as some mocked out the whole service call instead, for example: `@Test` `@PactTestFor(pactMethod = "articles")` `void testArticles(MockServer mockServer) throws IOException, GeneralSecurityException {` `HttpResponse httpResponse = get(mockServer.getUrl() + "/articles.json");` `assertThat(httpResponse.getStatusLine().getStatusCode(), is(equalTo(200)));` `assertThat(IOUtils.toString(httpResponse.getEntity().getContent()),` `is(equalTo("{\"articles\":[{\"variants\":{\"0032\":{\"description\":\"sample description\"}}}]}")));` `}` To me, using the actual service code in the test is the intended way as it helps us validate the request body/shape etc. Mocking the whole service call feels wrong to me. Top of my head, here are some reasons: 1. If the consumer code for that service call changes, this test is not going to capture that. 2. If we are to mock everything do we need the tests to be in consumer code then? They can be anywhere (some other test repository for example). What are you thoughts on this? Is there a "Correct" way of writing these tests?

ryan.quinn
2023-12-11 17:57
has joined #pact-jvm

ryan.quinn
2023-12-11 18:00
I'm a co-worker of Devin's. This has continued to be an intermittent (though frequent) issue for us. We are using PactFlow. Here is the most recent element in our matrix, which shows SOS having a mainline branch and tag. We aren't using environments.

ryan.quinn
2023-12-11 18:01
Using this `return selectorBuilder.branch(System.getProperty("consumer.branch", "mainline"), "SOS")` Gives me this output: ```au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify Provider: DASHBOARD Consumer: SOS Source: Pact Broker https://smartsheet2.pactflow.io consumerVersionSelectors=[Branch(name=mainline, consumer=SOS, fallback=null)]```

ryan.quinn
2023-12-11 18:01
If I don't specify any consumer version selector, the tests run as expected, against the most recently published consumer pact.

ryan.quinn
2023-12-11 18:02
If I specify the mainline tag, it finds a bunch of tests to run.

ryan.quinn
2023-12-11 18:07
Using `selector.mainBranch()` returns a similar error as above: ```au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify Provider: DASHBOARD Consumer: SOS Source: Pact Broker https://smartsheet2.pactflow.io consumerVersionSelectors=[au.com.dius.pact.core.pactbroker.ConsumerVersionSelectors$MainBranch@6cdfd50a]```

bas
2023-12-11 19:29
If you do consumer-driven contract testing, you?re writing the code that generates the contract in the consumer project. So, to me, you should use the consumer code, i.e., the second option. And yes, these tests should be in the consumer code, as the tests that generate the Pact can also be used to test consumer implementation, using the mock provider that Pact generates for you. Your team didn?t mock the entire service call, Pact generates a mock provider from the expectations you set in the `@Pact` method. Please keep in mind that consumer-driven contracts are meant to convey the expectations the consumer has about provider behaviour, so they?re written from the consumer perspective. In other words, they?re not meant to test provider implantation, they?re meant to verify that consumer and provider can communicate. That?s a big difference.

rholshausen
2023-12-11 22:20
In the second example you are not testing anything other than the Pact-JVM mock server.

aniket.rane
2023-12-11 22:29
Thanks @bas. I think you meant to say go with option 1 and not 2nd. I agree with you there.

aniket.rane
2023-12-11 22:29
@uglyog: Correct. So maybe as an example the 2nd option is ok but should not be implemented as final solution. PS: I took both these code snippets from pact-jvm examples from pact-foundation github repos 1. https://github.com/pact-foundation/pact-workshop-jvm-spring/blob/main/consumer/src/test/java/au/com/dius/pactworkshop/consumer/ProductConsumerPactTest.java 2. https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit5/src/test/java/au/com/dius/pact/consumer/junit5/ArticlesTest.java

rholshausen
2023-12-11 22:30
Yes, the Pact-JVM examples don't have anything to test, because they are not part of a consumer project. And they are there to test the mock server and DSL.

rholshausen
2023-12-11 22:31
The workshop is the correct example to base your tests on

bas
2023-12-12 06:53
I see it now, I thought that `RestTemplate` was a provider thing. In that case yes, I?d prefer option one, too.

arnon
2023-12-12 09:01
has joined #pact-jvm

lewis.blackwood
2023-12-12 14:04
has joined #pact-jvm

ilie.cotiuga
2023-12-12 14:26
has joined #pact-jvm

remyjaume
2023-12-12 15:46
has joined #pact-jvm

amelie.frappier
2023-12-12 18:55
has joined #pact-jvm

flament.thom
2023-12-12 20:43
has joined #pact-jvm

ckbisk
2023-12-12 22:18
has joined #pact-jvm

sterankin
2023-12-13 10:57
has joined #pact-jvm

shane.bogdan
2023-12-13 12:06
has joined #pact-jvm

luis.nuno
2023-12-13 18:08
has joined #pact-jvm

raleigh.schickel
2023-12-13 23:15
has joined #pact-jvm

ashish_garg5
2023-12-14 18:09
Hi Team, *mvn clean install -Dpact.verifier.publishResults=true -Dpact.provider.version=6.4.0.c19b67a-3* *-Dpact.provider.tag=test -Dpact.provider.branch=dev* Want to know how I can make use of the branch. I am running the above command which is tagging the tag and branch with "test" how I can tag the version with my branch name "dev" ? Thanks.

rholshausen
2023-12-14 22:14
What version of Pact-JVM are you using? And how are you propagating the properties set on the command line to the running tests?

ashish_garg5
2023-12-15 03:17
4.1.41 pact-jvm

ashish_garg5
2023-12-15 03:18
Is it available from higher versions ?

rholshausen
2023-12-15 03:33
Should be available in 4.1.30 and later

hataipat.sup
2023-12-15 05:26
has joined #pact-jvm

hakan.dilaver
2023-12-15 13:54
has joined #pact-jvm

ashish_garg5
2023-12-15 14:38
ok and this is the correct way to use it right pact.provider.branch ?

eliranbardavid
2023-12-17 09:06
has joined #pact-jvm

anthony.trad
2023-12-17 12:30
has joined #pact-jvm

rholshausen
2023-12-17 22:01
That passes it on the command line to the Maven process, not to your test. You need to check how the other values are being passed to the tests.

ashish_garg5
2023-12-18 01:28
Yeah that I was setting in the JVM system property. And I got the issue pact.provider.branch is available from 4.3.0-beta.7+ versions.

ashish_garg5
2023-12-18 01:29
Now looks like If I want to use this property I have to work on the some code changes.

ulises.cervino
2023-12-18 14:47
hi all, how does one deal with deeply nested fields that should be overridden in the provider state, e.g. via `valueFromProviderState`? I don?t want to build the request body with `LambdaDsl` , I?d rather use actual request objects if possible, etc.

m.mohammadi.se
2023-12-18 19:31
has joined #pact-jvm

lewis.foreman
2023-12-18 21:45
has joined #pact-jvm

eran.bergman560
2023-12-19 18:43
has joined #pact-jvm

eran.bergman560
2023-12-20 03:12
Hello Pacters! I'm working on a very large (Spring Boot + Hibernate) monolith which we are now starting to decompose into multiple services. As part of this effort we would like to venture into the world of Contract Testing but I'm not really sure how to operatively approach a few basic (monolithic) things: 1. I noticed that in most if not all of the code samples I've found `@SpringBootTest` is used along with mocking of beans. Since we are working with a very large application we would need to mock hundreds of beans in order to test even the most simple APIs. I'm wondering if the guidance is actually mocking or using the actual beans. I suppose this is a conceptual question: how "deeply" do you test your provider application. 2. as a followup (assuming testing with actual beans) State is a concern as well as the application (and existing unit tests) currently rely on various entities to be created in the DB per test, how should we approach this in Pact where I don't really see a good way to pass things such entities IDs to the calls that a `SpringRestPactRunner` is making to the endpoints. entity IDs are part of our API but I don't know how to match it, is there a way to do that which I haven't seen? 3. Our monolithic application takes a very long time to start up (5+ minutes) and in terms of performance we would like to "reuse" the same process for testing multiple APIs which normally means writing all the tests in a single class which obviously won't scale as we already have hundreds+ of APIs and managing this amount of test code will be a challenge. Any practical advice for how to approach this? (this topic is probably across Spring, Pact, unit tests and code management) As you can probably tell I'm coming from an end-to-end testing mindset and trying to figure out how to adapt to Pact. I would appreciate any pointers, especially regarding monolithic applications.

matt.fellows
2023-12-20 04:30
I can?t answer the very java specific questions, but I?ll attempt to help

matt.fellows
2023-12-20 04:32
On (1) - you don?t need to mock all of the beans, however you will definitely want to mock them in a few cases 1. Where those beans interact with external systems (because we want tests to be deterministic, or at least, close to) 2. Where you need fine-grained control over their behaviour to satisfy a test (because we?ll need to test many scenarios, and using mocks is a nice way to get that control) If the state of the system can be controlled by simply calling the beans themselves in the test, that is probably also fine. Much of this is on the concept of ?provider states?. If you haven?t come across that term yet, worth digging through the docs and examples to get a feel for it. This tends to resolve a lot of the problems that come from having that end-to-end testing mindset you astutely pointed out.

ulises.cervino
2023-12-20 06:52
hi all, I?m struggling to figure this one out: what are the consumer selectors that will give me behaviour such as ?verify _all_ contracts?, i.e. not just main branches or deployed, but all consumer branches, for all consumers (I am aware that it?ll be expensive, but right now I want to get coverage first, then optimise).

ulises.cervino
2023-12-20 06:53
I suspect I?ll need pending + wip pacts? Because of course that I don?t want a bad contract from a consumer branch to prevent me from deploying.

matt.fellows
2023-12-20 06:54
Yep, Wip pacts would be what you need to get a wide base. I'm just on mobile but I'm not sure there is a selector for "all", but that's really the intent of WIP to an extent (catch all the ones I didn't expect and don't fail my build)

eran.bergman560
2023-12-20 07:07
I wasn't sure this is the right place for the Java questions but thought it was worth a shot just in case someone has encountered similar problems Thanks for the response :slightly_smiling_face:

eran.bergman560
2023-12-20 07:15
I actually looked at the `@State` and played around with it, my question was particularly about this, for a lot of our tests we will need to create some entities (business objects) in our DB as we have a very complex system with a lot of intertwine logic that I can't simply mock away. I'm expecting that my `@State` will need to create an entity but I don't know how to pass along an ID of an entity created in the `@State` as part of the API call (the ID is currently part of the API). Could you point out some relevant documentation for that? - I couldn't find anything regarding that in the https://docs.pact.io/implementation_guides/jvm/provider/junit area

ulises.cervino
2023-12-20 08:00
follow up question: if I enable pending pacts I need to provide a tag for my provider verification results, but `master` isn?t it because I want the same behaviour for my provider branches too. Is tag supposed to represent a version? a branch? a release?

matt.fellows
2023-12-20 09:32
> I wasn?t sure this is the right place for the Java questions but thought it was worth a shot just in case someone has encountered similar problems It?s the right spot, i?m just not that Java-y :stuck_out_tongue:

matt.fellows
2023-12-20 09:36
> I?m expecting that my `@State` will need to create an entity but I don?t know how to pass along an ID of an entity created in the `@State` as part of the API call (the ID is currently part of the API). > Could you point out some relevant documentation for that? - I couldn?t find anything regarding that in the https://docs.pact.io/implementation_guides/jvm/provider/junit area (edited) see ?Having values injected from provider state callbacks? from https://docs.pact.io/implementation_guides/jvm/consumer/junit5#forcing-pact-files-to-be-overwritten

tom.dracz
2023-12-20 09:53
has joined #pact-jvm

ivan.gutowski-smith
2023-12-20 10:40
has joined #pact-jvm

nicolas.vaquero
2023-12-20 11:31
has joined #pact-jvm


gjourdanweil
2023-12-20 12:08
Tags are deprecated in favour of explicit attributes.

gjourdanweil
2023-12-20 12:09
In the case of pending pacts, I believe a branch is expected.

gjourdanweil
2023-12-20 12:10
And that would be the provider branch, so it shouldn't always be master, it's the current branch you're testing.

ulises.cervino
2023-12-20 14:28
right, that was my understanding. It?s just that in pact-jvm we still have `providerTags`, i.e. ```@PactBroker( includeWipPactsSince = "2023-01-01", enablePendingPacts = "true", providerTags = "master")```

ulises.cervino
2023-12-20 14:28
ah, there?s also `providerBranch`, I?ll use that!

emailmvj
2023-12-20 16:18
has joined #pact-jvm

matt.fellows
2023-12-21 00:56
Sorry I missed this guys, looking into it now?

matt.fellows
2023-12-21 01:15
Thanks @gjourdanweil!

matt.fellows
2023-12-21 01:17
Any chance you could please share `DEBUG` level logs with me from the verification process? That would really help

matt.fellows
2023-12-21 01:18
Actually, could you please send them to SmartBear support? I?ll be on leave from today, and don?t want this to get lost (howtosmartbearsupport)

2023-12-21 01:18
Please create a ticket here with the issue details so that we can properly track the resolution and the PactFlow product support team will continue to work through it with you: https://support.smartbear.com/pactflow/message

noelmccrory
2023-12-21 12:31
has joined #pact-jvm

fajfer.pawel
2023-12-21 13:39
has joined #pact-jvm

praful.poudel
2023-12-21 13:44
has joined #pact-jvm

pratyush.jaiswal88
2023-12-23 16:45
has joined #pact-jvm

grzegorz.v.bobrowski
2023-12-24 02:37
has joined #pact-jvm

elias.coelho
2023-12-27 17:52
has joined #pact-jvm

tomer
2023-12-28 21:52
has joined #pact-jvm

christopher316
2024-01-02 20:10
has joined #pact-jvm

matt.pichette
2024-01-02 20:26
has joined #pact-jvm

ocean.razafiarison
2024-01-03 08:57
has joined #pact-jvm

salmaan60
2024-01-03 20:14
has joined #pact-jvm

sam.huang1
2024-01-04 03:20
has joined #pact-jvm

ratnajenisha
2024-01-04 04:04
has joined #pact-jvm

markkellett
2024-01-04 18:27
has joined #pact-jvm

varghesevarampi
2024-01-05 02:10
has joined #pact-jvm

lbrndmrcr
2024-01-05 11:52
has joined #pact-jvm

mcarballido17
2024-01-05 20:12
has joined #pact-jvm

yonahlipman
2024-01-07 04:00
has joined #pact-jvm

x1destory
2024-01-07 19:21
has joined #pact-jvm

christopher.tonog
2024-01-08 18:53
has joined #pact-jvm

harshad.rayunipet
2024-01-09 08:06
has joined #pact-jvm

kumar.vas85
2024-01-09 09:50
has joined #pact-jvm

devin.woods
2024-01-09 22:40
Is there a way to force Pact to always generate the Pact files? For some reason, I am seeing that when using Pact with Java, and the Maven surefire plugin, the Pacts are no longer being generated as I expect. Details in thread.

devin.woods
2024-01-09 22:41
I'm using maven-surefire-plugin 3.1.0, and the consumer junit5 Pact artifact v4.4.6.

devin.woods
2024-01-09 22:42
I have a very simple test set up, just to make a dummy contract which my example provider pulls and looks at. It has all been working until I just discovered that my CI/CD pipeline was no longer finding artifacts to upload as a result of running `mvn test`.

devin.woods
2024-01-09 22:43
I would expect that when I run `mvn test` here, `./target/pacts` is generated and the updated Pact file exists. This has always worked for me.

devin.woods
2024-01-09 22:44
However, it is no longer being generated. When I run `mvn test`, I can see that the test (the only one in this repo) was run, and it succeeded. But no Pacts.

devin.woods
2024-01-09 22:45
I've tried setting some system property variables on the surefire plugin config in my pom.xml too:

devin.woods
2024-01-09 22:45
```<plugin> <artifactId>maven-surefire-plugin</artifactId> <version>3.1.0</version> <configuration> <systemPropertyVariables> <pact.rootDir>target/pacts</pact.rootDir> <pact.writer.overwrite>true</pact.writer.overwrite> </systemPropertyVariables> <classpathDependencyExcludes> <!-- to avoid multiple binding warning from slf4j in unit-tests --> <classpathDependencyExclude>org.apache.logging.log4j:log4j-slf4j-impl</classpathDependencyExclude> </classpathDependencyExcludes> </configuration> </plugin>```

devin.woods
2024-01-09 22:45
Doing this, and passing the flags in manually to the command line via `-D` flags yields the same result.

devin.woods
2024-01-09 22:46
I've tried manually wiping out the entire `target` folder, and re-running - same result.

matt.fellows
2024-01-09 23:32
Do you have any logs to help us out here? There is no reason why the pact wouldn?t be generated on a clean build. Does it work locally?

matt.fellows
2024-01-09 23:32
If you can get some DEBUG level logs, we might be able to see what?s going on


shuo.diao
2024-01-09 23:54
has joined #pact-jvm

chris.speck
2024-01-10 02:52
has joined #pact-jvm

devin.woods
2024-01-10 17:28
> Does it work locally? Nope, once I started seeing the issue in my pipeline I switched over to debugging locally, which is where I see the issue still happening. Tried deleting `/target` and running the tests through the command line and IntelliJ, to no avail.

devin.woods
2024-01-10 17:30
> I assume also you?ve seen https://docs.pact.io/implementation_guides/jvm/provider/junit5#-important-note-for-maven-users-? I didn't have that value set, and it was working previously. I just tried adding it and am seeing the same behavior on my local.

devin.woods
2024-01-10 17:30
> If you can get some DEBUG level logs, we might be able to see what?s going on This is a super thin example repo I am setting up for my company, so I don't really have logging infra set up. I'll give this a shot though.

trevor.cook
2024-01-10 18:33
has joined #pact-jvm

devin.woods
2024-01-10 20:45
Ah, I found my issue! I had changed the underlying implementation to "fake" a safe change, replacing the implementation of the HTTP client. When I changed it, I told it to just return a mock instead of hitting Pact's mock server, so I think that Pact never actually got the interaction, and thus, didn't generate a contract. Thanks for the help @matt.fellows!

matt.fellows
2024-01-10 21:53
ah, no worries - that would do it :wink:

devin.woods
2024-01-10 21:57
Curious though, for future issues, I have seen you mention DEBUG logs in a few posts. Is that a Pact flag that I can flip somewhere, or are you referring to just expanding our logging filter to the DEBUG level as a whole?

devin.woods
2024-01-10 21:58
For instance, I am running into the issue described https://pact-foundation.slack.com/archives/C9UN99H24/p1702318037796309?thread_ts=1696015979.911679&cid=C9UN99H24 again, and want to take another shot at it. You mention DEBUG logs there too. Anything special I need to do on the Pact side here?

matt.fellows
2024-01-10 22:00
> Curious though, for future issues, I have seen you mention DEBUG logs in a few posts. Is that a Pact flag that I can flip somewhere, or are you referring to just expanding our logging filter to the DEBUG level as a whole? Yeah, it?s been a while since I?ve done JVM but I believe you increase the verbosity for the Pact related packages

devin.woods
2024-01-10 22:01
What about on the `pact-go` side of things? Our shop uses Java and Go for both consumers and providers.


matt.fellows
2024-01-10 22:02
Go can be done in a few ways, there is a function to cal, or you can set an env var `LOG_LEVEL=debug`

devin.woods
2024-01-10 22:02
Awesome, thank you.

thomas.fisher
2024-01-11 10:42
:wave: hi all! is it possible to force the provider to only test against the "latest" pact, and ignore what's currently deployed? e.g. some combination of version selectors? We seem to have found a weird situation where we can't progress either consumer or provider pipeline. We've made two changes to the contract in one PR. The first time around, consumers validated the contract and everything went swimmingly. However,, after the second change, the provider verifies against the latest pact, but not against the one in Dev. This causes the provider test task to report a failure, so it does not deploy and is not marked as such in pactflow. Or, should I always allow my provider task to PASS even if there are test failures, and just let "can-I-deploy" decide? Maybe I have answered my own question :smile:

thomas.fisher
2024-01-11 11:18
That allowed me to progress onto "can-I-deploy", but weirdly this stage only used the verification from Dev, which was a failed verification, and ignored the one with latest. I wonder if there is some param we need to add/omit here to the "can-I-deploy" tasks. I don't own the pipeline code for this, so I will speak to that team - but if you have any ideas please let me know :smile:

ulises.cervino
2024-01-11 14:15
> Or, should I always allow my provider task to PASS even if there are test failures, and just let ?can-I-deploy? decide? Maybe I have answered my own question this is what we do

ulises.cervino
2024-01-11 14:15
you found yourself in a strange loop where everybody?s blocked. Been there before.

thomas.fisher
2024-01-11 14:15
cool :slightly_smiling_face: yes this makes sense

ulises.cervino
2024-01-11 14:15
at face value, this suggests that there?s a breaking change somewhere. Is that the case?

thomas.fisher
2024-01-11 14:18
yeah, so we found this issue in "the wild" and I was able to reproduce it in my own testing system. There were two changes that required the provider to make a change. On the first "flow", everything is OK - but I didn't merge the PRs at this time. Instead, we made another change to the consumer, that required another change from the provider. This is when things went awry

thomas.fisher
2024-01-11 14:19
It would make logical sense that after each contract change, we should be merging the PRs, but that's not always gonna be the case

ulises.cervino
2024-01-11 14:20
right, in principle the provider always merges first. Say you?re implementing a new endpoint `/new` and you have a current endpoint `/current` and you want your consumers to move over to `/new`. You still have to support `/current` in your verifications (this is how you get your verifications passing for what?s deployed). You also need to be able to verify `/new`, and you do this with pending+wip pacts.

ulises.cervino
2024-01-11 14:20
if you think about it from the backwards-compatibility (or breaking changes) POV it makes sense

ulises.cervino
2024-01-11 14:21
and so the sequence is: 1. provider implements `/new` alongside `/current` 2. provider verifies both (this includes deployed and wip+pending pacts) 3. if can-i-deploy is happy (it should be), _provider_ rolls out 4. now consumer can roll out the branch where the switch `/current`->`/new` happens

thomas.fisher
2024-01-11 14:26
^ that makes sense The specific change in my little test was to add a requirement that the provider returns a header with a value that matches UUID regex. The "old" provider doesn't do this, the new one does Both versions of the pact should pass against this provider, because in the old pact (deployed to Dev) it doesn't care if the header is there or not, and in the new pact it does care - but the provider does return this now

thomas.fisher
2024-01-11 14:26
so I guess what may have happened is I am now in state where my provider does not pass against the old one, therefore I have snookered myself :smile:

ulises.cervino
2024-01-11 14:26
right, so in theory you should be able to roll out the provider no bother

thomas.fisher
2024-01-11 14:26
I will look at why it is failing

thomas.fisher
2024-01-11 14:27
it's good to have that flow in my mind though

ulises.cervino
2024-01-11 14:27
off the record: you can always add `--ignore=` to `can-i-deploy` to get out of this rut, and then get rid of it once everything?s in sync again

thomas.fisher
2024-01-11 14:28
I think the pipeline owner will be doing something along those lines for the "real" one

ulises.cervino
2024-01-11 14:28
:nod-hmm-yes:

thomas.fisher
2024-01-11 14:30
I will take a look and get back to you :smile: thanks for the walkthrough

thomas.fisher
2024-01-11 14:30
it's always good to get chat things through

ulises.cervino
2024-01-11 14:30
no worries, let me know if I can help further :+1:

meetbogireddyhere
2024-01-11 16:20
has joined #pact-jvm

matt.fellows
2024-01-11 22:34
Thanks for your detailed answer Ulises

matt.fellows
2024-01-11 22:34
:taco: :taco: :taco: for you sir @ulises.cervino

noelmccrory
2024-01-12 10:36
I'm trying to generate a V2 Spec but am hitting the error `Pact specification V4 features can not be used with version V2 - Number matchers can only be used with Pact specification versions >= V3` . I've tried to use the example from https://github.com/pact-foundation/pact-jvm/issues/958 of using a `numberType` matcher, which should generate `match: 'type'` in the generated Pact file according to the corresponding change that was made, but I just get the error. Any ideas? Thanks.

david.garratt
2024-01-12 10:36
has joined #pact-jvm

noelmccrory
2024-01-12 10:45
The only success I've had in generating V2 specs with `PactDslJsonBody` is by using the `.xxxValue` methods, which doesn't actual generate any matchers in pact contract. I was able to use `PactBuilder` to generate `regex` matchers, but that's not ideal as I'd have to use regexes for everything rather than just matching on `type`

roger.vanburgh
2024-01-12 16:54
has joined #pact-jvm

roger.vanburgh
2024-01-12 16:59
Hey, I've noticed an interesting bug (or feature?) with the `newJsonBody` builder for the `LambdaDsl` tests in Junit5: The JsonBody I am trying to mock has a field that has a hyperlink as it's fieldName, but as soon as I add a fieldName into the builder that contains a `.` or a `/` character, it turns the fieldName into a JsonList of that string, instead of just leaving it as a plain old String. Screenshots in :thread: Any ideas on how to work around/fix this?

roger.vanburgh
2024-01-12 17:00
This is the "goal" of my Json mocking

roger.vanburgh
2024-01-12 17:02
This is the result from my code ```.withContent( newJsonBody( (body) -> { final PactDslJsonBody actualPactDsl = new PactDslJsonBody(); var jwtHelper = new JwtTestHelper( VALID_VC_HEADER, VALID_VC_BODY, VALID_VC_SIGNATURE); body.nullValue("error"); body.stringValue("iss", "f2f"); body.stringValue("sub", "test-subject"); body.stringType( "state", "f5f0d4d1-b937-4abe-b379-8269f600ad44"); body.minArrayLike( "https://vocab.account.gov.uk/v1/credentialJWT", 1, PactDslJsonRootValue.stringMatcher( jwtHelper .buildRegexMatcherIgnoringSignature(), jwtHelper.buildJwt()), 1); actualPactDsl.close(); body.nullValue("error_description"); }) .build())```

eran.bergman560
2024-01-13 19:34
What would be the correct way to specify a subdomain variable in a URL in the DSL for a REST call? is there a flavour of provider state callback similar to `pathFromProviderState` (https://docs.pact.io/implementation_guides/jvm/consumer/junit5) ? : ```.pathFromProviderState("/api/users/${id}", "/api/users/100")``` I need to represent a url of this type: `${tenant_subdomain}.pact_calling_url/api/users/${id}` where both `tenant_subdomain` and `id` would come from the provider state but I don't know how to treat the subdomain aspect of it as the PactDslWithProvider treats the path as everything after the `pact_calling_url` which at test time is `127.0.0.1` (not sure if this is translated by Spring or Pact)

matt.fellows
2024-01-14 09:59
The subdomain is irrelevant. It's just part of the host. Which Pact is agnostic to. Is it important in your use your case? E.g. do different tenants have different APIs or behave differently? If so. Arguably they are a different provider

matt.fellows
2024-01-14 09:59
Sounds like a bug to me, mind raising an issue over on GitHub?

pratyush.jaiswal88
2024-01-15 06:25
how to run the pact test using command line

matt.fellows
2024-01-15 07:17
Pact runs as part of your unit testing runner

roger.vanburgh
2024-01-15 09:06
Yep will do, thanks

sarah.omalley
2024-01-15 10:03
has joined #pact-jvm

lauren.flanagan
2024-01-15 13:51
has joined #pact-jvm

eran.bergman560
2024-01-15 16:11
I agree, subdomain is normally part of the host but distinguishing between tenants is a core part of our existing application logic (its not the API itself but part of the inputs for it - probably not your classic REST API design, if it was then it would probably have been passed as a parameter of sorts). I'm trying to adopt Pact and make it work with an existing application so this isn't a pure API concern I suppose but I can't really retrofit the application for this purpose.

anna.nava
2024-01-15 17:09
I have the same issue :disappointed: did you have any luck?

anna.nava
2024-01-15 17:17
:blobwave: After successfully published contracts and ran Consumer tests in the consumer repo (which is also kotlin +gradle) Now I am working on the provider verification....on this repo I have Gradle 7.6.2 & Kotlin 1.7.10 I am really stuck with the `pactVerify` : When I run the test class from my intelliJ'JUnit "run test" :arrow_forward: it simply works fine :white_check_mark: (ie I can see how it connects to the pact broker, fetches the corresponding contract for this providera and verifies the protobuf message I am sending to the broker actually matches the pact contract... because if I send a slightly odd value it does complain correctly) ... But the problem I have is when I try to follow the examples in https://docs.pact.io/implementation_guides/jvm/provider/gradle#for-pact-jvm-410-and-later :no_entry_sign: when I try to run `./gradlew pactVerify` I get a compilation error for `Unresolved reference: myServiceProvider, fromPactBroker, withSelectors, branch` on my `build.gradle.kts` file I have: ```plugins { id("org.jmailen.kotlinter") version "3.14.0" id("org.springframework.boot") version "3.0.2" kotlin("jvm") version "1.8.10" kotlin("plugin.spring") version "1.8.10" id("com.google.cloud.tools.jib") version "3.4.0" id("com.adarshr.test-logger") version "3.2.0" // code coverage jacoco id("org.sonarqube") version "4.0.0.2929" id("co.uzzu.dotenv.gradle") version "2.0.0" id("com.avast.gradle.docker-compose") version "0.17.5" id("com.ryandens.javaagent-jib") version "0.5.1" id("org.springdoc.openapi-gradle-plugin") version "1.6.0" id("au.com.dius.pact") version "4.6.3" } ... pact { broker { pactBrokerUrl = } serviceProviders { myServiceProvider { fromPactBroker { withSelectors { branch('test') } } } } }``` but when I try to run `./gradlew pactVerify` I get a compilation error for `Unresolved reference: myServiceProvider, fromPactBroker, withSelectors, branch` what am I missing? what's wrong with the syntax I am using?

tunga
2024-01-15 23:16
has joined #pact-jvm

matt.fellows
2024-01-16 00:39
I guess my question is, why should the _contract_ know about the different tenants? Does it change the API behaviour in anyway? If the tenant URL changed, would that invalidate the contracts?

roger.vanburgh
2024-01-16 09:25

anna.nava
2024-01-16 11:58
if it helps anyone with the same problem this was because I was trying to use groovy syntax in kotlin, so I've adapted to: ```pact { broker { pactBrokerUrl = <url to my pact broker> } serviceProviders { create( "myProvider" ) { fromPactBroker( closureOf<PactBrokerConsumerConfig> { withSelectors { branch("main") } } as Closure<PactBrokerConsumerConfig> ) } } }```


yousafn
2024-01-16 12:07
thanks for confirming and posting back Anna

sayan.adak
2024-01-16 12:21
has joined #pact-jvm

shobhit.agarwal
2024-01-16 12:22
has joined #pact-jvm

carmen.rietdijk
2024-01-16 12:53
has joined #pact-jvm

eran.bergman560
2024-01-16 17:10
oh, this isn't a contract consideration but a practical issue, our (HUGE) application components expects inputs in a certain way and part of the interceptor chain is extracting information such as domain and subdomain from the URL which is later used across the system. from what I can tell the ways to deal with this issue is one of the following: ? mock the information we aren't getting (a URL that our application can live with) ? use a HttpServletRequestWrapper to modify the URL to do the same thing (less invasive) I've implemented the latter for our tests (this is mainly for people from the future reading this)

matt.fellows
2024-01-16 21:07
ah! I see. How do you test against your tenanted application locally - do you have local subdomains with fake host entries? Or? :see_no_evil: are you not able to test it locally?

eran.bergman560
2024-01-16 21:22
we don't use `@SpringBootTest` but an actual running tomcat with an actual running application ontop of it so I guess a big part of the gap we need to cover is adopting running with `@SpringBootTest`

eran.bergman560
2024-01-16 21:23
(we have very specialized and homegrown CI and testing environments)

nick116
2024-01-17 09:57
has joined #pact-jvm

anna.nava
2024-01-17 11:42
:pray: does anyone know what alternatives do I have for this problem: *Problem:* I am working on the provider verification....on this repo I have `Gradle 7.6.2` & `Kotlin 1.7.10` ```au.com.dius.pact version "4.6.3"``` when I try to run `./gradlew pactVerify` I can see it connects successfully to the pact broker to fetch the correct version of the pacts to verify against to based on the selectors... but I am getting this error afterwards: ```Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /[0:0:0:0:0:0:0:1]:50691``` this looks like a problem with networking and DNS resolution within either load balancer or istio.. but given our setup it's not easy to simply setup a rule to send those ports to the pact server... *Alternatives I am considering:* :one: if there is any way for me to configure the range ports for the mock servers from the provider when I run `./gradlew pactVerify`? :question: either via JVM property or anything on the pact section of gradle? (I don't think there is, but thought worth asking, so I can have a bit more control to set clear rules in our networking) :two: or can anyone share if there is a specific range of ports? :question: so far I've seen this error on ports such as 50691 and 51852, but I haven't found any prove that pact JVM actually provides a specific range for the dynamically assigned ports used by the mock server... :three: or does anyone have an example of an easy way to have more control of the mock servers? :question: :four: Finally, but most importantly: I wonder what's the difference between running my provider test via `./gradlew pactVerify` vs running it as JUnit... because if I run it as a JUnit test it does work (ie it does fetch the pacts, and run the test with mock values provided by some sort of mock server) :laughing: :upside_down_face: :woman-shrugging: ... So if this is the cleanest approach can anyone share an example of how I can pass in the parameters such as consumer branch or publish results in JUnit? :question: :five: or does anyone know any better approach? :question:

anna.nava
2024-01-17 14:50
I think I've made the wrong assumption and that connectivity issue against the mock service happens actually within my machine! as it's in my local machine where I see that mock service been instantiated

anna.nava
2024-01-17 16:16
yup, I had to force to use IPv4 and it solved this part

ulises.cervino
2024-01-17 20:03
I was going to bring up the ipv6 address, but I also need to ask: why istio? For consumer tests (which use the mock server) it?s all local/unit test.

miguel.heitor
2024-01-18 09:03
has joined #pact-jvm

anshita.tripathi
2024-01-18 11:07
has joined #pact-jvm

roger.vanburgh
2024-01-18 12:27
Thanks for fixing, seems to be working now!

hiroshi.fujii
2024-01-18 14:50
has joined #pact-jvm

ebernardino
2024-01-19 04:08
has joined #pact-jvm

hegge.m
2024-01-19 09:40
has joined #pact-jvm

visser.r
2024-01-19 09:40
has joined #pact-jvm

matt.fellows
2024-01-21 02:37
Did you get to the bottom of this Anna?

dcrivella
2024-01-21 23:51
has joined #pact-jvm

dmondejar
2024-01-22 03:39
has joined #pact-jvm

grzegorzstanek
2024-01-22 10:46
has joined #pact-jvm

sumitsg004
2024-01-22 19:02
Hi All, I have an get API which responds with zip file, so in the pact method I set the expected response header to be 'application/zip'. I want to know if I can do more than just validating response header? Meaning can I set specific expectation to return a zip file? like .binaryType() or .binaryBody(). Do we have anything like this? Basically I want to do just more than setting response header expectation. Any suggestion would be helpful.

mike.key
2024-01-22 19:32
Hello, feel like I'm missing something simple but don't see it in the docs anywhere, I cannot get anything beyond 4.3.x to resolve in gradle from maven central: ``` Could not resolve au.com.dius.pact.provider:junit5spring:4.6.5.``` I have mavenCentral() available to this project which is SB 3.2 with Kotlin 9.20 and Java 17


anna.nava
2024-01-23 10:48
I meant, what I did in gradle task was: `systemProperty("http://java.net.preferIPv4Stack", true)` this solved the connectivity issue

francois.larouche1
2024-01-23 14:31
has joined #pact-jvm

sarah.souza
2024-01-23 15:24
has joined #pact-jvm

matt.fellows
2024-01-24 09:16
Does anybody know how to test both HTTP and non-HTTP targets in the same verification (see also https://stackoverflow.com/questions/77870684/how-to-implement-provider-side-contract-tests-when-the-provider-and-consumer-hav/77871748#77871748)

sumitsg004
2024-01-24 17:00
Hi All, I am trying to create a contract pact at consumer end for a provider which returns zip file in response. Currently I am setting expectations as below .willRespondWith() .status(HttpStatus.OK.code) .headers(mapOf(HttpHeaders.CONTENT_TYPE to zipContent)) Is there way to set expectation for contents of zip file? For example, if I want set expectation that inside zip file there should be specific directory/filename is present. Not bothered about file contents, but if a file or directory is present or not inside the zip file. Is there a way to set expectations like above? Reason I want this type of validation is my service is not directly consuming zip file, but is interested in the files inside it. Atleast I want to set expectation whether certain directory and files exists inside zip file

zachary.romano
2024-01-24 19:16
has joined #pact-jvm

ken.overgard
2024-01-24 19:32
has joined #pact-jvm

rama.ganapa
2024-01-24 21:13
has joined #pact-jvm

justin.gilroy
2024-01-24 21:46
has joined #pact-jvm

naveenkarkra
2024-01-24 23:36
has joined #pact-jvm

yangtao.ge
2024-01-25 11:07
has joined #pact-jvm

salman.bilalshah
2024-01-25 11:34
has joined #pact-jvm

sridhar.munendramani
2024-01-25 14:32
has joined #pact-jvm

scott.anderson
2024-01-25 15:05
has joined #pact-jvm

bala.kurakula
2024-01-25 17:21
has joined #pact-jvm

sarah.hand
2024-01-25 17:28
has joined #pact-jvm

corey.jewett
2024-01-25 18:48
has joined #pact-jvm

eddjlsh94
2024-01-26 09:41
has joined #pact-jvm

eddjlsh94
2024-01-26 09:43
Hey guys! Quick question about Pact and protobuf messages in Java. Does anyone have an example of matching `repeated string` types in the DSL? I can't find anything in the docs but I might be blind...

falkowski.b
2024-01-26 10:59
has joined #pact-jvm

yash.khade
2024-01-26 18:50
has joined #pact-jvm

joe.allen
2024-01-26 18:50
has joined #pact-jvm

andrew.voronin
2024-01-26 18:50
has joined #pact-jvm

richie.schramm
2024-01-26 18:55
has joined #pact-jvm

eran.bergman560
2024-01-26 22:57
I'm looking for some guidance/best practices on how to structure and manage Java+SpringBoot+Pact tests code: The provider service I'm working on has over 1000 APIs and in order to test it as a provider I need to write a test class with `@SpringBootTest` and `SpringRestPactRunner` for it to test the pacts as a SpringBoot API test. That is all good and well but there is only so much code (mostly `@State` methods as the rest is the actual application and configurations) I can possibly put in that single class without it getting out of hand and become unmanageable by humans . Is there a technique to split the pacts testing of a single provider across multiple such test classes? - when I try to split the `@State` methods across 2 such test classes they both fail because they run separately and each test is missing the other half of the `@State` methods that I moved to the other test. How do people manage Pact test code for very large applications?

dsteinbach77
2024-01-26 23:23
has joined #pact-jvm

bas
2024-01-27 08:39
How did you split the provider test classes? Just two separate classes without any relation other than that they?re in the same package, or did you use inheritance or composition?

eran.bergman560
2024-01-27 19:25
good question! I created a base class: ```@RunWith(SpringRestPactRunner.class) @SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @PactBroker(host="localhost", port = "8500") @Provider("inventory_provider") public class InventoryProviderBaseTest { }```

eran.bergman560
2024-01-27 19:26
both of the test classes are extending this base class and are all in the same package

eran.bergman560
2024-01-27 19:29
multiple `@SpringBootTest` should be able to share the application context once the application is spun up because I believe that's how Spring works (which is very important for me because my application startup time is ~5 minutes) from what I can tell the part that is failing my tests is the `SpringRestPactRunner` (or the Pact not combining results across multiple tests?)

rachida_laghmami
2024-01-28 15:53
has joined #pact-jvm


eran.bergman560
2024-01-29 00:49
I have not seen those... I don't know why but I read these pages and totally missed that Will definitely give that a shot! Thanks @matt.fellows

matt.fellows
2024-01-29 00:55
no probs!

hrushikesh.agrawal
2024-01-29 07:13
has joined #pact-jvm

santos.danallanbray
2024-01-29 10:50
has joined #pact-jvm

katie.andriacchi
2024-01-29 15:05
has joined #pact-jvm

darren.grove
2024-01-29 15:11
has joined #pact-jvm

michael.brandeis
2024-01-29 16:37
has joined #pact-jvm

niki.mahurin
2024-01-29 17:51
has joined #pact-jvm

yanov.alexander
2024-01-29 18:00
Hello team, I am trying to upgrade pact version as project migrating to java 17. We are using amazon corretto java 17 (17.0.10). And it looks like we can?t use provider:junit5 (4.6.5 version) as I can?t use @Provider annotation, when I am trying to open it says ?This class file was compiled with different version of Kotlin compiler and can?t be decompiled. Do you guys know any workarounds with Java Corretto?

arina
2024-01-29 21:48
has joined #pact-jvm

rholshausen
2024-01-29 22:14
Are you using Kotlin in your project?

yanov.alexander
2024-01-29 22:58
Actually, no, just Java

rholshausen
2024-01-29 23:01
This has nothing to do with amazon corretto java 17. It's your IDE. Which IDE are you using?

yanov.alexander
2024-01-29 23:02
Intellij IDEA

yanov.alexander
2024-01-29 23:02
do you think I need to clear cache?

rholshausen
2024-01-29 23:03
Hmm, maybe. You should set your IDE to use the source jars, not decompile the lib

yanov.alexander
2024-01-29 23:03
Okay, let me try it. thanks!

tomasz.perek
2024-01-30 12:19
has joined #pact-jvm

tomasz.perek
2024-01-30 12:41
Hey, I have a problem I don?t know how to solve. So I have a provider api, that has cursor-based pagination. Basically the idea is that to get another portion of results you need to use a ?next page token? provided with the response from api: ```GET http://myapp.com/api/endpoint?foo=bar { "data": [....], "nextPageToken": "abc123qwer" } // getting next page: GET http://myapp.com/api/endpoint?pageToken=abc123qwer { "data": [....], "nextPageToken": "abc123qwer2" } ...``` Now, the tokens are internally generated by the api and the client isn?t supposed to know the details how. I have to write a contract in which the client is fetching all resources using pagination in at least two subsequent requests. The problem I have is that I don?t know how to define a contract in which the second request is based on the value obtained from the first response. ```ConsumerPactBuilder .consumer("consumer") .hasPactWith("myapi") .`given`( "resources present", Map( "number" -> 300 // .... ) ) .uponReceiving("Request to get first page of resources") .method("GET") .path(s"/api/endponit") .query("foo=bar") .willRespondWith() .status(200) .body( new PactDslJsonBody() .stringType("nextPageToken") // ????????????????? .eachLike("data", 200) /// ... ) .uponReceiving("Request to get second page of resources") .method("GET") .path(s"/api/endponit") .query("pageToken=??????????") .willRespondWith() .status(200) .body( new PactDslJsonBody() .nullValue("nextPageToken") .eachLike("data", 100) /// ... )``` I could just put some arbitrary values there, but then when the contract would be verified with the api, the token passed with the second request would have to be valid and the api would need to be able to decode it properly to know that it is the second page requested. Is there a way to do it? Any advices?

sofia
2024-01-30 17:12
has joined #pact-jvm

wesley.williams
2024-01-30 18:02
has joined #pact-jvm

matt.fellows
2024-01-30 22:03
Why do you feel the need you need to test the second interaction?

matt.fellows
2024-01-30 22:04
From a contract point of view, the data shape is the same.

matt.fellows
2024-01-30 22:04
Pact doesn?t support dependent interactions - that?s what end-to-end tests do, and it?s what makes them very flakey and unmaintainable

matt.fellows
2024-01-30 22:05
To work around it (if you really need, and I don?t believe you do), you would use a provider state e.g. `given there are multiple pages` with the description `a request to get page 2 of a paginated response` returns the body you need. But looking at the shape, you don?t get anything valuable - just different data, not different data shapes.


tomasz.perek
2024-01-31 08:47
Ok, got it. Thanks for the reply. :+1:

james.perepiczka
2024-01-31 09:48
Hi, I?ve got a scenario whereby I?ve got two services that depend upon each other in a consumer and provider relationship (so Service A depends on Service B and Service B depends upon Service A). On CI, we have in parallel the consumer test running and the provider test for Service A but I am receiving an error: `Cannot change the content of the pact for Service A version ead6574 and provider Service B, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number` . We are using commit sha for the version number so it?s valid in both cases. Ideally wouldn?t want to publish different version numbers. Any ideas?

matt.fellows
2024-01-31 10:21
Are you sure it?s the cyclical relationship causing the problem? It sounds like the contract is changing for the same git sha (the error message), and by default, the broker won?t allow that because bad things

james.perepiczka
2024-01-31 11:19
It could be the pipeline be re-run even if the tests had previously passed, would that cause an issue? or would it either replace or ignore if it was same content? It?s worth mentioning when we get this issue the provider tests have passed but the consumer fail so not sure if that is leading to different content

matt.fellows
2024-01-31 11:20
I don?t see how the provider tests could impact the consumer contract

matt.fellows
2024-01-31 11:20
my guess is that there is some dynamic element in your contract generation. You can test this locally by generating the contract, and then putting it to one side, and then generating it again to see if there is a diff

j.sauret
2024-01-31 14:03
has joined #pact-jvm

joe.allen
2024-01-31 17:23
Just curious if anyone has any Kotlin examples similar to the JS and Java examples? Not a big deal since I plan on taking the Java example and just converting it to Kotlin, but wondered if anyone has an example?

yousafn
2024-01-31 17:35
Hey @joe.allen There is a Kotlin example here https://github.com/pactflow/injected-provider-states-example although it needs an update to the later libs, as its currently using `4.0.0-beta.5` - I started to take a look earlier in the week, just got distracted by a few other things. The DSL should be the same for Kotlin from Java. @barry.irvine wrote a good post on Pact with Kotlin/Android last year https://medium.com/go-city/pact-contract-testing-in-android-ff7e996d0910

joe.allen
2024-01-31 17:37
This is a huge help, thanks so much!

yousafn
2024-01-31 17:38
np dude, I can push up my changes on a fork, as to where I got up to

joe.allen
2024-01-31 17:39
Yeah, that would certainly help and I can take it from there

joe.allen
2024-01-31 17:39
Really appreciate it!

yousafn
2024-01-31 17:51
popped them both here https://github.com/pactflow/injected-provider-states-example/pulls Here is a reference PR for a workshop update that went from Java 8 -> 17, SpringBoot 3.x / Pact-JVM 4.1 -> 4.6 that may help. https://github.com/pact-foundation/pact-workshop-Maven-Springboot-JUnit5/pull/4/files Alternatively they might piece enough together to apply to a kotlin hello world starter project that uses all the modern syntax etc. Any more questions just shout and if anyone else is reading this and has Kotlin experience please shout out!

joe.allen
2024-01-31 18:09
Fantastic, thanks Yousaf!

yousafn
2024-01-31 22:06
This series looks good, not just for contract testing, but for mutation and snapshot too, and they have an example repo that looks up to date :+1: (Kotlin based) https://dev.to/rogervinas/contract-testing-with-pact-4g2n

michelle.ryals
2024-01-31 22:17
has joined #pact-jvm

jyothi.kaspa
2024-01-31 23:34
has joined #pact-jvm

ddongre
2024-02-01 06:08
Hello all! My compiler has been complaining about passing an instance of `PactVerificationContext` in a method annotated by `@BeforeEach`. I had written the attached Provider side test for a spring boot based service (which worked great) but came across the above when trying to convert it for a Guice based service (while also switching over to `au.com.dius.pact.provider:junit5`). I found out that Junit5 doesn't support passing a parameter for a `@BeforeEach` method and I need to implement the https://www.baeldung.com/junit-5-parameters interface. Can somebody help me with creating a `PactVerificationContext` object as I can see it's pretty complex? I have also seen a bunch of examples of people using the `au.com.dius.pact.provider:junit5` library successfully with code similar to mine facing no issues from the `@BeforeEach` annotation. ```@Provider("Provider-Charge") @Consumer("Consumer-Charge") @PactBroker(url = "https://pact-broker-stage.net") public class ConsumerVerificationTest { @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", 8085)); } @State(value = "post request") void postPreview() { } }```

rholshausen
2024-02-01 06:11
What version of JUnit 5 are you using? @BeforeEach definitely allows values to be injected

james.perepiczka
2024-02-01 08:31
Ok so I?ve tracked down the problem but not sure why it happens, we are using ```new PactDSLJsonBody().stringType("time", OffsetDateTime.now().toString())``` I believe it is failing due to the time being dynamic (though I was under the impression this is an example rather than absolute value), should that matter?

matt.fellows
2024-02-01 10:10
Yes, the contract diff in the broker doesn't look at the contents, just if the hash changes.

matt.fellows
2024-02-01 10:10
I'd use a fixed date in the example of you can

ddongre
2024-02-01 14:34
I don't have a separate Junit 5 dependency. Only using this one `implementation 'au.com.dius.pact.provider:junit5:4.3.7'`

ddongre
2024-02-01 15:38
With SpringBoot I don't have this issue as I use the following annotation on top of my class, `@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)`

patrika.patil
2024-02-01 16:41
has joined #pact-jvm

tim.willis
2024-02-01 16:44
has joined #pact-jvm

ddongre
2024-02-01 17:40
I am using Java 11 and I tried upgrading the pact junit5 library to the following but still getting the same issue, `implementation 'au.com.dius.pact.provider:junit5:4.5.8'`

yogi.patel
2024-02-01 18:38
has joined #pact-jvm

sebbmoreno
2024-02-01 21:23
has joined #pact-jvm

rholshausen
2024-02-01 22:03
Are you using Maven or Gradle? Which versions of those? And follow the junit 5 setup docs. Try the latest vesion.

rholshausen
2024-02-01 22:03
This could also be Guice doing something to the JUnit 5 setup

cverma28
2024-02-02 10:30
has joined #pact-jvm

cverma28
2024-02-02 10:34
Hi All, Does any one have pact java framework with BDD implementation any help to write normal pact test in BDD style

a.g.s.maxwell
2024-02-02 12:54
has joined #pact-jvm

gjourdanweil
2024-02-02 14:29
IMHO, Pact and BDD together don't make much sense. A Pact test should be seen as a technical unit/integration test only for the layer that sends/receives the HTTP/message call.

gjourdanweil
2024-02-02 14:30
What are you looking for in the BDD approach that you would like to apply in Pact?

ddongre
2024-02-02 15:54
Gradle -> 8.0.2 in my firm's repo I followed the JUnit 5 steps and got the latest dependency, `testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.1'`

bas
2024-02-02 16:01
Something like ```Given <a provider state> When <a request with certain properties is sent> Then <the provider responds in a certain way>``` ? That should be fairly easy to build. But as @gjourdanweil said, what's the use case? Are you really going to have conversations with your business stakeholders about these things? If not, there's pretty much zero added value adding a Gherkin layer on top of your tests.

ddongre
2024-02-02 16:21
I also got rid of the pact provider and guice dependencies in my gradle build to see how JUnit5 reacts on it's own but I still see the same issue with `@BeforeEach` Upon doing some reading I found that passing parameters in `@BeforeEach` is not supported https://stackoverflow.com/questions/62036724/how-to-parameterize-beforeeach-in-junit-5. The only workaround that's been working is using either of these on top my class (which have their own JUnit 5 implementations I guess), ```@ExtendWith({ WiremockResolver.class, WiremockUriResolver.class })``` ```@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)```

t.mazelin
2024-02-02 23:33
has joined #pact-jvm

maeleeuxs
2024-02-03 10:20
has joined #pact-jvm

swaroopsonline
2024-02-04 02:44
has joined #pact-jvm

jose.silva
2024-02-04 14:45
has joined #pact-jvm

joshua.ellis
2024-02-04 21:45
While I agree with the points above which should be considered, we do have our own BDD compatibility suite to ensure feature parity between the various language implementations/libraries. You can see the implementation for Pact-JVM https://github.com/pact-foundation/pact-jvm/tree/b52f5a7c5c1b0eddc2fb4e80e0d8c5b48be46552/compatibility-suite. It might be worth a look as to how it could be done if that's really the intention.

abubics
2024-02-05 00:30
Just a late chime in to say . . . some of these answers are a bit confusing. The consumer test DSL is already BDD-style (with `given` being the keyword that matches exactly, and the other parts being specialised around the use case).

sonal3062000
2024-02-05 09:52
has joined #pact-jvm

eddjlsh94
2024-02-05 12:45
Hey! I need to parse some values of the pact contract on the verifiers side. Does anyone know how I can do that? Basically loop through the pact contracts in `@PactFolder` and get each one, get some values, and use them in a test.

eddjlsh94
2024-02-05 12:46
Ideally I want to be able to `pactContract.get('contents').get('key1')` etc

lorenz.ammon082
2024-02-05 14:44
has joined #pact-jvm


eddjlsh94
2024-02-05 15:36
Would this work for _getting_ the values? This seems to be adding values to the request. Also, I'm working with the protobuf plugin and this example uses HttpRequest. Would it have an alternative type I can use there?

yousafn
2024-02-05 15:36
Maybe its worth asking what you are trying to achieve first and why?

yousafn
2024-02-05 15:38
I?ve used req filters before for getting values to provide to an aws sig v4 method to generate valid auth headers from the interaction contents

eddjlsh94
2024-02-05 15:43
As I wrote out my problem I realised there might be an easier solution, will take a quick look. But if there is a way to get the contract as a JSON object that I can assert stuff from that'd be amazing.

lorenz.ammon082
2024-02-05 15:53
Hey everybody. I'd like to ask a question regarding the selection of consumer versions in provider tests. We are passing in the default version selectors as system property "pactbroker.consumerversionselectors.rawjson". For special cases, we would like to be able to explicitly specify different selectors in a provider test. For such a use case, the SelectorBuilder of the PactBrokerConsumerVersionSelectors annotation would seem to be a nice fit. Unfortunately, the system property "pactbroker.consumerversionselectors.rawjson" seems to override the SelectorBuilder of the PactBrokerConsumerVersionSelectors annotation. Is there a way to change this behavior? I looked at the SelectorBuilder in the hope to find a flag that would give the builder priority over the "pactbroker.consumerversionselectors.rawjson" property, but there does not seem to be such a thing (would be nice if there were, though ;-) ). As a workaround I could clear the system property before running the test with different selectors provided by a SelectorBuilder, but then the property (being a system property) would also be cleared for other tests. I could backup the property before the test run and restore it after the test run, but this seems a bit clumsy and would still not allow tests to run in parallel.

gjourdanweil
2024-02-05 18:03
BDD style != BDD. Typically I don't see any reason to use a library like Cucumber to write Pact tests. And business people won't write Gherkin scenarios. That's what I meant in my 1st answer.

patrick.barnes
2024-02-05 19:44
has joined #pact-jvm

andrew.kostka
2024-02-05 20:24
has joined #pact-jvm

allie
2024-02-05 20:25
has joined #pact-jvm

bryan.anderson
2024-02-05 21:18
has joined #pact-jvm

alec.abdul-rahim
2024-02-05 23:34
has joined #pact-jvm

filip.olszewski
2024-02-06 12:00
has joined #pact-jvm

amol.jose
2024-02-06 18:03
has joined #pact-jvm

amol.jose
2024-02-06 18:32
Hello :wave: does anyone have examples of using pact for testing kafka using clojure ?

rholshausen
2024-02-06 22:07
Unfortunately, `pactbroker.consumerversionselectors.rawjson` is an override of all other settings. You should try to not use it.

ryoshida
2024-02-07 01:47
has joined #pact-jvm

pallam.sudhasrinivas1
2024-02-07 13:21
has joined #pact-jvm

james.perepiczka
2024-02-07 15:05
Could you not use the SelectorBuilder as a default? We use SelectorBuilders for standard use cases and when webhooks are triggered, we use the raw json property the SelectorBuilder. Logic is based on environment variables being set for us

michal
2024-02-07 16:36
has joined #pact-jvm

milda.abromaviciute
2024-02-08 11:34
hey all, someone in my team found an odd issue with the pact jvm consumer dependency update, from version `4.6.5` and up, specifically with query matchers. One provider we use has queries that have square brackets `[]` in them, i.e. `principle_identifier[account_id]` etc. When running pact tests to generate a contract, running individual test classes runs fine, but as soon as another test class is added to run together, the second class throws errors, seemingly treating the brackets in the query key as an array: ```[ERROR] GetAuthorizationContractTest -- Time elapsed: 0.919 s <<< ERROR! au.com.dius.pact.core.model.InvalidPathExpression: Indexes can only consist of numbers or a "*", found "a" instead in path expression "$.query.principal_identifier[account_id]" at index 29 at au.com.dius.pact.core.model.PathExpressionsKt.bracketPath(PathExpressions.kt:141) at au.com.dius.pact.core.model.PathExpressionsKt.pathExp(PathExpressions.kt:165) at au.com.dius.pact.core.model.PathExpressionsKt.parsePath(PathExpressions.kt:181) at au.com.dius.pact.core.model.matchingrules.MatchingRulesImpl.fromV2Json(MatchingRulesImpl.kt:34) at au.com.dius.pact.core.model.matchingrules.MatchingRulesImpl$Companion.fromJson(MatchingRulesImpl.kt:104) at au.com.dius.pact.core.model.Request$Companion.fromJson(Request.kt:170) at au.com.dius.pact.core.model.DefaultPactReader.extractRequest(PactReader.kt:327) at au.com.dius.pact.core.model.DefaultPactReader$loadV2Pact$interactions$1.invoke(PactReader.kt:283) at au.com.dius.pact.core.model.DefaultPactReader$loadV2Pact$interactions$1.invoke(PactReader.kt:282) at au.com.dius.pact.core.support.json.JsonValueKt.map(JsonValue.kt:338) at au.com.dius.pact.core.model.DefaultPactReader.loadV2Pact(PactReader.kt:282) at au.com.dius.pact.core.model.DefaultPactReader.pactFromJson(PactReader.kt:220) at au.com.dius.pact.core.model.DefaultPactWriter.writePact(PactWriter.kt:92) at au.com.dius.pact.core.model.BasePact.write(BasePact.kt:24) at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.afterAll(PactConsumerTestExt.kt:709) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)``` again, both classes run individually pass, the first class in the run list passes, even if they're swapped, and the second one throws this error. For now we're sticking to versions below the afflicted ones, but wanted to make sure to raise this

lorenz.ammon082
2024-02-08 11:57
I see, thank you. We are providing default pact configurations for pact tests via our CI/CD pipeline by defining pact properties. If a developer has/wants to deviate from the defaults the developer can do so in the test code. For pact verification builds triggerd by webhooks we use the @AllowOverridePactUrl annotation to make a test just verify the new/modified pact that triggered the webhook. To be able to provide default consumer version selectors using the new SelectorBuilder we would need to provide a default SelectorBuilder implementation e.g. in a base class which all Pact provider tests would then have to extend to activate the defaults (e.g. defined externally by environment variables). I think it would be preferrable to be able to activate a default behavior without the developers having to add code. Having developers add code to their tests in order to override defaults seems more natural.

niels.schuette
2024-02-08 14:18
has joined #pact-jvm

ddongre
2024-02-08 15:19
Hey @rholshausen let me know if that makes sense to you. Thanks :pray:

rholshausen
2024-02-08 23:05
I just tested a basic example with only JUnit5 + Pact-JVM dependencies. IntelliJ does give an warning, but the test runs and the context is passed into the before each method


rholshausen
2024-02-08 23:12
If I run that test, I see the following in the logs: ```11:52:45.041 [Test worker] INFO org.example.MainTest -- beforeEach called: PactVerificationContext(store=org.junit.jupiter.engine.execution.NamespaceAwareStore@f202d6d, context=org.junit.jupiter.engine.descriptor.MethodExtensionContext@60e21209, target=au.com.dius.pact.provider.junit5.HttpTestTarget@630d1b2f, verifier=null, valueResolver=au.com.dius.pact.core.support.expressions.SystemPropertyResolver@746b18fd, providerInfo=au.com.dius.pact.provider.ProviderInfo@476a736d[consumers=[],createClient=<null>,host=localhost,insecure=false,isDependencyForPactVerify=true,name=myAwesomeService,packagesToScan=[],path=/,port=8080,protocol=http,requestFilter=<null>,startProviderTask=<null>,stateChangeRequestFilter=<null>,stateChangeTeardown=false,stateChangeUrl=<null>,stateChangeUsesBody=true,terminateProviderTask=<null>,trustStore=<null>,trustStorePassword=changeit,verificationType=REQUEST_RESPONSE], consumer=ConsumerInfo(name='anotherService', stateChange=null, stateChangeUsesBody=true, packagesToScan=[], verificationType=null, pactSource=FileSource(file=/home/ronald/Development/Projects/Pact/junit-test/build/resources/test/pacts/contract.json, pact=null), notices=[], pending=false, wip=false), interaction=Interaction: Get data in states default request: method: GET path: /data query: {ticketId=[0000]} headers: {} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING response: status: 204 headers: {} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: MISSING, pact=BasePact(consumer=Consumer(name=anotherService), provider=Provider(name=myAwesomeService), metadata={pactSpecification={version=2.0.0}, pact-jvm={version=4.6.6}}, source=FileSource(file=/home/ronald/Development/Projects/Pact/junit-test/build/resources/test/pacts/contract.json, pact=null)), testExecutionResult=[], additionalTargets=[])```

jeremy.buchmann
2024-02-09 00:11
has joined #pact-jvm

rachel.green
2024-02-09 00:15
has joined #pact-jvm

rholshausen
2024-02-09 00:30
Can you raise a GitHub issue for this?

jj.guo
2024-02-09 00:33
has joined #pact-jvm

dipali.gulhane
2024-02-09 07:01
has joined #pact-jvm

manoj.chaudhari
2024-02-09 09:13
has joined #pact-jvm


martha.chambers
2024-02-09 16:15
has joined #pact-jvm

adonay.berhe
2024-02-09 16:52
has joined #pact-jvm

camilo.morales
2024-02-09 16:52
has joined #pact-jvm

jonathan.barker
2024-02-12 08:56
has joined #pact-jvm

eddjlsh94
2024-02-12 10:28
If anyone ever gets a `scan error` while testing contracts for messages using `context.setTarget(new MessageTestTarget())` try using `MessageTestTarget(of(this.getClass().getPackage().getName()))` - that was a hairy error to debug and fix :joy: I think because most code available online are test projects they don't run into the error with too many classes, but the examples don't work in "proper" services.

tobiasroland
2024-02-12 10:48
has joined #pact-jvm

samantha.lam
2024-02-12 12:32
has joined #pact-jvm

logi.ragnarsson
2024-02-12 15:22
has joined #pact-jvm

michal.patron
2024-02-13 10:41
has joined #pact-jvm

tomasz.fiechowski
2024-02-13 11:14
has joined #pact-jvm

coletaylor017
2024-02-13 19:50
has joined #pact-jvm

lachlan.austin
2024-02-13 22:44
has joined #pact-jvm

rejeesh.gangadharan
2024-02-14 00:55
has joined #pact-jvm

utku.kilincci01
2024-02-14 08:00
has joined #pact-jvm

utku.kilincci01
2024-02-14 08:05
Hi :cherry_blossom: , how can I set environment system property to provider in the maven project? :help-sign:

ahmadlotfygamersfield
2024-02-14 14:38
has joined #pact-jvm

evan.hafers
2024-02-14 15:11
has joined #pact-jvm

ulises.cervino
2024-02-14 15:26
hi all, I?m wondering where I?m going wrong, I have consumer version selectors in my provider tests like this: ``` @au.com.dius.pact.provider.junitsupport.loader.PactBrokerConsumerVersionSelectors public static SelectorBuilder consumerVersionSelectors() { SelectorBuilder selectorBuilder = new SelectorBuilder(); // The key is set in verify-consumer-contracts.sh via -D String consumerBranch = System.getProperty("pact.consumer.branch", CONSUMER_BRANCH_UNSET); if (!consumerBranch.equals(CONSUMER_BRANCH_UNSET)) { selectorBuilder.branch(consumerBranch); } else { selectorBuilder.mainBranch().deployedOrReleased(); } return selectorBuilder; }``` The idea is that if I don?t set `pact.consumer.branch` via `-D` (this is maven), then we default to main branches/what?s deployed. When I run this with `pact.consumer.branch` set, e.g. `-Dpact.consumer.branch=does_not_exist`, I still get all contracts from all branches and versions. It should be noted that my provider tests are also tagged like this ```@PactBroker(includeWipPactsSince = "2023-01-01", enablePendingPacts = "true")``` so perhaps this is what?s bringing in all the contracts? (the pending, etc.)

ulises.cervino
2024-02-14 15:27
my expectations here would be that if I specify a non-existing branch, then the build completes very quickly as there are no contracts. If I specify a good consumer branch, then only those contracts are verified (their latest version), etc.

ulises.cervino
2024-02-14 15:53
is it possible that `includeWipPactsSince = "2023-01-01"` fetches all contracts until that day, then does the branch filtering _client-side_?

yousafn
2024-02-14 16:00
you?ll get wip pacts included, if they are not explictly specified in the cvs?s 1. is the latest for its branch (or tags) 2. does not have a successful verification result from the current provider branch (or tags) - that is, the pact is in ?pending? state. 3. was not explicitly specified in the consumer version selectors


ulises.cervino
2024-02-14 16:01
that?s what I?m playing with

ulises.cervino
2024-02-14 16:01
the effect I?m trying to achieve is this: if I specify a consumer branch, only verify that. Default is WIP+main branch+deployed

ulises.cervino
2024-02-14 16:01
is that possible? is that even a good idea? I?m tweaking my verification jobs to be as lean as possible when triggered by webhooks (that?s the context)

yousafn
2024-02-14 16:03
if triggered by webhooks you would have a single contract to verify by url, and so you shouldn?t use consumer version selectors or include wip pacts etc. if using the new webhook, you would get triggered webhooks with a provider sha for head of main branch, and any deployed or released versions of provider

ulises.cervino
2024-02-14 16:04
that makes perfect sense: how do I, in the jvm, specify a single contract to be verified? Is that possible? (I couldn?t find much in the way of docs or inspecting the code)

yousafn
2024-02-14 16:04
that would be via pactUrl or pactUrls

yousafn
2024-02-14 16:05
erm let me check details in docs or example

ulises.cervino
2024-02-14 16:05
thanks in advance


yousafn
2024-02-14 16:10
> When a consumer publishes a new version of a pact file, the Pact broker can fire off a webhook with the URL of the changed pact file. To allow only the changed pact file to be verified, you can override the URL by adding the annotation `@AllowOverridePactUrl` to your test class and then setting using the `pact.filter.consumers` and `pact.filter.pacturl` values as either Java system properties or environment variables. If you have annotated your test class with `@Consumer` you don?t need to provide `pact.filter.consumers`.

yousafn
2024-02-14 16:11
I was looking for something that was like a conditional, if pactUrl is set then provide that, otherwise provide the provider change verification values (consumer version selector)

ulises.cervino
2024-02-14 16:11
gorgeous, I?ll give it a try. Somehow I missed it :disappointed:

yousafn
2024-02-14 16:12
it?s okay buddy, there are lots of jvm doccos

ulises.cervino
2024-02-14 16:12
I?m happy with the defaults + wip if the url isn?t there

ulises.cervino
2024-02-14 16:13
now I?m trying this ```@AllowOverridePactUrl @PactBroker(includeWipPactsSince = "2024-01-01", enablePendingPacts = "true")``` :crossed_fingers:


yousafn
2024-02-14 16:25
I don?t believe you can record deployments with pact-jvm, having a quick scan of the repo, support was added for can-i-deploy `toEnvironment` you can do it with the pact broker client which is a standalone tool https://github.com/pact-foundation/pact_broker-client?tab=readme-ov-file#installation


ulises.cervino
2024-02-14 22:16
ok, that worked a charm, thanks again!

wiktor2.karpinski
2024-02-15 09:31
has joined #pact-jvm

cae.vieira
2024-02-15 11:37
has joined #pact-jvm

m.barbosa
2024-02-15 13:54
has joined #pact-jvm

r_connolly
2024-02-15 20:22
has joined #pact-jvm

wally.yuen
2024-02-16 00:42
has joined #pact-jvm

david.montero
2024-02-16 10:29
has joined #pact-jvm

hristian.iliev
2024-02-16 10:37
has joined #pact-jvm

v-rybam-gri
2024-02-16 13:49
has joined #pact-jvm

msarayu1111
2024-02-16 13:49
has joined #pact-jvm

shivanirajebhosale16
2024-02-17 10:50
has joined #pact-jvm

maciej.harapinski
2024-02-19 09:42
has joined #pact-jvm

d.madureira
2024-02-19 14:17
has joined #pact-jvm

dpunna
2024-02-19 18:35
has joined #pact-jvm

michael.schmidt
2024-02-20 11:01
has joined #pact-jvm