Mockmvc test not work when Pathvariable is a String but work on int. Here is my code:
@Controller
@RequestMapping("/etablissement/{typeEtablissement}")
public class EtablissementController{
@RequestMapping(method = RequestMethod.GET)
public String accueil(@PathVariable("typeEtablissement") String typeEtablissement) {
return "/test";
}
}
// somewhere in my test
mockMvc.perform(get("/etablissement/{typeEtablissement}", "test")).andExpect(status().isOk()); // Error 400
But, if I use int instead of String it works
@RequestMapping(method = RequestMethod.GET)
public String accueil(@PathVariable("typeEtablissement") int typeEtablissement) {
return "/test";
}
// somewhere in my test
mockMvc.perform(get("/etablissement/{typeEtablissement}", 123)).andExpect(status().isOk()); // Works
Using Object also work
public String accueil(@PathVariable("typeEtablissement") Object typeEtablissement) {}
Thanks for your help !