@Test public void testIllegalStateException() throws RenderingEngineMissingException { ThymeleafInlineContentItemsResolver resolver = new ThymeleafInlineContentItemsResolver(); ArticleItem articleItem = new ArticleItem(); articleItem.setTitle("Test"); TemplateEngineModel templateEngineModel = new TemplateEngineModel(); templateEngineModel.setInlineContentItem(articleItem); Assert.assertFalse(resolver.supports(templateEngineModel)); try { resolver.resolve(templateEngineModel); Assert.fail("Expected IllegalStateException"); } catch (IllegalStateException e) { Assert.assertEquals("Engine not configured. Did you call setViewResolverConfiguration()?", e.getMessage()); } }
protected boolean supports(TemplateEngineModel data) { if (!configured) { return false; } String contentType = getContentTypeFromModel(data.getInlineContentItem()); if (contentType == null) { return false; } Set<ITemplateResolver> templateResolvers = templateEngine.getTemplateResolvers(); for (ITemplateResolver resolver : templateResolvers) { if (resolver instanceof AbstractTemplateResolver) { TemplateResolution templateResolution = resolver.resolveTemplate(templateEngine.getConfiguration(), null, contentType, null); if (templateResolution != null && templateResolution.getTemplateResource().exists()) { return true; } } } return false; }
ThymeleafTemplateEngine implements TemplateEngine { protected boolean supports(TemplateEngineModel data) { if (!configured) { return false; } String contentType = getContentTypeFromModel(data.getInlineContentItem()); if (contentType == null) { return false; } Set<ITemplateResolver> templateResolvers = templateEngine.getTemplateResolvers(); for (ITemplateResolver resolver : templateResolvers) { if (resolver instanceof AbstractTemplateResolver) { TemplateResolution templateResolution = resolver.resolveTemplate(templateEngine.getConfiguration(), null, contentType, null); if (templateResolution != null && templateResolution.getTemplateResource().exists()) { return true; } } } return false; } }
ThymeleafTemplateEngine implements TemplateEngine { protected boolean supports(TemplateEngineModel data) { if (!configured) { return false; } String contentType = getContentTypeFromModel(data.getInlineContentItem()); if (contentType == null) { return false; } Set<ITemplateResolver> templateResolvers = templateEngine.getTemplateResolvers(); for (ITemplateResolver resolver : templateResolvers) { if (resolver instanceof AbstractTemplateResolver) { TemplateResolution templateResolution = resolver.resolveTemplate(templateEngine.getConfiguration(), null, contentType, null); if (templateResolution != null && templateResolution.getTemplateResource().exists()) { return true; } } } return false; }  }
ThymeleafTemplateEngine implements TemplateEngine { protected boolean supports(TemplateEngineModel data) { if (!configured) { return false; } String contentType = getContentTypeFromModel(data.getInlineContentItem()); if (contentType == null) { return false; } Set<ITemplateResolver> templateResolvers = templateEngine.getTemplateResolvers(); for (ITemplateResolver resolver : templateResolvers) { if (resolver instanceof AbstractTemplateResolver) { TemplateResolution templateResolution = resolver.resolveTemplate(templateEngine.getConfiguration(), null, contentType, null); if (templateResolution != null && templateResolution.getTemplateResource().exists()) { return true; } } } return false; }  @Override void setViewResolverConfiguration(ViewResolverConfiguration viewResolverConfiguration); @Override String process(TemplateEngineModel data); }
ThymeleafTemplateEngine implements TemplateEngine { protected boolean supports(TemplateEngineModel data) { if (!configured) { return false; } String contentType = getContentTypeFromModel(data.getInlineContentItem()); if (contentType == null) { return false; } Set<ITemplateResolver> templateResolvers = templateEngine.getTemplateResolvers(); for (ITemplateResolver resolver : templateResolvers) { if (resolver instanceof AbstractTemplateResolver) { TemplateResolution templateResolution = resolver.resolveTemplate(templateEngine.getConfiguration(), null, contentType, null); if (templateResolution != null && templateResolution.getTemplateResource().exists()) { return true; } } } return false; }  @Override void setViewResolverConfiguration(ViewResolverConfiguration viewResolverConfiguration); @Override String process(TemplateEngineModel data);  }