| 1 | package fr.sii.ogham.testing.assertion.hamcrest; | |
| 2 | ||
| 3 | import org.hamcrest.BaseMatcher; | |
| 4 | import org.hamcrest.Description; | |
| 5 | import org.hamcrest.Matcher; | |
| 6 | ||
| 7 | /** | |
| 8 | * Decorates a Hamcrest matcher in order to provide a different reason. | |
| 9 | * | |
| 10 | * @author Aurélien Baudet | |
| 11 | * | |
| 12 | * @param <T> | |
| 13 | * the type of the actual value | |
| 14 | */ | |
| 15 | public class CustomReason<T> extends BaseMatcher<T> implements DecoratorMatcher<T> { | |
| 16 | private final String reason; | |
| 17 | private final Matcher<T> matcher; | |
| 18 | ||
| 19 | public CustomReason(String reason, Matcher<T> matcher) { | |
| 20 | super(); | |
| 21 | this.reason = reason; | |
| 22 | this.matcher = matcher; | |
| 23 | } | |
| 24 | ||
| 25 | @Override | |
| 26 | public boolean matches(Object item) { | |
| 27 |
10
1. matches : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::matches → NO_COVERAGE 2. matches : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::matches → NO_COVERAGE 3. matches : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::matches → SURVIVED 4. matches : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::matches → TIMED_OUT 5. matches : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::matches → TIMED_OUT 6. matches : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::matches → KILLED 7. matches : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::matches → KILLED 8. matches : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::matches → KILLED 9. matches : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::matches → KILLED 10. matches : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::matches → KILLED |
return matcher.matches(item); |
| 28 | } | |
| 29 | ||
| 30 | @Override | |
| 31 | public void describeTo(Description description) { | |
| 32 |
2
1. describeTo : removed call to org/hamcrest/Matcher::describeTo → NO_COVERAGE 2. describeTo : removed call to org/hamcrest/Matcher::describeTo → KILLED |
matcher.describeTo(description); |
| 33 | } | |
| 34 | ||
| 35 | public String getReason() { | |
| 36 |
2
1. getReason : replaced return value with "" for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::getReason → NO_COVERAGE 2. getReason : replaced return value with "" for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::getReason → KILLED |
return reason; |
| 37 | } | |
| 38 | ||
| 39 | public Matcher<T> getDecoree() { | |
| 40 |
2
1. getDecoree : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::getDecoree → NO_COVERAGE 2. getDecoree : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/CustomReason::getDecoree → KILLED |
return matcher; |
| 41 | } | |
| 42 | ||
| 43 | } | |
Mutations | ||
| 27 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 |
|
| 32 |
1.1 2.2 |
|
| 36 |
1.1 2.2 |
|
| 40 |
1.1 2.2 |