### Question:
DefaultPortalPreferenceService implements PortalPreferenceService { @Override public SearchResult<PortalPreference> getLimitedList(int offset, int pageSize) { final int count = repository.getCountAll(); final List<PortalPreference> portalPreferences = repository.getLimitedList(offset, pageSize); final SearchResult<PortalPreference> searchResult = new SearchResult<PortalPreference>(portalPreferences, count); searchResult.setOffset(offset); searchResult.setPageSize(pageSize); return searchResult; } @Autowired  DefaultPortalPreferenceService(PortalPreferenceRepository repository, RaveEventManager manager); @Override Map<String, PortalPreference> getPreferencesAsMap(); @Override PortalPreference getPreference(String key); @Override SearchResult<PortalPreference> getAll(); @Override SearchResult<PortalPreference> getLimitedList(int offset, int pageSize); @Override @Transactional void savePreference(String key, String value); @Override @Transactional void savePreference(String key, List<String> values); @Override @Transactional void savePreference(PortalPreference preference);  }### Answer:
@Test public void getLimitedList() { PortalPreference pp1 = new PortalPreferenceImpl("key1", "value1"); PortalPreference pp2 = new PortalPreferenceImpl("key2", "value1"); List<PortalPreference> portalPreferences = new ArrayList<PortalPreference>(); portalPreferences.add(pp1); portalPreferences.add(pp2); final int pageSize = 10; expect(repository.getCountAll()).andReturn(2); expect(repository.getLimitedList(0, pageSize)).andReturn(portalPreferences); replay(repository); SearchResult<PortalPreference> result = service.getLimitedList(0, pageSize); assertEquals(pageSize, result.getPageSize()); assertSame(portalPreferences, result.getResultSet()); verify(repository); }