Java Pact.io DSL for List of maps

973 views Asked by At

i have to create a pact dsl part to match the json to be serialized into the following java object:

List<Map<String, List<String>>> attributes = new ArrayList<>();

Currently i have following pact dsl part which is not working:

             .eachLike("attributes")
                .eachKeyMappedToAnArrayLike("sale")
                  .stringType("new sale")
                  .closeObject()
                .closeArray()
            .closeObject()
            .closeArray();

what's the issue in the above pact dsl? i am following this github page to implement that:

https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-consumer-junit

1

There are 1 answers

0
Murali Krishna On

You can try this

.array("attributes")
    .object()
        .array("Sale")
             .stringValue("new Sale")
        .closeArray()
    .closeObject()
    .object()
        .array("Material")
             .stringValue("silver")
        .closeArray()
    .closeObject()
.closeArray()