### Question:
DefaultAuthorityService implements AuthorityService { @Override public Authority getAuthorityByName(String authorityName) { return repository.getByAuthority(authorityName); } @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 getAuthorityByName() { Authority authority = createAuthority(); expect(repository.getByAuthority("FOO")).andReturn(authority); replay(repository); Authority sAuthority = service.getAuthorityByName("FOO"); assertEquals(sAuthority, authority); verify(repository); }