@Test public void shouldMergeTemplateIntoStringThrowExceptionOnNullTemplateReference() throws Exception { final Map<String, Object> modelObject = new ImmutableMap.Builder<String, Object>().build(); assertions.assertThat(modelObject).isNotNull(); expectedException.expect(NullPointerException.class); templateService.mergeTemplateIntoString(null, modelObject); fail("NullPointerException expected"); }
@Override public @NonNull String mergeTemplateIntoString(final @NonNull String templateReference, final @NonNull Map<String, Object> model) throws IOException, TemplateException { final String trimmedTemplateReference = templateReference.trim(); checkArgument(!isNullOrEmpty(trimmedTemplateReference), "The given template is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getNormalizedFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Thymeleaf template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.thymeleaf.suffix' in your application.properties file", expectedTemplateExtension(), getNormalizedFileExtension(trimmedTemplateReference)); final Context context = new Context(); context.setVariables(model); return thymeleafEngine.process(FilenameUtils.removeExtension(trimmedTemplateReference), context); }
ThymeleafTemplateService implements TemplateService { @Override public @NonNull String mergeTemplateIntoString(final @NonNull String templateReference, final @NonNull Map<String, Object> model) throws IOException, TemplateException { final String trimmedTemplateReference = templateReference.trim(); checkArgument(!isNullOrEmpty(trimmedTemplateReference), "The given template is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getNormalizedFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Thymeleaf template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.thymeleaf.suffix' in your application.properties file", expectedTemplateExtension(), getNormalizedFileExtension(trimmedTemplateReference)); final Context context = new Context(); context.setVariables(model); return thymeleafEngine.process(FilenameUtils.removeExtension(trimmedTemplateReference), context); } }
ThymeleafTemplateService implements TemplateService { @Override public @NonNull String mergeTemplateIntoString(final @NonNull String templateReference, final @NonNull Map<String, Object> model) throws IOException, TemplateException { final String trimmedTemplateReference = templateReference.trim(); checkArgument(!isNullOrEmpty(trimmedTemplateReference), "The given template is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getNormalizedFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Thymeleaf template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.thymeleaf.suffix' in your application.properties file", expectedTemplateExtension(), getNormalizedFileExtension(trimmedTemplateReference)); final Context context = new Context(); context.setVariables(model); return thymeleafEngine.process(FilenameUtils.removeExtension(trimmedTemplateReference), context); }  }
ThymeleafTemplateService implements TemplateService { @Override public @NonNull String mergeTemplateIntoString(final @NonNull String templateReference, final @NonNull Map<String, Object> model) throws IOException, TemplateException { final String trimmedTemplateReference = templateReference.trim(); checkArgument(!isNullOrEmpty(trimmedTemplateReference), "The given template is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getNormalizedFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Thymeleaf template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.thymeleaf.suffix' in your application.properties file", expectedTemplateExtension(), getNormalizedFileExtension(trimmedTemplateReference)); final Context context = new Context(); context.setVariables(model); return thymeleafEngine.process(FilenameUtils.removeExtension(trimmedTemplateReference), context); }  @Override @NonNull String mergeTemplateIntoString(final @NonNull String templateReference,
                                   final @NonNull Map<String, Object> model); @Override String expectedTemplateExtension(); }
ThymeleafTemplateService implements TemplateService { @Override public @NonNull String mergeTemplateIntoString(final @NonNull String templateReference, final @NonNull Map<String, Object> model) throws IOException, TemplateException { final String trimmedTemplateReference = templateReference.trim(); checkArgument(!isNullOrEmpty(trimmedTemplateReference), "The given template is null, empty or blank"); if (trimmedTemplateReference.contains(".")) checkArgument(Objects.equals(getNormalizedFileExtension(trimmedTemplateReference), expectedTemplateExtension()), "Expected a Thymeleaf template file with extension '%s', while '%s' was given. To check " + "the default extension look at 'spring.thymeleaf.suffix' in your application.properties file", expectedTemplateExtension(), getNormalizedFileExtension(trimmedTemplateReference)); final Context context = new Context(); context.setVariables(model); return thymeleafEngine.process(FilenameUtils.removeExtension(trimmedTemplateReference), context); }  @Override @NonNull String mergeTemplateIntoString(final @NonNull String templateReference,
                                   final @NonNull Map<String, Object> model); @Override String expectedTemplateExtension();  }