OghamThymeleafV2Configuration.java

1
package fr.sii.ogham.spring.v1.template;
2
3
import org.springframework.beans.factory.BeanFactory;
4
import org.springframework.beans.factory.annotation.Autowired;
5
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
6
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
7
import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication;
8
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
9
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafProperties;
10
import org.springframework.boot.context.properties.EnableConfigurationProperties;
11
import org.springframework.context.ApplicationContext;
12
import org.springframework.context.annotation.Bean;
13
import org.springframework.context.annotation.Configuration;
14
import org.springframework.core.convert.ConversionService;
15
import org.thymeleaf.spring4.expression.ThymeleafEvaluationContext;
16
import org.thymeleaf.spring4.naming.SpringContextVariableNames;
17
18
import fr.sii.ogham.spring.email.OghamEmailProperties;
19
import fr.sii.ogham.spring.sms.OghamSmsProperties;
20
import fr.sii.ogham.spring.template.OghamCommonTemplateProperties;
21
import fr.sii.ogham.spring.template.OghamThymeleafProperties;
22
import fr.sii.ogham.spring.template.ThymeLeafConfigurer;
23
import fr.sii.ogham.spring.template.thymeleaf.ContextMerger;
24
import fr.sii.ogham.spring.template.thymeleaf.RequestContextHolderWebContextProvider;
25
import fr.sii.ogham.spring.template.thymeleaf.SpringStandaloneThymeleafContextConverter;
26
import fr.sii.ogham.spring.template.thymeleaf.SpringWebThymeleafContextConverter;
27
import fr.sii.ogham.spring.template.thymeleaf.StaticVariablesProvider;
28
import fr.sii.ogham.spring.template.thymeleaf.TemplateEngineSupplier;
29
import fr.sii.ogham.spring.template.thymeleaf.ThymeleafEvaluationContextProvider;
30
import fr.sii.ogham.spring.template.thymeleaf.WebContextProvider;
31
import fr.sii.ogham.spring.v1.template.thymeleaf.NoOpRequestContextWrapper;
32
import fr.sii.ogham.spring.v1.template.thymeleaf.SpringWebContextProvider;
33
import fr.sii.ogham.spring.v1.template.thymeleaf.UpdateCurrentContextMerger;
34
import fr.sii.ogham.template.thymeleaf.common.SimpleThymeleafContextConverter;
35
import fr.sii.ogham.template.thymeleaf.common.ThymeleafContextConverter;
36
import fr.sii.ogham.template.thymeleaf.v2.buider.ThymeleafV2EmailBuilder;
37
import fr.sii.ogham.template.thymeleaf.v2.buider.ThymeleafV2SmsBuilder;
38
39
@Configuration
40
@ConditionalOnClass({org.thymeleaf.spring4.SpringTemplateEngine.class, fr.sii.ogham.template.thymeleaf.v2.buider.ThymeleafV2EmailBuilder.class})
41
@EnableConfigurationProperties(OghamThymeleafProperties.class)
42
public class OghamThymeleafV2Configuration {
43
	@Bean
44
	@ConditionalOnMissingBean(TemplateEngineSupplier.class)
45
	public TemplateEngineSupplier oghamTemplateEngineSupplier(@Autowired(required=false) org.thymeleaf.spring4.SpringTemplateEngine springTemplateEngine) {
46 2 1. lambda$oghamTemplateEngineSupplier$0 : replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::lambda$oghamTemplateEngineSupplier$0 → KILLED
2. oghamTemplateEngineSupplier : replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::oghamTemplateEngineSupplier → KILLED
		return () -> springTemplateEngine;
47
	}
48
49
	@Bean
50
	@ConditionalOnMissingBean(ThymeleafContextConverter.class)
51
	@ConditionalOnNotWebApplication
52
	public ThymeleafContextConverter springStandaloneThymeleafContextConverter(
53
			StaticVariablesProvider staticVariablesProvider, 
54
			ThymeleafEvaluationContextProvider thymeleafEvaluationContextProvider,
55
			ContextMerger contextMerger) {
56 1 1. springStandaloneThymeleafContextConverter : replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::springStandaloneThymeleafContextConverter → KILLED
		return springThymeleafContextConverter(staticVariablesProvider, thymeleafEvaluationContextProvider, contextMerger);
57
	}
58
59
	@Bean
60
	@ConditionalOnMissingBean(ThymeleafContextConverter.class)
61
	@ConditionalOnWebApplication
62
	public ThymeleafContextConverter springWebThymeleafContextConverter(
63
			StaticVariablesProvider staticVariablesProvider, 
64
			ThymeleafEvaluationContextProvider thymeleafEvaluationContextProvider,
65
			ContextMerger contextMerger,
66
			ApplicationContext applicationContext,
67
			WebContextProvider webContextProvider) {
68 1 1. springWebThymeleafContextConverter : replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::springWebThymeleafContextConverter → SURVIVED
		return new SpringWebThymeleafContextConverter(
69
				springThymeleafContextConverter(staticVariablesProvider, thymeleafEvaluationContextProvider, contextMerger), 
70
				SpringContextVariableNames.SPRING_REQUEST_CONTEXT, 
71
				applicationContext, 
72
				webContextProvider,
73
				new NoOpRequestContextWrapper(), 
74
				new SpringWebContextProvider(),
75
				contextMerger);
76
	}
77
	
78
	@Bean
79
	@ConditionalOnWebApplication
80
	public WebContextProvider webContextProvider() {
81 1 1. webContextProvider : replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::webContextProvider → SURVIVED
		return new RequestContextHolderWebContextProvider();
82
	}
83
84
	@Bean
85
	@ConditionalOnMissingBean(ThymeleafEvaluationContextProvider.class)
86
	public ThymeleafEvaluationContextProvider springThymeleafEvaluationContextProvider(
87
			OghamThymeleafProperties props,
88
			BeanFactory beanFactory, 
89
			@Autowired(required=false) ConversionService conversionService) {
90 1 1. springThymeleafEvaluationContextProvider : negated conditional → KILLED
		if (props.isEnableSpringBeans()) {
91 2 1. lambda$springThymeleafEvaluationContextProvider$1 : replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::lambda$springThymeleafEvaluationContextProvider$1 → KILLED
2. springThymeleafEvaluationContextProvider : replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::springThymeleafEvaluationContextProvider → KILLED
			return c -> new ThymeleafEvaluationContext(beanFactory, conversionService);
92
		}
93 1 1. springThymeleafEvaluationContextProvider : replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::springThymeleafEvaluationContextProvider → NO_COVERAGE
		return c -> null;
94
	}
95
96
	@Bean
97
	@ConditionalOnMissingBean(StaticVariablesProvider.class)
98
	public StaticVariablesProvider springThymeleafStaticVariablesProvider() {
99 1 1. springThymeleafStaticVariablesProvider : replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::springThymeleafStaticVariablesProvider → KILLED
		return c -> null;
100
	}
101
	
102
	@Bean
103
	@ConditionalOnMissingBean(ContextMerger.class)
104
	public ContextMerger contextMerger() {
105 1 1. contextMerger : replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::contextMerger → KILLED
		return new UpdateCurrentContextMerger();
106
	}
107
108
	@Bean
109
	@ConditionalOnMissingBean(ThymeLeafConfigurer.class)
110
	public ThymeLeafConfigurer thymeleafConfigurer(
111
			TemplateEngineSupplier springTemplateEngineSupplier,
112
			@Autowired(required=false) ThymeleafContextConverter contextConverter,
113
			@Autowired(required=false) OghamCommonTemplateProperties templateProperties,
114
			@Autowired(required=false) OghamEmailProperties emailProperties,
115
			@Autowired(required=false) OghamSmsProperties smsProperties,
116
			@Autowired(required=false) ThymeleafProperties thymeleafProperties) {
117 1 1. thymeleafConfigurer : replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::thymeleafConfigurer → KILLED
		return new ThymeLeafConfigurer(
118
				springTemplateEngineSupplier, 
119
				contextConverter, 
120
				templateProperties, 
121
				emailProperties, 
122
				smsProperties, 
123
				thymeleafProperties, 
124
				ThymeleafV2EmailBuilder.class, 
125
				ThymeleafV2SmsBuilder.class);
126
	}
127
128
	private static ThymeleafContextConverter springThymeleafContextConverter(
129
			StaticVariablesProvider staticVariablesProvider, 
130
			ThymeleafEvaluationContextProvider thymeleafEvaluationContextProvider,
131
			ContextMerger contextMerger) {
132 1 1. springThymeleafContextConverter : replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::springThymeleafContextConverter → KILLED
		return new SpringStandaloneThymeleafContextConverter(
133
				new SimpleThymeleafContextConverter(), 
134
				ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME, 
135
				staticVariablesProvider, 
136
				thymeleafEvaluationContextProvider,
137
				contextMerger);
138
	}
139
140
}

Mutations

46

1.1
Location : lambda$oghamTemplateEngineSupplier$0
Killed by : oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingThymeleaf(oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest)
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::lambda$oghamTemplateEngineSupplier$0 → KILLED

2.2
Location : oghamTemplateEngineSupplier
Killed by : oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingThymeleaf(oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest)
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::oghamTemplateEngineSupplier → KILLED

56

1.1
Location : springStandaloneThymeleafContextConverter
Killed by : oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingThymeleaf(oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest)
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::springStandaloneThymeleafContextConverter → KILLED

68

1.1
Location : springWebThymeleafContextConverter
Killed by : none
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::springWebThymeleafContextConverter → SURVIVED

81

1.1
Location : webContextProvider
Killed by : none
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::webContextProvider → SURVIVED

90

1.1
Location : springThymeleafEvaluationContextProvider
Killed by : oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingThymeleaf(oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest)
negated conditional → KILLED

91

1.1
Location : lambda$springThymeleafEvaluationContextProvider$1
Killed by : oghamspringbootv1autoconfigure.it.SpringWebBeanResolutionTest.smsUsingThymeleafTemplateShouldResolveBeansAndUrls(oghamspringbootv1autoconfigure.it.SpringWebBeanResolutionTest)
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::lambda$springThymeleafEvaluationContextProvider$1 → KILLED

2.2
Location : springThymeleafEvaluationContextProvider
Killed by : oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingThymeleaf(oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest)
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::springThymeleafEvaluationContextProvider → KILLED

93

1.1
Location : springThymeleafEvaluationContextProvider
Killed by : none
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::springThymeleafEvaluationContextProvider → NO_COVERAGE

99

1.1
Location : springThymeleafStaticVariablesProvider
Killed by : oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingThymeleaf(oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest)
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::springThymeleafStaticVariablesProvider → KILLED

105

1.1
Location : contextMerger
Killed by : oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingThymeleaf(oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest)
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::contextMerger → KILLED

117

1.1
Location : thymeleafConfigurer
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::thymeleafConfigurer → KILLED

132

1.1
Location : springThymeleafContextConverter
Killed by : oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingThymeleaf(oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest)
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafV2Configuration::springThymeleafContextConverter → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM