I'm writing tests for a spring code, one of my function contain PathVariable, which is used in the function itself, and i want to test it whenever it passes as null, but if i sent it as null, i got 400 status because it's not getting it pathvariable. my code:
@RequestMapping(value = "/{name}", method = RequestMethod.POST)
public importedName importName(... @PathVariable("name") String name ..) throws Exception {
if (name == null) {
do some stuff..
}
My naive approach:
String name = null;
mockMvc.perform(post(".." + "/{name}", name).header(..).accept(..))
and i cannot find a way to enter inside the if statement