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 2.2 3.3 |
|
42 |
1.1 2.2 3.3 |
|
46 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 |
|
53 |
1.1 2.2 3.3 |