### Question:
MongoDbPageRepository implements PageRepository { @Override public List<Page> getAllPagesForUserType(String userId, String pageType) { return sort(template.find(query(where("pageType").is(getString(pageType)).andOperator(where("members").elemMatch(where("userId").is(userId))))), userId); }  @Override List<Page> getAllPagesForUserType(String userId, String pageType); @Override List<Page> getPagesForContextType(String contextId, String pageType); @Override int deletePages(String userId, String pageType); @Override Page createPageForUser(User user, PageTemplate pt); @Override boolean hasPersonPage(String userId); @Override boolean hasPage(String userId, String pageType); @Override List<PageUser> getPagesForUser(String userId, String pageType); @Override PageUser getSingleRecord(String userId, String pageId); @Override Class<? extends Page> getType(); @Override Page get(String  id); @Override Page save(Page item); @Override void delete(Page item); @Override List<Page> getAll(); @Override List<Page> getLimitedList(int offset, int pageSize); @Override int getCountAll(); MongoPageOperations getTemplate(); void setTemplate(MongoPageOperations template);  }### Answer:
@Test public void getAllPages(){ String userId = "1234L"; String userId1 = "9999L"; PageType pageType = PageType.USER; PageUserImpl user = new PageUserImpl(); user.setId("3333L"); user.setUserId(userId1); PageUserImpl user2 = new PageUserImpl(); user2.setId(userId); user2.setUserId(userId); List<Page> pages = Lists.newArrayList(); List<PageUser> page_users = Lists.newArrayList(); List<PageUser> page2_users = Lists.newArrayList(); page_users.add(user); page2_users.add(user2); Page page = new PageImpl(); page.setMembers(page_users); Page page2 = new PageImpl(); page2.setMembers(page2_users); pages.add(page); pages.add(page2); expect(template.find(isA(Query.class))).andReturn(pages); replay(template); List<Page> result = repo.getAllPagesForUserType(userId, pageType.toString()); assertNotNull(result); }