### Question:
DefaultAuthorityService implements AuthorityService { @Override public SearchResult<Authority> getAllAuthorities() { final int count = repository.getCountAll(); final List<Authority> authorities = repository.getAll(); return new SearchResult<Authority>(authorities, count); } @Autowired  DefaultAuthorityService(AuthorityRepository repository); @Override Authority getAuthorityById(String entityId); @Override Authority getAuthorityByName(String authorityName); @Override SearchResult<Authority> getAllAuthorities(); @Override SearchResult<Authority> getDefaultAuthorities();  }### Answer:
@Test public void allAuthorities() { List<Authority> authorities = new ArrayList<Authority>(); Authority foo = new AuthorityImpl(); foo.setAuthority("FOO"); Authority bar = new AuthorityImpl(); bar.setAuthority("BAR"); authorities.add(foo); authorities.add(bar); expect(repository.getAll()).andReturn(authorities); expect(repository.getCountAll()).andReturn(authorities.size()); replay(repository); SearchResult<Authority> allAuthorities = service.getAllAuthorities(); verify(repository); assertEquals(2, allAuthorities.getTotalResults()); assertEquals(2, allAuthorities.getResultSet().size()); }