ExceptionMatchers.java

1
package fr.sii.ogham.testing.assertion.hamcrest;
2
3
import static org.hamcrest.Matchers.instanceOf;
4
import static org.hamcrest.Matchers.is;
5
import static org.hamcrest.Matchers.notNullValue;
6
7
import org.hamcrest.Matcher;
8
9
public final class ExceptionMatchers {
10
11
	/**
12
	 * Returns a matcher that verifies that any exception in the stack matches
13
	 * the finder exists.
14
	 *
15
	 * @param expectedClass
16
	 *            to find the cause in exception stack
17
	 * @param <T>
18
	 *            type of the outer exception
19
	 * @return the matcher
20
	 */
21
	public static <T extends Throwable> Matcher<T> hasAnyCause(final Class<? extends Throwable> expectedClass) {
22 4 1. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → NO_COVERAGE
2. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
3. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
4. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
		return hasAnyCause(instanceOf(expectedClass));
23
	}
24
25
	/**
26
	 * Returns a matcher that verifies that any exception in the stack matches
27
	 * the finder exists.
28
	 *
29
	 * @param finder
30
	 *            to find the cause in exception stack, the finder is also the matcher
31
	 * @param <T>
32
	 *            type of the outer exception
33
	 * @return the matcher
34
	 */
35
	public static <T extends Throwable> Matcher<T> hasAnyCause(final Matcher<? extends Throwable> finder) {
36 4 1. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → NO_COVERAGE
2. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
3. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
4. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
		return new ThrowableAnyCauseMatcher<>(finder, notNullValue(Throwable.class));
37
	}
38
39
	/**
40
	 * Returns a matcher that verifies that any exception in the stack matches
41
	 * the finder and also checks that the supplied matcher evaluates to true.
42
	 *
43
	 * @param finder
44
	 *            to find the cause in exception stack
45
	 * @param matcher
46
	 *            to apply to the cause of the outer exception
47
	 * @param <T>
48
	 *            type of the outer exception
49
	 * @return the matcher
50
	 */
51
	public static <T extends Throwable> Matcher<T> hasAnyCause(final Matcher<? extends Throwable> finder, final Matcher<? extends Throwable> matcher) {
52 3 1. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → NO_COVERAGE
2. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
3. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
		return new ThrowableAnyCauseMatcher<>(finder, matcher);
53
	}
54
55
	/**
56
	 * Returns a matcher that verifies that any exception in the stack matches
57
	 * the expected class and also checks that the supplied matcher evaluates to
58
	 * true.
59
	 *
60
	 * @param expectedClass
61
	 *            to find the cause in exception stack
62
	 * @param matcher
63
	 *            to apply to the cause of the outer exception
64
	 * @param <T>
65
	 *            type of the outer exception
66
	 * @return the matcher
67
	 */
68
	public static <T extends Throwable> Matcher<T> hasAnyCause(final Class<? extends Throwable> expectedClass, final Matcher<? extends Throwable> matcher) {
69 8 1. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → NO_COVERAGE
2. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → TIMED_OUT
3. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
4. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
5. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
6. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
7. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
8. hasAnyCause : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED
		return new ThrowableAnyCauseMatcher<>(instanceOf(expectedClass), matcher);
70
	}
71
72
	/**
73
	 * Returns a matcher that verifies that the exception has a message for
74
	 * which the supplied matcher evaluates to true.
75
	 *
76
	 * @param matcher
77
	 *            to apply to the cause of the exception
78
	 * @param <T>
79
	 *            type of the outer exception
80
	 * @return the matcher
81
	 */
82
	public static <T extends Throwable> Matcher<T> hasMessage(final Matcher<? extends String> matcher) {
83 9 1. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → NO_COVERAGE
2. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → TIMED_OUT
3. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED
4. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED
5. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED
6. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED
7. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED
8. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED
9. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED
		return new ThrowableMessageMatcher<>(matcher);
84
	}
85
86
	/**
87
	 * shortcut to:
88
	 * 
89
	 * <pre>
90
	 * {@code
91
	 * hasMessage(is("some message"))
92
	 * }
93
	 * </pre>
94
	 *
95
	 * @param expectedMessage
96
	 *            the expected message of the exception
97
	 * @param <T>
98
	 *            type of the outer exception
99
	 * @return the matcher
100
	 */
101
	public static <T extends Throwable> Matcher<T> hasMessage(String expectedMessage) {
102 5 1. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → NO_COVERAGE
2. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED
3. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED
4. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED
5. hasMessage : replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED
		return new ThrowableMessageMatcher<>(is(expectedMessage));
103
	}
104
105
	private ExceptionMatchers() {
106
		super();
107
	}
108
}

Mutations

22

1.1
Location : hasAnyCause
Killed by : oghamcore.it.core.sender.AutoRetryTest.smsNotRetriedOnFirstExecutionDueToParsingError(oghamcore.it.core.sender.AutoRetryTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

2.2
Location : hasAnyCause
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → NO_COVERAGE

3.3
Location : hasAnyCause
Killed by : oghamcloudhopper.it.ReuseSessionStrategyTest.reuseSessionButSendFailsDueToSessionClosedByServer(oghamcloudhopper.it.ReuseSessionStrategyTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

4.4
Location : hasAnyCause
Killed by : oghamall.it.retry.AutoRetryTest.doNotResendEmailIfTemplateNotFound(oghamall.it.retry.AutoRetryTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

36

1.1
Location : hasAnyCause
Killed by : oghamcloudhopper.it.ReuseSessionStrategyTest.reuseSessionButSendFailsDueToSessionClosedByServer(oghamcloudhopper.it.ReuseSessionStrategyTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

2.2
Location : hasAnyCause
Killed by : oghamall.it.retry.AutoRetryTest.doNotResendEmailIfTemplateNotFound(oghamall.it.retry.AutoRetryTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

3.3
Location : hasAnyCause
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → NO_COVERAGE

4.4
Location : hasAnyCause
Killed by : oghamcore.it.core.sender.AutoRetryTest.smsNotRetriedOnFirstExecutionDueToParsingError(oghamcore.it.core.sender.AutoRetryTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

52

1.1
Location : hasAnyCause
Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

2.2
Location : hasAnyCause
Killed by : oghamcloudhopper.it.ConnectionFailureTest.invalidSystemId(oghamcloudhopper.it.ConnectionFailureTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

3.3
Location : hasAnyCause
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → NO_COVERAGE

69

1.1
Location : hasAnyCause
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → NO_COVERAGE

2.2
Location : hasAnyCause
Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

3.3
Location : hasAnyCause
Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

4.4
Location : hasAnyCause
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

5.5
Location : hasAnyCause
Killed by : oghamcore.it.core.sender.AutoRetryTest.smsNotRetriedOnFirstExecutionDueToParsingError(oghamcore.it.core.sender.AutoRetryTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

6.6
Location : hasAnyCause
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → TIMED_OUT

7.7
Location : hasAnyCause
Killed by : oghamthymeleafv3.it.ExternalFileTest.fileUnreadable(oghamthymeleafv3.it.ExternalFileTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

8.8
Location : hasAnyCause
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredAndImageInliningEnabledButUnconfiguredResourceResolutionCantInlineImages(oghamall.it.configuration.EmptyBuilderTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasAnyCause → KILLED

83

1.1
Location : hasMessage
Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED

2.2
Location : hasMessage
Killed by : oghamcore.it.core.builder.CustomTemplateBuilderTest.asDeveloperICantRegisterABuilderWithWrongConstructor(oghamcore.it.core.builder.CustomTemplateBuilderTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED

3.3
Location : hasMessage
Killed by : oghamcloudhopper.it.KeepAliveSessionStrategyTest.keepAliveButSendFailsDueToSessionClosedByServer(oghamcloudhopper.it.KeepAliveSessionStrategyTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED

4.4
Location : hasMessage
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → TIMED_OUT

5.5
Location : hasMessage
Killed by : oghamthymeleafv3.it.ExternalFileTest.fileUnreadable(oghamthymeleafv3.it.ExternalFileTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED

6.6
Location : hasMessage
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredAndTemplateParsersOnlyRegisteredCantHandleTemplateContentDueToResourceResolutionNotConfigured(oghamall.it.configuration.EmptyBuilderTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED

7.7
Location : hasMessage
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → NO_COVERAGE

8.8
Location : hasMessage
Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED

9.9
Location : hasMessage
Killed by : oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingFreemarker(oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED

102

1.1
Location : hasMessage
Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED

2.2
Location : hasMessage
Killed by : oghamcloudhopper.it.PartialConfigurationTest.splitterEnabledAndAutoGuessEnabledAndGsm7bitEncodingConfiguredAndLongMessageWithUnsupportedCharactersShouldFailIndicatingThatMessageCantBeSplit(oghamcloudhopper.it.PartialConfigurationTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED

3.3
Location : hasMessage
Killed by : none
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → NO_COVERAGE

4.4
Location : hasMessage
Killed by : oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingThymeleaf(oghamspringbootv1autoconfigure.it.SpringBeanResolutionTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED

5.5
Location : hasMessage
Killed by : oghamspringbootv2autoconfigure.it.SpringBeanResolutionTest.missingBeanErrorUsingThymeleaf(oghamspringbootv2autoconfigure.it.SpringBeanResolutionTest)
replaced return value with null for fr/sii/ogham/testing/assertion/hamcrest/ExceptionMatchers::hasMessage → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM