Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: newJsonBody() builder unable to handle certain field names #1760

Closed
RogVanGDS opened this issue Jan 15, 2024 · 0 comments
Closed

BUG: newJsonBody() builder unable to handle certain field names #1760

RogVanGDS opened this issue Jan 15, 2024 · 0 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@RogVanGDS
Copy link

RogVanGDS commented Jan 15, 2024

I'm using the newJsonBody builder for the LambdaDsl tests in Java - Junit5

The JsonBody I am trying to mock has a field that has a hyperlink as it's fieldName, but as soon as I add a fieldName into the builder that contains a . or a / character, it turns the fieldName into a JsonList of that string, instead of just leaving it as a plain old String.

This is the goal of my mocked response:
Screenshot 2024-01-12 at 16 59 52

This is the code I am currently using:

withContent(
      newJsonBody(
                (body) -> {
                    final PactDslJsonBody actualPactDsl =
                            new PactDslJsonBody();

                    var jwtHelper =
                            new JwtTestHelper(
                                    VALID_VC_HEADER,
                                    VALID_VC_BODY,
                                    VALID_VC_SIGNATURE);

                    body.nullValue("error");
                    body.stringValue("iss", "f2f");
                    body.stringValue("sub", "test-subject");
                    body.stringType(
                            "state",
                            "f5f0d4d1-b937-4abe-b379-8269f600ad44");
                    body.minArrayLike(
                            "https://vocab.account.gov.uk/v1/credentialJWT",
                            1,
                            PactDslJsonRootValue.stringMatcher(
                                    jwtHelper
                                            .buildRegexMatcherIgnoringSignature(),
                                    jwtHelper.buildJwt()),
                            1);
                    actualPactDsl.close();

                    body.nullValue("error_description");
                })
        .build())

This code produces the following JSON:

Screenshot 2024-01-12 at 17 00 29

@rholshausen rholshausen added the bug Indicates an unexpected problem or unintended behavior label Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants