1 | package fr.sii.ogham.core.sender; | |
2 | ||
3 | import static fr.sii.ogham.core.util.LogUtils.logString; | |
4 | ||
5 | import org.slf4j.Logger; | |
6 | import org.slf4j.LoggerFactory; | |
7 | ||
8 | import fr.sii.ogham.core.exception.MessageException; | |
9 | import fr.sii.ogham.core.filler.MessageFiller; | |
10 | import fr.sii.ogham.core.message.Message; | |
11 | ||
12 | /** | |
13 | * Decorator sender that adds extra information to the message. This sender | |
14 | * relies on a {@link MessageFiller} to add extra information on the message. | |
15 | * Once filler has done its job, this sender delegates the real sending to the | |
16 | * decorated sender. | |
17 | * | |
18 | * @author Aurélien Baudet | |
19 | * | |
20 | */ | |
21 | public class FillerSender implements ConditionalSender { | |
22 | private static final Logger LOG = LoggerFactory.getLogger(FillerSender.class); | |
23 | ||
24 | /** | |
25 | * The filler that will add additional information to the message before | |
26 | * sending it | |
27 | */ | |
28 | private MessageFiller filler; | |
29 | ||
30 | /** | |
31 | * The decorated sender that will be called once the filler has added extra | |
32 | * information on the message | |
33 | */ | |
34 | private MessageSender delegate; | |
35 | ||
36 | /** | |
37 | * Initialize the sender with the filler instance and the decorated sender. | |
38 | * | |
39 | * @param filler | |
40 | * the filler that will add additional information on the message | |
41 | * before sending it | |
42 | * @param delegate | |
43 | * the decorated sender that will really send the message | |
44 | */ | |
45 | public FillerSender(MessageFiller filler, MessageSender delegate) { | |
46 | super(); | |
47 | this.filler = filler; | |
48 | this.delegate = delegate; | |
49 | } | |
50 | ||
51 | @Override | |
52 | public void send(Message message) throws MessageException { | |
53 | LOG.debug("Filling message {} with {} filler", logString(message), filler); | |
54 | // fill message with automatic values | |
55 |
4
1. send : removed call to fr/sii/ogham/core/filler/MessageFiller::fill → SURVIVED 2. send : removed call to fr/sii/ogham/core/filler/MessageFiller::fill → NO_COVERAGE 3. send : removed call to fr/sii/ogham/core/filler/MessageFiller::fill → TIMED_OUT 4. send : removed call to fr/sii/ogham/core/filler/MessageFiller::fill → KILLED |
filler.fill(message); |
56 | LOG.debug("Message {} is filled, send it using {}", logString(message), delegate); | |
57 | // send message | |
58 |
6
1. send : removed call to fr/sii/ogham/core/sender/MessageSender::send → NO_COVERAGE 2. send : removed call to fr/sii/ogham/core/sender/MessageSender::send → TIMED_OUT 3. send : removed call to fr/sii/ogham/core/sender/MessageSender::send → KILLED 4. send : removed call to fr/sii/ogham/core/sender/MessageSender::send → KILLED 5. send : removed call to fr/sii/ogham/core/sender/MessageSender::send → KILLED 6. send : removed call to fr/sii/ogham/core/sender/MessageSender::send → KILLED |
delegate.send(message); |
59 | } | |
60 | ||
61 | @Override | |
62 | public boolean supports(Message message) { | |
63 |
6
1. supports : negated conditional → SURVIVED 2. supports : negated conditional → NO_COVERAGE 3. supports : negated conditional → TIMED_OUT 4. supports : negated conditional → KILLED 5. supports : negated conditional → KILLED 6. supports : negated conditional → KILLED |
if (delegate instanceof ConditionalSender) { |
64 |
12
1. supports : replaced boolean return with false for fr/sii/ogham/core/sender/FillerSender::supports → NO_COVERAGE 2. supports : replaced boolean return with true for fr/sii/ogham/core/sender/FillerSender::supports → NO_COVERAGE 3. supports : replaced boolean return with true for fr/sii/ogham/core/sender/FillerSender::supports → SURVIVED 4. supports : replaced boolean return with false for fr/sii/ogham/core/sender/FillerSender::supports → TIMED_OUT 5. supports : replaced boolean return with true for fr/sii/ogham/core/sender/FillerSender::supports → TIMED_OUT 6. supports : replaced boolean return with false for fr/sii/ogham/core/sender/FillerSender::supports → KILLED 7. supports : replaced boolean return with false for fr/sii/ogham/core/sender/FillerSender::supports → KILLED 8. supports : replaced boolean return with false for fr/sii/ogham/core/sender/FillerSender::supports → KILLED 9. supports : replaced boolean return with false for fr/sii/ogham/core/sender/FillerSender::supports → KILLED 10. supports : replaced boolean return with true for fr/sii/ogham/core/sender/FillerSender::supports → KILLED 11. supports : replaced boolean return with true for fr/sii/ogham/core/sender/FillerSender::supports → KILLED 12. supports : replaced boolean return with true for fr/sii/ogham/core/sender/FillerSender::supports → KILLED |
return ((ConditionalSender) delegate).supports(message); |
65 | } | |
66 |
1
1. supports : replaced boolean return with false for fr/sii/ogham/core/sender/FillerSender::supports → NO_COVERAGE |
return true; |
67 | } | |
68 | ||
69 | @Override | |
70 | public String toString() { | |
71 | StringBuilder builder = new StringBuilder(); | |
72 | builder.append("FillerSender [filler=").append(filler).append(", delegate=").append(delegate).append("]"); | |
73 |
3
1. toString : replaced return value with "" for fr/sii/ogham/core/sender/FillerSender::toString → SURVIVED 2. toString : replaced return value with "" for fr/sii/ogham/core/sender/FillerSender::toString → NO_COVERAGE 3. toString : replaced return value with "" for fr/sii/ogham/core/sender/FillerSender::toString → TIMED_OUT |
return builder.toString(); |
74 | } | |
75 | } | |
Mutations | ||
55 |
1.1 2.2 3.3 4.4 |
|
58 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
63 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
64 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 12.12 |
|
66 |
1.1 |
|
73 |
1.1 2.2 3.3 |