Package testUtils
Class LoggingMatcher<T>
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeMatcher<T>
testUtils.LoggingMatcher<T>
- Type Parameters:
T
- the type of object being matched
- All Implemented Interfaces:
org.hamcrest.Matcher<T>
,org.hamcrest.SelfDescribing
public class LoggingMatcher<T>
extends org.hamcrest.TypeSafeMatcher<T>
A Hamcrest matcher that logs assertion results using Log4j2.
-
Constructor Summary
ConstructorsConstructorDescriptionLoggingMatcher
(org.apache.logging.log4j.Logger logger, org.hamcrest.Matcher<? super T> matcher, String message) Constructs a LoggingMatcher. -
Method Summary
Modifier and TypeMethodDescriptionvoid
describeTo
(org.hamcrest.Description description) Describes the matcher to the given description.static <T> LoggingMatcher
<T> log
(org.apache.logging.log4j.Logger logger, org.hamcrest.Matcher<? super T> matcher, String message) Factory method to create a LoggingMatcher.protected boolean
matchesSafely
(T actual) Evaluates the matcher and logs the result.Methods inherited from class org.hamcrest.TypeSafeMatcher
describeMismatch, describeMismatchSafely, matches
Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
-
Constructor Details
-
Method Details
-
matchesSafely
Evaluates the matcher and logs the result.- Specified by:
matchesSafely
in classorg.hamcrest.TypeSafeMatcher<T>
- Parameters:
actual
- the actual value- Returns:
- true if the match is successful, false otherwise
-
describeTo
public void describeTo(org.hamcrest.Description description) Describes the matcher to the given description.- Parameters:
description
- the description to append to
-
log
public static <T> LoggingMatcher<T> log(org.apache.logging.log4j.Logger logger, org.hamcrest.Matcher<? super T> matcher, String message) Factory method to create a LoggingMatcher.- Type Parameters:
T
- the type of object being matched- Parameters:
logger
- the logger to usematcher
- the matcher to delegate tomessage
- the assertion message- Returns:
- a new LoggingMatcher instance
-