/** * Response body to return * * @param body Response body built using the Pact body DSL */ public PactDslResponse body(DslPart body) { DslPart parent = body.close(); if (parent instanceof PactDslJsonRootValue) { ((PactDslJsonRootValue)parent).setEncodeJson(true); } responseMatchers.addCategory(parent.getMatchers()); responseGenerators.addGenerators(parent.generators); if (parent.getBody() != null) { responseBody = OptionalBody.body(parent.getBody().toString()); } else { responseBody = OptionalBody.nullBody(); } if (!responseHeaders.containsKey(CONTENT_TYPE)) { matchHeader(CONTENT_TYPE, DEFAULT_JSON_CONTENT_TYPE_REGEX, ContentType.APPLICATION_JSON.toString()); } return this; }
/** * Response body to return * * @param body Response body built using the Pact body DSL */ public PactDslResponse body(DslPart body) { DslPart parent = body.close(); if (parent instanceof PactDslJsonRootValue) { ((PactDslJsonRootValue)parent).setEncodeJson(true); } responseMatchers.addCategory(parent.getMatchers()); responseGenerators.addGenerators(parent.generators); if (parent.getBody() != null) { responseBody = OptionalBody.body(parent.getBody().toString()); } else { responseBody = OptionalBody.nullBody(); } if (!responseHeaders.containsKey(CONTENT_TYPE)) { matchHeader(CONTENT_TYPE, DEFAULT_JSON_CONTENT_TYPE_REGEX, ContentType.APPLICATION_JSON.toString()); } return this; }