1 | package fr.sii.ogham.spring.template; | |
2 | ||
3 | import static freemarker.template.Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS; | |
4 | ||
5 | import java.io.IOException; | |
6 | ||
7 | import javax.servlet.Servlet; | |
8 | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | |
10 | import org.springframework.beans.factory.annotation.Qualifier; | |
11 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | |
12 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | |
13 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | |
14 | import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication; | |
15 | import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; | |
16 | import org.springframework.boot.autoconfigure.freemarker.FreeMarkerProperties; | |
17 | import org.springframework.boot.context.properties.EnableConfigurationProperties; | |
18 | import org.springframework.context.ApplicationContext; | |
19 | import org.springframework.context.annotation.Bean; | |
20 | import org.springframework.context.annotation.Configuration; | |
21 | import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; | |
22 | import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; | |
23 | ||
24 | import fr.sii.ogham.spring.email.OghamEmailProperties; | |
25 | import fr.sii.ogham.spring.sms.OghamSmsProperties; | |
26 | import fr.sii.ogham.template.freemarker.builder.FreemarkerEmailBuilder; | |
27 | import freemarker.template.TemplateException; | |
28 | import freemarker.template.TemplateExceptionHandler; | |
29 | ||
30 | @Configuration | |
31 | @ConditionalOnClass({ freemarker.template.Configuration.class, FreemarkerEmailBuilder.class }) | |
32 | @EnableConfigurationProperties(OghamFreemarkerProperties.class) | |
33 | public class OghamFreemarkerConfiguration { | |
34 | ||
35 | @Bean | |
36 | @ConditionalOnMissingBean(FreemarkerConfigurer.class) | |
37 | public FreemarkerConfigurer freemarkerConfigurer(@Qualifier("email") freemarker.template.Configuration emailFreemarkerConfiguration, | |
38 | @Qualifier("sms") freemarker.template.Configuration smsFreemarkerConfiguration, | |
39 | @Autowired(required=false) OghamCommonTemplateProperties templateProperties, | |
40 | @Autowired(required=false) OghamEmailProperties emailProperties, | |
41 | @Autowired(required=false) OghamSmsProperties smsProperties, | |
42 | @Autowired(required=false) FreeMarkerProperties freemarkerProperties, | |
43 | @Autowired(required=false) OghamFreemarkerProperties oghamFreemarkerProperties, | |
44 | @Autowired ApplicationContext applicationContext) { | |
45 |
2
1. freemarkerConfigurer : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration::freemarkerConfigurer → KILLED 2. freemarkerConfigurer : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration::freemarkerConfigurer → KILLED |
return new FreemarkerConfigurer(emailFreemarkerConfiguration, smsFreemarkerConfiguration, templateProperties, emailProperties, smsProperties, freemarkerProperties, oghamFreemarkerProperties, applicationContext); |
46 | } | |
47 | ||
48 | | |
49 | @Configuration | |
50 | @ConditionalOnNotWebApplication | |
51 | @ConditionalOnBean({ FreeMarkerConfigurationFactoryBean.class }) | |
52 | public static class OghamFreeMarkerNonWebConfiguration { | |
53 | @Bean | |
54 | @Qualifier("email") | |
55 | @ConditionalOnMissingBean(name = "emailFreemarkerConfiguration") | |
56 | public freemarker.template.Configuration emailFreemarkerConfiguration(FreeMarkerConfigurationFactoryBean factory) throws IOException, TemplateException { | |
57 |
2
1. emailFreemarkerConfiguration : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$OghamFreeMarkerNonWebConfiguration::emailFreemarkerConfiguration → KILLED 2. emailFreemarkerConfiguration : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$OghamFreeMarkerNonWebConfiguration::emailFreemarkerConfiguration → KILLED |
return factory.createConfiguration(); |
58 | } | |
59 | ||
60 | @Bean | |
61 | @Qualifier("sms") | |
62 | @ConditionalOnMissingBean(name = "smsFreemarkerConfiguration") | |
63 | public freemarker.template.Configuration smsFreemarkerConfiguration(FreeMarkerConfigurationFactoryBean factory) throws IOException, TemplateException { | |
64 |
2
1. smsFreemarkerConfiguration : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$OghamFreeMarkerNonWebConfiguration::smsFreemarkerConfiguration → KILLED 2. smsFreemarkerConfiguration : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$OghamFreeMarkerNonWebConfiguration::smsFreemarkerConfiguration → KILLED |
return factory.createConfiguration(); |
65 | } | |
66 | ||
67 | } | |
68 | ||
69 | @Configuration | |
70 | @ConditionalOnClass({ Servlet.class, FreeMarkerConfigurer.class }) | |
71 | @ConditionalOnWebApplication | |
72 | @ConditionalOnBean({ FreeMarkerConfigurer.class }) | |
73 | public static class OghamFreeMarkerWebConfiguration { | |
74 | @Bean | |
75 | @Qualifier("email") | |
76 | @ConditionalOnMissingBean(name = "emailFreemarkerConfiguration") | |
77 | public freemarker.template.Configuration emailFreemarkerConfiguration(FreeMarkerConfigurer configurer) throws IOException, TemplateException { | |
78 |
1
1. emailFreemarkerConfiguration : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$OghamFreeMarkerWebConfiguration::emailFreemarkerConfiguration → NO_COVERAGE |
return configurer.createConfiguration(); |
79 | } | |
80 | ||
81 | @Bean | |
82 | @Qualifier("sms") | |
83 | @ConditionalOnMissingBean(name = "smsFreemarkerConfiguration") | |
84 | public freemarker.template.Configuration smsFreemarkerConfiguration(FreeMarkerConfigurer configurer) throws IOException, TemplateException { | |
85 |
1
1. smsFreemarkerConfiguration : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$OghamFreeMarkerWebConfiguration::smsFreemarkerConfiguration → NO_COVERAGE |
return configurer.createConfiguration(); |
86 | } | |
87 | } | |
88 | | |
89 | | |
90 | @Configuration | |
91 | @ConditionalOnMissingBean(type= {"org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer", "org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean"}) | |
92 | public static class FreeMarkerDefaultOghamConfiguration { | |
93 | | |
94 | @Bean | |
95 | @Qualifier("email") | |
96 | @ConditionalOnMissingBean(name = "emailFreemarkerConfiguration") | |
97 | public freemarker.template.Configuration emailFreemarkerConfiguration(OghamFreemarkerProperties props) { | |
98 |
2
1. emailFreemarkerConfiguration : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$FreeMarkerDefaultOghamConfiguration::emailFreemarkerConfiguration → KILLED 2. emailFreemarkerConfiguration : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$FreeMarkerDefaultOghamConfiguration::emailFreemarkerConfiguration → KILLED |
return defaultConfiguration(props); |
99 | } | |
100 | | |
101 | @Bean | |
102 | @Qualifier("sms") | |
103 | @ConditionalOnMissingBean(name = "smsFreemarkerConfiguration") | |
104 | public freemarker.template.Configuration smsFreemarkerConfiguration(OghamFreemarkerProperties props) { | |
105 |
2
1. smsFreemarkerConfiguration : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$FreeMarkerDefaultOghamConfiguration::smsFreemarkerConfiguration → KILLED 2. smsFreemarkerConfiguration : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$FreeMarkerDefaultOghamConfiguration::smsFreemarkerConfiguration → KILLED |
return defaultConfiguration(props); |
106 | } | |
107 | | |
108 | private static freemarker.template.Configuration defaultConfiguration(OghamFreemarkerProperties props) { | |
109 | freemarker.template.Configuration configuration = new freemarker.template.Configuration(DEFAULT_INCOMPATIBLE_IMPROVEMENTS); | |
110 |
1
1. defaultConfiguration : removed call to freemarker/template/Configuration::setDefaultEncoding → SURVIVED |
configuration.setDefaultEncoding(props.getDefaultEncoding()); |
111 |
2
1. defaultConfiguration : removed call to freemarker/template/Configuration::setTemplateExceptionHandler → SURVIVED 2. defaultConfiguration : removed call to freemarker/template/Configuration::setTemplateExceptionHandler → TIMED_OUT |
configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); |
112 |
2
1. defaultConfiguration : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$FreeMarkerDefaultOghamConfiguration::defaultConfiguration → KILLED 2. defaultConfiguration : replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$FreeMarkerDefaultOghamConfiguration::defaultConfiguration → KILLED |
return configuration; |
113 | } | |
114 | } | |
115 | } | |
Mutations | ||
45 |
1.1 2.2 |
|
57 |
1.1 2.2 |
|
64 |
1.1 2.2 |
|
78 |
1.1 |
|
85 |
1.1 |
|
98 |
1.1 2.2 |
|
105 |
1.1 2.2 |
|
110 |
1.1 |
|
111 |
1.1 2.2 |
|
112 |
1.1 2.2 |