### Question:
MongoDbAuthorityRepository implements AuthorityRepository { @Override public Authority getByAuthority(String authorityName) { return template.findOne(query(where("authority").is(authorityName)), CLASS, AUTHORITY_COLLECTION); }  @Override Authority getByAuthority(String authorityName); @Override List<Authority> getAll(); @Override List<Authority> getLimitedList(int offset, int limit); @Override List<Authority> getAllDefault(); @Override int getCountAll(); @Override Class<? extends Authority> getType(); @Override Authority get(String id); @Override Authority save(Authority item); @Override void delete(Authority item); void setTemplate(MongoOperations template); void setConverter(HydratingConverterFactory converter); MongoOperations getTemplate(); HydratingConverterFactory getConverter(); static final Class<MongoDbAuthority> CLASS; }### Answer:
@Test public void getByAuthority(){ Authority authority = new MongoDbAuthority(); authority.setAuthority("test"); Authority result; template.save(authority, AUTHORITY_COLLECTION); expect(template.findOne(query(where("authority").is("test")), CLASS, AUTHORITY_COLLECTION)).andReturn((MongoDbAuthority)authority); replay(template); result = repo.getByAuthority("test"); assertThat(result, is(sameInstance(authority))); }