### Question:
DefaultWidgetService implements WidgetService { @Override public SearchResult<Widget> getLimitedList(int offset, int pageSize) { final int count = widgetRepository.getCountAll(); final List<Widget> widgets = widgetRepository.getLimitedList(offset, pageSize); final SearchResult<Widget> searchResult = new SearchResult<Widget>(widgets, count); searchResult.setOffset(offset); searchResult.setPageSize(pageSize); return searchResult; } @Autowired  DefaultWidgetService(WidgetRepository widgetRepository, UserRepository userRepository, CategoryRepository categoryRepository); @Override SearchResult<Widget> getAll(); @Override SearchResult<Widget> getLimitedList(int offset, int pageSize); @Override SearchResult<Widget> getWidgetsByFreeTextSearch(String searchTerm,
                                                           int offset, int pageSize); @Override Widget getWidget(String id); @Override SearchResult<Widget> getPublishedWidgets(int offset, int pageSize); @Override SearchResult<Widget> getPublishedWidgetsByFreeTextSearch(String searchTerm,
                                                                    int offset, int pageSize); @Override SearchResult<Widget> getWidgetsBySearchCriteria(String searchTerm, String widgetType, String widgetStatus,
                                                           int offset, int pageSize); @Override SearchResult<Widget> getWidgetsByOwner(String ownerId, int offset, int pageSize); @Override Widget getWidgetByUrl(String widgetUrl); @Override boolean isRegisteredUrl(String widgetUrl); @Override @Transactional Widget registerNewWidget(Widget widget); @Override WidgetStatistics getWidgetStatistics(String widgetId, String userId); @Override Map<String, WidgetStatistics> getAllWidgetStatistics(String userId); @Override @Transactional void updateWidget(Widget widget); @Override SearchResult<Widget> getWidgetsByTag(String tagKeyWord, int offset, int pageSize); @Override SearchResult<Widget> getWidgetsByCategory(String categoryId, int offset, int pageSize); @Override WidgetTag getWidgetTag(String id); @Override @Transactional WidgetTag createWidgetTag(String widgetId, WidgetTag widgetTag); @Override WidgetTag getWidgetTagByWidgetIdAndKeyword(String widgetId, String keyword); @Override WidgetComment getWidgetComment(String widgetId, String commentId); @Override @Transactional void createWidgetComment(String widgetId, WidgetComment widgetComment); @Override @Transactional void updateWidgetComment(String widgetId, WidgetComment widgetComment); @Override @Transactional void removeWidgetComment(String widgetId, String commentId); @Override @Transactional int deleteAllWidgetComments(String userId); @Override WidgetRating getWidgetRatingByWidgetIdAndUserId(String widgetId, String userId); @Override @Transactional void updateWidgetRatingScore(String widgetId, WidgetRating widgetRating, Integer score); @Override @Transactional void saveWidgetRating(String widgetId, WidgetRating rating); @Override @Transactional void removeWidgetRating(String widgetId, String userId); @Override @Transactional int removeAllWidgetRatings(String userId);  }### Answer:
@Test public void getLimitedList() { Widget widget1 = new WidgetImpl("2", "http: Widget widget2 = new WidgetImpl("3", "http: List<Widget> widgets = new ArrayList<Widget>(); widgets.add(widget1); widgets.add(widget2); final int pageSize = 10; expect(widgetRepository.getCountAll()).andReturn(2); expect(widgetRepository.getLimitedList(0, pageSize)).andReturn(widgets); replay(widgetRepository); SearchResult<Widget> result = widgetService.getLimitedList(0, pageSize); assertEquals(pageSize, result.getPageSize()); assertSame(widgets, result.getResultSet()); verify(widgetRepository); }