OghamThymeleafSpring5Configuration.java

1
package fr.sii.ogham.spring.v2.template;
2
3
import org.springframework.beans.factory.annotation.Autowired;
4
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
5
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
6
import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication;
7
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
8
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafProperties;
9
import org.springframework.boot.context.properties.EnableConfigurationProperties;
10
import org.springframework.context.ApplicationContext;
11
import org.springframework.context.annotation.Bean;
12
import org.springframework.context.annotation.Configuration;
13
import org.springframework.core.convert.ConversionService;
14
import org.thymeleaf.spring5.expression.ThymeleafEvaluationContext;
15
import org.thymeleaf.spring5.naming.SpringContextVariableNames;
16
17
import fr.sii.ogham.spring.email.OghamEmailProperties;
18
import fr.sii.ogham.spring.sms.OghamSmsProperties;
19
import fr.sii.ogham.spring.template.OghamCommonTemplateProperties;
20
import fr.sii.ogham.spring.template.OghamThymeleafProperties;
21
import fr.sii.ogham.spring.template.ThymeLeafConfigurer;
22
import fr.sii.ogham.spring.template.thymeleaf.ContextMerger;
23
import fr.sii.ogham.spring.template.thymeleaf.SpringWebThymeleafContextConverter;
24
import fr.sii.ogham.spring.template.thymeleaf.SpringStandaloneThymeleafContextConverter;
25
import fr.sii.ogham.spring.template.thymeleaf.StaticVariablesProvider;
26
import fr.sii.ogham.spring.template.thymeleaf.TemplateEngineSupplier;
27
import fr.sii.ogham.spring.template.thymeleaf.ThymeleafEvaluationContextProvider;
28
import fr.sii.ogham.spring.template.thymeleaf.WebContextProvider;
29
import fr.sii.ogham.spring.v2.template.thymeleaf.JavaxRequestContextHolderWebContextProvider;
30
import fr.sii.ogham.spring.v2.template.thymeleaf.JavaxRequestContextProvider;
31
import fr.sii.ogham.spring.v2.template.thymeleaf.Spring5WebMvcThymeleafRequestContextWrapper;
32
import fr.sii.ogham.spring.v2.template.thymeleaf.UpdateCurrentContextMerger;
33
import fr.sii.ogham.spring.v2.template.thymeleaf.WebExpressionContextProvider;
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.v3.buider.ThymeleafV3EmailBuilder;
37
import fr.sii.ogham.template.thymeleaf.v3.buider.ThymeleafV3SmsBuilder;
38
39
@Configuration
40
@ConditionalOnClass({org.thymeleaf.spring5.SpringTemplateEngine.class, fr.sii.ogham.template.thymeleaf.v3.buider.ThymeleafV3EmailBuilder.class})
41
@EnableConfigurationProperties(OghamThymeleafProperties.class)
42
public class OghamThymeleafSpring5Configuration {
43
	@Bean
44
	@ConditionalOnMissingBean(TemplateEngineSupplier.class)
45
	public TemplateEngineSupplier oghamTemplateEngineSupplier(@Autowired(required=false) org.thymeleaf.spring5.SpringTemplateEngine springTemplateEngine) {
46 2 1. lambda$oghamTemplateEngineSupplier$0 : replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafSpring5Configuration::lambda$oghamTemplateEngineSupplier$0 → RUN_ERROR
2. oghamTemplateEngineSupplier : replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafSpring5Configuration::oghamTemplateEngineSupplier → RUN_ERROR
		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/v2/template/OghamThymeleafSpring5Configuration::springStandaloneThymeleafContextConverter → RUN_ERROR
		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
			@Autowired(required=false) org.thymeleaf.spring5.SpringTemplateEngine springTemplateEngine) {
69 1 1. springWebThymeleafContextConverter : replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafSpring5Configuration::springWebThymeleafContextConverter → RUN_ERROR
		return new SpringWebThymeleafContextConverter(
70
				springThymeleafContextConverter(staticVariablesProvider, thymeleafEvaluationContextProvider, contextMerger), 
71
				SpringContextVariableNames.SPRING_REQUEST_CONTEXT, 
72
				applicationContext, 
73
				webContextProvider,
74
				new Spring5WebMvcThymeleafRequestContextWrapper(), 
75
				new WebExpressionContextProvider(springTemplateEngine),
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/v2/template/OghamThymeleafSpring5Configuration::webContextProvider → RUN_ERROR
		return new JavaxRequestContextHolderWebContextProvider();
84
	}
85
86
	@Bean
87
	@ConditionalOnMissingBean(ThymeleafEvaluationContextProvider.class)
88
	public ThymeleafEvaluationContextProvider springThymeleafEvaluationContextProvider(
89
			OghamThymeleafProperties props,
90
			ApplicationContext applicationContext, 
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/v2/template/OghamThymeleafSpring5Configuration::lambda$springThymeleafEvaluationContextProvider$1 → RUN_ERROR
2. springThymeleafEvaluationContextProvider : replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafSpring5Configuration::springThymeleafEvaluationContextProvider → RUN_ERROR
			return c -> new ThymeleafEvaluationContext(applicationContext, conversionService);
94
		}
95 1 1. springThymeleafEvaluationContextProvider : replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafSpring5Configuration::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/v2/template/OghamThymeleafSpring5Configuration::springThymeleafStaticVariablesProvider → RUN_ERROR
2. lambda$springThymeleafStaticVariablesProvider$3 : replaced return value with Collections.emptyMap for fr/sii/ogham/spring/v2/template/OghamThymeleafSpring5Configuration::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/v2/template/OghamThymeleafSpring5Configuration::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/v2/template/OghamThymeleafSpring5Configuration::thymeleafConfigurer → RUN_ERROR
		return new ThymeLeafConfigurer(
120
				springTemplateEngineSupplier, 
121
				contextConverter,
122
				templateProperties, 
123
				emailProperties, 
124
				smsProperties, 
125
				thymeleafProperties, 
126
				ThymeleafV3EmailBuilder.class, 
127
				ThymeleafV3SmsBuilder.class);
128
	}
129
130
	private static SpringStandaloneThymeleafContextConverter springThymeleafContextConverter(StaticVariablesProvider staticVariablesProvider,
131
			ThymeleafEvaluationContextProvider thymeleafEvaluationContextProvider, ContextMerger contextMerger) {
132 1 1. springThymeleafContextConverter : replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafSpring5Configuration::springThymeleafContextConverter → RUN_ERROR
		return new SpringStandaloneThymeleafContextConverter(
133
				new SimpleThymeleafContextConverter(), 
134
				ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME, 
135
				staticVariablesProvider, 
136
				thymeleafEvaluationContextProvider,
137
				contextMerger);
138
	}
139
}

Mutations

46

1.1
Location : lambda$oghamTemplateEngineSupplier$0
Killed by :
replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafSpring5Configuration::lambda$oghamTemplateEngineSupplier$0 → RUN_ERROR

2.2
Location : oghamTemplateEngineSupplier
Killed by :
replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafSpring5Configuration::oghamTemplateEngineSupplier → RUN_ERROR

56

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

69

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

83

1.1
Location : webContextProvider
Killed by :
replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafSpring5Configuration::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/v2/template/OghamThymeleafSpring5Configuration::lambda$springThymeleafEvaluationContextProvider$1 → RUN_ERROR

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

95

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

101

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

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

107

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

119

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

132

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

Active mutators

Tests examined


Report generated by PIT 1.13.1