### Question:
PageApi extends AbstractRestApi { @ResponseBody @RequestMapping(value = "{pageId}", method = RequestMethod.GET) public Page getPage(@PathVariable String pageId, @RequestParam(required=false) boolean export) { logger.debug("GET received for /api/rest/page/" + pageId); Page page = pageService.getPage(pageId); if(export) { modifyForExport(page); } return page; } @Autowired  PageApi(PageService pageService, OmdlService omdlService); @RequestMapping(value = "{pageId}", method = RequestMethod.DELETE) void deletePage(@PathVariable String pageId, HttpServletResponse response); @ResponseBody @RequestMapping(value = "{pageId}/omdl", method = RequestMethod.GET) OmdlOutputAdapter getOmdl(@PathVariable String pageId, HttpServletRequest request, HttpServletResponse response); @ResponseBody @RequestMapping(value = "{pageId}", method = RequestMethod.GET) Page getPage(@PathVariable String pageId, @RequestParam(required=false) boolean export);  }### Answer:
@Test public void getPage_validId() { Page p = new PageImpl(); expect(pageService.getPage(PAGE_ID)).andReturn(p).once(); replay(pageService); Page returned = pageApi.getPage(PAGE_ID, false); assertThat(returned, is(sameInstance(p))); }
@Test public void getPage_validId_export() { Page p = new PageImpl(); p.setRegions(new ArrayList<Region>()); p.setOwnerId(""); Region region = new RegionImpl(); region.setRegionWidgets(new ArrayList<RegionWidget>()); RegionWidget w = new RegionWidgetImpl(); w.setPreferences(new ArrayList<RegionWidgetPreference>()); w.getPreferences().add(new RegionWidgetPreferenceImpl()); region.getRegionWidgets().add(w); p.getRegions().add(region); expect(pageService.getPage(PAGE_ID)).andReturn(p).once(); replay(pageService); Page returned = pageApi.getPage(PAGE_ID, true); assertThat(returned, is(sameInstance(p))); assertThat(returned.getOwnerId(), is(nullValue())); assertThat(returned.getRegions().get(0).getRegionWidgets().get(0).getPreferences(), is(nullValue())); }