ShortMessagePreparator.java

1
package fr.sii.ogham.sms.sender.impl.cloudhopper.preparator;
2
3
import com.cloudhopper.smpp.pdu.SubmitSm;
4
import com.cloudhopper.smpp.type.SmppInvalidArgumentException;
5
6
import fr.sii.ogham.sms.message.PhoneNumber;
7
import fr.sii.ogham.sms.message.Sms;
8
import fr.sii.ogham.sms.message.addressing.AddressedPhoneNumber;
9
import fr.sii.ogham.sms.message.addressing.translator.PhoneNumberTranslator;
10
import fr.sii.ogham.sms.sender.impl.cloudhopper.exception.MessagePreparationException;
11
import fr.sii.ogham.sms.splitter.MessageSplitter;
12
import fr.sii.ogham.sms.splitter.Segment;
13
14
/**
15
 * This preparator creates {@link SubmitSm}s and places the message into the
16
 * {@code short_message} field.
17
 * 
18
 * <p>
19
 * This preparator detects which charset should be used to encode message string
20
 * and splits it if needed. It also converts {@link PhoneNumber} to
21
 * {@link AddressedPhoneNumber}.
22
 * 
23
 * @author Aurélien Baudet
24
 *
25
 */
26
public class ShortMessagePreparator extends BaseMessagePreparator {
27
28
	/**
29
	 * The preparator can split messages and provide data coding information.
30
	 * 
31
	 * <p>
32
	 * The phone number won't be translated meaning that if phone number is not
33
	 * already converted to {@link AddressedPhoneNumber} then an
34
	 * {@link IllegalStateException} is thrown.
35
	 * 
36
	 * @param messageSplitter
37
	 *            Split message in several parts if needed
38
	 * @param dataCodingProvider
39
	 *            Determines the data coding to use according to encoding
40
	 */
41
	public ShortMessagePreparator(MessageSplitter messageSplitter, DataCodingProvider dataCodingProvider) {
42
		super(messageSplitter, dataCodingProvider);
43
	}
44
45
	/**
46
	 * Initializes the preparator with message splitter, data coding provider
47
	 * and phone number translator.
48
	 * 
49
	 * @param messageSplitter
50
	 *            Split message in several parts if needed
51
	 * @param dataCodingProvider
52
	 *            Determines the data coding to use according to encoding
53
	 * @param phoneNumberTranslator
54
	 *            Fallback phone translator to handle addressing policy
55
	 */
56
	public ShortMessagePreparator(MessageSplitter messageSplitter, DataCodingProvider dataCodingProvider, PhoneNumberTranslator phoneNumberTranslator) {
57
		super(messageSplitter, dataCodingProvider, phoneNumberTranslator);
58
	}
59
60
	@Override
61
	protected void fill(Sms originalMessage, SubmitSm submit, Segment part) throws MessagePreparationException {
62
		try {
63 4 1. fill : removed call to com/cloudhopper/smpp/pdu/SubmitSm::setShortMessage → NO_COVERAGE
2. fill : removed call to com/cloudhopper/smpp/pdu/SubmitSm::setShortMessage → TIMED_OUT
3. fill : removed call to com/cloudhopper/smpp/pdu/SubmitSm::setShortMessage → KILLED
4. fill : removed call to com/cloudhopper/smpp/pdu/SubmitSm::setShortMessage → KILLED
			submit.setShortMessage(part.getBytes());
64
		} catch (SmppInvalidArgumentException e) {
65
			throw new MessagePreparationException("Failed to set 'short_message' field", originalMessage, e);
66
		}
67
	}
68
	
69
}

Mutations

63

1.1
Location : fill
Killed by : oghamall.it.sms.SmsSMPPGsm7bitTest.longMessage(oghamall.it.sms.SmsSMPPGsm7bitTest)
removed call to com/cloudhopper/smpp/pdu/SubmitSm::setShortMessage → KILLED

2.2
Location : fill
Killed by : none
removed call to com/cloudhopper/smpp/pdu/SubmitSm::setShortMessage → NO_COVERAGE

3.3
Location : fill
Killed by : none
removed call to com/cloudhopper/smpp/pdu/SubmitSm::setShortMessage → TIMED_OUT

4.4
Location : fill
Killed by : oghamcloudhopper.it.PartialConfigurationTest.nothingConfiguredAndLongMessageShouldSendOneLongMessageUsingDefaultEncoding(oghamcloudhopper.it.PartialConfigurationTest)
removed call to com/cloudhopper/smpp/pdu/SubmitSm::setShortMessage → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM