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

MessagePact with a string as a content #1619

Open
YanovAlexander opened this issue Oct 11, 2022 · 3 comments
Open

MessagePact with a string as a content #1619

YanovAlexander opened this issue Oct 11, 2022 · 3 comments

Comments

@YanovAlexander
Copy link

Trying to write consumer tests using MessagePactBuilder and ran into a problem that I can't pass a string to the withContent method, since our provider sends an event with a string representation, and not with Json, the content type being passed is application/x-www-form-urlencoded. Are there solutions for this problem?

@Pact(provider = PROVIDER_ID, consumer = CONSUMER_ID)
public MessagePact initialScreen(MessagePactBuilder builder) {
    Map<String, Object> metadata = new HashMap<>();
    metadata.put("contentType", "application/x-www-form-urlencoded");

    return builder.given(STATE)
        .expectsToReceive(DESCRIPTION)
        .withMetadata(metadata)
        .withContent() //need to place string body here
        .toPact();
}
@rholshausen
Copy link
Contributor

Released with version 4.3.16

@YanovAlexander
Copy link
Author

Thanks @rholshausen , right now we are using pact version 4.1.39 as we can migrate to the java 11+, any possibilities to make this changes compatible with the pact 4.1.+?

@rholshausen
Copy link
Contributor

4.1.40 released

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

3 participants