@Test @Rollback(false) @Ignore public void testFindGiftsByRecipient() throws Exception { mockMvc.perform(get((Uris.GIFTS_BY_RECIPIENT)).param("userName", "Recipient").accept("application/json")).andExpect(status().isOk()) .andExpect(jsonPath("$.[0].consignor.name").value("Consignore")).andExpect(jsonPath("$.[0].recipient.name").value("Recipient")) .andExpect(jsonPath("$.[0].code.code").value(codeString3)).andExpect(jsonPath("$.[0].status").value("REDEEMED")); }
@RequestMapping(value = Uris.GIFTS_BY_RECIPIENT, method = RequestMethod.GET) @JsonView(Views.OverviewGift.class) public ResponseEntity<?> findGiftsByRecipient(@RequestHeader(value = "X-AUTH-TOKEN") String userToken, @RequestParam String userName) { if (_tokenAuthenticationService.isAuthenticatedUser(userToken, userName)) { List<Gift> gifts = _giftRepository.findGiftsByRecipient(userName); return new ResponseEntity<>(gifts, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.FORBIDDEN); } }
GiftController { @RequestMapping(value = Uris.GIFTS_BY_RECIPIENT, method = RequestMethod.GET) @JsonView(Views.OverviewGift.class) public ResponseEntity<?> findGiftsByRecipient(@RequestHeader(value = "X-AUTH-TOKEN") String userToken, @RequestParam String userName) { if (_tokenAuthenticationService.isAuthenticatedUser(userToken, userName)) { List<Gift> gifts = _giftRepository.findGiftsByRecipient(userName); return new ResponseEntity<>(gifts, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.FORBIDDEN); } } }
GiftController { @RequestMapping(value = Uris.GIFTS_BY_RECIPIENT, method = RequestMethod.GET) @JsonView(Views.OverviewGift.class) public ResponseEntity<?> findGiftsByRecipient(@RequestHeader(value = "X-AUTH-TOKEN") String userToken, @RequestParam String userName) { if (_tokenAuthenticationService.isAuthenticatedUser(userToken, userName)) { List<Gift> gifts = _giftRepository.findGiftsByRecipient(userName); return new ResponseEntity<>(gifts, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.FORBIDDEN); } }  }
GiftController { @RequestMapping(value = Uris.GIFTS_BY_RECIPIENT, method = RequestMethod.GET) @JsonView(Views.OverviewGift.class) public ResponseEntity<?> findGiftsByRecipient(@RequestHeader(value = "X-AUTH-TOKEN") String userToken, @RequestParam String userName) { if (_tokenAuthenticationService.isAuthenticatedUser(userToken, userName)) { List<Gift> gifts = _giftRepository.findGiftsByRecipient(userName); return new ResponseEntity<>(gifts, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.FORBIDDEN); } }  @RequestMapping(value = Uris.GIFTS_BY_CONSIGNOR, method = RequestMethod.GET) @JsonView(Views.OverviewGift.class) ResponseEntity<?> findGiftsByConsignor(@RequestHeader(value = "X-AUTH-TOKEN") String userToken, @RequestParam String userName); @RequestMapping(value = Uris.GIFTS_BY_RECIPIENT, method = RequestMethod.GET) @JsonView(Views.OverviewGift.class) ResponseEntity<?> findGiftsByRecipient(@RequestHeader(value = "X-AUTH-TOKEN") String userToken, @RequestParam String userName); @RequestMapping(value = Uris.GIFT_CREATE, method = RequestMethod.POST) @Transactional ResponseEntity<?> generateGift(@RequestHeader(value = "X-AUTH-TOKEN") String userToken, @RequestBody PlantBag plantBag); @RequestMapping(value = Uris.GIFT_PDF, method = RequestMethod.GET, headers = "Accept=application/pdf") ResponseEntity<?> createGiftPdf(HttpServletResponse response, @RequestParam long giftId); }
GiftController { @RequestMapping(value = Uris.GIFTS_BY_RECIPIENT, method = RequestMethod.GET) @JsonView(Views.OverviewGift.class) public ResponseEntity<?> findGiftsByRecipient(@RequestHeader(value = "X-AUTH-TOKEN") String userToken, @RequestParam String userName) { if (_tokenAuthenticationService.isAuthenticatedUser(userToken, userName)) { List<Gift> gifts = _giftRepository.findGiftsByRecipient(userName); return new ResponseEntity<>(gifts, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.FORBIDDEN); } }  @RequestMapping(value = Uris.GIFTS_BY_CONSIGNOR, method = RequestMethod.GET) @JsonView(Views.OverviewGift.class) ResponseEntity<?> findGiftsByConsignor(@RequestHeader(value = "X-AUTH-TOKEN") String userToken, @RequestParam String userName); @RequestMapping(value = Uris.GIFTS_BY_RECIPIENT, method = RequestMethod.GET) @JsonView(Views.OverviewGift.class) ResponseEntity<?> findGiftsByRecipient(@RequestHeader(value = "X-AUTH-TOKEN") String userToken, @RequestParam String userName); @RequestMapping(value = Uris.GIFT_CREATE, method = RequestMethod.POST) @Transactional ResponseEntity<?> generateGift(@RequestHeader(value = "X-AUTH-TOKEN") String userToken, @RequestBody PlantBag plantBag); @RequestMapping(value = Uris.GIFT_PDF, method = RequestMethod.GET, headers = "Accept=application/pdf") ResponseEntity<?> createGiftPdf(HttpServletResponse response, @RequestParam long giftId);  }