ThrowableMessageMatcher.java

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
Location : matchesSafely
Killed by : oghamcore.it.core.builder.CustomTemplateBuilderTest.asDeveloperICantRegisterABuilderWithWrongConstructor(oghamcore.it.core.builder.CustomTemplateBuilderTest)
replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED

2.2
Location : matchesSafely
Killed by : none
replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → NO_COVERAGE

3.3
Location : matchesSafely
Killed by : oghamthymeleafv3.it.ExternalFileTest.fileUnreadable(oghamthymeleafv3.it.ExternalFileTest)
replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED

4.4
Location : matchesSafely
Killed by : none
replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → TIMED_OUT

5.5
Location : matchesSafely
Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec
replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED

6.6
Location : matchesSafely
Killed by : oghamspringbootv2autoconfigure.it.StaticMethodAccessTest.emailUsingFreemarkerTemplateAndStaticMethodAccessDisabledShouldFail(oghamspringbootv2autoconfigure.it.StaticMethodAccessTest)
replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED

7.7
Location : matchesSafely
Killed by : oghamcloudhopper.it.PartialConfigurationTest.splitterEnabledAndAutoGuessEnabledAndGsm7bitEncodingConfiguredAndLongMessageWithUnsupportedCharactersShouldFailIndicatingThatMessageCantBeSplit(oghamcloudhopper.it.PartialConfigurationTest)
replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED

8.8
Location : matchesSafely
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredAndTemplateParsersOnlyRegisteredCantHandleTemplateContentDueToResourceResolutionNotConfigured(oghamall.it.configuration.EmptyBuilderTest)
replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED

9.9
Location : matchesSafely
Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest)
replaced boolean return with false for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED

10.10
Location : matchesSafely
Killed by : none
replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → SURVIVED

11.11
Location : matchesSafely
Killed by : oghamtesting.it.assertion.hamcrest.ThrowableAnyCauseMatcherSpec
replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → KILLED

12.12
Location : matchesSafely
Killed by : none
replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → TIMED_OUT

13.13
Location : matchesSafely
Killed by : none
replaced boolean return with true for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::matchesSafely → NO_COVERAGE

35

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

40

1.1
Location : toString
Killed by : none
replaced return value with "" for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::toString → NO_COVERAGE

2.2
Location : toString
Killed by : none
replaced return value with "" for fr/sii/ogham/testing/assertion/hamcrest/ThrowableMessageMatcher::toString → SURVIVED

Active mutators

Tests examined


Report generated by PIT OGHAM