From 2f96792cb308d90207d2b8f1575a9593c5a3db52 Mon Sep 17 00:00:00 2001 From: Vitaliy Fedoriv Date: Sun, 6 Nov 2016 19:40:18 +0200 Subject: [PATCH] update PetRestController getPets() method --- .../samples/petclinic/rest/PetRestController.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)