首先,上述 URL 均无效。& 使用这个框架太难了.. 没有一个 API 有适当的文档,而且当某些东西不起作用时也很血腥,它也没有给出适当的错误消息。
就我而言,我一直在尝试发送一个名为“business-date”的请求参数,它需要一个格式为“yyyy-MM-dd”的日期,但以下选项似乎都不起作用——
matchQuery("business-date", "\\d{4}-\\d{2}-\\d{2}", "2020-05-18")
query("business-date="+getBusinessDate())
queryMatchingDate("business-date", "yyyy-MM-dd")
matchQuery("business-date", "\\d{4}-\\d{2}-\\d{2}")
queryMatchingDate("business-date", "yyyy-MM-dd")
queryMatchingISODate("business-date", "yyyy-MM-dd")
异常看起来像这样
org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Internal Server Error: [{ "error": "Unexpected request : \tmethod: GET\n\tpath: \/api\/batch_activities\/ACTIVITY\/STARTED\n\tquery: {}\n\theaders: {X-b3-traceid=[6c88f0a1a0ae288e], Accept=[application\/json], Connection=[ke... (443 bytes)]
Caused by: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Internal Server Error: [{ "error": "Unexpected request : \tmethod: GET\n\tpath: \/api\/batch_activities\/ACTIVITY\/STARTED\n\tquery: {}\n\theaders: {X-b3-traceid=[6c88f0a1a0ae288e], Accept=[application\/json], Connection=[ke... (443 bytes)]
一旦 DSL 的实例如下所示 -
builder.given("Fetch Batch Activity by status")
.uponReceiving("Receiving Batch activity status").headers(headers).method(HttpMethod.GET)
.matchPath(pathRegex, path)
.matchQuery("business-date", "\\d{4}-\\d{2}-\\d{2}")
.willRespondWith().status(200).headers(headers).body(jsonUtil.getObjectAsString(
formatBatchActivityForStatus(FeedExporterConstants.BATCH_STATUS_STARTED)))
.toPact();