OptionalParameterAdapter.java

1
package fr.sii.ogham.testing.sms.simulator.jsmpp;
2
3
import fr.sii.ogham.testing.sms.simulator.bean.OptionalParameter;
4
import ogham.testing.com.cloudhopper.commons.util.HexUtil;
5
import ogham.testing.org.jsmpp.bean.SubmitSm;
6
7
import java.math.BigInteger;
8
import java.util.Arrays;
9
10
/**
11
 * Adapts a JSMPP optional parameter to the Ogham abstraction
12
 * 
13
 * @author Aurélien Baudet
14
 *
15
 */
16
public class OptionalParameterAdapter implements OptionalParameter {
17
	private final SubmitSm original;
18
	private final short tag;
19
20
	/**
21
	 * @param original
22
	 *            the JSMPP {@link SubmitSm} request
23
	 * @param tag
24
	 *            the tag to extract
25
	 */
26
	public OptionalParameterAdapter(SubmitSm original, short tag) {
27
		super();
28
		this.original = original;
29
		this.tag = tag;
30
	}
31
32
	@Override
33
	public Short getTag() {
34
		byte[] tagValue = getOptionalParameterBytes(0, 2);
35 1 1. getTag : negated conditional → NO_COVERAGE
		if (tagValue == null) {
36 1 1. getTag : replaced Short return value with 0 for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::getTag → NO_COVERAGE
			return null;
37
		}
38 1 1. getTag : replaced Short return value with 0 for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::getTag → NO_COVERAGE
		return new BigInteger(tagValue).shortValue();
39
	}
40
41
	@Override
42
	public Integer getLength() {
43
		byte[] length = getOptionalParameterBytes(2, 4);
44 1 1. getLength : negated conditional → NO_COVERAGE
		if (length == null) {
45 1 1. getLength : replaced Integer return value with 0 for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::getLength → NO_COVERAGE
			return null;
46
		}
47 1 1. getLength : replaced Integer return value with 0 for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::getLength → NO_COVERAGE
		return new BigInteger(length).intValue();
48
	}
49
50
	@Override
51
	public byte[] getValue() {
52 1 1. getValue : replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::getValue → NO_COVERAGE
		return getOptionalParameterBytes(4, null);
53
	}
54
	
55
	@Override
56
	public String toString() {
57 1 1. toString : replaced return value with "" for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::toString → NO_COVERAGE
		return "["+getTag()+"|"+getLength()+"|"+HexUtil.toHexString(getValue())+"]";
58
	}
59
60
	@SuppressWarnings("squid:S1168")
61
	private byte[] getOptionalParameterBytes(int from, Integer to) {
62
		ogham.testing.org.jsmpp.bean.OptionalParameter parameter = original.getOptionalParameter(tag);
63 1 1. getOptionalParameterBytes : negated conditional → NO_COVERAGE
		if (parameter == null) {
64
			return null;
65
		}
66
		byte[] bytes = parameter.serialize();
67 1 1. getOptionalParameterBytes : negated conditional → NO_COVERAGE
		if (bytes == null) {
68
			return null;
69
		}
70 2 1. getOptionalParameterBytes : negated conditional → NO_COVERAGE
2. getOptionalParameterBytes : replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::getOptionalParameterBytes → NO_COVERAGE
		return Arrays.copyOfRange(bytes, from, to == null ? bytes.length : to);
71
	}
72
}

Mutations

35

1.1
Location : getTag
Killed by :
negated conditional → NO_COVERAGE

36

1.1
Location : getTag
Killed by :
replaced Short return value with 0 for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::getTag → NO_COVERAGE

38

1.1
Location : getTag
Killed by :
replaced Short return value with 0 for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::getTag → NO_COVERAGE

44

1.1
Location : getLength
Killed by :
negated conditional → NO_COVERAGE

45

1.1
Location : getLength
Killed by :
replaced Integer return value with 0 for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::getLength → NO_COVERAGE

47

1.1
Location : getLength
Killed by :
replaced Integer return value with 0 for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::getLength → NO_COVERAGE

52

1.1
Location : getValue
Killed by :
replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::getValue → NO_COVERAGE

57

1.1
Location : toString
Killed by :
replaced return value with "" for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::toString → NO_COVERAGE

63

1.1
Location : getOptionalParameterBytes
Killed by :
negated conditional → NO_COVERAGE

67

1.1
Location : getOptionalParameterBytes
Killed by :
negated conditional → NO_COVERAGE

70

1.1
Location : getOptionalParameterBytes
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : getOptionalParameterBytes
Killed by :
replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/OptionalParameterAdapter::getOptionalParameterBytes → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.13.1