OptionalParameterWithContext.java

1
package fr.sii.ogham.testing.assertion.sms;
2
3
import static java.util.regex.Matcher.quoteReplacement;
4
import static java.util.regex.Pattern.quote;
5
6
import fr.sii.ogham.testing.assertion.context.Context;
7
import fr.sii.ogham.testing.sms.simulator.bean.OptionalParameter;
8
import fr.sii.ogham.testing.sms.simulator.bean.Tag;
9
10
/**
11
 * Dedicated context for one particular optional parameter (identified by the
12
 * tag).
13
 * 
14
 * @author Aurélien Baudet
15
 *
16
 */
17
public class OptionalParameterWithContext implements Context {
18
	private final Tag tag;
19
	private final OptionalParameter parameter;
20
	private final Context parent;
21
22
	/**
23
	 * 
24
	 * @param tag
25
	 *            the tag of the optional parameter
26
	 * @param parameter
27
	 *            the optional parameter (Tag-Length-Value)
28
	 * @param parent
29
	 *            the parent context
30
	 */
31
	public OptionalParameterWithContext(Tag tag, OptionalParameter parameter, Context parent) {
32
		super();
33
		this.tag = tag;
34
		this.parameter = parameter;
35
		this.parent = parent;
36
	}
37
38
	@Override
39
	public String evaluate(String template) {
40
		String result = template.replaceAll(quote("${tagName}"), quoteReplacement(tag.getTagName()));
41 3 1. evaluate : negated conditional → SURVIVED
2. evaluate : negated conditional → NO_COVERAGE
3. evaluate : negated conditional → KILLED
		result = result.replaceAll(quote("${found}"), quoteReplacement(parameterFound() ? "" : " (/!\\ not found)"));
42 3 1. evaluate : replaced return value with "" for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::evaluate → NO_COVERAGE
2. evaluate : replaced return value with "" for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::evaluate → SURVIVED
3. evaluate : replaced return value with "" for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::evaluate → KILLED
		return parent.evaluate(result);
43
	}
44
45
	private boolean parameterFound() {
46 9 1. parameterFound : replaced boolean return with true for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::parameterFound → NO_COVERAGE
2. parameterFound : replaced boolean return with true for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::parameterFound → SURVIVED
3. parameterFound : negated conditional → SURVIVED
4. parameterFound : negated conditional → NO_COVERAGE
5. parameterFound : negated conditional → SURVIVED
6. parameterFound : negated conditional → NO_COVERAGE
7. parameterFound : replaced boolean return with true for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::parameterFound → KILLED
8. parameterFound : negated conditional → KILLED
9. parameterFound : negated conditional → KILLED
		return parameter != null && parameter.getTag() != null;
47
	}
48
49
	/**
50
	 * @return the optional parameter
51
	 */
52
	public OptionalParameter getParameter() {
53 3 1. getParameter : replaced return value with null for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::getParameter → NO_COVERAGE
2. getParameter : replaced return value with null for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::getParameter → KILLED
3. getParameter : replaced return value with null for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::getParameter → KILLED
		return parameter;
54
	}
55
56
}

Mutations

41

1.1
Location : evaluate
Killed by : none
negated conditional → SURVIVED

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

3.3
Location : evaluate
Killed by : oghamtesting.it.assertion.FluentSmsAssertionsSpec
negated conditional → KILLED

42

1.1
Location : evaluate
Killed by : none
replaced return value with "" for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::evaluate → NO_COVERAGE

2.2
Location : evaluate
Killed by : none
replaced return value with "" for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::evaluate → SURVIVED

3.3
Location : evaluate
Killed by : oghamtesting.it.assertion.FluentSmsAssertionsSpec
replaced return value with "" for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::evaluate → KILLED

46

1.1
Location : parameterFound
Killed by : none
replaced boolean return with true for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::parameterFound → NO_COVERAGE

2.2
Location : parameterFound
Killed by : oghamtesting.it.assertion.FluentSmsAssertionsSpec
replaced boolean return with true for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::parameterFound → KILLED

3.3
Location : parameterFound
Killed by : none
replaced boolean return with true for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::parameterFound → SURVIVED

4.4
Location : parameterFound
Killed by : oghamtesting.it.assertion.FluentSmsAssertionsSpec
negated conditional → KILLED

5.5
Location : parameterFound
Killed by : none
negated conditional → SURVIVED

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

7.7
Location : parameterFound
Killed by : oghamtesting.it.assertion.FluentSmsAssertionsSpec
negated conditional → KILLED

8.8
Location : parameterFound
Killed by : none
negated conditional → SURVIVED

9.9
Location : parameterFound
Killed by : none
negated conditional → NO_COVERAGE

53

1.1
Location : getParameter
Killed by : oghamcloudhopper.it.TlvMessagePayloadTest.simple(oghamcloudhopper.it.TlvMessagePayloadTest)
replaced return value with null for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::getParameter → KILLED

2.2
Location : getParameter
Killed by : oghamtesting.it.assertion.FluentSmsAssertionsSpec
replaced return value with null for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::getParameter → KILLED

3.3
Location : getParameter
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/sms/OptionalParameterWithContext::getParameter → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT OGHAM