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

providerStates missing from consumer contract in version 4.6.15 #1854

Closed
markozz opened this issue Feb 6, 2025 · 1 comment
Closed

providerStates missing from consumer contract in version 4.6.15 #1854

markozz opened this issue Feb 6, 2025 · 1 comment

Comments

@markozz
Copy link
Contributor

markozz commented Feb 6, 2025

When I have a test with:

    @Pact(provider = "UserService", consumer = "UserConsumer")
    V4Pact getAllUsers(PactBuilder builder) {
        return builder
                .given("Users exist")
                .usingLegacyDsl()
                .uponReceiving("A request to get all users")
                .path("/api/users")
                .method("GET")
                .willRespondWith()
                .status(200)
                .headers(Map.of("Content-Type", "application/json"))
                .body("{\"2fd273a1-58f2-4409-a578-2bcadd8ab613\":{\"id\":\"2fd273a1-58f2-4409-a578-2bcadd8ab613\",\"firstName\":\"John\",\"lastName\":\"Doe\",\"dateOfBirth\":\"01-01-1970\"}}")
                .toPact(V4Pact.class);
    }

Then:

Actual:
The contract does not include a provider state for the interation

Expected:
Interaction includes attribute providerstate with value "User exist"

@markozz
Copy link
Contributor Author

markozz commented Feb 6, 2025

Specifying as follows does include provider state:

@Pact(provider = "UserService", consumer = "UserConsumer")
    V4Pact getAllUsers(PactBuilder builder) {
        return builder
                .given("Users exist")
                .expectsToReceiveHttpInteraction("A request to get all users", httpBuilder -> {
                    return httpBuilder
                            .withRequest(requestBuilder -> requestBuilder
                                    .path("/api/users")
                                    .method("GET"))
                            .willRespondWith(responseBuilder -> responseBuilder
                                    .status(200)
                                    .body("{\"2fd273a1-58f2-4409-a578-2bcadd8ab613\":{\"id\":\"2fd273a1-58f2-4409-a578-2bcadd8ab613\",\"firstName\":\"John\",\"lastName\":\"Doe\",\"dateOfBirth\":\"01-01-1970\"}}")
                                    .header("Content-Type", "application/json")
                            )
                            .comment("This is also a comment");
                })
                .comment("This is also a comment")
                .toPact();
    }

@markozz markozz closed this as completed Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant