Search code examples
javapactpact-java

PactDslJsonObject getting resolved to Empty Map {}


The object, below, while debugging is being displayed as {} instead of {"types" : ["Ice Cream"] } as one would expect. Why is this happening.

  PactDslJsonObject  resquest = new PactDslJsonObject()         
    .array("type").stringMatcher("\w+","Ice Cream");

Solution

  • Sorry to answer my own question. Looks like we must close the children of PactDslJsonObject or whatever (could be an array as well in that case you will have to close the object withing the array.) is it that we would like to request or respond from aor to a service.

    So, in this case it should be,

    DslPart response = new PactDslJsonObject()         
    .array("type").stringMatcher("\w+","Ice Cream").closeArray();