### Question:
MongoDbPageRepository implements PageRepository { @Override public boolean hasPersonPage(String userId) { return template.count(query(where("pageType").is(PageType.PERSON_PROFILE.toString().toUpperCase()).andOperator(where("ownerId").is(userId)))) > 0; }  @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 hasPersonPage_true(){ String userId = "1234L"; User user = new UserImpl(userId); Page page = new PageImpl(); page.setPageType(PageType.PERSON_PROFILE.toString()); page.setOwnerId(userId); expect(template.count(query(where("pageType").is("PERSON_PROFILE").andOperator(where("ownerId").is(userId))))).andReturn(1L); replay(template); boolean result = repo.hasPersonPage(userId); assertTrue(result); }
@Test public void hasPersonPage_false(){ String userId = "1234L"; expect(template.count(query(where("pageType").is("PERSON_PROFILE").andOperator(where("ownerId").is(userId))))).andReturn(0L); replay(template); boolean result = repo.hasPersonPage(userId); assertFalse(result); }