### Question:
MongoDbPageRepository implements PageRepository { @Override public Page createPageForUser(User user, PageTemplate pt) { return save(convertTemplate(pt, user)); }  @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 createPageForUser(){ Page result = new PageImpl(); String userId = "2424L"; User user = new UserImpl(userId); PageTemplate pt = new PageTemplateImpl(); PageLayout layout = new PageLayoutImpl(); List<PageTemplateRegion> regions = Lists.newArrayList(); List<PageTemplateRegion> subRegions = Lists.newArrayList(); List<PageTemplateWidget> widgets = Lists.newArrayList(); List<PageTemplate> subPageTemplates = Lists.newArrayList(); PageTemplate sub = new PageTemplateImpl(); sub.setName("sub"); PageTemplateRegion subRegion = new PageTemplateRegionImpl(); subRegion.setRenderSequence(5555L); subRegion.setLocked(true); subRegion.setPageTemplateWidgets(widgets); subRegions.add(subRegion); sub.setPageTemplateRegions(subRegions); sub.setName("sub"); sub.setPageType(PageType.SUB_PAGE.toString()); sub.setPageLayout(layout); sub.setPageTemplateRegions(subRegions); sub.setRenderSequence(2000L); PageTemplateWidget widget = new PageTemplateWidgetImpl(); Widget w = new WidgetImpl("1234"); widget.setLocked(true); widget.setHideChrome(true); widget.setRenderSeq(2000L); widget.setWidgetId(w.getId()); widgets.add(widget); PageTemplateRegion region = new PageTemplateRegionImpl(); region.setRenderSequence(1111L); region.setPageTemplateWidgets(widgets); region.setLocked(true); regions.add(region); pt.setName("carol"); pt.setPageType(PageType.USER.toString()); pt.setPageLayout(layout); subPageTemplates.add(sub); pt.setSubPageTemplates(subPageTemplates); pt.setPageTemplateRegions(regions); pt.setRenderSequence(2000L); expect(template.save(isA(Page.class))).andReturn(result); replay(template); result = repo.createPageForUser(user, pt); assertNotNull(result); }