AbstractDefaultThymeleafSmsConfigurer.java

1
package fr.sii.ogham.template.thymeleaf.common.configure;
2
3
import fr.sii.ogham.core.builder.MessagingBuilder;
4
import fr.sii.ogham.core.builder.configurer.DefaultMessagingConfigurer;
5
import fr.sii.ogham.core.builder.configurer.MessagingConfigurer;
6
import fr.sii.ogham.core.builder.configurer.MessagingConfigurerAdapter;
7
import fr.sii.ogham.core.builder.env.EnvironmentBuilder;
8
import fr.sii.ogham.core.builder.resolution.ResourceResolutionBuilder;
9
import fr.sii.ogham.core.exception.configurer.ConfigureException;
10
import fr.sii.ogham.template.thymeleaf.common.buider.AbstractThymeleafBuilder;
11
12
/**
13
 * Default configurer for Thymeleaf template engine that is automatically
14
 * applied every time a {@link MessagingBuilder} instance is created through
15
 * {@link MessagingBuilder#standard()} or {@link MessagingBuilder#minimal()}.
16
 * 
17
 * <p>
18
 * The configurer has a priority of 70000 in order to be applied after global
19
 * configurer but before any sender implementation.
20
 * </p>
21
 * 
22
 * This configurer is applied only if {@code org.thymeleaf.TemplateEngine} is
23
 * present in the classpath. If not present, template engine is not registered
24
 * at all.
25
 * 
26
 * <p>
27
 * This configurer inherits environment configuration (see
28
 * {@link EnvironmentBuilder}).
29
 * </p>
30
 * <p>
31
 * It also copies resource resolution configuration of
32
 * {@link DefaultMessagingConfigurer} to inherit resource resolution lookups
33
 * (see {@link ResourceResolutionBuilder}).
34
 * </p>
35
 * 
36
 * <p>
37
 * This configurer applies the following configuration:
38
 * <ul>
39
 * <li>Configures template prefix/suffix paths:
40
 * <ul>
41
 * <li>Uses the first property that has a value for classpath resolution prefix:
42
 * <ol>
43
 * <li>"ogham.sms.thymeleaf.classpath.path-prefix"</li>
44
 * <li>"ogham.sms.template.classpath.path-prefix"</li>
45
 * <li>"ogham.sms.thymeleaf.path-prefix"</li>
46
 * <li>"ogham.sms.template.path-prefix"</li>
47
 * <li>"ogham.template.path-prefix"</li>
48
 * </ol>
49
 * </li>
50
 * <li>Uses the first property that has a value for classpath resolution suffix:
51
 * <ol>
52
 * <li>"ogham.sms.thymeleaf.classpath.path-suffix"</li>
53
 * <li>"ogham.sms.template.classpath.path-suffix"</li>
54
 * <li>"ogham.sms.thymeleaf.path-suffix"</li>
55
 * <li>"ogham.sms.template.path-suffix"</li>
56
 * <li>"ogham.template.path-suffix"</li>
57
 * </ol>
58
 * </li>
59
 * <li>Uses the first property that has a value for file resolution prefix:
60
 * <ol>
61
 * <li>"ogham.sms.thymeleaf.file.path-prefix"</li>
62
 * <li>"ogham.sms.template.file.path-prefix"</li>
63
 * <li>"ogham.sms.thymeleaf.path-prefix"</li>
64
 * <li>"ogham.sms.template.path-prefix"</li>
65
 * <li>"ogham.template.path-prefix"</li>
66
 * </ol>
67
 * </li>
68
 * <li>Uses the first property that has a value for file resolution suffix:
69
 * <ol>
70
 * <li>"ogham.sms.thymeleaf.file.path-suffix"</li>
71
 * <li>"ogham.sms.template.file.path-suffix"</li>
72
 * <li>"ogham.sms.thymeleaf.path-suffix"</li>
73
 * <li>"ogham.sms.template.path-suffix"</li>
74
 * <li>"ogham.template.path-suffix"</li>
75
 * </ol>
76
 * </li>
77
 * </ul>
78
 * </li>
79
 * <li>Configures template detection:
80
 * <ul>
81
 * <li>Uses ThymeleafTemplateDetector to detect if templates are
82
 * parseable by Thymeleaf</li>
83
 * </ul>
84
 * </li>
85
 * </ul>
86
 * 
87
 * @author Aurélien Baudet
88
 *
89
 */
90
public abstract class AbstractDefaultThymeleafSmsConfigurer implements MessagingConfigurer {
91
	private final MessagingConfigurerAdapter delegate;
92
93
	public AbstractDefaultThymeleafSmsConfigurer() {
94
		this(new DefaultMessagingConfigurer());
95
	}
96
97
	public AbstractDefaultThymeleafSmsConfigurer(MessagingConfigurerAdapter delegate) {
98
		super();
99
		this.delegate = delegate;
100
	}
101
102
	@Override
103
	public void configure(MessagingBuilder msgBuilder) throws ConfigureException {
104 1 1. configure : removed call to fr/sii/ogham/template/thymeleaf/common/configure/AbstractDefaultThymeleafSmsConfigurer::checkCanUseThymeleaf → NO_COVERAGE
		checkCanUseThymeleaf();
105
106
		AbstractThymeleafBuilder<?, ?, ?> builder = msgBuilder.sms().template(getBuilderClass());
107
		// apply default resource resolution configuration
108 1 1. configure : negated conditional → NO_COVERAGE
		if (delegate != null) {
109 1 1. configure : removed call to fr/sii/ogham/core/builder/configurer/MessagingConfigurerAdapter::configure → NO_COVERAGE
			delegate.configure(builder);
110
		}
111
		// @formatter:off
112
		builder
113
			.classpath()
114
				.pathPrefix()
115
					.properties("${ogham.sms.thymeleaf.classpath.path-prefix}", 
116
								"${ogham.sms.template.classpath.path-prefix}", 
117
								"${ogham.sms.thymeleaf.path-prefix}",
118
								"${ogham.sms.template.path-prefix}", 
119
								"${ogham.template.path-prefix}")
120
					.and()
121
				.pathSuffix()
122
					.properties("${ogham.sms.thymeleaf.classpath.path-suffix}", 
123
								"${ogham.sms.template.classpath.path-suffix}", 
124
								"${ogham.sms.thymeleaf.path-suffix}",
125
								"${ogham.sms.template.path-suffix}", 
126
								"${ogham.template.path-suffix}")
127
					.and()
128
				.and()
129
			.file()
130
				.pathPrefix()
131
					.properties("${ogham.sms.thymeleaf.file.path-prefix}", 
132
								"${ogham.sms.template.file.path-prefix}", 
133
								"${ogham.sms.thymeleaf.path-prefix}",
134
								"${ogham.sms.template.path-prefix}", 
135
								"${ogham.template.path-prefix}")
136
					.and()
137
				.pathSuffix()
138
					.properties("${ogham.sms.thymeleaf.file.path-suffix}", 
139
								"${ogham.sms.template.file.path-suffix}", 
140
								"${ogham.sms.thymeleaf.path-suffix}",
141
								"${ogham.sms.template.path-suffix}", 
142
								"${ogham.template.path-suffix}")
143
					.and()
144
				.and()
145
			.cache()
146
				.properties("${ogham.sms.thymeleaf.cache}",
147
							"${ogham.sms.template.cache}",
148
							"${ogham.template.cache}");
149
		// @formatter:on
150
	}
151
152
	protected abstract Class<? extends AbstractThymeleafBuilder<?, ?, ?>> getBuilderClass();
153
154
	protected abstract void checkCanUseThymeleaf() throws ConfigureException;
155
156
}

Mutations

104

1.1
Location : configure
Killed by :
removed call to fr/sii/ogham/template/thymeleaf/common/configure/AbstractDefaultThymeleafSmsConfigurer::checkCanUseThymeleaf → NO_COVERAGE

108

1.1
Location : configure
Killed by :
negated conditional → NO_COVERAGE

109

1.1
Location : configure
Killed by :
removed call to fr/sii/ogham/core/builder/configurer/MessagingConfigurerAdapter::configure → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.13.1