jeudi 6 juin 2019

PACT testing: correct way to write PactDslJsonBody

I have the following JSON format

{
    "file": {
        "version": "v1.4",
        "release": "1.1"
    },
    "status": "ON",
    "document": {
        "status": "NOT_FOUND",
        "release": "undefined"
    }
}

and I would like to know how I can add the format into my PactDslJsonBody, something like?

DslPart result = new PactDslJsonBody()
        .stringType("file.version", "v1.4")
        .stringType("file.release", "1.1")
        .stringType("status", "ON")
        .stringType("document.status", "NOT_FOUND")
        .stringType("document.release", "release") 
        .asBody();

Or is it possible to add a Java Pojo? I have the class ApplicationResponse:

public class ApplicationResponse {

  private File file;
  private String status;
  private Document document;

  //...

}

Something like ??
    DslPart result = new PactDslJsonBody()
            .object(ApplicationResponse)
            .asBody();

What could be the best approach? could you please add an example

Aucun commentaire:

Enregistrer un commentaire