@Test public void testSaveUserRatingNull() { String rating = "3"; String review = "Good job"; Mockito.when(req.getRemoteUser()).thenReturn("jdoe"); ModelAndView modelAndView = marketplaceRESTController.saveUserRating(req, F_NAME, rating, review); MarketplaceEntryRating entry = (MarketplaceEntryRating) modelAndView.getModel().get("rating"); Assert.assertNotNull(entry); }
@RequestMapping(value = "/marketplace/{fname}/rating/{rating}", method = RequestMethod.POST) public ModelAndView saveUserRating( HttpServletRequest request, @PathVariable String fname, @PathVariable String rating, @RequestParam(required = false) String review) { Validate.notNull(rating, "Please supply a rating - should not be null"); Validate.notNull(fname, "Please supply a portlet to rate - should not be null"); marketplaceRatingDAO.createOrUpdateRating( Integer.parseInt(rating), request.getRemoteUser(), review, marketplaceService.getOrCreateMarketplacePortletDefinitionIfTheFnameExists(fname)); return new ModelAndView( "json", "rating", new MarketplaceEntryRating(Integer.parseInt(rating), review)); }
MarketplaceRESTController { @RequestMapping(value = "/marketplace/{fname}/rating/{rating}", method = RequestMethod.POST) public ModelAndView saveUserRating( HttpServletRequest request, @PathVariable String fname, @PathVariable String rating, @RequestParam(required = false) String review) { Validate.notNull(rating, "Please supply a rating - should not be null"); Validate.notNull(fname, "Please supply a portlet to rate - should not be null"); marketplaceRatingDAO.createOrUpdateRating( Integer.parseInt(rating), request.getRemoteUser(), review, marketplaceService.getOrCreateMarketplacePortletDefinitionIfTheFnameExists(fname)); return new ModelAndView( "json", "rating", new MarketplaceEntryRating(Integer.parseInt(rating), review)); } }
MarketplaceRESTController { @RequestMapping(value = "/marketplace/{fname}/rating/{rating}", method = RequestMethod.POST) public ModelAndView saveUserRating( HttpServletRequest request, @PathVariable String fname, @PathVariable String rating, @RequestParam(required = false) String review) { Validate.notNull(rating, "Please supply a rating - should not be null"); Validate.notNull(fname, "Please supply a portlet to rate - should not be null"); marketplaceRatingDAO.createOrUpdateRating( Integer.parseInt(rating), request.getRemoteUser(), review, marketplaceService.getOrCreateMarketplacePortletDefinitionIfTheFnameExists(fname)); return new ModelAndView( "json", "rating", new MarketplaceEntryRating(Integer.parseInt(rating), review)); }  }
MarketplaceRESTController { @RequestMapping(value = "/marketplace/{fname}/rating/{rating}", method = RequestMethod.POST) public ModelAndView saveUserRating( HttpServletRequest request, @PathVariable String fname, @PathVariable String rating, @RequestParam(required = false) String review) { Validate.notNull(rating, "Please supply a rating - should not be null"); Validate.notNull(fname, "Please supply a portlet to rate - should not be null"); marketplaceRatingDAO.createOrUpdateRating( Integer.parseInt(rating), request.getRemoteUser(), review, marketplaceService.getOrCreateMarketplacePortletDefinitionIfTheFnameExists(fname)); return new ModelAndView( "json", "rating", new MarketplaceEntryRating(Integer.parseInt(rating), review)); }  @Autowired void setMarketplaceService(IMarketplaceService marketplaceService); @Autowired void setPersonManager(IPersonManager personManager); @Autowired void setMarketplaceRatingDAO(IMarketplaceRatingDao marketplaceRatingDAO); @RequestMapping(value = "/marketplace/entries.json", method = RequestMethod.GET) ModelAndView marketplaceEntriesFeed(HttpServletRequest request); @RequestMapping(value = "/marketplace/entry/{fname}.json") ModelAndView marketplaceEntryFeed(
            HttpServletRequest request, HttpServletResponse response, @PathVariable String fname); @RequestMapping(value = "/v5-0/marketplace/{fname}/ratings", method = RequestMethod.GET) ModelAndView getPortletRatings(HttpServletRequest request, @PathVariable String fname); @RequestMapping(value = "/marketplace/{fname}/getRating", method = RequestMethod.GET) ModelAndView getUserRating(HttpServletRequest request, @PathVariable String fname); @RequestMapping(value = "/marketplace/{fname}/rating/{rating}", method = RequestMethod.POST) ModelAndView saveUserRating(
            HttpServletRequest request,
            @PathVariable String fname,
            @PathVariable String rating,
            @RequestParam(required = false) String review); }
MarketplaceRESTController { @RequestMapping(value = "/marketplace/{fname}/rating/{rating}", method = RequestMethod.POST) public ModelAndView saveUserRating( HttpServletRequest request, @PathVariable String fname, @PathVariable String rating, @RequestParam(required = false) String review) { Validate.notNull(rating, "Please supply a rating - should not be null"); Validate.notNull(fname, "Please supply a portlet to rate - should not be null"); marketplaceRatingDAO.createOrUpdateRating( Integer.parseInt(rating), request.getRemoteUser(), review, marketplaceService.getOrCreateMarketplacePortletDefinitionIfTheFnameExists(fname)); return new ModelAndView( "json", "rating", new MarketplaceEntryRating(Integer.parseInt(rating), review)); }  @Autowired void setMarketplaceService(IMarketplaceService marketplaceService); @Autowired void setPersonManager(IPersonManager personManager); @Autowired void setMarketplaceRatingDAO(IMarketplaceRatingDao marketplaceRatingDAO); @RequestMapping(value = "/marketplace/entries.json", method = RequestMethod.GET) ModelAndView marketplaceEntriesFeed(HttpServletRequest request); @RequestMapping(value = "/marketplace/entry/{fname}.json") ModelAndView marketplaceEntryFeed(
            HttpServletRequest request, HttpServletResponse response, @PathVariable String fname); @RequestMapping(value = "/v5-0/marketplace/{fname}/ratings", method = RequestMethod.GET) ModelAndView getPortletRatings(HttpServletRequest request, @PathVariable String fname); @RequestMapping(value = "/marketplace/{fname}/getRating", method = RequestMethod.GET) ModelAndView getUserRating(HttpServletRequest request, @PathVariable String fname); @RequestMapping(value = "/marketplace/{fname}/rating/{rating}", method = RequestMethod.POST) ModelAndView saveUserRating(
            HttpServletRequest request,
            @PathVariable String fname,
            @PathVariable String rating,
            @RequestParam(required = false) String review);  }