1
|
|
package fr.sii.ogham.sms.builder; |
2
|
|
|
3
|
|
import fr.sii.ogham.core.builder.Builder; |
4
|
|
import fr.sii.ogham.core.builder.context.BuildContext; |
5
|
|
import fr.sii.ogham.core.builder.context.DefaultBuildContext; |
6
|
|
import fr.sii.ogham.core.builder.env.EnvironmentBuilder; |
7
|
|
import fr.sii.ogham.core.fluent.AbstractParent; |
8
|
|
import fr.sii.ogham.sms.message.PhoneNumber; |
9
|
|
import fr.sii.ogham.sms.message.addressing.AddressedPhoneNumber; |
10
|
|
import fr.sii.ogham.sms.message.addressing.translator.CompositePhoneNumberTranslator; |
11
|
|
import fr.sii.ogham.sms.message.addressing.translator.PhoneNumberHandler; |
12
|
|
import fr.sii.ogham.sms.message.addressing.translator.PhoneNumberTranslator; |
13
|
|
|
14
|
|
/** |
15
|
|
* Configures the recipient phone number conversion (from a {@link PhoneNumber} |
16
|
|
* to an {@link AddressedPhoneNumber}). |
17
|
|
* |
18
|
|
* The {@link PhoneNumber} is used by the developer to provide a simple phone |
19
|
|
* number without knowing how phone number works (no need to handle formats, |
20
|
|
* addressing, countries...). The {@link AddressedPhoneNumber} is used by Ogham |
21
|
|
* implementations to have a phone number that is usable by a technical system. |
22
|
|
* |
23
|
|
* @author Aurélien Baudet |
24
|
|
* |
25
|
|
*/ |
26
|
|
public class RecipientNumberBuilder extends AbstractParent<PhoneNumbersBuilder> implements Builder<PhoneNumberTranslator> { |
27
|
|
private final BuildContext buildContext; |
28
|
|
private RecipientNumberFormatBuilder formatBuilder; |
29
|
|
private PhoneNumberTranslator customTranslator; |
30
|
|
|
31
|
|
/** |
32
|
|
* Default constructor used without all Ogham work. |
33
|
|
* |
34
|
|
* <strong>WARNING: use is only if you know what you are doing !</strong> |
35
|
|
*/ |
36
|
|
public RecipientNumberBuilder() { |
37
|
|
this(null, new DefaultBuildContext()); |
38
|
|
} |
39
|
|
|
40
|
|
/** |
41
|
|
* Initializes the builder with a parent builder. The parent builder is used |
42
|
|
* when calling {@link #and()} method. The {@link EnvironmentBuilder} is |
43
|
|
* used to evaluate properties when {@link #build()} method is called. |
44
|
|
* |
45
|
|
* @param parent |
46
|
|
* the parent builder |
47
|
|
* @param buildContext |
48
|
|
* for registering instances and property evaluation |
49
|
|
*/ |
50
|
|
public RecipientNumberBuilder(PhoneNumbersBuilder parent, BuildContext buildContext) { |
51
|
|
super(parent); |
52
|
|
this.buildContext = buildContext; |
53
|
|
} |
54
|
|
|
55
|
|
/** |
56
|
|
* Defines which standard conversions may be applied on the phone number to |
57
|
|
* convert it from a {@link PhoneNumber} to an {@link AddressedPhoneNumber}. |
58
|
|
* |
59
|
|
* @return the builder to configure standard phone number conversions |
60
|
|
*/ |
61
|
|
public RecipientNumberFormatBuilder format() { |
62
|
8
1. format : negated conditional → NO_COVERAGE
2. format : negated conditional → TIMED_OUT
3. format : negated conditional → KILLED
4. format : negated conditional → KILLED
5. format : negated conditional → KILLED
6. format : negated conditional → KILLED
7. format : negated conditional → KILLED
8. format : negated conditional → KILLED
|
if (formatBuilder == null) { |
63
|
|
formatBuilder = new RecipientNumberFormatBuilder(this, buildContext); |
64
|
|
} |
65
|
8
1. format : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → NO_COVERAGE
2. format : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED
3. format : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED
4. format : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED
5. format : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED
6. format : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED
7. format : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED
8. format : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED
|
return formatBuilder; |
66
|
|
} |
67
|
|
|
68
|
|
/** |
69
|
|
* Overrides the standard phone number conversions by the provided handler. |
70
|
|
* |
71
|
|
* <p> |
72
|
|
* If you call this method several times, only the last custom handler is |
73
|
|
* used. If you need to apply several conversions, you can use |
74
|
|
* {@link CompositePhoneNumberTranslator} implementation that delegates to |
75
|
|
* {@link PhoneNumberHandler}s. |
76
|
|
* |
77
|
|
* @param handler |
78
|
|
* the handler to use |
79
|
|
* @return this instance for fluent chaining |
80
|
|
*/ |
81
|
|
public RecipientNumberBuilder convert(PhoneNumberTranslator handler) { |
82
|
|
this.customTranslator = handler; |
83
|
1
1. convert : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::convert → NO_COVERAGE
|
return this; |
84
|
|
} |
85
|
|
|
86
|
|
@Override |
87
|
|
public PhoneNumberTranslator build() { |
88
|
6
1. build : negated conditional → SURVIVED
2. build : negated conditional → NO_COVERAGE
3. build : negated conditional → KILLED
4. build : negated conditional → KILLED
5. build : negated conditional → KILLED
6. build : negated conditional → KILLED
|
if (customTranslator != null) { |
89
|
1
1. build : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → NO_COVERAGE
|
return customTranslator; |
90
|
|
} |
91
|
6
1. build : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → NO_COVERAGE
2. build : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → SURVIVED
3. build : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → KILLED
4. build : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → KILLED
5. build : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → KILLED
6. build : replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → KILLED
|
return formatBuilder.build(); |
92
|
|
} |
93
|
|
} |
| | Mutations |
62 |
|
1.1 Location : format Killed by : oghamall.it.sms.message.addressing.translator.ReceiverPhoneNumberTranslatorTest.translateNull(oghamall.it.sms.message.addressing.translator.ReceiverPhoneNumberTranslatorTest) negated conditional → KILLED 2.2 Location : format Killed by : none negated conditional → NO_COVERAGE 3.3 Location : format Killed by : none negated conditional → TIMED_OUT 4.4 Location : format Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests) negated conditional → KILLED 5.5 Location : format Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest) negated conditional → KILLED 6.6 Location : format Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec negated conditional → KILLED 7.7 Location : format Killed by : oghamcore.it.core.service.CleanupTest.manualCleanupShouldAutomaticallyCleanTheSenders(oghamcore.it.core.service.CleanupTest) negated conditional → KILLED 8.8 Location : format Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest) negated conditional → KILLED
|
65 |
|
1.1 Location : format Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest) replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED 2.2 Location : format Killed by : oghamall.it.sms.message.addressing.translator.ReceiverPhoneNumberTranslatorTest.translateNull(oghamall.it.sms.message.addressing.translator.ReceiverPhoneNumberTranslatorTest) replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED 3.3 Location : format Killed by : none replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → NO_COVERAGE 4.4 Location : format Killed by : oghamcore.it.core.service.CleanupTest.manualCleanupShouldAutomaticallyCleanTheSenders(oghamcore.it.core.service.CleanupTest) replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED 5.5 Location : format Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests.oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence(oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests) replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED 6.6 Location : format Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest) replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED 7.7 Location : format Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests) replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED 8.8 Location : format Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::format → KILLED
|
83 |
|
1.1 Location : convert Killed by : none replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::convert → NO_COVERAGE
|
88 |
|
1.1 Location : build Killed by : oghamspringbootv2autoconfigure.it.StaticMethodAccessTest.smsUsingFreemarkerTemplateAndStaticMethodAccessDisabledShouldFail(oghamspringbootv2autoconfigure.it.StaticMethodAccessTest) negated conditional → KILLED 2.2 Location : build Killed by : oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest.smsUsingFreemarkerTemplateShouldResolveBeans(oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest) negated conditional → KILLED 3.3 Location : build Killed by : oghamcloudhopper.it.ConnectionFailureTest.invalidSystemId(oghamcloudhopper.it.ConnectionFailureTest) negated conditional → KILLED 4.4 Location : build Killed by : oghamall.it.sms.SmsCustomImplTest.simple(oghamall.it.sms.SmsCustomImplTest) negated conditional → KILLED 5.5 Location : build Killed by : none negated conditional → SURVIVED 6.6 Location : build Killed by : none negated conditional → NO_COVERAGE
|
89 |
|
1.1 Location : build Killed by : none replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → NO_COVERAGE
|
91 |
|
1.1 Location : build Killed by : oghamcloudhopper.it.ConnectionFailureTest.invalidSystemId(oghamcloudhopper.it.ConnectionFailureTest) replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → KILLED 2.2 Location : build Killed by : none replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → NO_COVERAGE 3.3 Location : build Killed by : oghamspringbootv2autoconfigure.it.StaticMethodAccessTest.smsUsingFreemarkerTemplateAndStaticMethodAccessDisabledShouldFail(oghamspringbootv2autoconfigure.it.StaticMethodAccessTest) replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → KILLED 4.4 Location : build Killed by : oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest.smsUsingFreemarkerTemplateShouldResolveBeans(oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest) replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → KILLED 5.5 Location : build Killed by : oghamall.it.sms.SmsCustomImplTest.simple(oghamall.it.sms.SmsCustomImplTest) replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → KILLED 6.6 Location : build Killed by : none replaced return value with null for fr/sii/ogham/sms/builder/RecipientNumberBuilder::build → SURVIVED
|