SupportedEncoderConditionalSplitter.java

1
package fr.sii.ogham.sms.sender.impl.cloudhopper.splitter;
2
3
import java.util.List;
4
5
import fr.sii.ogham.sms.encoder.SupportingEncoder;
6
import fr.sii.ogham.sms.exception.message.SplitMessageException;
7
import fr.sii.ogham.sms.splitter.MessageSplitter;
8
import fr.sii.ogham.sms.splitter.Segment;
9
import fr.sii.ogham.sms.splitter.SupportingSplitter;
10
11
/**
12
 * A splitter that indicates if it is able to split the message based on the
13
 * result of {@link SupportingEncoder#canEncode(String)} of the associated
14
 * encoder.
15
 * 
16
 * @author Aurélien Baudet
17
 *
18
 */
19
public class SupportedEncoderConditionalSplitter implements SupportingSplitter {
20
	private final SupportingEncoder associatedEncoder;
21
	private final MessageSplitter delegate;
22
23
	/**
24
	 * Initializes with the encoder that will encode the string message into a
25
	 * byte array. The encoder implements {@link SupportingEncoder} so it can
26
	 * indicate if it is able to encode the message or not.
27
	 * 
28
	 * @param associatedEncoder
29
	 *            the encoder used to encode the message if it can handle it
30
	 * @param delegate
31
	 *            the splitter that will really split the message
32
	 */
33
	public SupportedEncoderConditionalSplitter(SupportingEncoder associatedEncoder, MessageSplitter delegate) {
34
		super();
35
		this.associatedEncoder = associatedEncoder;
36
		this.delegate = delegate;
37
	}
38
39
	@SuppressWarnings("squid:S1168")
40
	@Override
41
	public List<Segment> split(String message) throws SplitMessageException {
42 1 1. split : negated conditional → RUN_ERROR
		if (canSplit(message)) {
43 1 1. split : replaced return value with Collections.emptyList for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::split → RUN_ERROR
			return delegate.split(message);
44
		}
45 1 1. split : replaced return value with Collections.emptyList for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::split → NO_COVERAGE
		return null;
46
	}
47
48
	@Override
49
	public boolean canSplit(String message) {
50 2 1. canSplit : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::canSplit → RUN_ERROR
2. canSplit : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::canSplit → RUN_ERROR
		return associatedEncoder.canEncode(message);
51
	}
52
53
}

Mutations

42

1.1
Location : split
Killed by :
negated conditional → RUN_ERROR

43

1.1
Location : split
Killed by :
replaced return value with Collections.emptyList for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::split → RUN_ERROR

45

1.1
Location : split
Killed by :
replaced return value with Collections.emptyList for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::split → NO_COVERAGE

50

1.1
Location : canSplit
Killed by :
replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::canSplit → RUN_ERROR

2.2
Location : canSplit
Killed by :
replaced boolean return with false for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::canSplit → RUN_ERROR

Active mutators

Tests examined


Report generated by PIT 1.13.1