### Question:
MongoDbPageRepository implements PageRepository { @Override public int deletePages(String userId, String pageType) { Query query = query(where("pageType").is(pageType).andOperator(where("ownerId").is(userId))); int count = (int)template.count(query); template.remove(query); return count; }  @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 deletePages(){ int resultCount; String userID = "1111L"; expect((int)template.count(isA(Query.class))).andReturn(1); template.remove(isA(Query.class)); expectLastCall(); replay(template); resultCount = repo.deletePages(userID, PageType.USER.toString().toString()); assertThat(resultCount, is(equalTo(1))); verify(template); }