1
|
|
package fr.sii.ogham.core.builder.env; |
2
|
|
|
3
|
|
import java.util.ArrayList; |
4
|
|
import java.util.List; |
5
|
|
|
6
|
|
import fr.sii.ogham.core.builder.configuration.MayOverride; |
7
|
|
import fr.sii.ogham.core.convert.Converter; |
8
|
|
import fr.sii.ogham.core.convert.ConverterRegistry; |
9
|
|
import fr.sii.ogham.core.convert.DefaultConverter; |
10
|
|
import fr.sii.ogham.core.convert.SupportingConverter; |
11
|
|
import fr.sii.ogham.core.fluent.AbstractParent; |
12
|
|
|
13
|
|
/** |
14
|
|
* A {@link ConverterBuilder} that builds the converter: |
15
|
|
* <ul> |
16
|
|
* <li>If a custom converter is defined, use it</li> |
17
|
|
* <li>If no custom converter, use {@link DefaultConverter}</li> |
18
|
|
* <li>If {@link DefaultConverter} or custom converter that also implements |
19
|
|
* {@link ConverterRegistry}, register all previously registered |
20
|
|
* {@link SupportingConverter}s</li> |
21
|
|
* </ul> |
22
|
|
* |
23
|
|
* @author Aurélien Baudet |
24
|
|
* |
25
|
|
* @param <P> |
26
|
|
* the type of the parent builder (when calling {@link #and()} |
27
|
|
* method) |
28
|
|
*/ |
29
|
|
public class SimpleConverterBuilder<P> extends AbstractParent<P> implements ConverterBuilder<P> { |
30
|
|
private List<SupportingConverter> delegates; |
31
|
|
private Converter converter; |
32
|
|
private Converter defaultConverter; |
33
|
|
|
34
|
|
/** |
35
|
|
* Initializes the builder with the provided parent. The list of |
36
|
|
* {@link SupportingConverter}s is initialized with an empty list. |
37
|
|
* |
38
|
|
* @param parent |
39
|
|
* the parent builder |
40
|
|
*/ |
41
|
|
public SimpleConverterBuilder(P parent) { |
42
|
|
super(parent); |
43
|
|
delegates = new ArrayList<>(); |
44
|
|
} |
45
|
|
|
46
|
|
/** |
47
|
|
* Copies values from other parameter to this instance. |
48
|
|
* |
49
|
|
* @param parent |
50
|
|
* the parent builder |
51
|
|
* @param other |
52
|
|
* the other builder that needs to be copied |
53
|
|
*/ |
54
|
|
public SimpleConverterBuilder(P parent, SimpleConverterBuilder<?> other) { |
55
|
|
this(parent); |
56
|
|
this.converter = other.converter; |
57
|
|
this.delegates = new ArrayList<>(other.delegates); |
58
|
|
} |
59
|
|
|
60
|
|
@Override |
61
|
|
public SimpleConverterBuilder<P> override(Converter converter) { |
62
|
|
this.converter = converter; |
63
|
2
1. override : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::override → SURVIVED
2. override : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::override → NO_COVERAGE
|
return this; |
64
|
|
} |
65
|
|
|
66
|
|
@Override |
67
|
|
public SimpleConverterBuilder<P> register(SupportingConverter converter) { |
68
|
|
delegates.add(converter); |
69
|
2
1. register : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::register → SURVIVED
2. register : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::register → NO_COVERAGE
|
return this; |
70
|
|
} |
71
|
|
|
72
|
|
@Override |
73
|
|
public ConverterBuilder<P> defaultConverter(MayOverride<Converter> converter) { |
74
|
|
defaultConverter = converter.override(defaultConverter); |
75
|
2
1. defaultConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::defaultConverter → NO_COVERAGE
2. defaultConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::defaultConverter → SURVIVED
|
return this; |
76
|
|
} |
77
|
|
|
78
|
|
/** |
79
|
|
* Build the converter: |
80
|
|
* <ul> |
81
|
|
* <li>If a custom converter is defined, use it</li> |
82
|
|
* <li>If no custom converter, use {@link DefaultConverter}</li> |
83
|
|
* <li>If {@link DefaultConverter} or custom converter that also implements |
84
|
|
* {@link ConverterRegistry}, register all previously registered |
85
|
|
* {@link SupportingConverter}s</li> |
86
|
|
* </ul> |
87
|
|
*/ |
88
|
|
@Override |
89
|
|
public Converter build() { |
90
|
|
Converter builtConverter = buildBaseConverter(); |
91
|
3
1. build : negated conditional → NO_COVERAGE
2. build : negated conditional → SURVIVED
3. build : negated conditional → KILLED
|
if (builtConverter instanceof ConverterRegistry) { |
92
|
|
for (SupportingConverter conv : delegates) { |
93
|
|
((ConverterRegistry) builtConverter).register(conv); |
94
|
|
} |
95
|
|
} |
96
|
8
1. build : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → NO_COVERAGE
2. build : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED
3. build : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED
4. build : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED
5. build : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED
6. build : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED
7. build : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED
8. build : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED
|
return builtConverter; |
97
|
|
} |
98
|
|
|
99
|
|
private Converter buildBaseConverter() { |
100
|
8
1. buildBaseConverter : negated conditional → NO_COVERAGE
2. buildBaseConverter : negated conditional → TIMED_OUT
3. buildBaseConverter : negated conditional → KILLED
4. buildBaseConverter : negated conditional → KILLED
5. buildBaseConverter : negated conditional → KILLED
6. buildBaseConverter : negated conditional → KILLED
7. buildBaseConverter : negated conditional → KILLED
8. buildBaseConverter : negated conditional → KILLED
|
if (converter != null) { |
101
|
2
1. buildBaseConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → NO_COVERAGE
2. buildBaseConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED
|
return converter; |
102
|
|
} |
103
|
4
1. buildBaseConverter : negated conditional → SURVIVED
2. buildBaseConverter : negated conditional → NO_COVERAGE
3. buildBaseConverter : negated conditional → KILLED
4. buildBaseConverter : negated conditional → KILLED
|
if (defaultConverter != null) { |
104
|
8
1. buildBaseConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → NO_COVERAGE
2. buildBaseConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED
3. buildBaseConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED
4. buildBaseConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED
5. buildBaseConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED
6. buildBaseConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED
7. buildBaseConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED
8. buildBaseConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED
|
return defaultConverter; |
105
|
|
} |
106
|
3
1. buildBaseConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → NO_COVERAGE
2. buildBaseConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED
3. buildBaseConverter : replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED
|
return new DefaultConverter(); |
107
|
|
} |
108
|
|
} |
| | Mutations |
63 |
|
1.1 Location : override Killed by : none replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::override → SURVIVED 2.2 Location : override Killed by : none replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::override → NO_COVERAGE
|
69 |
|
1.1 Location : register Killed by : none replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::register → SURVIVED 2.2 Location : register Killed by : none replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::register → NO_COVERAGE
|
75 |
|
1.1 Location : defaultConverter Killed by : none replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::defaultConverter → NO_COVERAGE 2.2 Location : defaultConverter Killed by : none replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::defaultConverter → SURVIVED
|
91 |
|
1.1 Location : build Killed by : none negated conditional → NO_COVERAGE 2.2 Location : build Killed by : oghamcore.it.core.convert.CustomConverterTest.asDeveloperIUseARegisterCustomConverter(oghamcore.it.core.convert.CustomConverterTest) negated conditional → KILLED 3.3 Location : build Killed by : none negated conditional → SURVIVED
|
96 |
|
1.1 Location : build Killed by : oghamspringbootv2autoconfigure.it.StaticMethodAccessTest.emailUsingFreemarkerTemplateShouldBeAbleToCallStaticMethodsWithCustomVariableName(oghamspringbootv2autoconfigure.it.StaticMethodAccessTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED 2.2 Location : build Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED 3.3 Location : build Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED 4.4 Location : build Killed by : oghamspringbootv1autoconfigure.it.StaticMethodsAccessTest.emailUsingFreemarkerTemplateShouldBeAbleToCallStaticMethods(oghamspringbootv1autoconfigure.it.StaticMethodsAccessTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED 5.5 Location : build Killed by : none replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → NO_COVERAGE 6.6 Location : build Killed by : oghamjavamail.it.builder.JavaMailCustomConfigurationTest.oghamPropertyShouldOverride(oghamjavamail.it.builder.JavaMailCustomConfigurationTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED 7.7 Location : build Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED 8.8 Location : build Killed by : oghamcore.it.core.convert.CustomConverterTest.asDeveloperIUseMyCustomConverter(oghamcore.it.core.convert.CustomConverterTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::build → KILLED
|
100 |
|
1.1 Location : buildBaseConverter Killed by : oghamspringbootv1autoconfigure.it.StaticMethodsAccessTest.emailUsingFreemarkerTemplateShouldBeAbleToCallStaticMethods(oghamspringbootv1autoconfigure.it.StaticMethodsAccessTest) negated conditional → KILLED 2.2 Location : buildBaseConverter Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec negated conditional → KILLED 3.3 Location : buildBaseConverter Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest) negated conditional → KILLED 4.4 Location : buildBaseConverter Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest) negated conditional → KILLED 5.5 Location : buildBaseConverter Killed by : oghamjavamail.it.builder.JavaMailCustomConfigurationTest.oghamPropertyShouldOverride(oghamjavamail.it.builder.JavaMailCustomConfigurationTest) negated conditional → KILLED 6.6 Location : buildBaseConverter Killed by : none negated conditional → NO_COVERAGE 7.7 Location : buildBaseConverter Killed by : oghamcore.it.core.convert.CustomConverterTest.asDeveloperIUseMyCustomConverter(oghamcore.it.core.convert.CustomConverterTest) negated conditional → KILLED 8.8 Location : buildBaseConverter Killed by : none negated conditional → TIMED_OUT
|
101 |
|
1.1 Location : buildBaseConverter Killed by : oghamcore.it.core.convert.CustomConverterTest.asDeveloperIUseMyCustomConverter(oghamcore.it.core.convert.CustomConverterTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED 2.2 Location : buildBaseConverter Killed by : none replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → NO_COVERAGE
|
103 |
|
1.1 Location : buildBaseConverter Killed by : none negated conditional → SURVIVED 2.2 Location : buildBaseConverter Killed by : oghamjavamail.it.builder.JavaMailCustomConfigurationTest.oghamPropertyShouldOverride(oghamjavamail.it.builder.JavaMailCustomConfigurationTest) negated conditional → KILLED 3.3 Location : buildBaseConverter Killed by : none negated conditional → NO_COVERAGE 4.4 Location : buildBaseConverter Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest) negated conditional → KILLED
|
104 |
|
1.1 Location : buildBaseConverter Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED 2.2 Location : buildBaseConverter Killed by : none replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → NO_COVERAGE 3.3 Location : buildBaseConverter Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED 4.4 Location : buildBaseConverter Killed by : oghamall.it.configuration.ThymeleafConfigurationTest.asDeveloperIDefineCustomPathPrefixInMyOwnCode(oghamall.it.configuration.ThymeleafConfigurationTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED 5.5 Location : buildBaseConverter Killed by : oghamspringbootv2autoconfigure.it.StaticMethodAccessTest.emailUsingFreemarkerTemplateShouldBeAbleToCallStaticMethodsWithCustomVariableName(oghamspringbootv2autoconfigure.it.StaticMethodAccessTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED 6.6 Location : buildBaseConverter Killed by : oghamcore.it.core.sender.AutoRetryTest.smsSentSuccessfullyOnFirstExecution(oghamcore.it.core.sender.AutoRetryTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED 7.7 Location : buildBaseConverter Killed by : oghamspringbootv1autoconfigure.it.StaticMethodsAccessTest.emailUsingFreemarkerTemplateShouldBeAbleToCallStaticMethods(oghamspringbootv1autoconfigure.it.StaticMethodsAccessTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED 8.8 Location : buildBaseConverter Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED
|
106 |
|
1.1 Location : buildBaseConverter Killed by : none replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → NO_COVERAGE 2.2 Location : buildBaseConverter Killed by : oghamjavamail.it.builder.JavaMailCustomConfigurationTest.oghamPropertyShouldOverride(oghamjavamail.it.builder.JavaMailCustomConfigurationTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED 3.3 Location : buildBaseConverter Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest) replaced return value with null for fr/sii/ogham/core/builder/env/SimpleConverterBuilder::buildBaseConverter → KILLED
|