### Question:
DefaultCategoryService implements CategoryService { @Override public SearchResult<Category> getLimitedList(int offset, int pageSize) { final int count = categoryRepository.getCountAll(); final List<Category> categories = categoryRepository.getLimitedList(offset, pageSize); final SearchResult<Category> searchResult = new SearchResult<Category>(categories, count); searchResult.setOffset(offset); searchResult.setPageSize(pageSize); return searchResult; } @Autowired  DefaultCategoryService(CategoryRepository categoryRepository); @Override Category get(String id); @Override List<Category> getAllList(); @Override SearchResult<Category> getAll(); @Override SearchResult<Category> getLimitedList(int offset, int pageSize); @Override @Transactional Category create(String text, User createdUser); @Override @Transactional Category update(String categoryId, String text, User lastModifiedUser); @Override @Transactional void delete(Category category);  }### Answer:
@Test public void getLimitedList(){ Category cat1 = new CategoryImpl("2", "Fake Category"); Category cat2 = new CategoryImpl("3", "Another Fake Category"); List<Category> categories = new ArrayList<Category>(); categories.add(cat1); categories.add(cat2); final int pageSize = 10; expect(repository.getCountAll()).andReturn(2); expect(repository.getLimitedList(0, pageSize)).andReturn(categories); replay(repository); SearchResult<Category> result = service.getLimitedList(0, pageSize); assertEquals(pageSize, result.getPageSize()); assertSame(categories, result.getResultSet()); verify(repository); }