WorldpayConfiguredFlowsAppender implements WorldpaySupportEmailAppender { @Override public String appendContent() { final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(System.lineSeparator()).append("Active Payment Flow:").append(System.lineSeparator()); final Collection<CMSSiteModel> sites = cmsSiteService.getSites(); for (final CMSSiteModel site : sites) { final String siteName = site.getName(); stringBuilder.append(ONE_TAB).append(siteName).append(System.lineSeparator()); final List<CatalogVersionModel> contentCatalogModels = filterOnlineContentCatalogs(site); for (final CatalogVersionModel contentCatalogModel : contentCatalogModels) { final String contentCatalogName = contentCatalogModel.getCatalog().getName(); stringBuilder.append(TWO_TABS).append(contentCatalogName).append(System.lineSeparator()); final Collection<ContentPageModel> allPagesByLabel = cmsPageDao.findPagesByLabel(PAYMENT_AND_BILLING_LABEL, singletonList(contentCatalogModel)); for (final AbstractPageModel pageModel : allPagesByLabel) { final String pageUid = pageModel.getUid(); stringBuilder.append(THREE_TABS).append("PageId: ").append(pageUid).append(System.lineSeparator()); final String template = pageModel.getMasterTemplate().getUid(); stringBuilder.append(FOUR_TABS).append("Template: ").append(template).append(System.lineSeparator()); } } } return stringBuilder.toString(); }  @Override String appendContent(); @Required void setCmsSiteService(CMSSiteService cmsSiteService); @Required void setCmsPageDao(CMSPageDao cmsPageDao); static final String ONLINE_FLAG; }
@Test public void testAppendContent() throws Exception { when(cmsSiteServiceMock.getSites()).thenReturn(asList(cmsSite1Mock, cmsSite2Mock)); when(cmsSite1Mock.getName()).thenReturn(SITE_NAME); when(cmsSite2Mock.getName()).thenReturn(SITE_NAME); when(cmsSite1Mock.getContentCatalogs()).thenReturn(asList(contentCatalogOnlineMock, contentCatalogStagedMock)); when(cmsSite2Mock.getContentCatalogs()).thenReturn(singletonList(contentCatalogOnlineMock)); when(contentCatalogOnlineMock.getVersion()).thenReturn(ONLINE); when(contentCatalogStagedMock.getVersion()).thenReturn(STAGED); when(contentCatalogOnlineMock.getActiveCatalogVersion()).thenReturn(contentCatalogVersionMock); when(contentCatalogVersionMock.getCatalog().getName()).thenReturn(CATALOG_NAME); final Collection<ContentPageModel> allPaymentPages = asList(cmsPageDesktopMock, cmsPageMobileMock); when(cmsPageDao.findPagesByLabel(PAYMENT_AND_BILLING_LABEL, singletonList(contentCatalogVersionMock))).thenReturn(allPaymentPages); when(cmsPageDesktopMock.getMasterTemplate().getUid()).thenReturn(ACTIVE_PAGE_TEMPLATE); when(cmsPageMobileMock.getMasterTemplate().getUid()).thenReturn(ACTIVE_PAGE_TEMPLATE); final String result = testObj.appendContent(); assertTrue(result.contains("Active Payment Flow:")); assertEquals(2, StringUtils.countMatches(result, SITE_NAME)); assertEquals(2, StringUtils.countMatches(result, CATALOG_NAME)); assertEquals(4, StringUtils.countMatches(result, ACTIVE_PAGE_TEMPLATE)); }