@Test public void generateEmailBody_test() { final String email = "user_email"; final String header = "header"; final String baseUrl = "base_url"; final String title = "title"; final String footer = "footer"; final long fileId = 1234; final String token = "token"; final String version = "1.0"; final String note = "<br/>" + fileId + "&version=" + version + "&acm_email_ticket=" + token + "<br/>"; List<String> addresses = new ArrayList<>(); addresses.add(email); List<Long> fileIds = new ArrayList<>(); fileIds.add(fileId); EmailWithEmbeddedLinksDTO inputDTO = new EmailWithEmbeddedLinksDTO(); inputDTO.setTitle(title); inputDTO.setHeader(header); inputDTO.setEmailAddresses(addresses); inputDTO.setBaseUrl(baseUrl); inputDTO.setFileIds(fileIds); inputDTO.setFooter(footer); EcmFile ecmFile = new EcmFile(); ecmFile.setActiveVersionTag(version); when(mockAuthenticationTokenService.generateAndSaveAuthenticationToken(fileId, email, mockAuthentication)) .thenReturn(token); when(mockEcmFileDao.find(Mockito.anyLong())).thenReturn(ecmFile); AuthenticationToken authenticationToken = new AuthenticationToken(); authenticationToken.setKey(token); authenticationToken.setStatus(AuthenticationTokenConstants.ACTIVE); authenticationToken.setEmail(email); authenticationToken.setFileId(fileId); String emailContent = acmEmailContentGeneratorService.generateEmailBody(inputDTO, email, mockAuthentication); assertNotNull(emailContent); assertTrue(emailContent.contains(note)); assertTrue(emailContent.contains(header)); assertTrue(emailContent.contains(footer)); }
public String generateEmailBody(EmailWithEmbeddedLinksDTO emailDTO, String emailAddress, Authentication authentication) { emailDTO.setTemplatingEngine(getTemplatingEngine()); StringBuilder body = new StringBuilder(); body.append(emailDTO.getBody() != null ? emailDTO.getBody() : "").append("<br/>"); if (emailDTO.getFileIds() != null) { for (Long fileId : emailDTO.getFileIds()) { EcmFile ecmFile = getEcmFileDao().find(fileId); String token = authenticationTokenService.generateAndSaveAuthenticationToken(fileId, emailAddress, authentication); body.append(fileId).append("&version=").append(ecmFile.getActiveVersionTag()).append("&acm_email_ticket=").append(token).append("<br/>"); emailDTO.getTokens().add(token); emailDTO.setFileVersion(ecmFile.getActiveVersionTag()); } } return emailDTO.buildMessageBodyFromTemplate(body.toString()); }
AcmEmailContentGeneratorService { public String generateEmailBody(EmailWithEmbeddedLinksDTO emailDTO, String emailAddress, Authentication authentication) { emailDTO.setTemplatingEngine(getTemplatingEngine()); StringBuilder body = new StringBuilder(); body.append(emailDTO.getBody() != null ? emailDTO.getBody() : "").append("<br/>"); if (emailDTO.getFileIds() != null) { for (Long fileId : emailDTO.getFileIds()) { EcmFile ecmFile = getEcmFileDao().find(fileId); String token = authenticationTokenService.generateAndSaveAuthenticationToken(fileId, emailAddress, authentication); body.append(fileId).append("&version=").append(ecmFile.getActiveVersionTag()).append("&acm_email_ticket=").append(token).append("<br/>"); emailDTO.getTokens().add(token); emailDTO.setFileVersion(ecmFile.getActiveVersionTag()); } } return emailDTO.buildMessageBodyFromTemplate(body.toString()); } }
AcmEmailContentGeneratorService { public String generateEmailBody(EmailWithEmbeddedLinksDTO emailDTO, String emailAddress, Authentication authentication) { emailDTO.setTemplatingEngine(getTemplatingEngine()); StringBuilder body = new StringBuilder(); body.append(emailDTO.getBody() != null ? emailDTO.getBody() : "").append("<br/>"); if (emailDTO.getFileIds() != null) { for (Long fileId : emailDTO.getFileIds()) { EcmFile ecmFile = getEcmFileDao().find(fileId); String token = authenticationTokenService.generateAndSaveAuthenticationToken(fileId, emailAddress, authentication); body.append(fileId).append("&version=").append(ecmFile.getActiveVersionTag()).append("&acm_email_ticket=").append(token).append("<br/>"); emailDTO.getTokens().add(token); emailDTO.setFileVersion(ecmFile.getActiveVersionTag()); } } return emailDTO.buildMessageBodyFromTemplate(body.toString()); }  }
AcmEmailContentGeneratorService { public String generateEmailBody(EmailWithEmbeddedLinksDTO emailDTO, String emailAddress, Authentication authentication) { emailDTO.setTemplatingEngine(getTemplatingEngine()); StringBuilder body = new StringBuilder(); body.append(emailDTO.getBody() != null ? emailDTO.getBody() : "").append("<br/>"); if (emailDTO.getFileIds() != null) { for (Long fileId : emailDTO.getFileIds()) { EcmFile ecmFile = getEcmFileDao().find(fileId); String token = authenticationTokenService.generateAndSaveAuthenticationToken(fileId, emailAddress, authentication); body.append(fileId).append("&version=").append(ecmFile.getActiveVersionTag()).append("&acm_email_ticket=").append(token).append("<br/>"); emailDTO.getTokens().add(token); emailDTO.setFileVersion(ecmFile.getActiveVersionTag()); } } return emailDTO.buildMessageBodyFromTemplate(body.toString()); }  String generateEmailBody(EmailWithEmbeddedLinksDTO emailDTO, String emailAddress, Authentication authentication); AuthenticationTokenService getAuthenticationTokenService(); void setAuthenticationTokenService(AuthenticationTokenService authenticationTokenService); AuthenticationTokenDao getAuthenticationTokenDao(); void setAuthenticationTokenDao(AuthenticationTokenDao authenticationTokenDao); TemplatingEngine getTemplatingEngine(); void setTemplatingEngine(TemplatingEngine templatingEngine); EcmFileDao getEcmFileDao(); void setEcmFileDao(EcmFileDao ecmFileDao); }
AcmEmailContentGeneratorService { public String generateEmailBody(EmailWithEmbeddedLinksDTO emailDTO, String emailAddress, Authentication authentication) { emailDTO.setTemplatingEngine(getTemplatingEngine()); StringBuilder body = new StringBuilder(); body.append(emailDTO.getBody() != null ? emailDTO.getBody() : "").append("<br/>"); if (emailDTO.getFileIds() != null) { for (Long fileId : emailDTO.getFileIds()) { EcmFile ecmFile = getEcmFileDao().find(fileId); String token = authenticationTokenService.generateAndSaveAuthenticationToken(fileId, emailAddress, authentication); body.append(fileId).append("&version=").append(ecmFile.getActiveVersionTag()).append("&acm_email_ticket=").append(token).append("<br/>"); emailDTO.getTokens().add(token); emailDTO.setFileVersion(ecmFile.getActiveVersionTag()); } } return emailDTO.buildMessageBodyFromTemplate(body.toString()); }  String generateEmailBody(EmailWithEmbeddedLinksDTO emailDTO, String emailAddress, Authentication authentication); AuthenticationTokenService getAuthenticationTokenService(); void setAuthenticationTokenService(AuthenticationTokenService authenticationTokenService); AuthenticationTokenDao getAuthenticationTokenDao(); void setAuthenticationTokenDao(AuthenticationTokenDao authenticationTokenDao); TemplatingEngine getTemplatingEngine(); void setTemplatingEngine(TemplatingEngine templatingEngine); EcmFileDao getEcmFileDao(); void setEcmFileDao(EcmFileDao ecmFileDao);  }