1 | package fr.sii.ogham.testing.assertion.hamcrest; | |
2 | ||
3 | import org.hamcrest.Description; | |
4 | import org.hamcrest.Matcher; | |
5 | import org.hamcrest.TypeSafeMatcher; | |
6 | ||
7 | /** | |
8 | * A matcher that applies a delegate matcher to the message of the current | |
9 | * Throwable, returning the result of that match. | |
10 | * | |
11 | * @param <T> | |
12 | * the type of the throwable being matched | |
13 | */ | |
14 | public class ThrowableMessageMatcher<T extends Throwable> extends TypeSafeMatcher<T> { | |
15 | private final Matcher<? extends String> messageMatcher; | |
16 | ||
17 | public ThrowableMessageMatcher(Matcher<? extends String> messageMatcher) { | |
18 | super(); | |
19 | this.messageMatcher = messageMatcher; | |
20 | } | |
21 | ||
22 | public void describeTo(Description description) { | |
23 | description.appendText("exception with message "); | |
24 | description.appendDescriptionOf(messageMatcher); | |
25 | } | |
26 | ||
27 | @Override | |
28 | protected boolean matchesSafely(T item) { | |
29 |
13
1. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → NO_COVERAGE 2. matchesSafely : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → SURVIVED 3. matchesSafely : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → NO_COVERAGE 4. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → TIMED_OUT 5. matchesSafely : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → TIMED_OUT 6. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED 7. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED 8. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED 9. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED 10. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED 11. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED 12. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED 13. matchesSafely : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED |
return messageMatcher.matches(item.getMessage()); |
30 | } | |
31 | ||
32 | @Override | |
33 | protected void describeMismatchSafely(T item, Description description) { | |
34 | description.appendText("message "); | |
35 |
2
1. describeMismatchSafely : removed call to org/hamcrest/Matcher::describeMismatch → NO_COVERAGE 2. describeMismatchSafely : removed call to org/hamcrest/Matcher::describeMismatch → KILLED |
messageMatcher.describeMismatch(item.getMessage(), description); |
36 | } | |
37 | | |
38 | @Override | |
39 | public String toString() { | |
40 |
2
1. toString : replaced return value with "" for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::toString → NO_COVERAGE 2. toString : replaced return value with "" for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::toString → SURVIVED |
return "hasMessage('"+messageMatcher+"')"; |
41 | } | |
42 | } | |
Mutations | ||
29 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 12.12 13.13 |
|
35 |
1.1 2.2 |
|
40 |
1.1 2.2 |