OghamFreemarkerConfiguration.java

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

Mutations

38

1.1
Location : freemarkerConfigurer
Killed by :
replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration::freemarkerConfigurer → RUN_ERROR

50

1.1
Location : emailFreemarkerConfiguration
Killed by :
replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$OghamFreeMarkerNonWebConfiguration::emailFreemarkerConfiguration → RUN_ERROR

57

1.1
Location : smsFreemarkerConfiguration
Killed by :
replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$OghamFreeMarkerNonWebConfiguration::smsFreemarkerConfiguration → RUN_ERROR

71

1.1
Location : emailFreemarkerConfiguration
Killed by :
replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$OghamFreeMarkerWebConfiguration::emailFreemarkerConfiguration → NO_COVERAGE

78

1.1
Location : smsFreemarkerConfiguration
Killed by :
replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$OghamFreeMarkerWebConfiguration::smsFreemarkerConfiguration → NO_COVERAGE

91

1.1
Location : emailFreemarkerConfiguration
Killed by :
replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$FreeMarkerDefaultOghamConfiguration::emailFreemarkerConfiguration → RUN_ERROR

98

1.1
Location : smsFreemarkerConfiguration
Killed by :
replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$FreeMarkerDefaultOghamConfiguration::smsFreemarkerConfiguration → RUN_ERROR

103

1.1
Location : defaultConfiguration
Killed by :
removed call to freemarker/template/Configuration::setDefaultEncoding → RUN_ERROR

104

1.1
Location : defaultConfiguration
Killed by :
removed call to freemarker/template/Configuration::setTemplateExceptionHandler → RUN_ERROR

105

1.1
Location : defaultConfiguration
Killed by :
replaced return value with null for fr/sii/ogham/spring/template/OghamFreemarkerConfiguration$FreeMarkerDefaultOghamConfiguration::defaultConfiguration → RUN_ERROR

Active mutators

Tests examined


Report generated by PIT 1.13.1