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