diff --git a/src/main/java/org/springframework/samples/petclinic/rest/PetRestController.java b/src/main/java/org/springframework/samples/petclinic/rest/PetRestController.java index e2e55c3b4..b2f8803ad 100644 --- a/src/main/java/org/springframework/samples/petclinic/rest/PetRestController.java +++ b/src/main/java/org/springframework/samples/petclinic/rest/PetRestController.java @@ -60,7 +60,11 @@ public class PetRestController { @RequestMapping(value = "/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public ResponseEntity> getPets(){ - return new ResponseEntity>(this.clinicService.findAllPets(), HttpStatus.OK); + Collection pets = this.clinicService.findAllPets(); + if(pets.isEmpty()){ + return new ResponseEntity>(HttpStatus.NOT_FOUND); + } + return new ResponseEntity>(pets, HttpStatus.OK); } @RequestMapping(value = "/pettypes}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)