我正在尝试编写DSL Groovy脚本来测试支持多部分的API。这是我的API合同:
PostMapping(value = "/application" + "/{applicationNumber}",
consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
LoanDecisionResponseDto updateLoanApproval(
@PathVariable("applicationNumber") String applicationNumber,
@RequestPart("approval") DecisionRequestDto loanDecisionRequestDto,
@RequestPart("attachments") MultipartFile[] attachments);
这是我尝试编写的DSL Groovy脚本:
Contract.make {
request {
method POST()
url '/lending-decisioning/applications/LOAN_APP_NO_NOT_FOUND_FOR_UPDATE_LOAN_APPROVAL'
headers {
header 'Channel': 'Channel.Web'
header 'Content-Type': 'multipart/form-data'
header 'Consume': 'application/json'
}
/** I don't know how to write this part... **/
multipart(
approval: '{"status": "anyName", "reason": "1.0"}',
multipartFile: named(
)
)
}
response {
status 500
headers {
contentType('application/json;charset=UTF-8')
}
}
由于我是Spring Cloud Contract测试的新手。请帮助我填写多部分内容。