### Question:
WidgetApi extends AbstractRestApi { @RequestMapping(value = "/{widgetId}/rating", method = RequestMethod.POST) public void setWidgetRating(@PathVariable String widgetId, @RequestParam(value = "score") Integer score, HttpServletResponse response) { logger.debug("POST WidgetRating received for /api/rest/widgets/{} score: {}", widgetId, score); WidgetRating widgetRating = new WidgetRatingImpl(); widgetRating.setScore(score); widgetRating.setUserId(userService.getAuthenticatedUser().getId()); widgetService.saveWidgetRating(widgetId, widgetRating); response.setStatus(HttpStatus.NO_CONTENT.value()); } @Autowired  WidgetApi(UserService userService,
                     TagService tagService, WidgetService widgetService); @RequestMapping(method = RequestMethod.GET) void getAllWidgets(); @RequestMapping(method = RequestMethod.POST, value = "/{widgetId}/comments") void createWidgetComment(@PathVariable String widgetId,
                                    @RequestParam String text,
                                    HttpServletResponse response); @ResponseBody @RequestMapping(method = RequestMethod.GET, value = "/{widgetId}/comments/{widgetCommentId}") WidgetComment getWidgetComment(@PathVariable String widgetId,
                                          @PathVariable String widgetCommentId); @RequestMapping(method = RequestMethod.POST, value = "/{widgetId}/comments/{widgetCommentId}") void updateWidgetComment(@PathVariable String widgetId,
                                    @PathVariable String widgetCommentId,
                                    @RequestParam String text,
                                    HttpServletResponse response); @RequestMapping(method = RequestMethod.DELETE, value = "/{widgetId}/comments/{widgetCommentId}") void deleteWidgetComment(@PathVariable String widgetId,
                                    @PathVariable String widgetCommentId,
                                    HttpServletResponse response); @RequestMapping(value = "/{widgetId}/rating", method = RequestMethod.DELETE) void deleteWidgetRating(@PathVariable String widgetId,
                                   HttpServletResponse response); @RequestMapping(value = "/{widgetId}/rating", method = RequestMethod.POST) void setWidgetRating(@PathVariable String widgetId,
                                @RequestParam(value = "score") Integer score,
                                HttpServletResponse response); @ResponseBody @RequestMapping(method = RequestMethod.GET, value = "/{widgetId}/users") List<Person> getAllUsers(@PathVariable String widgetId); @RequestMapping(method = RequestMethod.POST, value = "/{widgetId}/tags") void createWidgetTag(@PathVariable String widgetId,
                                @RequestParam String tagText,
                                HttpServletResponse response); @ResponseBody @RequestMapping(method = RequestMethod.GET, value = "/{widgetId}/tags") List<Tag> getTags(@PathVariable String widgetId, HttpServletResponse response); @ResponseBody @RequestMapping(method = RequestMethod.GET, value = "/tags") List<Tag> getAllTags();  }### Answer:
@Test public void updateWidgetRating() { WidgetRating widgetRating = new WidgetRatingImpl(); widgetRating.setScore(5); widgetRating.setUserId("5"); expect(userService.getAuthenticatedUser()).andReturn(user); widgetService.saveWidgetRating(eq("1"), eq(widgetRating)); expectLastCall(); response.setStatus(HttpStatus.NO_CONTENT.value()); replay(userService, widgetService, response); User user = new UserImpl("2"); widgetApi.setWidgetRating("1", 5, response); verify(widgetService, userService, response); }