### Question:
WidgetApi extends AbstractRestApi { @ResponseBody @RequestMapping(method = RequestMethod.GET, value = "/{widgetId}/tags") public List<Tag> getTags(@PathVariable String widgetId, HttpServletResponse response) { ArrayList<Tag> tags = new ArrayList<Tag>(); Widget widget = widgetService.getWidget(widgetId); if (widget == null) { response.setStatus(404); return null; } for (WidgetTag wt : widget.getTags()) { tags.add(tagService.getTagById(wt.getTagId())); } return tags; } @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 getTags() { WidgetImpl widget = new WidgetImpl(VALID_WIDGET_ID); WidgetTagImpl widgetTag = new WidgetTagImpl(VALID_USER_ID, new Date(), tagList.get(0).getId()); widget.getTags().add(widgetTag); expect(widgetService.getWidget(VALID_WIDGET_ID)).andReturn(widget); replay(widgetService); expect(tagService.getTagById(tagList.get(0).getId())).andReturn(tagList.get(0)); replay(tagService); List<Tag> tags = widgetApi.getTags(VALID_WIDGET_ID, response); assertEquals(tags.size(), 1); verify(tagService); }