@Test public void shouldParseAdvancedTemplate() throws Exception { TemplateReader templateReader = new TemplateReader(); Object[] arguments = {"j.kowalski", "j.kowalski@example.org", "Kowalski Enterprises", "k-enterprises"}; TemplateContentData templateContent = templateReader.getContentData("advanced.etemplate", arguments); assertThat(templateContent).isNotNull(); assertThat(templateContent.getSubject()).isEqualTo("Welcome to Company!"); assertThat(templateContent.getContent()).contains("Welcome "+arguments[0]); assertThat(templateContent.getContent()).contains("your organization: "+arguments[2]); assertThat(templateContent.getContent()).contains("http: assertThat(templateContent.getContent()).contains("Username: "+arguments[0]); assertThat(templateContent.getContent()).contains("Email: "+arguments[1]); }
public TemplateContentData getContentData(String templateName, Object[] arguments) { TemplateContentData templateContentData = getContentDataFromTemplate(templateName); if (arguments != null && arguments.length > 0) { templateContentData.setContent(MessageFormat.format(templateContentData.getContent(), arguments)); } return templateContentData; }
TemplateReader { public TemplateContentData getContentData(String templateName, Object[] arguments) { TemplateContentData templateContentData = getContentDataFromTemplate(templateName); if (arguments != null && arguments.length > 0) { templateContentData.setContent(MessageFormat.format(templateContentData.getContent(), arguments)); } return templateContentData; } }
TemplateReader { public TemplateContentData getContentData(String templateName, Object[] arguments) { TemplateContentData templateContentData = getContentDataFromTemplate(templateName); if (arguments != null && arguments.length > 0) { templateContentData.setContent(MessageFormat.format(templateContentData.getContent(), arguments)); } return templateContentData; }  }
TemplateReader { public TemplateContentData getContentData(String templateName, Object[] arguments) { TemplateContentData templateContentData = getContentDataFromTemplate(templateName); if (arguments != null && arguments.length > 0) { templateContentData.setContent(MessageFormat.format(templateContentData.getContent(), arguments)); } return templateContentData; }  TemplateContentData getContentData(String templateName, Object[] arguments); }
TemplateReader { public TemplateContentData getContentData(String templateName, Object[] arguments) { TemplateContentData templateContentData = getContentDataFromTemplate(templateName); if (arguments != null && arguments.length > 0) { templateContentData.setContent(MessageFormat.format(templateContentData.getContent(), arguments)); } return templateContentData; }  TemplateContentData getContentData(String templateName, Object[] arguments); static final String KEY_SUBJECT; }