### Question:
MongoDbPageLayoutRepository implements PageLayoutRepository { @Override public PageLayout getByPageLayoutCode(String codename) { return template.findOne(new Query(where("code").is(codename)), CLASS, PAGE_LAYOUT_COLLECTION); }  @Override PageLayout getByPageLayoutCode(String codename); @Override List<PageLayout> getAll(); @Override List<PageLayout> getLimitedList(int offset, int limit); @Override int getCountAll(); @Override List<PageLayout> getAllUserSelectable(); @Override Class<? extends PageLayout> getType(); @Override PageLayout get(String id); @Override PageLayout save(PageLayout item); @Override void delete(PageLayout item); void setTemplate(MongoOperations template); static final Class<MongoDbPageLayout> CLASS; }### Answer:
@Test public void getByPageLayoutCode_Valid() { String codename = "codename"; MongoDbPageLayout found = new MongoDbPageLayout(); expect(template.findOne(new Query(where("code").is(codename)), MongoDbPageLayoutRepository.CLASS, CollectionNames.PAGE_LAYOUT_COLLECTION)).andReturn(found); replay(template); assertThat((MongoDbPageLayout) pageLayoutRepository.getByPageLayoutCode(codename), is(sameInstance(found))); }