| 1 | package fr.sii.ogham.spring.general; | |
| 2 | ||
| 3 | import java.util.List; | |
| 4 | import java.util.function.Supplier; | |
| 5 | ||
| 6 | import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | |
| 8 | import org.springframework.boot.context.properties.EnableConfigurationProperties; | |
| 9 | import org.springframework.context.annotation.Bean; | |
| 10 | import org.springframework.context.annotation.Configuration; | |
| 11 | import org.springframework.core.env.Environment; | |
| 12 | ||
| 13 | import fr.sii.ogham.core.builder.MessagingBuilder; | |
| 14 | import fr.sii.ogham.core.builder.configurer.ConfigurationPhase; | |
| 15 | import fr.sii.ogham.core.service.MessagingService; | |
| 16 | import fr.sii.ogham.core.template.parser.TemplateParser; | |
| 17 | import fr.sii.ogham.spring.common.OghamMimetypeProperties; | |
| 18 | import fr.sii.ogham.spring.common.SpringEnvironmentConfigurer; | |
| 19 | import fr.sii.ogham.spring.common.SpringMessagingConfigurer; | |
| 20 | import fr.sii.ogham.spring.email.OghamEmailProperties; | |
| 21 | import fr.sii.ogham.spring.sms.OghamSmsProperties; | |
| 22 | import fr.sii.ogham.spring.template.OghamCommonTemplateProperties; | |
| 23 | ||
| 24 | //@formatter:off | |
| 25 | @Configuration | |
| 26 | @EnableConfigurationProperties({ | |
| 27 | MessagingProperties.class, | |
| 28 | OghamEmailProperties.class, | |
| 29 | OghamSmsProperties.class, | |
| 30 | OghamMimetypeProperties.class, | |
| 31 | OghamCommonTemplateProperties.class }) | |
| 32 | //@formatter:on | |
| 33 | public class OghamGeneralConfiguration { | |
| 34 | ||
| 35 | /** | |
| 36 | * Configures the Messaging service and the {@link TemplateParser}. A | |
| 37 | * ThymeLeaf parser will be configured. If we find SpringTemplateEngine, we | |
| 38 | * will set it as its template engine implementation. If we find a | |
| 39 | * FreeMarker configuration already configured by spring-boot, we will add a | |
| 40 | * FreeMarker parser. | |
| 41 | * | |
| 42 | * @param builder | |
| 43 | * The builder used to create the messaging service | |
| 44 | * | |
| 45 | * @return A configured messaging service | |
| 46 | */ | |
| 47 | @Bean | |
| 48 | @ConditionalOnMissingBean | |
| 49 | public MessagingService messagingService(MessagingBuilder builder) { | |
| 50 |
2
1. messagingService : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → KILLED 2. messagingService : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → KILLED |
builder.configure(ConfigurationPhase.BEFORE_BUILD); |
| 51 |
2
1. messagingService : replaced return value with null for fr/sii/ogham/spring/general/OghamGeneralConfiguration::messagingService → KILLED 2. messagingService : replaced return value with null for fr/sii/ogham/spring/general/OghamGeneralConfiguration::messagingService → KILLED |
return builder.build(); |
| 52 | } | |
| 53 | ||
| 54 | @Bean | |
| 55 | @ConditionalOnMissingBean | |
| 56 | public Supplier<MessagingBuilder> messagingBuilderFactory() { | |
| 57 |
4
1. lambda$messagingBuilderFactory$0 : replaced return value with null for fr/sii/ogham/spring/general/OghamGeneralConfiguration::lambda$messagingBuilderFactory$0 → KILLED 2. lambda$messagingBuilderFactory$0 : replaced return value with null for fr/sii/ogham/spring/general/OghamGeneralConfiguration::lambda$messagingBuilderFactory$0 → KILLED 3. messagingBuilderFactory : replaced return value with null for fr/sii/ogham/spring/general/OghamGeneralConfiguration::messagingBuilderFactory → KILLED 4. messagingBuilderFactory : replaced return value with null for fr/sii/ogham/spring/general/OghamGeneralConfiguration::messagingBuilderFactory → KILLED |
return () -> new MessagingBuilder(false); |
| 58 | } | |
| 59 | | |
| 60 | @Bean | |
| 61 | @ConditionalOnMissingBean | |
| 62 | public MessagingBuilder defaultMessagingBuilder(Supplier<MessagingBuilder> messagingBuilderFactory, List<SpringMessagingConfigurer> configurers) { | |
| 63 | MessagingBuilder builder = MessagingBuilder.standard(messagingBuilderFactory, false, MessagingBuilder.BASE_PACKAGE); | |
| 64 | for (SpringMessagingConfigurer configurer : configurers) { | |
| 65 | builder.register(configurer, configurer.getOrder()); | |
| 66 | } | |
| 67 |
1
1. defaultMessagingBuilder : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → SURVIVED |
builder.configure(ConfigurationPhase.AFTER_INIT); |
| 68 |
2
1. defaultMessagingBuilder : replaced return value with null for fr/sii/ogham/spring/general/OghamGeneralConfiguration::defaultMessagingBuilder → KILLED 2. defaultMessagingBuilder : replaced return value with null for fr/sii/ogham/spring/general/OghamGeneralConfiguration::defaultMessagingBuilder → KILLED |
return builder; |
| 69 | } | |
| 70 | ||
| 71 | @Bean | |
| 72 | public SpringEnvironmentConfigurer springEnvironmentConfigurer(Environment environment) { | |
| 73 |
2
1. springEnvironmentConfigurer : replaced return value with null for fr/sii/ogham/spring/general/OghamGeneralConfiguration::springEnvironmentConfigurer → KILLED 2. springEnvironmentConfigurer : replaced return value with null for fr/sii/ogham/spring/general/OghamGeneralConfiguration::springEnvironmentConfigurer → KILLED |
return new SpringEnvironmentConfigurer(environment); |
| 74 | } | |
| 75 | ||
| 76 | // @formatter:off | |
| 77 | @Bean | |
| 78 | @ConditionalOnMissingBean(SpringGeneralMessagingConfigurer.class) | |
| 79 | public SpringGeneralMessagingConfigurer springGeneralMessagingConfigurer( | |
| 80 | @Autowired(required = false) MessagingProperties generalProperties, | |
| 81 | @Autowired(required = false) OghamEmailProperties emailProperties, | |
| 82 | @Autowired(required = false) OghamSmsProperties smsProperties, | |
| 83 | @Autowired(required = false) OghamMimetypeProperties mimetypeProperties) { | |
| 84 |
2
1. springGeneralMessagingConfigurer : replaced return value with null for fr/sii/ogham/spring/general/OghamGeneralConfiguration::springGeneralMessagingConfigurer → SURVIVED 2. springGeneralMessagingConfigurer : replaced return value with null for fr/sii/ogham/spring/general/OghamGeneralConfiguration::springGeneralMessagingConfigurer → KILLED |
return new SpringGeneralMessagingConfigurer(generalProperties, emailProperties, smsProperties, mimetypeProperties); |
| 85 | } | |
| 86 | // @formatter:on | |
| 87 | ||
| 88 | } | |
Mutations | ||
| 50 |
1.1 2.2 |
|
| 51 |
1.1 2.2 |
|
| 57 |
1.1 2.2 3.3 4.4 |
|
| 67 |
1.1 |
|
| 68 |
1.1 2.2 |
|
| 73 |
1.1 2.2 |
|
| 84 |
1.1 2.2 |