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

    Josh

    05/13/2022, 3:43 PM
    I'm trying to use @ignorenopactstoverify for provider tests using junit. If there's no PACT for the provider recorded in the broker, I realise that the context will be null but even if I try to handle the exception I can't get the test to pass. Are there any examples for the use of @ignorenopactstoverify ?
    đź‘‹ 1
    y
    • 2
    • 4
  • s

    samiksha fulzele

    05/16/2022, 9:57 AM
    Do pact support avro schema registry , i am little confused can someone help me out with this?
    r
    y
    +2
    • 5
    • 13
  • a

    Akash

    05/17/2022, 12:53 AM
    Hi all. Does Pact consumer supersede pact-jvm-consumer-junit? Edit - More specifically, the new Lambda DSL supposedly does supersede pact-jvm-consumer-junit if I understood the docs correctly. if it does, I can’t find a maven repository for io.pactfoundation.
    r
    • 2
    • 15
  • a

    Akash

    05/17/2022, 1:24 AM
    @rholshausen just a little more context for the reason why I am looking to switch to the Lamda DSL docs — it’s because as pointed out in the docs, the junit4 DSL seems to be buggy (I’m on version
    4.2.20
    ). We’ve got 2 different similar requests like:
    Copy code
    DslPart requestOneResponseBodyDslPart = PactDslJsonArray
                    .arrayEachLike()
                        .uuid("id", UUID.randomUUID())
                        .datetime("startTime", INSTANT_FORMAT_STRING)
                        // More keys here
                    .closeObject();
    
    DslPart requestTwoResponseBodyDslPart = PactDslJsonArray
                    .arrayEachLike()
                        .uuid("id", UUID.randomUUID())
                        .datetime("scheduledStartTime", INSTANT_FORMAT_STRING)
                    .closeObject();
    Both of them generate random UUIDs and the default datetime string adhering to the format like:
    "2000-02-01T00:00:00.000000Z"
    in the pact JSON file. The problem is that `requestOneResponseBodyDslPart`’s provider verification is expecting exact value matches for both the
    .uuid
    and
    .datetime
    fields, which is really odd, considering we’ve used PactDslJsonArray before too.
    r
    • 2
    • 7
  • o

    Oscar Calderin

    05/17/2022, 10:18 AM
    Hi guys, I have this contract
    Copy code
    .body(PactDslJsonArray.arrayMinLike(1)
        .stringType("transactionHash")
        .stringType("originWallet")
        .stringType("destinationWallet")
        .decimalType("amount", 1.0)
        .datetime("creationDate")
        .stringType("method")
        .stringType("status")
        .decimalType("fee")
    ).toPact();
    when I execute my consumer tests they are passing, but then when I'm running my provider tests I'm getting this error: body: $.0.creationDate Expected 1652738400000 to match a datetime of 'yyyy-MM-dd'T'HHmmss': Unable to parse the date: 1652738400000
    f
    • 2
    • 20
  • m

    Muthukumar Ramachandran

    05/17/2022, 9:58 PM
    Issue: In the provider end, pact tests is failing with below error:- Request to provider failed with an exception: “/” is not allowed in an identifier in path expression “$.data[0].relationships.user/shippingAddress.data.id” at index 28 (au.com.dius.pact.core.model.InvalidPathExpression) My Request (POST): “relationships”: { “user/shippingAddress”: { “data”: { “id”: “12345”, “type”: “user/shipping-address” } } We are using junit5spring version 4.3.7. Is this a known issue in the pact ? Is there any way to fix this issue? Thanks.
    r
    g
    • 3
    • 4
  • j

    James Weng

    05/18/2022, 6:10 AM
    hi , im trying to connect my provider with pactflow using the example https://docs.pactflow.io/ (java/junit5) @Provider("<Your provider name here>") @PactBroker(host = "<YOUR_BROKER>.pactflow.io", scheme = "https", authentication = @PactBrokerAuth(scheme = "bearer", username = "<TOKEN>", password = "")) but it keeps prompting cannot resolve method 'scheme' am i missing some import in the lib?
    m
    • 2
    • 5
  • t

    Thomas Cederholm

    05/18/2022, 11:19 AM
    If I have two Pact test classes (1 test per state) that run, as soon as I added
    @PactFilter
    annotation, with the exact string of the state, then both tests fail to find pacts. Without the annotation it breaks because a test only contains one state. Do I have to have all states in each test file together with the
    @PactFilter
    ?
    r
    • 2
    • 2
  • a

    Anja Gruss

    05/18/2022, 12:03 PM
    anyone encounter "Error parsing json" when uploading the OAS to the broker? happens both for yml and json file, the file is created by springdoc-openapi and generates a 3.0.1 openapi version file which seems valid to my ide
    m
    • 2
    • 18
  • r

    Rubén Pérez

    05/19/2022, 11:11 AM
    Hi there 🙂 I was looking into the documentation, trying to see if the JVM libraries already supported branches, environments, pending pacts, WIP pacts... and I though they didn't. But also I saw some comments in this channel and the changelog of the JVM section, and it looks like at least some of those things are already implemented. Could you help me understand what is the current state of the JVM ecosystem regarding those new features, or where I can find documentation to understand it? Thank you 🙂
    r
    • 2
    • 5
  • n

    Nitesh Rajgopal

    05/20/2022, 7:28 AM
    This is my kotlin code so far:
    Copy code
    private fun responseBody2(): DslPart? {
    
        return PactDslJsonArray.arrayEachLike()
                .`object`("type")
                        .`object`("content")
                         .stringType("title", "Search Results")
                        .closeObject()
                .closeObject()
                .`object`("type2")
                    .`object`("content")
                        .stringType("price", "$500")
                        .stringType("subTitle", "")
                        .stringType("title", "")
                    .closeObject()
                .closeObject()
    
    }
    b
    • 2
    • 1
  • n

    Nitesh Rajgopal

    05/20/2022, 7:30 AM
    I have 2 problems here. 1. I cannot repeat objects with the same name "type". They get overwritten.
    b
    • 2
    • 14
  • b

    Ben Pilgrim

    05/23/2022, 8:22 AM
    Any chance of getting a new release cut?
    • 1
    • 1
  • Ă©

    Édouard Lopez

    05/23/2022, 10:04 AM
    With message queue, is it mandatory to have a match between
    @PactVerifyProvider(…)
    value and the consumer
    expectsToReceive(…)
    one. I was using Pact only for REST until now and, to my understanding, I never had to use that. Why this difference?
    m
    • 2
    • 4
  • a

    André Sousa

    05/23/2022, 4:13 PM
    this is possible to surpass without creating for example a new provider name?
    t
    • 2
    • 2
  • t

    Thomas K

    05/24/2022, 1:21 PM
    hello, does anyone have recommendations for expression to use for an email address in pattern matching? regex for email is usually very hard and not recommended, but
    valueFromProviderState
    seems to require an expression and example for my email address value, any recommendations here please?
    r
    • 2
    • 3
  • c

    Carlos Henrique

    05/24/2022, 6:31 PM
    Hello team! I have a question: is the gRPC support (pact-jvm) only for Pact Flow? Thanks
    m
    • 2
    • 1
  • q

    Qingyuan Liu

    05/25/2022, 6:42 AM
    Hi team, I would like to implement a message contract using kafka. A provider will send a message to a kafka topic and a consumer will read the message from the kafka topic. Could you provide some related doc or example for my reference? Thanks!
    đź‘‹ 1
    r
    • 2
    • 4
  • e

    Emirhan Emmez

    05/26/2022, 6:41 AM
    Hi all, is there any good doc for android contract testing? It can be repo also, thank you
    m
    • 2
    • 5
  • s

    Shaun Mendham

    05/26/2022, 8:07 AM
    Hi all, This looks to be an already discussed topic, but struggling to find a conclusive answer to a question we have. Effectively we have a microservice which interacts both via HTTP and Kafka with other microservices, we are looking to PACT test both of these interaction types. Is it currently not possible to define multiple provider types against the same provider name? (E.g. we would need to define a two providers
    service-name
    and
    service-name-kafka
    ) What I am seeing currently with a single provider name across two test classes, is that all contracts for the provider are run against both types of which the opposite type contracts fail.
    👍 1
    y
    r
    • 3
    • 14
  • g

    GitHub

    05/26/2022, 6:21 PM
    #1562 Pending Pacts - pactbroker.providerBranches not working New issue created by praveen-em I tried using
    pactbroker.providerBranches
    (replacing
    pactbroker.providerTags
    ) on my provider with latest release
    4.3.8
    . It is not able to fetch pending and wip pacts using branches. It was able to fetch the pending and wip pacts using tags. Doing bit of investigation, it appears the problem is because this code populates
    providerVersionBranches
    but Pact broker expects
    providerVersionBranch
    I think (@Beth (pactflow.io/Pact Broker/pact-ruby) ?). This is my suspect but I am not sure. Pactbroker log:
    Copy code
    2022-05-26 17:48:01.586098 I [7:puma srv tp 001] PactBroker::Api::Resources::ProviderPactsForVerification -- Fetching pacts for verification by pactdemo-provider-springboot -- {:provider_name=>"pactdemo-provider-springboot", :params=>{"consumerVersionSelectors"=>[{"mainBranch"=>true}, {"deployedOrReleased"=>true}], "includePendingStatus"=>true, "includeWipPactsSince"=>"2022-05-01", "providerVersionBranches"=>["mybranch"], "providerVersionTags"=>[]}}
    pact-foundation/pact-jvm
    y
    b
    • 3
    • 2
  • j

    Jayakannan Jeyapandian

    05/27/2022, 8:01 AM
    Hello, have anyone tried passing the port number for the mock server as a command line argument when running consumer tests? Tried it but failing, may be I am missing something. Any thoughts? Thanks.
    Copy code
    @PactTestFor(providerName = "test-provider", port = "${pact.server.port}")
    We would be setting the same port in one of our config yml file hence we would like to either set it via command line or read and pass it to our yml config similar to using @AutoConfigureWiremockPort which exposes the port via ${wiremock.server.port}
    m
    • 2
    • 6
  • a

    Aurelia

    05/27/2022, 9:05 AM
    Hello, I’m checking the branches feature, and according to this page : https://docs.pact.io/pact_broker/branches#support it has not beed included in pact-jvm yet. Does anyone know if it’s planned to be included soon ?
    y
    • 2
    • 2
  • f

    Francisco González

    05/27/2022, 10:56 AM
    Hi everyone đź‘‹ Any thoughts regarding this issue? https://github.com/pact-foundation/pact-jvm/issues/768#issuecomment-1139506120
    y
    • 2
    • 4
  • w

    Wiesław Bondyra

    05/27/2022, 11:05 AM
    Hello, I am trying to test POST request with multipart but I have got error likr this java: cannot access org.json.JSONObject class file for org.json.JSONObject not found I am using au.com.dius.pact.consumerjunit54.2.21 version. My Pact and test is here:
    Copy code
    @Pact(consumer = CONSUMER_NAME, provider = PROVIDER_NAME)
        public RequestResponsePact createPactForWiesaTest(PactDslWithProvider pactDslWithProvider) {
    
            MultipartEntityBuilder multipart2 = MultipartEntityBuilder.create()
                    .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
                    .setContentType(ContentType.APPLICATION_FORM_URLENCODED)
                    .addBinaryBody("file", "1,2,3".getBytes(), ContentType.create("text/csv"), "data.csv")
                    .addTextBody("textPart", "sample text");
    
            PactDslResponse builder = pactDslWithProvider
                    .given("Check buildId")
                    .uponReceiving("Request to get wiesa buildId")
                    .path("/wiesabuild")
                    .body(multipart2)
                    .method("POST")
                    .willRespondWith()
                    .status(HttpStatus.OK.getCode())
                    .body("is OK", MediaType.TEXT_PLAIN);
            return builder.toPact();
        }
    
        @Test
        @PactTestFor(providerName = "WiesaMultipartService", pactMethod = "createPactForWiesaTest")
        void testWiesaMultipartService(MockServer mockServer) throws MalformedURLException {
            String url = mockServer.getUrl();
            String response;
    
            MultipartEntityBuilder multipart2 = MultipartEntityBuilder.create()
                    .setMode(HttpMultipartMode.STRICT)
                    .setContentType(ContentType.APPLICATION_FORM_URLENCODED)
                    .addBinaryBody("file", "1,2,3".getBytes(), ContentType.create("text/csv"), "data.csv")
                    .addTextBody("textPart", "sample text");
    
            try (RxHttpClient rxHttpClient = RxHttpClient.create(new URL(url))) {
                response = rxHttpClient.toBlocking().retrieve(
                        <http://HttpRequest.POST|HttpRequest.POST>("/wiesabuild", multipart2)
                                .contentType(APPLICATION_FORM_URLENCODED)
                                .accept(APPLICATION_FORM_URLENCODED),
                        String.class
                );
                assertThat(response).as("body should be with simple is OK statement").isEqualToIgnoringWhitespace("is OK");
            }
        }
    What might be wrong in this example?
    • 1
    • 1
  • a

    Akash

    05/30/2022, 1:31 AM
    Also worth noting that the default seems to be false already for that property, and yet, if I understand the docs correctly, the behaviour seems to be
    true
    .
    • 1
    • 1
  • a

    Akash

    05/31/2022, 4:47 AM
    Any ideas on this?
    m
    r
    • 3
    • 4
  • s

    Shivam Kumar

    05/31/2022, 10:41 AM
    Hey, We are trying to update the request uri path in our provider contract test using below snippet. But we are getting an
    org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter
    exception. Can someone please help us on fixing it? If there is recommendation to use another approach, Can you please share?
    Copy code
    @TestTemplate
        @ExtendWith(PactVerificationInvocationContextProvider::class)
        fun pactVerificationTestTemplate(context: PactVerificationContext, requestBuilder: org.apache.hc.core5.http.HttpRequest) {
            var newUri = sanitiseUrl(requestBuilder.uri.toString())
            requestBuilder.setUri(URI(newUri))
            context.verifyInteraction()
        }
    Dependencies used:
    <http://au.com|au.com>.dius.pact.consumer.junit5
    ,
    'org.apache.httpcomponents.core5', name: 'httpcore5', version: '5.1.3'
    âž• 5
    r
    • 2
    • 3
  • a

    Akash

    06/01/2022, 1:25 AM
    Hi. We have a micro-services architecture on one of our projects. We’re using the following packages in the same micro-service which is a client to another micro-service and a server for other clients:
    Copy code
    "au.com.dius.pact.provider:junit5spring:4.3.8"
    "au.com.dius.pact.consumer:junit5:4.3.8" // tried this with junit 4 as well.
    Because of this, running either tests now keep failing:
    Copy code
    ...
            at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
            at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
            at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
            at java.base/java.lang.Thread.run(Thread.java:834)
    We think it’s because of including those packages together, despite running different classes for 1) generating the consumer tests. 2) running provider verifications. Any ideas for if this is indeed supported?
    r
    • 2
    • 10
  • q

    Qingyuan Liu

    06/06/2022, 4:52 AM
    Hi team, could anyone give some clue why this exception "Failed to invoke provider method 'creatPact' (java.lang.RuntimeException)" happened? Thanks!
    r
    • 2
    • 4
12345...14Latest