CidBuilder.java

1
package fr.sii.ogham.email.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.fluent.AbstractParent;
6
import fr.sii.ogham.core.id.generator.IdGenerator;
7
import fr.sii.ogham.core.id.generator.SequentialIdGenerator;
8
import fr.sii.ogham.email.message.Email;
9
10
/**
11
 * Configures how images are attached to {@link Email}s.
12
 * 
13
 * Image defined in a html must be referenced by a
14
 * <a href="https://tools.ietf.org/html/rfc4021#section-2.2.2">Content-ID (or
15
 * CID)</a> if the image is attached to the email. You can define how CIDs are
16
 * generated.
17
 * 
18
 * 
19
 * @author Aurélien Baudet
20
 *
21
 */
22
public class CidBuilder extends AbstractParent<AttachImageBuilder> implements Builder<IdGenerator> {
23
	private final BuildContext buildContext;
24
	private IdGenerator idGenerator;
25
	private boolean sequential;
26
27
	/**
28
	 * Initializes with the parent (used when calling {@link #and()} method for
29
	 * fluent chaining).
30
	 * 
31
	 * @param parent
32
	 *            the parent builder
33
	 * @param buildContext
34
	 *            for registering instances and property evaluation
35
	 */
36
	public CidBuilder(AttachImageBuilder parent, BuildContext buildContext) {
37
		super(parent);
38
		this.buildContext = buildContext;
39
	}
40
41
	/**
42
	 * Image defined in a html must be referenced by a
43
	 * <a href="https://tools.ietf.org/html/rfc4021#section-2.2.2">Content-ID
44
	 * (or CID)</a> if the image is attached to the email. You can define how
45
	 * CIDs are generated by defining an {@link IdGenerator}.
46
	 * 
47
	 * <p>
48
	 * Use this method to provide custom CID generation strategy.
49
	 * 
50
	 * <p>
51
	 * Any call to this method preempts any other configuration.
52
	 * 
53
	 * <p>
54
	 * If this method is called several times, only the last provided value is
55
	 * used.
56
	 * 
57
	 * <p>
58
	 * If {@code null} value is provided, it disables custom generator.
59
	 * 
60
	 * @param generator
61
	 *            the cid generator
62
	 * @return this instance for fluent chaining
63
	 */
64
	public CidBuilder generator(IdGenerator generator) {
65
		idGenerator = generator;
66 2 1. generator : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::generator → NO_COVERAGE
2. generator : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::generator → KILLED
		return this;
67
	}
68
69
	/**
70
	 * Image defined in a html must be referenced by a
71
	 * <a href="https://tools.ietf.org/html/rfc4021#section-2.2.2">Content-ID
72
	 * (or CID)</a> if the image is attached to the email. You can define how
73
	 * CIDs are generated by defining an {@link IdGenerator}.
74
	 * 
75
	 * <p>
76
	 * Enables basic sequential CID generation: 0, 1, 2, 3...
77
	 * 
78
	 * 
79
	 * @return this instance for fluent chaining
80
	 */
81
	public CidBuilder sequential() {
82
		this.sequential = true;
83 8 1. sequential : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → NO_COVERAGE
2. sequential : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED
3. sequential : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED
4. sequential : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED
5. sequential : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED
6. sequential : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED
7. sequential : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED
8. sequential : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED
		return this;
84
	}
85
86
	@Override
87
	public IdGenerator build() {
88 8 1. build : negated conditional → NO_COVERAGE
2. build : negated conditional → KILLED
3. build : negated conditional → KILLED
4. build : negated conditional → KILLED
5. build : negated conditional → KILLED
6. build : negated conditional → KILLED
7. build : negated conditional → KILLED
8. build : negated conditional → KILLED
		if (idGenerator != null) {
89 2 1. build : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → NO_COVERAGE
2. build : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED
			return idGenerator;
90
		}
91 8 1. build : negated conditional → NO_COVERAGE
2. build : negated conditional → KILLED
3. build : negated conditional → KILLED
4. build : negated conditional → KILLED
5. build : negated conditional → KILLED
6. build : negated conditional → KILLED
7. build : negated conditional → KILLED
8. build : negated conditional → KILLED
		if (sequential) {
92 8 1. build : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → NO_COVERAGE
2. build : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED
3. build : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED
4. build : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED
5. build : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED
6. build : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED
7. build : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED
8. build : replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED
			return buildContext.register(new SequentialIdGenerator());
93
		}
94
		return null;
95
	}
96
}

Mutations

66

1.1
Location : generator
Killed by : oghamall.it.email.EmailSMTPDefaultsTest.invalidTemplate(oghamall.it.email.EmailSMTPDefaultsTest)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::generator → KILLED

2.2
Location : generator
Killed by : none
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::generator → NO_COVERAGE

83

1.1
Location : sequential
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED

2.2
Location : sequential
Killed by : oghamcore.it.core.service.CleanupTest.manualCleanupShouldAutomaticallyCleanTheSenders(oghamcore.it.core.service.CleanupTest)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED

3.3
Location : sequential
Killed by : oghamall.it.html.translator.JsoupInlineCssTranslatorTest.notHtml(oghamall.it.html.translator.JsoupInlineCssTranslatorTest)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED

4.4
Location : sequential
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED

5.5
Location : sequential
Killed by : none
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → NO_COVERAGE

6.6
Location : sequential
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED

7.7
Location : sequential
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests.oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence(oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED

8.8
Location : sequential
Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::sequential → KILLED

88

1.1
Location : build
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests.oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence(oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests)
negated conditional → KILLED

2.2
Location : build
Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest)
negated conditional → KILLED

3.3
Location : build
Killed by : oghamcore.it.core.service.CleanupTest.manualCleanupShouldAutomaticallyCleanTheSenders(oghamcore.it.core.service.CleanupTest)
negated conditional → KILLED

4.4
Location : build
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
negated conditional → KILLED

5.5
Location : build
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
negated conditional → KILLED

6.6
Location : build
Killed by : none
negated conditional → NO_COVERAGE

7.7
Location : build
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
negated conditional → KILLED

8.8
Location : build
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredAndImageInliningEnabledButUnconfiguredResourceResolutionCantInlineImages(oghamall.it.configuration.EmptyBuilderTest)
negated conditional → KILLED

89

1.1
Location : build
Killed by : none
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → NO_COVERAGE

2.2
Location : build
Killed by : oghamall.it.email.EmailSMTPDefaultsTest.invalidTemplate(oghamall.it.email.EmailSMTPDefaultsTest)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED

91

1.1
Location : build
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
negated conditional → KILLED

2.2
Location : build
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
negated conditional → KILLED

3.3
Location : build
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
negated conditional → KILLED

4.4
Location : build
Killed by : none
negated conditional → NO_COVERAGE

5.5
Location : build
Killed by : oghamcore.it.core.service.CleanupTest.manualCleanupShouldAutomaticallyCleanTheSenders(oghamcore.it.core.service.CleanupTest)
negated conditional → KILLED

6.6
Location : build
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredAndImageInliningEnabledButUnconfiguredResourceResolutionCantInlineImages(oghamall.it.configuration.EmptyBuilderTest)
negated conditional → KILLED

7.7
Location : build
Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest)
negated conditional → KILLED

8.8
Location : build
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests.oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence(oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests)
negated conditional → KILLED

92

1.1
Location : build
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests.oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence(oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED

2.2
Location : build
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED

3.3
Location : build
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredAndImageInliningEnabledButUnconfiguredResourceResolutionCantInlineImages(oghamall.it.configuration.EmptyBuilderTest)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED

4.4
Location : build
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED

5.5
Location : build
Killed by : none
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → NO_COVERAGE

6.6
Location : build
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED

7.7
Location : build
Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED

8.8
Location : build
Killed by : oghamcore.it.core.service.CleanupTest.manualCleanupShouldAutomaticallyCleanTheSenders(oghamcore.it.core.service.CleanupTest)
replaced return value with null for fr/sii/ogham/email/builder/CidBuilder::build → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM