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

    Thai Le

    10/13/2022, 8:27 PM
    Hello, when i run the provider verification (junit5spring:4.3.15), i got so much DEBUG log including http connection, BASIC auth cred echange and retry,... . How can i lower the level to WARN or INFO ?
    u
    • 2
    • 2
  • m

    Matthew Farwell

    10/18/2022, 9:30 AM
    Hello, I have a small problem using pact testing and the junit5 integration, from gradle, testCompile group: 'au.com.dius.pact.provider', name: 'junit5', version: '4.2.0'. I have ane endpoint which I'm testing, which returns a content type of application/x-json-stream, the contents of which are like: { "id": 1, "foo": "bar" } { "id": 2, "foo": "baz" } When running context.verifyInteraction(), the JsonParser is throwing an exception, saying that it can't parse the above, because it isn't valid JSON. Which it isn't. If I understand correctly, this comes down to the following code in Ma tchingConfig.kt: val bodyMatchers = mapOf( "application/.*xml" to "au.com.dius.pact.core.matchers.XmlBodyMatcher", "text/xml" to "au.com.dius.pact.core.matchers.XmlBodyMatcher", ".*json.*" to "au.com.dius.pact.core.matchers.JsonBodyMatcher", "text/plain" to "au.com.dius.pact.core.matchers.PlainTextBodyMatcher", "multipart/form-data" to "au.com.dius.pact.core.matchers.MultipartMessageBodyMatcher", "multipart/mixed" to "au.com.dius.pact.core.matchers.MultipartMessageBodyMatcher", "application/x-www-form-urlencoded" to "au.com.dius.pact.core.matchers.FormPostBodyMatcher" ) @JvmStatic fun lookupBodyMatcher(contentType: String?): BodyMatcher? { return if (contentType != null) { val matcher = bodyMatchers.entries.find { contentType.matches(Regex(it.key)) }?.value if (matcher != null) { val clazz = Class.forName(matcher).kotlin (clazz.objectInstance ?: clazz.createInstance()) as BodyMatcher? } else { val override = System.getProperty("pact.content_type.override.$contentType") The call to lookupBodyMatcher has contentType == application/x-json-stream, so it is matching the regexp ".*json.*" and trying to parse the expected content as JSON. And the JSON isn't valid. It never will be. It doesn't look like there is any way of overriding this either. My question is this: what is the best approach for this situation? I currently use reflection to insert a new entry in the bodyMatchers map which handles the x-json-stream body matcher correctly. This obviously is quite fragile, but I can't see a way around it for the minute?
    u
    • 2
    • 2
  • m

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

    10/18/2022, 10:30 AM
    Any takers for this one: https://stackoverflow.com/questions/74107296/how-to-access-the-pact-mock-server-dynamic-port-in-junit-test
  • m

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

    10/18/2022, 10:33 AM
    Also https://stackoverflow.com/questions/74096334/error-when-running-my-first-pact-jvm-test
  • j

    Jorge Bo

    10/18/2022, 8:15 PM
    Hi, i’m writing an async consumer test in kotling and having the following error. Not sure what if i am missing something.
    Copy code
    null cannot be cast to non-null type au.com.dius.pact.core.model.BasePact
    java.lang.NullPointerException: null cannot be cast to non-null type au.com.dius.pact.core.model.BasePact
    	at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.storePactForWrite(PactConsumerTestExt.kt:478)
    	at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.afterTestExecution(PactConsumerTestExt.kt:459)
    	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterTestExecutionCallbacks$9(TestMethodTestDescriptor.java:233)
    	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$13(TestMethodTestDescriptor.java:273)
    	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$14(TestMethodTestDescriptor.java:273)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAllAfterMethodsOrCallbacks(TestMethodTestDescriptor.java:272)
    	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAfterTestExecutionCallbacks(TestMethodTestDescriptor.java:232)
    	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137)
    	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
    	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
    	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    	at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    	at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
    	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99)
    	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
    	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
    	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    	at com.sun.proxy.$Proxy5.stop(Unknown Source)
    	at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
    	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
    	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
    	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
    	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
    	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
    	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
    	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
    	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
    u
    • 2
    • 9
  • s

    Shirley

    10/19/2022, 9:51 AM
    Hello, I'd like to pass in dynamic path to PathFolder. Does anyone have any workaround?
  • r

    Rachel Butler

    10/25/2022, 2:58 PM
    Hi, we are trying to get Pact JVM's matchQuery() to work with PactFlow's Hosted Stubs. Because matching rules are a requirement for us, we are using Pact v2 contracts. In our efforts to try and get dynamic query parameters working, we are facing the below error:
    Copy code
    Error from Pactflow stub: Pact::Error - Value to generate \"[\"string\"]\" does not match regular expression /[A-Za-z0-9]{1,}/
    For reference, we have tried both of the two ways (one including a custom example, and the other not):
    Copy code
    // Example not included (Pactflow generates randomly)
    pactDslRequestWithPath = pactDslRequestWithPath.matchQuery(parameter.getName(), "[A-Za-z0-9]{1,}");
    // Example included
    pactDslRequestWithPath = pactDslRequestWithPath.matchQuery(parameter.getName(), "[A-Za-z0-9]{1,}", "string");
    Here is the relevant part of the contract that was generated:
    Copy code
    "request": {
       "method": "GET",
       "path": "<path>",
       "query": "response_type=string&client_id=string&redirect_uri=string&state=string&scope=string",
       "matchingRules": {
          <path>,
          "$.query.response_type": {
             "match": "regex",
             "regex": "[A-Za-z0-9]{1,}"
          },
          "$.query.client_id": {
             "match": "regex",
             "regex": "[A-Za-z0-9]{1,}"
          },
          ...
    }
    We were facing similar issues with machPath() when we were not including the example, but including the custom example worked in that case. Has anyone got this feature working with v2 contracts? Am I missing something?
    u
    y
    m
    • 4
    • 10
  • a

    Anh Vuong

    10/26/2022, 1:04 AM
    I got error when trying to retrieve a consumer pact from local pact broker in provider to verify a pact against its non-http message. I tried few versions including 4.3.14 and 4.2.9 <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit5</artifactId> <version>4.3.14</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius.pact.provider</groupId> <artifactId>junit</artifactId> <version>4.3.14</version> <scope>test</scope> </dependency> 175913.737 [main] DEBUG au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider - Pact sources on test class: @au.com.dius.pact.provider.junitsupport.loader.PactSource(au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.class) java.lang.NoSuchMethodError: 'au.com.dius.pact.provider.junitsupport.loader.PactLoader au.com.dius.pact.provider.ProviderUtils.instantiatePactLoader(au.com.dius.pact.provider.junitsupport.loader.PactSource, java.lang.Class, java.lang.annotation.Annotation)'
    u
    • 2
    • 5
  • v

    Veda

    10/30/2022, 11:11 PM
    Hi Team, Is it possible to hit the provider dev service from the consumer test instead of Mock? we wanted to generate the contract by hitting the provide service instead of mock but pact is throwing error
    m
    • 2
    • 1
  • f

    fisher

    11/02/2022, 9:12 AM
    hi all! Is it possible to log out the request/response on provider tests? I think so, but I am not quite sure how to go about it. I am using the junit5 version in this instance.
  • n

    Nathan Deamer

    11/09/2022, 6:35 PM
    Evening everyone, Can I get a sanity check please on webhooks? I have pushed a consumer with a branch to pactflow (all good) This has then triggered a webhook in our CICD to trigger the provider - with some properties such as the pact-url for verification (all good) In the provider I have set the following properties:
    Copy code
    systemProperty "pact.provider.version", getGitHash()
    systemProperty "pact.provider.branch", getGitBranch()
    systemProperty "pact.verifier.publishResults", "true"
    
    systemProperty "pact.filter.consumers", [nameOfConsumer]
    systemProperty "pact.filter.pacturl", [pact-url-from-webhook]
    I’d expect given I have set the
    pact.filter.pacturl
    that it should only run the provider tests for that are in the url provided - but it seems to be running everything and also not verifying the consumer branch I am expecting. It is as though the
    pact.filter.pacturl
    is being ignored?
    • 1
    • 1
  • j

    João Luiz Vieira

    11/09/2022, 10:29 PM
    Hello everyone. Searched a lot and was not able to find a solution, so I am asking help here. I am trying to write the code for the provider side of contract in java (
    au.com.dius.pact.provider:spring:4.3.16
    ). A have a few tests working, but when I try to test a controller that has a
    Pageable
    as a parameter, I get.
    Copy code
    1.1) Request processing failed; nested exception is java.lang.IllegalStateException: No primary or single unique constructor found for interface org.springframework.data.domain.Pageable
    I am already using the
    messageConverters
    of the
    MockMvcTarget
    but I could not find an argument resolver of sorts. One solution would be to break down the pageable in the values, but I was trying to avoid that. Any ideas on how to fix this error with pageable as a parameter? (code in the first comments of the thread)
    • 1
    • 3
  • m

    Marek Czerwiński

    11/15/2022, 12:05 PM
    Hi all! Do you have any examples which show how can I use JUnit
    @ParameterizedTest
    on a consumer side?
  • a

    Angad Singh

    11/15/2022, 1:14 PM
    Hi All, I am trying to integrate contract testing in Android along with the Instrumentation tests (UI tests). So far we have tried to use
    Pact-jvm
    (https://github.com/pact-foundation/pact-jvm) and
    wiremock-pact-generator
    plugin (https://bitbucket.org/atlassian/wiremock-pact-generator) but facing some issues with both of these libraries. With
    Pact-jvm
    , I am not able to mock the responses and with
    wiremock-pact-generator
    plugin I am not able to add providerState or a matcher in the pact generated. Has anyone faced/resolved a similar kind of issue?
  • l

    Laith

    11/15/2022, 4:17 PM
    Hi! I’m using v4.1.39 of the JUnit5 provider plugin in Java 11, and I’m trying to modify the request sent to the pact broker to include a basic auth header as per the docs. However, when I inspect the packets being sent to the pact broker, I see that the header is not being added, and so the authentication fails. I’m probably missing something obvious, is anyone able to help? See thread for my code etc.
    m
    • 2
    • 6
  • s

    Shivam Kumar

    11/15/2022, 5:08 PM
    hey everyone, We have been using Pact-jvm (version 4.1.34) for contract test across our web and microservices (25-30 applications pact logo white). I was looking to setup some kind of
    observability
    for our contract test executions to monitor the failures 🎯. Has anyone seen any example implemented where we could read the Verification Results at the end of provider test completion and publish the meaningful info from results as part of AfterAll or end of execution.
    m
    • 2
    • 2
  • r

    Riley Martine

    11/16/2022, 10:48 PM
    Hi! Really great work from the pact team lately 🙂 I've been encountering this issue: https://github.com/pact-foundation/pact-plugins/issues/9 It's preventing the pact-protobuf-plugin from working from pact-jvm inside a docker container (which is how we run tests in our build system). Does anyone have a workaround?
    ❤️ 2
    👋 1
    u
    m
    • 3
    • 9
  • j

    James P

    11/18/2022, 2:35 PM
    Is it possible to set a default state? I’ve currently got some mocks setup when running the provider tests but for those tests I use particular states. There are some consumers that hit endpoints that dont require for us to mock but because the mocks are setup on a service level it is affecting their behaviour? Is there a default state annotation that we can use to tell the mock service to use real methods for the calls it needs to make?
    u
    • 2
    • 1
  • h

    huy

    11/19/2022, 1:48 AM
    hello everybody. i'm not sure if this is the correct place to ask this. i am trying to test a contract against a provider that exposes it's API through an endpoint
    /graphql
    . the request is done through 2 methods: 1. lambda sdk call by another back end service 2. front end POST through the aws api gateway in both cases, the endpoints are not set up in the application itself but rather through lambda or aws api gateway (and the cdk) when running the test on the provider side, i always get 404 because the endpoint
    /graphql
    doesn't exist when the test is running locally. any ideas how to get around this? is using a Message Contract rather than an HTTP contract the best use here?
    u
    m
    • 3
    • 6
  • m

    Marcin Grzejszczak

    11/23/2022, 11:55 AM
    hey! I tried pinging @Matt (pactflow.io / pact-js / pact-go) about this but didn't get any response so I'll post the message here. I'm Marcin and I'm the lead of Spring Cloud Contract. I've got a thing I would like to discuss. I tried to upgrade Pact support in Spring Cloud Contract from version 4.1 to 4.3. Unfortunately, there were API breakages (which I've managed to fix) and functionality breakages (which I didn't manage to fix). I often have to spend a lot of time on the upgrades even with minor releases (actually I see breaking changes even between 4.2.7 and 4.2.20). We've decided to move the SCC - Pact integration out of SCC (I've temporarilly moved the whole code here https://github.com/marcingrzejszczak/spring-cloud-contract-pact together with e2e samples) . My question is - would someone (I guess the Pact foundation) be willing to take in the SCC - Pact integration?
    👋 2
    y
    m
    • 3
    • 5
  • g

    GitHub

    11/24/2022, 1:57 PM
    #1642 To test Multipart service using pact New issue created by Dedeepya-Kolli Hi Team, We need to write contract testing for a service which accepts requests in MultiParts. 1.Part is of File Upload(which is of Multipart/formdata content type) 2.Part is of JSON Data (which is of application/json content type). How can I write the pact for this.Please suggest. Used withFileUpload ->it is considering only the file upload part. How can I include the JSON request as well. pact-foundation/pact-jvm
    r
    • 2
    • 1
  • g

    Glenn Halstead

    11/28/2022, 9:14 PM
    When running the producer tests for a service that has other downstream service dependencies is the approach to mock / stub those downstream dependencies?
    ✅ 1
    m
    • 2
    • 3
  • g

    Glenn Halstead

    11/29/2022, 8:05 PM
    Is there a current state of the art pact + springboot example github repo you can recommend. Some of the examples linked in the docs have code from 2015. (ref: https://docs.pact.io/implementation_guides/jvm/readme#links)
    u
    m
    s
    • 4
    • 7
  • f

    Francislainy Campos

    12/01/2022, 4:43 AM
    Hi, how do we tag a contract with the PR branch from the mvn command when publishing it? Can’t find the right syntax for that. Not sure if something like this?
    Copy code
    ./mvnw -Dpactbroker.auth.token=${pactBrokerToken} pact:publish -Dpact.consumer.version=Aversion -Dpactbroker.tags=ATag
    u
    • 2
    • 66
  • f

    Francislainy Campos

    12/01/2022, 4:44 AM
    This is coming from Jenkins and we would like to tag our contracts with the git commit hash.
  • j

    James P

    12/01/2022, 8:51 AM
    Hi, is it possible to do a pact verification based off of the consumer version number? I’m thinking of the scenarios where a webhook is triggered by the broker, there are a number of properties to get the consumer and their version such as
    ${pactbroker.consumerVersionNumber}
    and
    ${pactbroker.consumerName}
    . Is there a way of combining that in order to give a selector such as
    Copy code
    SelectorBuilder().consumer("consumer1").version("1234567")
    I was looking to see if the raw json selectors would do it but I couldn’t find any examples of what can be passed
  • f

    Francislainy Campos

    12/01/2022, 11:12 AM
    Is this how we inject an id dynamically into the body for a consumer?
    Copy code
    @ExtendWith(PactConsumerTestExt.class)
    class PactConsumerSendScoreIT {
    
        private final Map<String, String> headers = new HashMap<>();
        private final String path = "/v5/assignmentStatus/update";
    
        @Pact(provider = PACT_PROVIDER, consumer = PACT_CONSUMER)
        public RequestResponsePact scoreConsumerPact(PactDslWithProvider builder) {
    
            headers.put("Content-Type", "application/json");
    
            //Body given and returned
            DslPart body = new PactDslJsonBody()
                    .valueFromProviderState("assignmentId", "assignmentId", "c1ef3bbf-55a2-4638-8f93-22b2916fe085")
                    .stringType("timestamp", DateTime.now().plusHours(3).toString())
                    .decimalType("scoreGiven", 75.00)
                    .decimalType("scoreMaximum", 100.00)
                    .stringType("comment", "Good work!")
                    .stringType("status", "IN_PROGRESS")
                    .stringType("userId", "c2ef3bbf-55a2-4638-8f93-22b2916fe085")
                    .close();
    
            return builder
                    .given("Scoring info is passed between ags-tool and assignmentapi")
                    .uponReceiving("Scoring info is passed between ags-tool and assignmentapi")
                    .path(path)
                    .method("POST")
                    .body(body)
                    .headers(headers)
                    .willRespondWith()
                    .status(201)
                    .body(body)
                    .toPact();
    
        }
    
        @Test
        @PactTestFor(pactMethod = "scoreConsumerPact", providerName = PACT_PROVIDER, port = "8080", pactVersion = PactSpecVersion.V3)
        void runTest(MockServer mockServer) {
    
            String updateAssignmentId = "c2ef3bbf-55a2-4638-8f93-22b2916fe085";
    
            HashMap<String, Object> map = new HashMap<>();
            map.put("timestamp", DateTime.now().plusHours(3).toString());
            map.put("scoreGiven", 75.00);
            map.put("scoreMaximum", 100.00);
            map.put("comment", "Good work!");
            map.put("status", "IN_PROGRESS");
            map.put("userId", "c2ef3bbf-55a2-4638-8f93-22b2916fe085");
            map.put("assignmentId", updateAssignmentId);
    
            //Mock url
            RequestSpecification rq = Util.getRequestSpecification().baseUri(mockServer.getUrl()).headers(headers);
    
            Response response = rq.body(map)
                    .post(path);
    
            assertEquals(201, response.getStatusCode());
        }
    b
    • 2
    • 2
  • f

    Francislainy Campos

    12/01/2022, 11:12 AM
    Copy code
    @State("Scoring info is passed between ags-tool and assignmentapi")
    Map<String, Object> getScoringInfo() {
    
        Map<String, Object> map = new HashMap<>();
        map.put("assignmentId",updateAssignmentId);
        return map;
    }
  • f

    Francislainy Campos

    12/01/2022, 11:13 AM
    I think we may need to have sth set inside the runTest code to make sure we’re configuring it to be dynamically generated perhaps?
  • f

    Francislainy Campos

    12/01/2022, 11:13 AM
    As of now, it’s still using the hardcoded id given under the sample part.
1...8910...14Latest