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 cause 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 ThrowableAnyCauseMatcher<T extends Throwable> extends TypeSafeMatcher<T> { |
15
|
|
private final Matcher<? extends Throwable> causeFinder; |
16
|
|
private final Matcher<? extends Throwable> causeMatcher; |
17
|
|
|
18
|
|
public ThrowableAnyCauseMatcher(Matcher<? extends Throwable> causeFinder, Matcher<? extends Throwable> causeMatcher) { |
19
|
|
this.causeFinder = causeFinder; |
20
|
|
this.causeMatcher = causeMatcher; |
21
|
|
} |
22
|
|
|
23
|
|
public void describeTo(Description description) { |
24
|
|
description.appendText("exception with cause matching "); |
25
|
|
description.appendDescriptionOf(causeFinder); |
26
|
|
description.appendText(" and matched cause "); |
27
|
|
description.appendDescriptionOf(causeMatcher); |
28
|
|
} |
29
|
|
|
30
|
|
@Override |
31
|
|
protected boolean matchesSafely(T item) { |
32
|
|
Throwable cause = item; |
33
|
9
1. matchesSafely : negated conditional → NO_COVERAGE
2. matchesSafely : negated conditional → TIMED_OUT
3. matchesSafely : negated conditional → KILLED
4. matchesSafely : negated conditional → KILLED
5. matchesSafely : negated conditional → KILLED
6. matchesSafely : negated conditional → KILLED
7. matchesSafely : negated conditional → KILLED
8. matchesSafely : negated conditional → KILLED
9. matchesSafely : negated conditional → KILLED
|
while (cause != null) { |
34
|
9
1. matchesSafely : negated conditional → NO_COVERAGE
2. matchesSafely : negated conditional → TIMED_OUT
3. matchesSafely : negated conditional → KILLED
4. matchesSafely : negated conditional → KILLED
5. matchesSafely : negated conditional → KILLED
6. matchesSafely : negated conditional → KILLED
7. matchesSafely : negated conditional → KILLED
8. matchesSafely : negated conditional → KILLED
9. matchesSafely : negated conditional → KILLED
|
if (causeFinder.matches(cause)) { |
35
|
13
1. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → NO_COVERAGE
2. matchesSafely : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → NO_COVERAGE
3. matchesSafely : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → SURVIVED
4. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → TIMED_OUT
5. matchesSafely : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → TIMED_OUT
6. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED
7. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED
8. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED
9. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED
10. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED
11. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED
12. matchesSafely : replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED
13. matchesSafely : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED
|
return causeMatcher.matches(cause); |
36
|
|
} |
37
|
|
cause = cause.getCause(); |
38
|
|
} |
39
|
2
1. matchesSafely : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → NO_COVERAGE
2. matchesSafely : replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED
|
return false; |
40
|
|
} |
41
|
|
|
42
|
|
@Override |
43
|
|
protected void describeMismatchSafely(T item, Description description) { |
44
|
|
Throwable cause = item; |
45
|
2
1. describeMismatchSafely : negated conditional → NO_COVERAGE
2. describeMismatchSafely : negated conditional → KILLED
|
while (cause != null) { |
46
|
2
1. describeMismatchSafely : negated conditional → NO_COVERAGE
2. describeMismatchSafely : negated conditional → KILLED
|
if (causeFinder.matches(cause)) { |
47
|
|
break; |
48
|
|
} |
49
|
|
cause = cause.getCause(); |
50
|
|
} |
51
|
2
1. describeMismatchSafely : negated conditional → NO_COVERAGE
2. describeMismatchSafely : negated conditional → KILLED
|
if (cause == null) { |
52
|
|
description.appendText("was not found in exception stack"); |
53
|
|
} else { |
54
|
2
1. describeMismatchSafely : removed call to org/hamcrest/Matcher::describeMismatch → NO_COVERAGE
2. describeMismatchSafely : removed call to org/hamcrest/Matcher::describeMismatch → KILLED
|
causeMatcher.describeMismatch(cause, description); |
55
|
|
} |
56
|
|
} |
57
|
|
|
58
|
|
} |
| | Mutations |
33 |
|
1.1 Location : matchesSafely Killed by : none negated conditional → NO_COVERAGE 2.2 Location : matchesSafely Killed by : none negated conditional → TIMED_OUT 3.3 Location : matchesSafely Killed by : oghamcloudhopper.it.ReuseSessionStrategyTest.reuseSessionButSendFailsDueToSessionClosedByServer(oghamcloudhopper.it.ReuseSessionStrategyTest) negated conditional → KILLED 4.4 Location : matchesSafely Killed by : oghamthymeleafv3.it.ExternalFileTest.fileUnreadable(oghamthymeleafv3.it.ExternalFileTest) negated conditional → KILLED 5.5 Location : matchesSafely Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredAndImageInliningEnabledButUnconfiguredResourceResolutionCantInlineImages(oghamall.it.configuration.EmptyBuilderTest) negated conditional → KILLED 6.6 Location : matchesSafely Killed by : oghamcore.it.core.sender.AutoRetryTest.smsNotRetriedOnFirstExecutionDueToParsingError(oghamcore.it.core.sender.AutoRetryTest) negated conditional → KILLED 7.7 Location : matchesSafely Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec negated conditional → KILLED 8.8 Location : matchesSafely Killed by : oghamspringbootv2autoconfigure.it.StaticMethodAccessTest.emailUsingFreemarkerTemplateAndStaticMethodAccessDisabledShouldFail(oghamspringbootv2autoconfigure.it.StaticMethodAccessTest) negated conditional → KILLED 9.9 Location : matchesSafely Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest) negated conditional → KILLED
|
34 |
|
1.1 Location : matchesSafely Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest) negated conditional → KILLED 2.2 Location : matchesSafely Killed by : oghamcore.it.core.sender.AutoRetryTest.smsNotRetriedOnFirstExecutionDueToParsingError(oghamcore.it.core.sender.AutoRetryTest) negated conditional → KILLED 3.3 Location : matchesSafely Killed by : none negated conditional → NO_COVERAGE 4.4 Location : matchesSafely Killed by : oghamthymeleafv3.it.ExternalFileTest.fileNotFound(oghamthymeleafv3.it.ExternalFileTest) negated conditional → KILLED 5.5 Location : matchesSafely Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec negated conditional → KILLED 6.6 Location : matchesSafely Killed by : none negated conditional → TIMED_OUT 7.7 Location : matchesSafely Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest) negated conditional → KILLED 8.8 Location : matchesSafely Killed by : oghamspringbootv2autoconfigure.it.StaticMethodAccessTest.emailUsingFreemarkerTemplateAndStaticMethodAccessDisabledShouldFail(oghamspringbootv2autoconfigure.it.StaticMethodAccessTest) negated conditional → KILLED 9.9 Location : matchesSafely Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredAndImageInliningEnabledButUnconfiguredResourceResolutionCantInlineImages(oghamall.it.configuration.EmptyBuilderTest) negated conditional → KILLED
|
35 |
|
1.1 Location : matchesSafely Killed by : oghamcore.it.core.sender.AutoRetryTest.smsNotRetriedOnFirstExecutionDueToParsingError(oghamcore.it.core.sender.AutoRetryTest) replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED 2.2 Location : matchesSafely Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED 3.3 Location : matchesSafely Killed by : none replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → NO_COVERAGE 4.4 Location : matchesSafely Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredAndImageInliningEnabledButUnconfiguredResourceResolutionCantInlineImages(oghamall.it.configuration.EmptyBuilderTest) replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED 5.5 Location : matchesSafely Killed by : oghamcloudhopper.it.ReuseSessionStrategyTest.reuseSessionButSendFailsDueToSessionClosedByServer(oghamcloudhopper.it.ReuseSessionStrategyTest) replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED 6.6 Location : matchesSafely Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest) replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED 7.7 Location : matchesSafely Killed by : oghamthymeleafv3.it.ExternalFileTest.fileUnreadable(oghamthymeleafv3.it.ExternalFileTest) replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED 8.8 Location : matchesSafely Killed by : none replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → TIMED_OUT 9.9 Location : matchesSafely Killed by : oghamspringbootv2autoconfigure.it.StaticMethodAccessTest.emailUsingFreemarkerTemplateAndStaticMethodAccessDisabledShouldFail(oghamspringbootv2autoconfigure.it.StaticMethodAccessTest) replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED 10.10 Location : matchesSafely Killed by : none replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → NO_COVERAGE 11.11 Location : matchesSafely Killed by : none replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → TIMED_OUT 12.12 Location : matchesSafely Killed by : none replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → SURVIVED 13.13 Location : matchesSafely Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED
|
39 |
|
1.1 Location : matchesSafely Killed by : none replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → NO_COVERAGE 2.2 Location : matchesSafely Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableAnyCauseMatcher::matchesSafely → KILLED
|
45 |
|
1.1 Location : describeMismatchSafely Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec negated conditional → KILLED 2.2 Location : describeMismatchSafely Killed by : none negated conditional → NO_COVERAGE
|
46 |
|
1.1 Location : describeMismatchSafely Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec negated conditional → KILLED 2.2 Location : describeMismatchSafely Killed by : none negated conditional → NO_COVERAGE
|
51 |
|
1.1 Location : describeMismatchSafely Killed by : none negated conditional → NO_COVERAGE 2.2 Location : describeMismatchSafely Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec negated conditional → KILLED
|
54 |
|
1.1 Location : describeMismatchSafely Killed by : none removed call to org/hamcrest/Matcher::describeMismatch → NO_COVERAGE 2.2 Location : describeMismatchSafely Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec removed call to org/hamcrest/Matcher::describeMismatch → KILLED
|