PortalImpl implements Portal { @Override public boolean removePage(PageId pageId) { Parameters.requireNonNull(pageId, "pageId"); try { return pageService.destroyPage(Util.from(pageId)); } catch (PageServiceException e) { if (e.getError() == PageError.NO_SITE) { throw new EntityNotFoundException("Cannot remove page '" + pageId.getPageName() + "'. Site " + pageId.getSiteId() + " does not exist."); } else { throw new ApiException("Failed to remove page " + pageId, e); } } catch (Throwable t) { throw new ApiException("Failed to remove page " + pageId, t); } } PortalImpl(DataStorage dataStorage, PageService pageService, NavigationService navigationService,
                      DescriptionService descriptionService, ResourceBundleManager bundleManager, Authenticator authenticator,
                      IdentityRegistry identityRegistry, UserACL acl, UserPortalConfigService userPortalConfigService,
                      OAuthProviderAccessor oauthProviderAccessor); @Override Site getSite(SiteId siteId); @Override Site createSite(SiteId siteId); @Override Site createSite(SiteId siteId, String templateName); @Override List<Site> findSites(SiteQuery query); @Override void saveSite(Site site); @Override boolean removeSite(SiteId siteId); @Override Navigation getNavigation(SiteId siteId); @Override PageBuilder newPageBuilder(); @Override ApplicationRegistry getApplicationRegistry(); @Override Page getPage(PageId pageId); List<ContainerItem> getPageRootContainer(PageContext pageContext); @Override Page createPage(PageId pageId); @Override List<Page> findPages(PageQuery query); @Override void savePage(Page page); @Override boolean removePage(PageId pageId); @Override boolean hasPermission(User user, Permission permission); @Override OAuthProvider getOAuthProvider(String oauthProviderKey);  }
@Test public void removePage() { createSite(new SiteId("removePage"), "page1", "page2"); assertNotNull(portal.getPage(new PageId("removePage", "page1"))); assertNotNull(portal.getPage(new PageId("removePage", "page2"))); assertTrue(portal.removePage(new PageId("removePage", "page1"))); assertNull(portal.getPage(new PageId("removePage", "page1"))); assertNotNull(portal.getPage(new PageId("removePage", "page2"))); assertTrue(portal.removePage(new PageId("removePage", "page2"))); assertNull(portal.getPage(new PageId("removePage", "page1"))); assertNull(portal.getPage(new PageId("removePage", "page2"))); }
@Test(expected = IllegalArgumentException.class) public void removePage_NullSiteId() { portal.removePage(null); }