当我在带有查询参数的restdoc测试中创建dslcontracts时,它会创建groovy合同文件和存根文件。但是当我使用@EnableStubRunnerServer部署合同时,我永远无法获得匹配的查询参数。
我意识到存根文件是通过如下请求生成的:
"request" : {
"url" : "/search",
"method" : "GET",
"queryParameters" : {
"query" : {
"equalTo" : "friday"
}
}
}
However if i change the stub file to :
"request" : {
"urlPathPattern" : "/search",
"method" : "GET",
"queryParameters" : {
"query" : {
"equalTo" : "friday"
}
}
}
it seems to work. Is there a way to make this work?
Here is how i'm writing the test:
@Test
public void searchWithQuery() throws Exception {
Map<String, Object> param = new HashMap<>();
param.put("query", "equalTo(\"friday\")");
mockMvc.perform(get(SEARCH_PATH + "?query=friday"))
.andExpect(status().isOk())
.andDo(document("search-query",
dslContract(param)
));
}