FillerSender.java

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 1 1. send : removed call to fr/sii/ogham/core/filler/MessageFiller::fill → RUN_ERROR
		filler.fill(message);
56
		LOG.debug("Message {} is filled, send it using {}", logString(message), delegate);
57
		// send message
58 1 1. send : removed call to fr/sii/ogham/core/sender/MessageSender::send → RUN_ERROR
		delegate.send(message);
59
	}
60
61
	@Override
62
	public boolean supports(Message message) {
63 1 1. supports : negated conditional → RUN_ERROR
		if (delegate instanceof ConditionalSender) {
64 2 1. supports : replaced boolean return with false for fr/sii/ogham/core/sender/FillerSender::supports → RUN_ERROR
2. supports : replaced boolean return with true for fr/sii/ogham/core/sender/FillerSender::supports → RUN_ERROR
			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 1 1. toString : replaced return value with "" for fr/sii/ogham/core/sender/FillerSender::toString → RUN_ERROR
		return builder.toString();
74
	}
75
}

Mutations

55

1.1
Location : send
Killed by :
removed call to fr/sii/ogham/core/filler/MessageFiller::fill → RUN_ERROR

58

1.1
Location : send
Killed by :
removed call to fr/sii/ogham/core/sender/MessageSender::send → RUN_ERROR

63

1.1
Location : supports
Killed by :
negated conditional → RUN_ERROR

64

1.1
Location : supports
Killed by :
replaced boolean return with false for fr/sii/ogham/core/sender/FillerSender::supports → RUN_ERROR

2.2
Location : supports
Killed by :
replaced boolean return with true for fr/sii/ogham/core/sender/FillerSender::supports → RUN_ERROR

66

1.1
Location : supports
Killed by :
replaced boolean return with false for fr/sii/ogham/core/sender/FillerSender::supports → NO_COVERAGE

73

1.1
Location : toString
Killed by :
replaced return value with "" for fr/sii/ogham/core/sender/FillerSender::toString → RUN_ERROR

Active mutators

Tests examined


Report generated by PIT 1.13.1