DefaultSmsCodingDetector.java

1
package fr.sii.ogham.sms.sender.impl.ovh;
2
3
/**
4
 * See <a href=
5
 * "https://docs.ovh.com/fr/sms/envoyer_des_sms_depuis_une_url_-_http2sms/#annexe_2">https://docs.ovh.com/fr/sms/envoyer_des_sms_depuis_une_url_-_http2sms/#annexe_2</a>
6
 * 
7
 * @author Aurélien Baudet
8
 *
9
 */
10
public class DefaultSmsCodingDetector implements SmsCodingDetector {
11
	/**
12
	 * Basic characters
13
	 */
14
	private static final char[] CHAR_TABLE = {
15
		// @formatter:off
16
		'@', '\u00a3', '$', '\u00a5', '\u00e8', '\u00e9', '\u00f9', '\u00ec',
17
		'\u00f2', '\u00c7', '\n', '\u00d8', '\u00f8', '\r', '\u00c5', '\u00e5',
18
		'\u0394', '_', '\u03a6', '\u0393', '\u039b', '\u03a9', '\u03a0', '\u03a8',
19
		'\u03a3', '\u0398', '\u039e', ' ', '\u00c6', '\u00e6', '\u00df', '\u00c9',  // 0x1B is actually an escape which we'll encode to a space char
20
		' ', '!', '"', '#', '\u00a4', '%', '&', '\'',
21
		'(', ')', '*', '+', ',', '-', '.', '/',
22
		'0', '1', '2', '3', '4', '5', '6', '7',
23
		'8', '9', ':', ';', '<', '=', '>', '?',
24
		'\u00a1', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
25
		'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
26
		'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
27
		'X', 'Y', 'Z', '\u00c4', '\u00d6', '\u00d1', '\u00dc', '\u00a7',
28
		'\u00bf', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
29
		'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
30
		'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
31
		'x', 'y', 'z', '\u00e4', '\u00f6', '\u00f1', '\u00fc', '\u00e0',
32
		// @formatter:on
33
	};
34
35
	/**
36
	 * Extended character table.
37
	 */
38
	private static final char[] EXT_CHAR_TABLE = {
39
		// @formatter:off
40
		'\u20ac' /* € */, '\f', '[', '\\', ']',
41
		'^', '{', '|', '}', '~', 
42
		 // @formatter:on
43
	};
44
45
	@Override
46
	public SmsCoding detect(String message) {
47 4 1. detect : negated conditional → NO_COVERAGE
2. detect : replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::detect → NO_COVERAGE
3. detect : negated conditional → KILLED
4. detect : replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::detect → KILLED
		return canUseGsm7(message) ? SmsCoding.GSM7 : SmsCoding.UNICODE;
48
	}
49
50
	private static boolean canUseGsm7(String message) {
51 6 1. canUseGsm7 : changed conditional boundary → NO_COVERAGE
2. canUseGsm7 : Changed increment from 1 to -1 → NO_COVERAGE
3. canUseGsm7 : negated conditional → NO_COVERAGE
4. canUseGsm7 : changed conditional boundary → KILLED
5. canUseGsm7 : Changed increment from 1 to -1 → KILLED
6. canUseGsm7 : negated conditional → KILLED
		for (int i=0 ; i<message.length() ; i++) {
52
			char c = message.charAt(i);
53 4 1. canUseGsm7 : negated conditional → NO_COVERAGE
2. canUseGsm7 : negated conditional → NO_COVERAGE
3. canUseGsm7 : negated conditional → KILLED
4. canUseGsm7 : negated conditional → KILLED
			if (!isInCharTable(c) && !isInExtensionCharTable(c)) {
54 2 1. canUseGsm7 : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::canUseGsm7 → NO_COVERAGE
2. canUseGsm7 : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::canUseGsm7 → KILLED
				return false;
55
			}
56
		}
57 2 1. canUseGsm7 : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::canUseGsm7 → NO_COVERAGE
2. canUseGsm7 : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::canUseGsm7 → KILLED
		return true;
58
	}
59
	
60
	private static boolean isInCharTable(char c) {
61 6 1. isInCharTable : changed conditional boundary → NO_COVERAGE
2. isInCharTable : Changed increment from 1 to -1 → NO_COVERAGE
3. isInCharTable : negated conditional → NO_COVERAGE
4. isInCharTable : negated conditional → TIMED_OUT
5. isInCharTable : changed conditional boundary → KILLED
6. isInCharTable : Changed increment from 1 to -1 → KILLED
		for (int i=0 ; i<CHAR_TABLE.length ; i++) {
62 2 1. isInCharTable : negated conditional → NO_COVERAGE
2. isInCharTable : negated conditional → TIMED_OUT
			if (c == CHAR_TABLE[i]) {
63 2 1. isInCharTable : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInCharTable → NO_COVERAGE
2. isInCharTable : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInCharTable → KILLED
				return true;
64
			}
65
		}
66 2 1. isInCharTable : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInCharTable → NO_COVERAGE
2. isInCharTable : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInCharTable → KILLED
		return false;
67
	}
68
69
	private static boolean isInExtensionCharTable(char c) {
70 6 1. isInExtensionCharTable : changed conditional boundary → NO_COVERAGE
2. isInExtensionCharTable : Changed increment from 1 to -1 → NO_COVERAGE
3. isInExtensionCharTable : negated conditional → NO_COVERAGE
4. isInExtensionCharTable : changed conditional boundary → KILLED
5. isInExtensionCharTable : Changed increment from 1 to -1 → KILLED
6. isInExtensionCharTable : negated conditional → KILLED
		for (int i=0 ; i<EXT_CHAR_TABLE.length ; i++) {
71 2 1. isInExtensionCharTable : negated conditional → NO_COVERAGE
2. isInExtensionCharTable : negated conditional → KILLED
			if (c == EXT_CHAR_TABLE[i]) {
72 2 1. isInExtensionCharTable : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInExtensionCharTable → NO_COVERAGE
2. isInExtensionCharTable : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInExtensionCharTable → KILLED
				return true;
73
			}
74
		}
75 2 1. isInExtensionCharTable : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInExtensionCharTable → NO_COVERAGE
2. isInExtensionCharTable : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInExtensionCharTable → KILLED
		return false;
76
	}
77
78
}

Mutations

47

1.1
Location : detect
Killed by : oghamovh.it.SmsCodingTest.unicode(oghamovh.it.SmsCodingTest)
negated conditional → KILLED

2.2
Location : detect
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : detect
Killed by : oghamovh.it.SmsCodingTest.unicode(oghamovh.it.SmsCodingTest)
replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::detect → KILLED

4.4
Location : detect
Killed by : none
replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::detect → NO_COVERAGE

51

1.1
Location : canUseGsm7
Killed by : oghamovh.it.OvhSmsTest.nationalNumber(oghamovh.it.OvhSmsTest)
changed conditional boundary → KILLED

2.2
Location : canUseGsm7
Killed by : none
changed conditional boundary → NO_COVERAGE

3.3
Location : canUseGsm7
Killed by : none
Changed increment from 1 to -1 → NO_COVERAGE

4.4
Location : canUseGsm7
Killed by : oghamovh.it.OvhSmsTest.nationalNumber(oghamovh.it.OvhSmsTest)
Changed increment from 1 to -1 → KILLED

5.5
Location : canUseGsm7
Killed by : none
negated conditional → NO_COVERAGE

6.6
Location : canUseGsm7
Killed by : oghamovh.it.SmsCodingTest.unicode(oghamovh.it.SmsCodingTest)
negated conditional → KILLED

53

1.1
Location : canUseGsm7
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : canUseGsm7
Killed by : oghamovh.it.SmsCodingTest.gsm7BasicCharacters(oghamovh.it.SmsCodingTest)
negated conditional → KILLED

3.3
Location : canUseGsm7
Killed by : oghamovh.it.SmsCodingTest.unicode(oghamovh.it.SmsCodingTest)
negated conditional → KILLED

4.4
Location : canUseGsm7
Killed by : none
negated conditional → NO_COVERAGE

54

1.1
Location : canUseGsm7
Killed by : oghamovh.it.SmsCodingTest.unicode(oghamovh.it.SmsCodingTest)
replaced boolean return with true for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::canUseGsm7 → KILLED

2.2
Location : canUseGsm7
Killed by : none
replaced boolean return with true for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::canUseGsm7 → NO_COVERAGE

57

1.1
Location : canUseGsm7
Killed by : none
replaced boolean return with false for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::canUseGsm7 → NO_COVERAGE

2.2
Location : canUseGsm7
Killed by : oghamovh.it.SmsCodingTest.gsm7BasicCharacters(oghamovh.it.SmsCodingTest)
replaced boolean return with false for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::canUseGsm7 → KILLED

61

1.1
Location : isInCharTable
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : isInCharTable
Killed by : oghamovh.it.SmsCodingTest.unicode(oghamovh.it.SmsCodingTest)
changed conditional boundary → KILLED

3.3
Location : isInCharTable
Killed by : none
Changed increment from 1 to -1 → NO_COVERAGE

4.4
Location : isInCharTable
Killed by : oghamovh.it.OvhSmsTest.nationalNumber(oghamovh.it.OvhSmsTest)
Changed increment from 1 to -1 → KILLED

5.5
Location : isInCharTable
Killed by : none
negated conditional → TIMED_OUT

6.6
Location : isInCharTable
Killed by : none
negated conditional → NO_COVERAGE

62

1.1
Location : isInCharTable
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : isInCharTable
Killed by : none
negated conditional → TIMED_OUT

63

1.1
Location : isInCharTable
Killed by : oghamovh.it.SmsCodingTest.gsm7BasicCharacters(oghamovh.it.SmsCodingTest)
replaced boolean return with false for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInCharTable → KILLED

2.2
Location : isInCharTable
Killed by : none
replaced boolean return with false for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInCharTable → NO_COVERAGE

66

1.1
Location : isInCharTable
Killed by : oghamovh.it.SmsCodingTest.unicode(oghamovh.it.SmsCodingTest)
replaced boolean return with true for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInCharTable → KILLED

2.2
Location : isInCharTable
Killed by : none
replaced boolean return with true for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInCharTable → NO_COVERAGE

70

1.1
Location : isInExtensionCharTable
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : isInExtensionCharTable
Killed by : oghamovh.it.SmsCodingTest.unicode(oghamovh.it.SmsCodingTest)
changed conditional boundary → KILLED

3.3
Location : isInExtensionCharTable
Killed by : none
Changed increment from 1 to -1 → NO_COVERAGE

4.4
Location : isInExtensionCharTable
Killed by : oghamovh.it.SmsCodingTest.unicode(oghamovh.it.SmsCodingTest)
Changed increment from 1 to -1 → KILLED

5.5
Location : isInExtensionCharTable
Killed by : none
negated conditional → NO_COVERAGE

6.6
Location : isInExtensionCharTable
Killed by : oghamovh.it.SmsCodingTest.gsm7ExtensionCharacters(oghamovh.it.SmsCodingTest)
negated conditional → KILLED

71

1.1
Location : isInExtensionCharTable
Killed by : oghamovh.it.SmsCodingTest.unicode(oghamovh.it.SmsCodingTest)
negated conditional → KILLED

2.2
Location : isInExtensionCharTable
Killed by : none
negated conditional → NO_COVERAGE

72

1.1
Location : isInExtensionCharTable
Killed by : oghamovh.it.SmsCodingTest.gsm7ExtensionCharacters(oghamovh.it.SmsCodingTest)
replaced boolean return with false for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInExtensionCharTable → KILLED

2.2
Location : isInExtensionCharTable
Killed by : none
replaced boolean return with false for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInExtensionCharTable → NO_COVERAGE

75

1.1
Location : isInExtensionCharTable
Killed by : none
replaced boolean return with true for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInExtensionCharTable → NO_COVERAGE

2.2
Location : isInExtensionCharTable
Killed by : oghamovh.it.SmsCodingTest.unicode(oghamovh.it.SmsCodingTest)
replaced boolean return with true for fr/sii/ogham/sms/sender/impl/ovh/DefaultSmsCodingDetector::isInExtensionCharTable → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM