I have a controller that contains 2+ methods:
@RequestMapping(method = RequestMethod.GET, value = "/{uuid}", produces = "application/json")
public MyObject findByUuid(
@PathVariable("uuid") String uuid) {
...
}
@RequestMapping(method = RequestMethod.POST, value = "/findByStringPropertyEquals", produces = "application/json")
public List<MyObject> findByStringPropertyEquals(
@RequestParam("type") String type,
@RequestParam("property") String property,
@RequestParam("value") String value) {
...
}
Now when I try to test the second method like
mvc.perform(get("/findByStringPropertyEquals?type={0}&property={1}&value={2}", "Person", "testPropInt", 42))
.andExpect(status().isOk())
.andExpect(jsonPath("$", hasSize(1)));
then MockMvc
picks up the findByUuid
controller method unfortunately. Output is
MockHttpServletRequest:
HTTP Method = GET
Request URI = /api/v1/domain-entities/findByStringPropertyEquals
Parameters = {type=[Person], property=[testPropInt], value=[42]}
Headers = {}
Body = <no character encoding set>
Session Attrs = {}
Handler:
Type = com.example.MyObjectController
Method = public com.example.MyObject com.example.MyObjectController.findByUuid(java.lang.String)
However, accessing the REST API regularly when the web server is started is working fine. Is that a bug or do I do something wrong?