https://pact.io logo
Join Slack
Powered by
# pact-jvm
  • b

    bstyle killa

    07/07/2022, 7:34 PM
    We are on this step of the workshop. https://docs.pactflow.io/docs/workshops/ci-cd/workshop/implementing-the-provider-changes
  • j

    J

    07/08/2022, 11:52 AM
    Hi. I'm trying to write a Pact test for gRPC. Can I control the port that the Pact Mock Service Provider listens on? I would like it to mimic the standard port of the external service that it's standing in for. I've tried this annotation but I still get a random port, and I get a deprecation warning on the "port" parameter.
    @PactTestFor(pactMethod = "someMethod", port="5000")
    u
    • 2
    • 5
  • g

    Guillermo

    07/11/2022, 10:47 AM
    Anyone know if there's an existing dependency issue/conflict with PACT provider and Xerces?
  • g

    Guillermo

    07/11/2022, 12:19 PM
    I'm getting this error when running the producer :
    Property '<http://javax.xml.XMLConstants/property/accessExternalDTD>' is not recognized.
  • g

    Guillermo

    07/11/2022, 12:20 PM
    Which if my googling is correct is due to an XML parsing error, however this only fails on producer tests, not when running my app
  • s

    Sahil Jain

    07/12/2022, 10:34 AM
    Hello Everyone. I am bit new to Contract testing and recently started exploring it for consumer driven contract testing in Android App. The use case I am trying to solve is to generate pact file while i am running my UI Tests in Android app. My Android app makes multiple API requests to our backend server which i have currently mocked the responses through "Wiremock" framework.
  • s

    Sahil Jain

    07/12/2022, 10:46 AM
    Hello Everyone. I am bit new to Contract testing and recently started exploring it for consumer driven contract testing in Android App. The use case I am trying to solve is to generate pact file while i am running my UI Tests in Android app. My Android app makes multiple API requests to our backend server which i have currently mocked the responses through "Wiremock" framework. The next step i want to do is to record all the interactions made by the app and create a pact file so as i can validate it against my reack backend server. In order to do so i have integrated "Wiremock Pact Generator" developed by Atlassian team : https://bitbucket.org/atlassian/wiremock-pact-generator/src/master/ but i am facing crash while running my UI tests.
    Copy code
    com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:108)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
         at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
         at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
         at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
         at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
         at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
         at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
         at org.eclipse.jetty.servlets.gzip.GzipHandler.handle(GzipHandler.java:479)
         at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
         at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
         at org.eclipse.jetty.server.Server.handle(Server.java:499)
         at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
         at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258)
         at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
         at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
         at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
         at java.lang.Thread.run(Thread.java:784)
     Caused by: java.nio.file.NoSuchFileException: target/pacts/the-consumer-the-provider-febea806-232d-4527-bacb-d501e5048f78-pact.json
         at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
         at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
         at java.nio.file.Files.newOutputStream(Files.java:216)
         at java.nio.file.Files.write(Files.java:3292)
         at com.atlassian.ta.wiremockpactgenerator.pactgenerator.LocalFileSystem.saveFile(LocalFileSystem.java:14)
         at com.atlassian.ta.wiremockpactgenerator.pactgenerator.PactSaver.saveFile(PactSaver.java:39)
       ... 24 more
    Can someone please help why its not able to save pact file? or i am doing something wrong here. Thanks in Advance.
    m
    • 2
    • 1
  • s

    Sri Naga Sai Krishna Sanka

    07/12/2022, 9:15 PM
    how do we support Integer class type within a response body. We have
    integerType
    that supports primitive int. Where as for Integer the value can be either null or plain integer. How can this be handled?
    m
    • 2
    • 1
  • j

    Jason Army

    07/12/2022, 9:51 PM
    On a related note to above, we have a provider that returns either null or an integer for one of its response keys. I looked into using
    .valueFromProviderState("degree", "set degree to null", null)
    but I've been unable to figure out how to validate it in the provider side using
    @State
    with SpringBootTest. Any help would be appreciated!
    • 1
    • 1
  • k

    Kyriacos Elia

    07/13/2022, 9:17 AM
    Hey all, I’ve been looking online but I can’t seem to find a good guide about how to upgrade an existing JVM Pact suite onto v4 Pact spec. Anyone know of any good references?
  • p

    Paul

    07/14/2022, 3:55 PM
    Hi, We are trying to make the move from tags to environments and deployments to overcome many problems we are having our workflow. Early work in JS looks promising. However we have hit a snag in Java when trying to upgrade the version from 4.3.9 to the new 4.3.11 (or indeed 4.3.10). Running JUnit5 with maven. We get the error during runtime of [ERROR] pactVerificationTestTemplate{PactVerificationContext, HttpRequest} Time elapsed: 6.217 s <<< ERROR! java.lang.RuntimeException: java.lang.NoSuchMethodError: 'void kotlin.jvm.internal.FunctionReferenceImpl.<init>(int, java.lang.Class, java.lang.String, java.lang.String, int)' Caused by: java.lang.NoSuchMethodError: 'void kotlin.jvm.internal.FunctionReferenceImpl.<init>(int, java.lang.Class, java.lang.String, java.lang.String, int)' The tests run fine against
    Copy code
    <dependency>
      <groupId>au.com.dius.pact.provider</groupId>
      <artifactId>junit5</artifactId>
      <version>4.3.9</version>
    </dependency>
    but give that error in 4.3.11. Appreciate any help in this. Many thanks
    r
    u
    m
    • 4
    • 8
  • r

    ritika arora

    07/19/2022, 9:07 AM
    Hi team I am facing issue related to consumer filtering. • I have multiple consumer(say C1 and C2) for one provider. • Both consumer publish their individual contracts. • When feature branch of C1 publishes new contract, webhook triggers build for provider with pact Url and consumer name environment variables for AllowOverridePactUrl annotation. • When provider build runs it fails with Provider state call back failed for C2. Below error log shows filter consumer name is “sync-service” and has pact url but its still trying to find state in “TaskRunner” provider test. It should check in SyncServiceToProductCT
    Copy code
    TaskRunnerToProductCT > sync-service - GET Product by Product Code STANDARD_OUT
        [06:17:38,247][INFO] provider.junit5.PactVerificationStateChangeExtension - Invoking state change method 'GetByProductCode':SETUP
        Verifying a pact between sync-service and product-service
          [from Pact Broker <https://pact-broker.rc.vkp.viatorsystems.com/pacts/provider/product-service/consumer/sync-service/pact-version/9ba7240b86a1ad9f4900fa75e3dab5619744a4e5/metadata/Y3ZuPTk1MTJlNzIzNGEzMjdhYjg4ZjZkMjMxNTA5ZWE2NWUwYjliZTRkMGQmY3Z0W109ZmVhdHVyZV9TVVBQTFktODMxNS1za2lwLW5vbi1zYXBpLXByb2R1Y3RzLXdoZW4tZW5hYmxlLXNjaGVkdWxpbmctcGFjJnc9dHJ1ZQ>]
          Given GetByProductCode
          GET Product by Product Code
        [06:17:38,270][WARN] api.text.TextContentHelper - ContentRef not found :: {"contentRef":"CR-REF1"}
            returns a response which
              has status code 200 (OK)
              has a matching body (OK)
        [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator - Not all of the 7 were verified. The following were missing:
        [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator -     Get First Publish Requested User By product code
        [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator -     GET Supplier by Product Code
        [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator -     Lookup Product Details
        [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator -     GET product code request
        [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator -     GET products status
        [06:17:38,277][WARN] pact.provider.DefaultTestResultAccumulator -     GET Supplier by Product Code
    SupplyTaskRunnerToProductServiceCT > sync-service - Get First Publish Requested User By product code STANDARD_OUT
        [06:17:38,279][ERROR] provider.junit5.PactVerificationStateChangeExtension - Provider state change callback failed
        au.com.dius.pact.provider.junitsupport.MissingStateChangeMethod: Did not find a test class method annotated with @State("GetFirstPublishRequestedUser") 
        for Interaction "Get First Publish Requested User By product code" 
        with Consumer "sync-service"
        	at au.com.dius.pact.provider.junit5.PactVerificationStateChangeExtension.invokeStateChangeMethods(PactVerificationStateChangeExtension.kt:125) ~[junit5-4.1.32.jar:4.1.32]
    Please suggest how to fix it
    u
    • 2
    • 4
  • q

    Qingyuan Liu

    07/19/2022, 9:42 AM
    Hi team, in the consumer side message level contract test, we use the MessagePactBuilder to build a message wrapped in a MessagePact type. And store the message into PACT broker. However, in the producer side test, under the @*PactVerifyProvider,* provider will wrap the message in a MessageAndMetadata type. And then we pass this back to PACT which will compare it to what is held in the PACT broker. I'm wondering since the message generated by consumer is wrapped in MessagePact and the message generated by provider is wrapped in MessageAndMetadata. How could we compare these two different type of object? Thanks!
    u
    • 2
    • 2
  • v

    vassilis spiliopoulos

    07/20/2022, 4:58 PM
    Any direction regarding pact contract testing, Kafka avro messages and also using Confluent schema registry? thx!
  • m

    Matt (pactflow.io / pact-js / pact-go)

    07/20/2022, 10:29 PM
    Somebody asked about avro the other day. Try a quick search for some useful links/ materials (sorry on mobile)
  • m

    Madhulika Mitra

    07/22/2022, 2:28 PM
    Hi Team. I have a question regarding matching in pact-jvm. We can specify the matching rules while creating the PactDslJsonBody , but in case we are using the body from an existing json object we create in our project, could we additionally specify the matching rules ? - I do have an open enhancement on this https://github.com/pact-foundation/pact-jvm/issues/1541 🙂 .
  • a

    Abdurahman Hijazi

    07/22/2022, 3:38 PM
    Anyone know how to implement consumer version selectors to filter through pacts, not by using tags. This link https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors talks about using environments and other things, but in the code implementation for Java they only use tags to filter through consumers. I can't find any other code examples I'm using junit runners
    u
    • 2
    • 1
  • g

    Gustavs

    07/26/2022, 11:38 AM
    Hey. I was wondering if its possible to have multiple VerifyContractTest classes on the provider verification? I want some tests to use testTarget but other tests to use MockMvc with testTarget.
    j
    • 2
    • 4
  • h

    Hari Ravi

    07/27/2022, 4:50 PM
    Hi Team, I Need your inputs what i am doing wrong here on Consumer Contracts. When i run the Test it says no one is called but when i run with debugger i notice MockServer and the healthcheck end point have same host and port number and the end point as well. Please guide me what i am missing here
    • 1
    • 5
  • a

    Ankit Mittal

    07/28/2022, 4:51 PM
    Hi Team, In most of the documentations, it is recommended to use the branching approach instead the tags. But, in one of the document, it is mentioned TBC for pact-jvm. So, want to confirm what is status of roll out for pact-jvm client library. PFB the Link, where it is mentioned as TBC: https://docs.pact.io/pact_broker/branches
    u
    • 2
    • 1
  • j

    James P

    07/28/2022, 10:09 PM
    Hi, for the java gradle plugin, in the canIDeploy task, is it possible to prevent it from failing if no verifications exist and only fail on failed verifications?
    u
    • 2
    • 1
  • j

    James P

    07/28/2022, 10:54 PM
    I have another question also, when verifying a pact as a provider using the following attributes
    Copy code
    @PactBroker(url = "${pactbroker.url}", consumerVersionSelectors = {
            @VersionSelector(tag = "main")
    })
    I can see from the output that it is correctly targetting a main consumer
    Copy code
    Verifying a pact between saasConsumer and saasProvider for tag main
    However whenever I look at the broker, it shows verifications against multiple previous versions of the contract both on the main branch and a couple of other feature branches, is there a reason for this?
    m
    • 2
    • 2
  • j

    James P

    07/28/2022, 10:55 PM
    I can only assume it is because the contract hasnt changed but I cant see why it would present this behaviour
  • j

    James P

    07/28/2022, 11:22 PM
    Last question: Is there any functionality in the gradle plugin for recording a release or do you have to use the cli for that?
  • m

    Matt (pactflow.io / pact-js / pact-go)

    07/28/2022, 11:23 PM
    I would highly recommend ditching the canIDeploy maven task, and instead use the CLI tools
  • m

    Matt (pactflow.io / pact-js / pact-go)

    07/28/2022, 11:23 PM
    (which yes, you can record releases etc. from also)
  • v

    Vishal Kukreja

    07/29/2022, 12:53 PM
    Hi, I am trying to integrate pact in Android Project. while I did not find any sort of documentation for integrating Pact in Android project. Till now what I have done is:-
    Copy code
    @HiltAndroidTest
    @Config(sdk = [Build.VERSION_CODES.Q])
    @PactTestFor(
        providerName = "our_provider"
    )
    @PactFolder("target/pacts")
    @ExtendWith(
        PactConsumerTestExt::class)
    class VerificationEstimationPactTest {
        private var HEADERS: MutableMap<String, String> = HashMap()
        private var JSON: String? = null
    
    
        @get:Rule
        var rule: TestRule = InstantTaskExecutorRule()
    
        @get:Rule
        var hiltRule = HiltAndroidRule(this)
    
        @Inject
        lateinit var viewModel: MutualFundVerificationViewModel
    
        init
        {
            HEADERS["Content-Type"] = "application/json"
            JSON="{\n" +
                "        \"estimationDate\": \"2022-07-26T10:59:29.935Z\",\n"+
                "        \"oEstimationDate\": \"2022-07-27T10:59:56.342Z\",\n"+
                "        \"estimationDate\": \"2022-07-27T11:12:26.640Z\",\n"+
                "        \"gstimationDate\": \null \n"+
                " }"
    
        }
    
        @Before
        fun setUp() {
           hiltRule.inject()
        }
    
        @Throws(
            UnsupportedEncodingException::class
        )
        @Pact(provider = "our_provider", consumer = "our_consumer")
        fun createFragment(builder: PactDslWithProvider): RequestResponsePact {
            return builder
                .given("data count is > 0")
                .uponReceiving("a request for json data")
                .path("/provider.json")
                .method("GET")
                .willRespondWith()
                .status(200)
                .headers(HEADERS)
                .body(JSON)
                .toPact()
        }
    
        @Test
        @PactTestFor(pactMethod = "createFragment")
        fun should_process_the_json_payload_from_provider() {
    //        val observer: TestObserver<VerificationTimeResponse> = viewModel.flowUseCase.getVerificationTime().test()
    //        observer.assertNoErrors()
            /*observer.assertValue(
                VerificationTimeResponse(
                    Timestamp("2022-07-26T10:59:29.935Z".toLong()),
                    Timestamp("2022-07-27T10:59:56.342Z".toLong()),
                    Timestamp("2022-07-27T11:12:26.640Z".toLong()),
                    null
                )
            )*/
        }
    still unable to generate the contract file. Kindly help for same.
    m
    b
    • 3
    • 2
  • v

    Vishal Kukreja

    08/01/2022, 3:06 PM
    Hi I am unable to generate contract and have given lot of time for doing so and rnd, I am an android developer , Is anyone could help me in that.
  • v

    Vishal Kukreja

    08/01/2022, 3:06 PM
    ?
  • h

    Hari Ravi

    08/01/2022, 12:24 AM
    Hi Team, Please let me know does PACT Mock Server support spring webclient ?
    u
    • 2
    • 17
1...567...14Latest