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

Mutations

47

1.1
Location : oghamTemplateEngineSupplier
Killed by :
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafSpring4Configuration::oghamTemplateEngineSupplier → RUN_ERROR

2.2
Location : lambda$oghamTemplateEngineSupplier$0
Killed by :
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafSpring4Configuration::lambda$oghamTemplateEngineSupplier$0 → RUN_ERROR

57

1.1
Location : springStandaloneThymeleafContextConverter
Killed by :
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafSpring4Configuration::springStandaloneThymeleafContextConverter → RUN_ERROR

69

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

83

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

92

1.1
Location : springThymeleafEvaluationContextProvider
Killed by :
negated conditional → RUN_ERROR

93

1.1
Location : lambda$springThymeleafEvaluationContextProvider$1
Killed by :
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafSpring4Configuration::lambda$springThymeleafEvaluationContextProvider$1 → RUN_ERROR

2.2
Location : springThymeleafEvaluationContextProvider
Killed by :
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafSpring4Configuration::springThymeleafEvaluationContextProvider → RUN_ERROR

95

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

101

1.1
Location : springThymeleafStaticVariablesProvider
Killed by :
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafSpring4Configuration::springThymeleafStaticVariablesProvider → RUN_ERROR

2.2
Location : lambda$springThymeleafStaticVariablesProvider$3
Killed by :
replaced return value with Collections.emptyMap for fr/sii/ogham/spring/v1/template/OghamThymeleafSpring4Configuration::lambda$springThymeleafStaticVariablesProvider$3 → RUN_ERROR

107

1.1
Location : contextMerger
Killed by :
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafSpring4Configuration::contextMerger → RUN_ERROR

119

1.1
Location : thymeleafConfigurer
Killed by :
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafSpring4Configuration::thymeleafConfigurer → RUN_ERROR

134

1.1
Location : springThymeleafContextConverter
Killed by :
replaced return value with null for fr/sii/ogham/spring/v1/template/OghamThymeleafSpring4Configuration::springThymeleafContextConverter → RUN_ERROR

Active mutators

Tests examined


Report generated by PIT 1.13.1