@Test public void testGetUserRatingNULL() { String remoteUser = "jdoe"; Mockito.when(req.getRemoteUser()).thenReturn("jdoe"); IPortletType portletType = new PortletTypeImpl("John Doe", "http: portletType.setDescription("Portlet Type"); PortletDefinitionImpl tempPortlet = new PortletDefinitionImpl( portletType, "John", "Doe", "Course", "app-id", "Courses", true); Mockito.when( marketplaceService.getOrCreateMarketplacePortletDefinitionIfTheFnameExists( remoteUser)) .thenReturn(null); Mockito.when(marketplaceRatingDAO.getRating(remoteUser, tempPortlet)).thenReturn(null); ModelAndView modelAndView = marketplaceRESTController.getUserRating(req, F_NAME); Assert.assertNull(modelAndView.getModel().get("rating")); }
@RequestMapping(value = "/marketplace/{fname}/getRating", method = RequestMethod.GET) public ModelAndView getUserRating(HttpServletRequest request, @PathVariable String fname) { Validate.notNull(fname, "Please supply a portlet to get rating for - should not be null"); IMarketplaceRating tempRating = marketplaceRatingDAO.getRating( request.getRemoteUser(), marketplaceService.getOrCreateMarketplacePortletDefinitionIfTheFnameExists( fname)); if (tempRating != null) { return new ModelAndView( "json", "rating", new MarketplaceEntryRating(tempRating.getRating(), tempRating.getReview())); } return new ModelAndView("json", "rating", null); }
MarketplaceRESTController { @RequestMapping(value = "/marketplace/{fname}/getRating", method = RequestMethod.GET) public ModelAndView getUserRating(HttpServletRequest request, @PathVariable String fname) { Validate.notNull(fname, "Please supply a portlet to get rating for - should not be null"); IMarketplaceRating tempRating = marketplaceRatingDAO.getRating( request.getRemoteUser(), marketplaceService.getOrCreateMarketplacePortletDefinitionIfTheFnameExists( fname)); if (tempRating != null) { return new ModelAndView( "json", "rating", new MarketplaceEntryRating(tempRating.getRating(), tempRating.getReview())); } return new ModelAndView("json", "rating", null); } }
MarketplaceRESTController { @RequestMapping(value = "/marketplace/{fname}/getRating", method = RequestMethod.GET) public ModelAndView getUserRating(HttpServletRequest request, @PathVariable String fname) { Validate.notNull(fname, "Please supply a portlet to get rating for - should not be null"); IMarketplaceRating tempRating = marketplaceRatingDAO.getRating( request.getRemoteUser(), marketplaceService.getOrCreateMarketplacePortletDefinitionIfTheFnameExists( fname)); if (tempRating != null) { return new ModelAndView( "json", "rating", new MarketplaceEntryRating(tempRating.getRating(), tempRating.getReview())); } return new ModelAndView("json", "rating", null); }  }
MarketplaceRESTController { @RequestMapping(value = "/marketplace/{fname}/getRating", method = RequestMethod.GET) public ModelAndView getUserRating(HttpServletRequest request, @PathVariable String fname) { Validate.notNull(fname, "Please supply a portlet to get rating for - should not be null"); IMarketplaceRating tempRating = marketplaceRatingDAO.getRating( request.getRemoteUser(), marketplaceService.getOrCreateMarketplacePortletDefinitionIfTheFnameExists( fname)); if (tempRating != null) { return new ModelAndView( "json", "rating", new MarketplaceEntryRating(tempRating.getRating(), tempRating.getReview())); } return new ModelAndView("json", "rating", null); }  @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}/getRating", method = RequestMethod.GET) public ModelAndView getUserRating(HttpServletRequest request, @PathVariable String fname) { Validate.notNull(fname, "Please supply a portlet to get rating for - should not be null"); IMarketplaceRating tempRating = marketplaceRatingDAO.getRating( request.getRemoteUser(), marketplaceService.getOrCreateMarketplacePortletDefinitionIfTheFnameExists( fname)); if (tempRating != null) { return new ModelAndView( "json", "rating", new MarketplaceEntryRating(tempRating.getRating(), tempRating.getReview())); } return new ModelAndView("json", "rating", null); }  @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);  }