InterfaceVersion.java

1
package fr.sii.ogham.sms.builder.cloudhopper;
2
3
import java.util.Arrays;
4
import java.util.List;
5
6
import com.cloudhopper.smpp.SmppConstants;
7
8
import fr.sii.ogham.core.convert.StringToEnumConverter.FactoryMethod;
9
10
/**
11
 * Wraps the version for builder
12
 * 
13
 * @author Aurélien Baudet
14
 *
15
 */
16
@FactoryMethod(name = "of")
17
public enum InterfaceVersion {
18
	/**
19
	 * SMPP 3.3 the oldest used version (despite its limitations, it is still
20
	 * widely used); supports GSM only. Generates an immediate response for each
21
	 * message sent.
22
	 */
23
	VERSION_3_3(SmppConstants.VERSION_3_3, "3.3"),
24
	/**
25
	 * SMPP 3.4 adds optional Tag-Length-Value (TLV) parameters, support of
26
	 * non-GSM SMS technologies and the transceiver support (single connections
27
	 * that can send and receive messages). The exchange of SMPP request and
28
	 * response PDUs between an ESME Transmitter and SMSC may occur
29
	 * synchronously or asynchronously.
30
	 */
31
	VERSION_3_4(SmppConstants.VERSION_3_4, "3.4"),
32
	/**
33
	 * SMPP 5.0 is the latest version of SMPP; adds support for cell
34
	 * broadcasting, smart flow control. As of 2019, it is not widely used.
35
	 */
36
	VERSION_5_0(SmppConstants.VERSION_5_0, "5.0", "5");
37
38
	private final byte value;
39
	private final List<String> versionNames;
40
41
	InterfaceVersion(byte value, String... versionNames) {
42
		this.value = value;
43
		this.versionNames = Arrays.asList(versionNames);
44
	}
45
46
	/**
47
	 * Get the version as byte value.
48
	 * 
49
	 * @return the byte value for the version
50
	 */
51
	public byte value() {
52 3 1. value : replaced byte return with 0 for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::value → SURVIVED
2. value : replaced byte return with 0 for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::value → TIMED_OUT
3. value : replaced byte return with 0 for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::value → KILLED
		return value;
53
	}
54
	
55
	/**
56
	 * The version as string.
57
	 * 
58
	 * @return the version string
59
	 */
60
	public String getVersionString() {
61 1 1. getVersionString : replaced return value with "" for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::getVersionString → NO_COVERAGE
		return versionNames.get(0);
62
	}
63
64
	private boolean matches(String versionName) {
65
		for (String v : versionNames) {
66 2 1. matches : negated conditional → NO_COVERAGE
2. matches : negated conditional → KILLED
			if (v.equals(versionName)) {
67 2 1. matches : replaced boolean return with false for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::matches → NO_COVERAGE
2. matches : replaced boolean return with false for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::matches → KILLED
				return true;
68
			}
69
		}
70 2 1. matches : replaced boolean return with true for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::matches → NO_COVERAGE
2. matches : replaced boolean return with true for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::matches → KILLED
		return false;
71
	}
72
73
	/**
74
	 * Get the {@link InterfaceVersion} from the byte value.
75
	 * 
76
	 * If value is {@code null}, {@code null} is returned
77
	 * 
78
	 * @param value
79
	 *            the byte value that represents the version
80
	 * @return the corresponding interface version
81
	 * @throws IllegalArgumentException
82
	 *             if the value doesn't match any known version
83
	 */
84
	public static InterfaceVersion fromValue(Byte value) {
85 2 1. fromValue : negated conditional → NO_COVERAGE
2. fromValue : negated conditional → KILLED
		if (value == null) {
86
			return null;
87
		}
88
		for (InterfaceVersion version : values()) {
89 2 1. fromValue : negated conditional → NO_COVERAGE
2. fromValue : negated conditional → KILLED
			if (version.value() == value) {
90 2 1. fromValue : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::fromValue → NO_COVERAGE
2. fromValue : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::fromValue → KILLED
				return version;
91
			}
92
		}
93
		throw new IllegalArgumentException("Unknown interface version with value " + value);
94
	}
95
96
	/**
97
	 * Get the {@link InterfaceVersion} from either the enum name (
98
	 * {@link InterfaceVersion#VERSION_3_3},
99
	 * {@link InterfaceVersion#VERSION_3_4},
100
	 * {@link InterfaceVersion#VERSION_5_0}) or from a string that represents
101
	 * the version ("3.3", "3.4", "5.0").
102
	 * 
103
	 * If version name is {@code null}, {@code null} is returned
104
	 * 
105
	 * @param version
106
	 *            the version as string
107
	 * @return the interface version
108
	 * @throws IllegalArgumentException
109
	 *             if the version name doesn't match any known version
110
	 */
111
	public static InterfaceVersion of(String version) {
112 6 1. of : negated conditional → NO_COVERAGE
2. of : negated conditional → NO_COVERAGE
3. of : negated conditional → KILLED
4. of : negated conditional → KILLED
5. of : negated conditional → KILLED
6. of : negated conditional → KILLED
		if (version == null || version.isEmpty()) {
113
			return null;
114
		}
115
		for (InterfaceVersion iv : values()) {
116 2 1. of : negated conditional → NO_COVERAGE
2. of : negated conditional → KILLED
			if (iv.name().equals(version)) {
117 2 1. of : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::of → NO_COVERAGE
2. of : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::of → KILLED
				return iv;
118
			}
119 2 1. of : negated conditional → NO_COVERAGE
2. of : negated conditional → KILLED
			if (iv.matches(version)) {
120 2 1. of : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::of → NO_COVERAGE
2. of : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::of → KILLED
				return iv;
121
			}
122
		}
123
		throw new IllegalArgumentException("Unknown interface version named " + version);
124
	}
125
}

Mutations

52

1.1
Location : value
Killed by : none
replaced byte return with 0 for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::value → SURVIVED

2.2
Location : value
Killed by : none
replaced byte return with 0 for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::value → TIMED_OUT

3.3
Location : value
Killed by : oghamcloudhopper.ut.InterfaceVersionSpec
replaced byte return with 0 for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::value → KILLED

61

1.1
Location : getVersionString
Killed by : none
replaced return value with "" for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::getVersionString → NO_COVERAGE

66

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

2.2
Location : matches
Killed by : oghamcloudhopper.ut.InterfaceVersionSpec
negated conditional → KILLED

67

1.1
Location : matches
Killed by : none
replaced boolean return with false for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::matches → NO_COVERAGE

2.2
Location : matches
Killed by : oghamcloudhopper.ut.InterfaceVersionSpec
replaced boolean return with false for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::matches → KILLED

70

1.1
Location : matches
Killed by : oghamcloudhopper.ut.InterfaceVersionSpec
replaced boolean return with true for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::matches → KILLED

2.2
Location : matches
Killed by : none
replaced boolean return with true for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::matches → NO_COVERAGE

85

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

2.2
Location : fromValue
Killed by : oghamcloudhopper.ut.InterfaceVersionSpec
negated conditional → KILLED

89

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

2.2
Location : fromValue
Killed by : oghamcloudhopper.ut.InterfaceVersionSpec
negated conditional → KILLED

90

1.1
Location : fromValue
Killed by : oghamcloudhopper.ut.InterfaceVersionSpec
replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::fromValue → KILLED

2.2
Location : fromValue
Killed by : none
replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::fromValue → NO_COVERAGE

112

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

2.2
Location : of
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
negated conditional → KILLED

3.3
Location : of
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests.oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence(oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests)
negated conditional → KILLED

4.4
Location : of
Killed by : oghamcloudhopper.ut.InterfaceVersionSpec
negated conditional → KILLED

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

6.6
Location : of
Killed by : oghamcloudhopper.ut.InterfaceVersionSpec
negated conditional → KILLED

116

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

2.2
Location : of
Killed by : oghamcloudhopper.ut.InterfaceVersionSpec
negated conditional → KILLED

117

1.1
Location : of
Killed by : oghamcloudhopper.ut.InterfaceVersionSpec
replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::of → KILLED

2.2
Location : of
Killed by : none
replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::of → NO_COVERAGE

119

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

2.2
Location : of
Killed by : oghamcloudhopper.ut.InterfaceVersionSpec
negated conditional → KILLED

120

1.1
Location : of
Killed by : none
replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::of → NO_COVERAGE

2.2
Location : of
Killed by : oghamcloudhopper.ut.InterfaceVersionSpec
replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/InterfaceVersion::of → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM