| 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.RequestContextHolderWebContextProvider; | |
| 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.v2.template.thymeleaf.SpringWebMvcThymeleafRequestContextWrapper; | |
| 31 | import fr.sii.ogham.spring.v2.template.thymeleaf.UpdateCurrentContextMerger; | |
| 32 | import fr.sii.ogham.spring.v2.template.thymeleaf.WebExpressionContextProvider; | |
| 33 | import fr.sii.ogham.template.thymeleaf.common.SimpleThymeleafContextConverter; | |
| 34 | import fr.sii.ogham.template.thymeleaf.common.ThymeleafContextConverter; | |
| 35 | import fr.sii.ogham.template.thymeleaf.v3.buider.ThymeleafV3EmailBuilder; | |
| 36 | import fr.sii.ogham.template.thymeleaf.v3.buider.ThymeleafV3SmsBuilder; | |
| 37 | ||
| 38 | @Configuration | |
| 39 | @ConditionalOnClass({org.thymeleaf.spring5.SpringTemplateEngine.class, fr.sii.ogham.template.thymeleaf.v3.buider.ThymeleafV3EmailBuilder.class}) | |
| 40 | @EnableConfigurationProperties(OghamThymeleafProperties.class) | |
| 41 | public class OghamThymeleafV3Configuration { | |
| 42 | 	@Bean | |
| 43 | 	@ConditionalOnMissingBean(TemplateEngineSupplier.class) | |
| 44 | 	public TemplateEngineSupplier oghamTemplateEngineSupplier(@Autowired(required=false) org.thymeleaf.spring5.SpringTemplateEngine springTemplateEngine) { | |
| 45 | 
2
1. lambda$oghamTemplateEngineSupplier$0 : replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafV3Configuration::lambda$oghamTemplateEngineSupplier$0 → KILLED 2. oghamTemplateEngineSupplier : replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafV3Configuration::oghamTemplateEngineSupplier → KILLED  | 
		return () -> springTemplateEngine; | 
| 46 | 	} | |
| 47 | ||
| 48 | 	@Bean | |
| 49 | 	@ConditionalOnMissingBean(ThymeleafContextConverter.class) | |
| 50 | 	@ConditionalOnNotWebApplication | |
| 51 | 	public ThymeleafContextConverter springStandaloneThymeleafContextConverter( | |
| 52 | 			StaticVariablesProvider staticVariablesProvider,  | |
| 53 | 			ThymeleafEvaluationContextProvider thymeleafEvaluationContextProvider, | |
| 54 | 			ContextMerger contextMerger) { | |
| 55 | 
1
1. springStandaloneThymeleafContextConverter : replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafV3Configuration::springStandaloneThymeleafContextConverter → TIMED_OUT | 
		return springThymeleafContextConverter(staticVariablesProvider, thymeleafEvaluationContextProvider, contextMerger); | 
| 56 | 	} | |
| 57 | 	 | |
| 58 | 	@Bean | |
| 59 | 	@ConditionalOnMissingBean(ThymeleafContextConverter.class) | |
| 60 | 	@ConditionalOnWebApplication | |
| 61 | 	public ThymeleafContextConverter springWebThymeleafContextConverter( | |
| 62 | 			StaticVariablesProvider staticVariablesProvider,  | |
| 63 | 			ThymeleafEvaluationContextProvider thymeleafEvaluationContextProvider, | |
| 64 | 			ContextMerger contextMerger, | |
| 65 | 			ApplicationContext applicationContext, | |
| 66 | 			WebContextProvider webContextProvider, | |
| 67 | 			@Autowired(required=false) org.thymeleaf.spring5.SpringTemplateEngine springTemplateEngine) { | |
| 68 | 
1
1. springWebThymeleafContextConverter : replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafV3Configuration::springWebThymeleafContextConverter → SURVIVED | 
		return new SpringWebThymeleafContextConverter( | 
| 69 | 				springThymeleafContextConverter(staticVariablesProvider, thymeleafEvaluationContextProvider, contextMerger),  | |
| 70 | 				SpringContextVariableNames.SPRING_REQUEST_CONTEXT,  | |
| 71 | 				applicationContext,  | |
| 72 | 				webContextProvider, | |
| 73 | 				new SpringWebMvcThymeleafRequestContextWrapper(),  | |
| 74 | 				new WebExpressionContextProvider(springTemplateEngine), | |
| 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/v2/template/OghamThymeleafV3Configuration::webContextProvider → KILLED | 
		return new RequestContextHolderWebContextProvider(); | 
| 82 | 	} | |
| 83 | ||
| 84 | 	@Bean | |
| 85 | 	@ConditionalOnMissingBean(ThymeleafEvaluationContextProvider.class) | |
| 86 | 	public ThymeleafEvaluationContextProvider springThymeleafEvaluationContextProvider( | |
| 87 | 			OghamThymeleafProperties props, | |
| 88 | 			ApplicationContext applicationContext,  | |
| 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/v2/template/OghamThymeleafV3Configuration::lambda$springThymeleafEvaluationContextProvider$1 → TIMED_OUT 2. springThymeleafEvaluationContextProvider : replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafV3Configuration::springThymeleafEvaluationContextProvider → KILLED  | 
			return c -> new ThymeleafEvaluationContext(applicationContext, conversionService); | 
| 92 | 		} | |
| 93 | 
1
1. springThymeleafEvaluationContextProvider : replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafV3Configuration::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/v2/template/OghamThymeleafV3Configuration::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/v2/template/OghamThymeleafV3Configuration::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/v2/template/OghamThymeleafV3Configuration::thymeleafConfigurer → KILLED | 
		return new ThymeLeafConfigurer( | 
| 118 | 				springTemplateEngineSupplier,  | |
| 119 | 				contextConverter, | |
| 120 | 				templateProperties,  | |
| 121 | 				emailProperties,  | |
| 122 | 				smsProperties,  | |
| 123 | 				thymeleafProperties,  | |
| 124 | 				ThymeleafV3EmailBuilder.class,  | |
| 125 | 				ThymeleafV3SmsBuilder.class); | |
| 126 | 	} | |
| 127 | ||
| 128 | 	private static SpringStandaloneThymeleafContextConverter springThymeleafContextConverter(StaticVariablesProvider staticVariablesProvider, | |
| 129 | 			ThymeleafEvaluationContextProvider thymeleafEvaluationContextProvider, ContextMerger contextMerger) { | |
| 130 | 
1
1. springThymeleafContextConverter : replaced return value with null for fr/sii/ogham/spring/v2/template/OghamThymeleafV3Configuration::springThymeleafContextConverter → KILLED | 
		return new SpringStandaloneThymeleafContextConverter( | 
| 131 | 				new SimpleThymeleafContextConverter(),  | |
| 132 | 				ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME,  | |
| 133 | 				staticVariablesProvider,  | |
| 134 | 				thymeleafEvaluationContextProvider, | |
| 135 | 				contextMerger); | |
| 136 | 	} | |
| 137 | } | |
Mutations | ||
| 45 | 
 
 1.1 2.2  | 
|
| 55 | 
 
 1.1  | 
|
| 68 | 
 
 1.1  | 
|
| 81 | 
 
 1.1  | 
|
| 90 | 
 
 1.1  | 
|
| 91 | 
 
 1.1 2.2  | 
|
| 93 | 
 
 1.1  | 
|
| 99 | 
 
 1.1  | 
|
| 105 | 
 
 1.1  | 
|
| 117 | 
 
 1.1  | 
|
| 130 | 
 
 1.1  |