com.codereligion.cherry.test.hamcrest.logback
Class LoggingEventIterableHasItem
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeDiagnosingMatcher<Iterable<ch.qos.logback.classic.spi.ILoggingEvent>>
com.codereligion.cherry.test.hamcrest.logback.LoggingEventIterableHasItem
- All Implemented Interfaces:
- org.hamcrest.Matcher<Iterable<ch.qos.logback.classic.spi.ILoggingEvent>>, org.hamcrest.SelfDescribing
public class LoggingEventIterableHasItem
- extends org.hamcrest.TypeSafeDiagnosingMatcher<Iterable<ch.qos.logback.classic.spi.ILoggingEvent>>
A matcher which expects at least one item of an iterable of ILoggingEvents to match the given Matcher.
- Since:
- 23.03.2015
- Author:
- Sebastian Gröbler
|
Method Summary |
void |
describeTo(org.hamcrest.Description description)
|
static org.hamcrest.Matcher<Iterable<ch.qos.logback.classic.spi.ILoggingEvent>> |
hasItem(org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> itemMatcher)
Creates a new matcher for iterables of ILoggingEvents that only matches when at least one event matches
the given Matcher. |
static org.hamcrest.Matcher<Iterable<ch.qos.logback.classic.spi.ILoggingEvent>> |
hasNoItem(org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> itemMatcher)
Creates a new matcher for iterables of ILoggingEvents that only matches when at no event matches the
given Matcher. |
protected boolean |
matchesSafely(Iterable<ch.qos.logback.classic.spi.ILoggingEvent> collection,
org.hamcrest.Description mismatchDescription)
|
| Methods inherited from class org.hamcrest.TypeSafeDiagnosingMatcher |
describeMismatch, matches |
| Methods inherited from class org.hamcrest.BaseMatcher |
_dont_implement_Matcher___instead_extend_BaseMatcher_, toString |
hasItem
public static org.hamcrest.Matcher<Iterable<ch.qos.logback.classic.spi.ILoggingEvent>> hasItem(org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> itemMatcher)
- Creates a new matcher for iterables of
ILoggingEvents that only matches when at least one event matches
the given Matcher. It is recommended to use this specific matcher instead of just combining the other matcher with CoreMatchers.hasItem(Object) because of the improved error output and generics handling.
Example usage: assertThat(event, hasItem(withLevel(Level.ERROR)));
Example output: Expected: an iterable containing an ILoggingEvent with level: ERROR but: was [ILoggingEvent{level=INFO, formattedMessage='some
Message', loggedBy=SomeLogger, throwable=null}]
- Parameters:
itemMatcher - the logging event Matcher to check the items with
- Returns:
- a new matcher
- Throws:
IllegalArgumentException - when the given parameter is null
hasNoItem
public static org.hamcrest.Matcher<Iterable<ch.qos.logback.classic.spi.ILoggingEvent>> hasNoItem(org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> itemMatcher)
- Creates a new matcher for iterables of
ILoggingEvents that only matches when at no event matches the
given Matcher. This matcher is the negation of hasItem(Matcher). It is recommended to use this
specific matcher instead of just combining the other matcher with CoreMatchers.not(Matcher) because of the improved error output.
Example usage: assertThat(event, hasNoItem(withLevel(Level.ERROR)));
Example output: Expected: an iterable not containing an ILoggingEvent with level: ERROR but: was [ILoggingEvent{level=ERROR,
formattedMessage='some Message', loggedBy=SomeLogger, throwable=null}]
- Parameters:
itemMatcher - the logging event Matcher to check the items with
- Returns:
- a new matcher
- Throws:
IllegalArgumentException - when the given itemMatcher is null
matchesSafely
protected boolean matchesSafely(Iterable<ch.qos.logback.classic.spi.ILoggingEvent> collection,
org.hamcrest.Description mismatchDescription)
- Specified by:
matchesSafely in class org.hamcrest.TypeSafeDiagnosingMatcher<Iterable<ch.qos.logback.classic.spi.ILoggingEvent>>
describeTo
public void describeTo(org.hamcrest.Description description)
Copyright © 2015. All rights reserved.