Ciao a tutti,
volevo preparare dei test per questa classe java, il problema è che questo metodo restituisce un json oppure una stringa per la chiamata http.
codice:
@Controller
@RequestMapping(value="/step/{idstep}")
public class StepInfoController {
@Autowired
StepInfoService stepInfoService;
@RequestMapping(method=RequestMethod.GET)
@ResponseBody
public Step getStepInformation(@PathVariable int idstep){
Step toBeReturned;
toBeReturned=stepInfoService.retrieveStepInfo(idstep);
if(toBeReturned!=null)
return toBeReturned;
throw new IllegalStateException("passo non trovato");
}
@ExceptionHandler(IllegalStateException.class)
@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Errore passo non trovato")
public void handleException3(IllegalStateException ex, HttpServletResponse response) throws IOException{
//invia al client un errore 404
}
}
avete qualche idea su come potrei fare?
Grazie in anticipo