pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.07k stars 475 forks source link

Java consumerBuilder array structure #1185

Open rilo03 opened 3 years ago

rilo03 commented 3 years ago

I use the following dependency:

            <dependency>
                <groupId>com.remondis.cdc</groupId>
                <artifactId>pact-consumer-builder</artifactId>
                <version>0.1.5</version>
            </dependency>

I try to generate the pact file from java bean, for example:

public class A {
    List<String> test;

    public A() {
    }

    public List<String> getTest() {
        return test;
    }

    public void setTest(List<String> test) {
        this.test = test;
    }
}

and generate the pact using consumerBuilder:

        A a = new A();
        a.setTest(Arrays.asList("testValue"));
        ConsumerBuilder<A> consumerBuilder = ConsumerExpects.type(A.class);
        PactDslJsonBody body = consumerBuilder .build(a);

I receive: {"test":[{"test":"testValue"}]}

but I would like to get: {"test":["testValue"]}

I tried some experiment with setting a custom array mapping for the consumerBuilder, but I couldn't get it to work, any help would be appreciated.

uglyog commented 3 years ago

Could you raise this on the pact-consumer-builder project?