AbstractMessageAwareFiller.java

1
package fr.sii.ogham.core.filler;
2
3
import java.util.Map;
4
5
import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilderHelper;
6
import fr.sii.ogham.core.exception.filler.FillMessageException;
7
import fr.sii.ogham.core.message.Message;
8
9
/**
10
 * Base class to help to fill a particular {@link Message} type.
11
 * 
12
 * @author Aurélien Baudet
13
 *
14
 * @param <M>
15
 *            the type of the message that the filler is able to handle
16
 */
17
public abstract class AbstractMessageAwareFiller<M> implements MessageFiller {
18
	protected final Map<String, ConfigurationValueBuilderHelper<?, ?>> defaultValues;
19
	private final Class<M> messageType;
20
21
	/**
22
	 * The list of properties is indexed by an alias that is known by the
23
	 * implementation. For example, if the keys is defined like this:
24
	 * 
25
	 * <pre>
26
	 * Map&lt;String, List&lt;String&gt;&gt; keys = new HashMap&lt;&gt;();
27
	 * keys.put("to", valueBuilder.properties("ogham.email.to.default-value"));
28
	 * keys.put("from", valueBuilder.properties("ogham.email.from.default-value", "mail.smtp.from"));
29
	 * </pre>
30
	 * 
31
	 * The implementation can then retrieve real property value using map key
32
	 * (alias):
33
	 * 
34
	 * <pre>
35
	 * getProperty("from");
36
	 * // will return either the value of "ogham.email.from.default-value" or
37
	 * // "mail.smtp.from"
38
	 * </pre>
39
	 * 
40
	 * @param defaultValues
41
	 *            a list of property keys indexed by an alias
42
	 * @param messageType
43
	 *            the class of the message that this implementation can handle
44
	 */
45
	protected AbstractMessageAwareFiller(Map<String, ConfigurationValueBuilderHelper<?, ?>> defaultValues, Class<M> messageType) {
46
		super();
47
		this.defaultValues = defaultValues;
48
		this.messageType = messageType;
49
	}
50
51
	@SuppressWarnings("unchecked")
52
	@Override
53
	public void fill(Message message) throws FillMessageException {
54 5 1. fill : negated conditional → NO_COVERAGE
2. fill : negated conditional → SURVIVED
3. fill : negated conditional → TIMED_OUT
4. fill : negated conditional → KILLED
5. fill : negated conditional → KILLED
		if (messageType.isAssignableFrom(message.getClass())) {
55 5 1. fill : removed call to fr/sii/ogham/core/filler/AbstractMessageAwareFiller::fill → SURVIVED
2. fill : removed call to fr/sii/ogham/core/filler/AbstractMessageAwareFiller::fill → NO_COVERAGE
3. fill : removed call to fr/sii/ogham/core/filler/AbstractMessageAwareFiller::fill → TIMED_OUT
4. fill : removed call to fr/sii/ogham/core/filler/AbstractMessageAwareFiller::fill → KILLED
5. fill : removed call to fr/sii/ogham/core/filler/AbstractMessageAwareFiller::fill → KILLED
			fill((M) message);
56
		}
57
	}
58
59
	protected abstract void fill(M message);
60
61
	/**
62
	 * Return whether the given property alias has at least one property key
63
	 * that is available for resolution, i.e., the value for the given key is
64
	 * not {@code null}.
65
	 * 
66
	 * @param alias
67
	 *            the property alias to resolve
68
	 * @return true if property exists, false otherwise
69
	 */
70
	protected boolean containsProperty(String alias) {
71
		ConfigurationValueBuilderHelper<?, ?> valueBuilder = defaultValues.get(alias);
72 17 1. containsProperty : replaced boolean return with true for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::containsProperty → NO_COVERAGE
2. containsProperty : negated conditional → SURVIVED
3. containsProperty : negated conditional → NO_COVERAGE
4. containsProperty : negated conditional → NO_COVERAGE
5. containsProperty : replaced boolean return with true for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::containsProperty → TIMED_OUT
6. containsProperty : negated conditional → TIMED_OUT
7. containsProperty : negated conditional → TIMED_OUT
8. containsProperty : replaced boolean return with true for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::containsProperty → KILLED
9. containsProperty : replaced boolean return with true for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::containsProperty → KILLED
10. containsProperty : replaced boolean return with true for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::containsProperty → KILLED
11. containsProperty : replaced boolean return with true for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::containsProperty → KILLED
12. containsProperty : negated conditional → KILLED
13. containsProperty : negated conditional → KILLED
14. containsProperty : negated conditional → KILLED
15. containsProperty : negated conditional → KILLED
16. containsProperty : negated conditional → KILLED
17. containsProperty : negated conditional → KILLED
		return valueBuilder != null && valueBuilder.getValue() != null;
73
	}
74
75
	/**
76
	 * Returns the value of first property represented by the provided alias
77
	 * that has a value (not {@code null}).
78
	 * 
79
	 * @param alias
80
	 *            the property alias to resolve
81
	 * @param valueClass
82
	 *            the class of the resulting value
83
	 * @param <T>
84
	 *            the type of the resulting value
85
	 * @return the property value or null
86
	 */
87
	@SuppressWarnings("unchecked")
88
	protected <T> T getProperty(String alias, Class<T> valueClass) {
89
		ConfigurationValueBuilderHelper<?, T> valueBuilder = (ConfigurationValueBuilderHelper<?, T>) defaultValues.get(alias);
90 6 1. getProperty : negated conditional → NO_COVERAGE
2. getProperty : replaced return value with null for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::getProperty → NO_COVERAGE
3. getProperty : negated conditional → KILLED
4. getProperty : negated conditional → KILLED
5. getProperty : replaced return value with null for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::getProperty → KILLED
6. getProperty : replaced return value with null for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::getProperty → KILLED
		return valueBuilder == null ? null : valueBuilder.getValue();
91
	}
92
}

Mutations

54

1.1
Location : fill
Killed by : none
negated conditional → TIMED_OUT

2.2
Location : fill
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : fill
Killed by : oghamall.it.sms.SmsCustomImplTest.simple(oghamall.it.sms.SmsCustomImplTest)
negated conditional → KILLED

4.4
Location : fill
Killed by : none
negated conditional → SURVIVED

5.5
Location : fill
Killed by : oghamcore.ut.sms.SmsFillerSpec
negated conditional → KILLED

55

1.1
Location : fill
Killed by : none
removed call to fr/sii/ogham/core/filler/AbstractMessageAwareFiller::fill → TIMED_OUT

2.2
Location : fill
Killed by : none
removed call to fr/sii/ogham/core/filler/AbstractMessageAwareFiller::fill → SURVIVED

3.3
Location : fill
Killed by : none
removed call to fr/sii/ogham/core/filler/AbstractMessageAwareFiller::fill → NO_COVERAGE

4.4
Location : fill
Killed by : oghamcore.ut.sms.SmsFillerSpec
removed call to fr/sii/ogham/core/filler/AbstractMessageAwareFiller::fill → KILLED

5.5
Location : fill
Killed by : oghamall.it.sms.SmsCustomImplTest.simple(oghamall.it.sms.SmsCustomImplTest)
removed call to fr/sii/ogham/core/filler/AbstractMessageAwareFiller::fill → KILLED

72

1.1
Location : containsProperty
Killed by : oghamcore.ut.sms.SmsFillerSpec
replaced boolean return with true for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::containsProperty → KILLED

2.2
Location : containsProperty
Killed by : oghamall.it.email.EmailSMTPAuthenticationTest.authenticated(oghamall.it.email.EmailSMTPAuthenticationTest)
replaced boolean return with true for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::containsProperty → KILLED

3.3
Location : containsProperty
Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest)
replaced boolean return with true for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::containsProperty → KILLED

4.4
Location : containsProperty
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::containsProperty → TIMED_OUT

5.5
Location : containsProperty
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::containsProperty → NO_COVERAGE

6.6
Location : containsProperty
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
replaced boolean return with true for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::containsProperty → KILLED

7.7
Location : containsProperty
Killed by : oghamall.it.sms.SmsCustomImplTest.simple(oghamall.it.sms.SmsCustomImplTest)
negated conditional → KILLED

8.8
Location : containsProperty
Killed by : oghamcore.ut.sms.SmsFillerSpec
negated conditional → KILLED

9.9
Location : containsProperty
Killed by : none
negated conditional → SURVIVED

10.10
Location : containsProperty
Killed by : none
negated conditional → NO_COVERAGE

11.11
Location : containsProperty
Killed by : none
negated conditional → TIMED_OUT

12.12
Location : containsProperty
Killed by : none
negated conditional → NO_COVERAGE

13.13
Location : containsProperty
Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest)
negated conditional → KILLED

14.14
Location : containsProperty
Killed by : oghamall.it.sms.SmsCustomImplTest.simple(oghamall.it.sms.SmsCustomImplTest)
negated conditional → KILLED

15.15
Location : containsProperty
Killed by : oghamcore.ut.sms.SmsFillerSpec
negated conditional → KILLED

16.16
Location : containsProperty
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
negated conditional → KILLED

17.17
Location : containsProperty
Killed by : none
negated conditional → TIMED_OUT

90

1.1
Location : getProperty
Killed by : oghamcore.ut.sms.SmsFillerSpec
negated conditional → KILLED

2.2
Location : getProperty
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : getProperty
Killed by : oghamall.it.sms.SmsCustomImplTest.simple(oghamall.it.sms.SmsCustomImplTest)
negated conditional → KILLED

4.4
Location : getProperty
Killed by : oghamcore.ut.sms.SmsFillerSpec
replaced return value with null for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::getProperty → KILLED

5.5
Location : getProperty
Killed by : oghamall.it.sms.SmsCustomImplTest.simple(oghamall.it.sms.SmsCustomImplTest)
replaced return value with null for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::getProperty → KILLED

6.6
Location : getProperty
Killed by : none
replaced return value with null for fr/sii/ogham/core/filler/AbstractMessageAwareFiller::getProperty → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT OGHAM