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 its 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