| 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 |
4
1. split : negated conditional → NO_COVERAGE 2. split : negated conditional → TIMED_OUT 3. split : negated conditional → KILLED 4. split : negated conditional → KILLED |
if (canSplit(message)) { |
| 43 |
4
1. split : replaced return value with Collections.emptyList for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::split → NO_COVERAGE 2. split : replaced return value with Collections.emptyList for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::split → TIMED_OUT 3. split : replaced return value with Collections.emptyList for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::split → KILLED 4. split : replaced return value with Collections.emptyList for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::split → KILLED |
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 |
8
1. canSplit : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::canSplit → NO_COVERAGE 2. canSplit : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::canSplit → NO_COVERAGE 3. canSplit : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::canSplit → TIMED_OUT 4. canSplit : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::canSplit → TIMED_OUT 5. canSplit : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::canSplit → KILLED 6. canSplit : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::canSplit → KILLED 7. canSplit : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::canSplit → KILLED 8. canSplit : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/splitter/SupportedEncoderConditionalSplitter::canSplit → KILLED |
return associatedEncoder.canEncode(message); |
| 51 | } | |
| 52 | ||
| 53 | } | |
Mutations | ||
| 42 |
1.1 2.2 3.3 4.4 |
|
| 43 |
1.1 2.2 3.3 4.4 |
|
| 45 |
1.1 |
|
| 50 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |