DefaultThymeleafV3EmailConfigurer.java

1
package fr.sii.ogham.template.thymeleaf.v3.configure;
2
3
import static fr.sii.ogham.template.thymeleaf.common.ThymeleafConstants.DEFAULT_THYMELEAF_EMAIL_CONFIGURER_PRIORITY;
4
5
import org.slf4j.Logger;
6
import org.slf4j.LoggerFactory;
7
8
import fr.sii.ogham.core.builder.MessagingBuilder;
9
import fr.sii.ogham.core.builder.configurer.ConfigurerFor;
10
import fr.sii.ogham.core.builder.configurer.DefaultMessagingConfigurer;
11
import fr.sii.ogham.core.builder.configurer.MessagingConfigurerAdapter;
12
import fr.sii.ogham.core.builder.context.BuildContext;
13
import fr.sii.ogham.core.builder.resolution.ResourceResolutionBuilder;
14
import fr.sii.ogham.core.util.ClasspathUtils;
15
import fr.sii.ogham.template.thymeleaf.common.buider.AbstractThymeleafMultiContentBuilder;
16
import fr.sii.ogham.template.thymeleaf.common.configure.AbstractDefaultThymeleafEmailConfigurer;
17
import fr.sii.ogham.template.thymeleaf.v3.ThymeleafV3TemplateDetector;
18
import fr.sii.ogham.template.thymeleaf.v3.buider.ThymeleafV3EmailBuilder;
19
20
/**
21
 * Default configurer for Thymeleaf template engine that is automatically
22
 * applied every time a {@link MessagingBuilder} instance is created through
23
 * {@link MessagingBuilder#standard()} or {@link MessagingBuilder#minimal()}.
24
 * 
25
 * <p>
26
 * The configurer has a priority of 90000 in order to be applied after global
27
 * configurer but before any sender implementation.
28
 * </p>
29
 * 
30
 * This configurer is applied only if {@code org.thymeleaf.TemplateEngine} is
31
 * present in the classpath. If not present, template engine is not registered
32
 * at all.
33
 * 
34
 * <p>
35
 * This configurer inherits environment configuration (see
36
 * {@link BuildContext}).
37
 * </p>
38
 * <p>
39
 * It also copies resource resolution configuration of
40
 * {@link DefaultMessagingConfigurer} to inherit resource resolution lookups
41
 * (see {@link ResourceResolutionBuilder}).
42
 * </p>
43
 * 
44
 * <p>
45
 * This configurer applies the following configuration:
46
 * <ul>
47
 * <li>Configures template prefix/suffix paths:
48
 * <ul>
49
 * <li>Uses the first property that has a value for classpath resolution prefix:
50
 * <ol>
51
 * <li>"ogham.email.thymeleaf.classpath.path-prefix"</li>
52
 * <li>"ogham.email.template.classpath.path-prefix"</li>
53
 * <li>"ogham.email.thymeleaf.path-prefix"</li>
54
 * <li>"ogham.email.template.path-prefix"</li>
55
 * <li>"ogham.template.path-prefix"</li>
56
 * </ol>
57
 * </li>
58
 * <li>Uses the first property that has a value for classpath resolution suffix:
59
 * <ol>
60
 * <li>"ogham.email.thymeleaf.classpath.path-suffix"</li>
61
 * <li>"ogham.email.template.classpath.path-suffix"</li>
62
 * <li>"ogham.email.thymeleaf.path-suffix"</li>
63
 * <li>"ogham.email.template.path-suffix"</li>
64
 * <li>"ogham.template.path-suffix"</li>
65
 * </ol>
66
 * </li>
67
 * <li>Uses the first property that has a value for file resolution prefix:
68
 * <ol>
69
 * <li>"ogham.email.thymeleaf.file.path-prefix"</li>
70
 * <li>"ogham.email.template.file.path-prefix"</li>
71
 * <li>"ogham.email.thymeleaf.path-prefix"</li>
72
 * <li>"ogham.email.template.path-prefix"</li>
73
 * <li>"ogham.template.path-prefix"</li>
74
 * </ol>
75
 * </li>
76
 * <li>Uses the first property that has a value for file resolution suffix:
77
 * <ol>
78
 * <li>"ogham.email.thymeleaf.file.path-suffix"</li>
79
 * <li>"ogham.email.template.file.path-suffix"</li>
80
 * <li>"ogham.email.thymeleaf.path-suffix"</li>
81
 * <li>"ogham.email.template.path-suffix"</li>
82
 * <li>"ogham.template.path-suffix"</li>
83
 * </ol>
84
 * </li>
85
 * </ul>
86
 * </li>
87
 * <li>Configures email alternative content:
88
 * <ul>
89
 * <li>Automatically loads HTML template if extension is .html</li>
90
 * <li>Automatically loads text template if extension is .txt</li>
91
 * </ul>
92
 * </li>
93
 * <li>Configures template detection:
94
 * <ul>
95
 * <li>Uses {@link ThymeleafV3TemplateDetector} to detect if templates are
96
 * parseable by Thymeleaf</li>
97
 * </ul>
98
 * </li>
99
 * </ul>
100
 * 
101
 * @author Aurélien Baudet
102
 *
103
 */
104
public final class DefaultThymeleafV3EmailConfigurer {
105
	private static final Logger LOG = LoggerFactory.getLogger(DefaultThymeleafV3EmailConfigurer.class);
106
107
	@ConfigurerFor(targetedBuilder = { "minimal", "standard" }, priority = DEFAULT_THYMELEAF_EMAIL_CONFIGURER_PRIORITY)
108
	public static class ThymeleafV3EmailConfigurer extends AbstractDefaultThymeleafEmailConfigurer {
109
		public ThymeleafV3EmailConfigurer() {
110
			super(LOG);
111
		}
112
113
		public ThymeleafV3EmailConfigurer(MessagingConfigurerAdapter delegate) {
114
			super(LOG, delegate);
115
		}
116
117
		@Override
118
		protected boolean canUseThymeleaf() {
119 8 1. canUseThymeleaf : replaced boolean return with false for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → NO_COVERAGE
2. canUseThymeleaf : replaced boolean return with false for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → SURVIVED
3. canUseThymeleaf : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → SURVIVED
4. canUseThymeleaf : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → NO_COVERAGE
5. canUseThymeleaf : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → TIMED_OUT
6. canUseThymeleaf : replaced boolean return with false for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → KILLED
7. canUseThymeleaf : replaced boolean return with false for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → KILLED
8. canUseThymeleaf : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → KILLED
			return canUseThymeleafV3();
120
		}
121
122
		@Override
123
		protected Class<? extends AbstractThymeleafMultiContentBuilder<?, ?, ?>> getBuilderClass() {
124 3 1. getBuilderClass : replaced return value with null for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::getBuilderClass → NO_COVERAGE
2. getBuilderClass : replaced return value with null for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::getBuilderClass → KILLED
3. getBuilderClass : replaced return value with null for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::getBuilderClass → KILLED
			return ThymeleafV3EmailBuilder.class;
125
		}
126
127
		private static boolean canUseThymeleafV3() {
128 11 1. canUseThymeleafV3 : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleafV3 → SURVIVED
2. canUseThymeleafV3 : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleafV3 → NO_COVERAGE
3. canUseThymeleafV3 : negated conditional → SURVIVED
4. canUseThymeleafV3 : negated conditional → NO_COVERAGE
5. canUseThymeleafV3 : negated conditional → NO_COVERAGE
6. canUseThymeleafV3 : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleafV3 → KILLED
7. canUseThymeleafV3 : negated conditional → KILLED
8. canUseThymeleafV3 : negated conditional → KILLED
9. canUseThymeleafV3 : negated conditional → KILLED
10. canUseThymeleafV3 : negated conditional → KILLED
11. canUseThymeleafV3 : negated conditional → KILLED
			return ClasspathUtils.exists("org.thymeleaf.TemplateEngine") && ClasspathUtils.exists("org.thymeleaf.IEngineConfiguration");
129
		}
130
	}
131
132
133
	private DefaultThymeleafV3EmailConfigurer() {
134
		super();
135
	}
136
}

Mutations

119

1.1
Location : canUseThymeleaf
Killed by : oghamspringbootv2autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingThymeleaf(oghamspringbootv2autoconfigure.it.SpringBeanResolutionTest)
replaced boolean return with false for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → KILLED

2.2
Location : canUseThymeleaf
Killed by : none
replaced boolean return with false for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → NO_COVERAGE

3.3
Location : canUseThymeleaf
Killed by : none
replaced boolean return with false for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → SURVIVED

4.4
Location : canUseThymeleaf
Killed by : oghamall.it.html.translator.JsoupInlineCssTranslatorTest.externalStyles(oghamall.it.html.translator.JsoupInlineCssTranslatorTest)
replaced boolean return with false for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → KILLED

5.5
Location : canUseThymeleaf
Killed by : none
replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → SURVIVED

6.6
Location : canUseThymeleaf
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1ThymeleafAutoConfigurationTests.useCustomThymeleafBean(oghamspringbootv1autoconfigure.it.OghamSpringBoot1ThymeleafAutoConfigurationTests)
replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → KILLED

7.7
Location : canUseThymeleaf
Killed by : none
replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → NO_COVERAGE

8.8
Location : canUseThymeleaf
Killed by : none
replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleaf → TIMED_OUT

124

1.1
Location : getBuilderClass
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests.oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence(oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests)
replaced return value with null for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::getBuilderClass → KILLED

2.2
Location : getBuilderClass
Killed by : none
replaced return value with null for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::getBuilderClass → NO_COVERAGE

3.3
Location : getBuilderClass
Killed by : oghamall.it.html.translator.JsoupInlineCssTranslatorTest.notHtml(oghamall.it.html.translator.JsoupInlineCssTranslatorTest)
replaced return value with null for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::getBuilderClass → KILLED

128

1.1
Location : canUseThymeleafV3
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1ThymeleafAutoConfigurationTests.useCustomThymeleafBean(oghamspringbootv1autoconfigure.it.OghamSpringBoot1ThymeleafAutoConfigurationTests)
replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleafV3 → KILLED

2.2
Location : canUseThymeleafV3
Killed by : none
replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleafV3 → SURVIVED

3.3
Location : canUseThymeleafV3
Killed by : none
replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v3/configure/DefaultThymeleafV3EmailConfigurer$ThymeleafV3EmailConfigurer::canUseThymeleafV3 → NO_COVERAGE

4.4
Location : canUseThymeleafV3
Killed by : none
negated conditional → SURVIVED

5.5
Location : canUseThymeleafV3
Killed by : oghamall.it.html.translator.JsoupInlineCssTranslatorTest.externalStyles(oghamall.it.html.translator.JsoupInlineCssTranslatorTest)
negated conditional → KILLED

6.6
Location : canUseThymeleafV3
Killed by : none
negated conditional → NO_COVERAGE

7.7
Location : canUseThymeleafV3
Killed by : oghamspringbootv2autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingThymeleaf(oghamspringbootv2autoconfigure.it.SpringBeanResolutionTest)
negated conditional → KILLED

8.8
Location : canUseThymeleafV3
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1ThymeleafAutoConfigurationTests.useCustomThymeleafBean(oghamspringbootv1autoconfigure.it.OghamSpringBoot1ThymeleafAutoConfigurationTests)
negated conditional → KILLED

9.9
Location : canUseThymeleafV3
Killed by : none
negated conditional → NO_COVERAGE

10.10
Location : canUseThymeleafV3
Killed by : oghamall.it.html.translator.JsoupInlineCssTranslatorTest.externalStyles(oghamall.it.html.translator.JsoupInlineCssTranslatorTest)
negated conditional → KILLED

11.11
Location : canUseThymeleafV3
Killed by : oghamspringbootv2autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingThymeleaf(oghamspringbootv2autoconfigure.it.SpringBeanResolutionTest)
negated conditional → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM