Package com.github.valfirst.slf4jtest
Class LevelAssert
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<C,TestLogger>
-
- com.github.valfirst.slf4jtest.LevelAssert
-
- All Implemented Interfaces:
org.assertj.core.api.Assert<LevelAssert,TestLogger>,org.assertj.core.api.Descriptable<LevelAssert>,org.assertj.core.api.ExtensionPoints<LevelAssert,TestLogger>
public class LevelAssert extends org.assertj.core.api.AbstractAssert<C,TestLogger>
A set of assertions to validate that logs have been logged to aTestLogger, for a specific log level.
-
-
Field Summary
Fields Modifier and Type Field Description protected Supplier<List<LoggingEvent>>loggingEventsSupplier
-
Constructor Summary
Constructors Constructor Description LevelAssert(TestLogger logger, Level level)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)protected static LoggingEventevent(Throwable throwable, Level level, String message, Object... arguments)protected static LoggingEventevent(Level level, String message, Object... arguments)protected longgetLogCount(Level level, Predicate<LoggingEvent> predicate)inthashCode()LevelAsserthasMessageContaining(String substring)Assert that the given log level includes a log message that contains a substring.LevelAsserthasMessageMatching(String regex)Assert that the given log level includes a log message that matches a regex.LevelAsserthasNumberOfLogs(int expected)Assert that the given log level has the expected number of logs, regardless of content.protected static Predicate<LoggingEvent>logWithMessage(String message, Object... arguments)protected static Predicate<LoggingEvent>logWithMessage(String message, Optional<Throwable> maybeThrowable, Object... arguments)-
Methods inherited from class org.assertj.core.api.AbstractAssert
asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
-
-
-
-
Field Detail
-
loggingEventsSupplier
protected Supplier<List<LoggingEvent>> loggingEventsSupplier
-
-
Constructor Detail
-
LevelAssert
public LevelAssert(TestLogger logger, Level level)
-
-
Method Detail
-
hasNumberOfLogs
public LevelAssert hasNumberOfLogs(int expected)
Assert that the given log level has the expected number of logs, regardless of content.- Parameters:
expected- the number of logs expected at this level- Returns:
- a
LevelAssertfor chaining
-
hasMessageContaining
public LevelAssert hasMessageContaining(String substring)
Assert that the given log level includes a log message that contains a substring.- Parameters:
substring- a substring of a log message that should be present- Returns:
- a
LevelAssertfor chaining
-
hasMessageMatching
public LevelAssert hasMessageMatching(String regex)
Assert that the given log level includes a log message that matches a regex.- Parameters:
regex- the regular expression to which this string is to be matched- Returns:
- a
LevelAssertfor chaining
-
equals
public boolean equals(Object o)
- Specified by:
equalsin interfaceorg.assertj.core.api.Assert<LevelAssert,TestLogger>- Overrides:
equalsin classorg.assertj.core.api.AbstractAssert<LevelAssert,TestLogger>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classorg.assertj.core.api.AbstractAssert<LevelAssert,TestLogger>
-
getLogCount
protected long getLogCount(Level level, Predicate<LoggingEvent> predicate)
-
logWithMessage
protected static Predicate<LoggingEvent> logWithMessage(String message, Object... arguments)
-
logWithMessage
protected static Predicate<LoggingEvent> logWithMessage(String message, Optional<Throwable> maybeThrowable, Object... arguments)
-
event
protected static LoggingEvent event(Level level, String message, Object... arguments)
-
event
protected static LoggingEvent event(Throwable throwable, Level level, String message, Object... arguments)
-
-