Class 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 a TestLogger, for a specific log level.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Supplier<List<LoggingEvent>> loggingEventsSupplier  
      • Fields inherited from class org.assertj.core.api.AbstractAssert

        actual, info, myself, objects, throwUnsupportedExceptionOnEquals
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(Object o)  
      protected static LoggingEvent event​(Throwable throwable, Level level, String message, Object... arguments)  
      protected static LoggingEvent event​(Level level, String message, Object... arguments)  
      protected long getLogCount​(Level level, Predicate<LoggingEvent> predicate)  
      int hashCode()  
      LevelAssert hasMessageContaining​(String substring)
      Assert that the given log level includes a log message that contains a substring.
      LevelAssert hasMessageMatching​(String regex)
      Assert that the given log level includes a log message that matches a regex.
      LevelAssert hasNumberOfLogs​(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
      • Methods inherited from interface org.assertj.core.api.Descriptable

        as, as, as, describedAs
    • Constructor Detail

    • 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 LevelAssert for 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 LevelAssert for 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 LevelAssert for chaining
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class org.assertj.core.api.AbstractAssert<LevelAssert,​TestLogger>