Class LogCaptorAssert

java.lang.Object
org.assertj.core.api.AbstractAssert<LogCaptorAssert, nl.altindag.log.LogCaptor>
org.assertj.core.api.AbstractObjectAssert<LogCaptorAssert, nl.altindag.log.LogCaptor>
nl.pim16aap2.testing.assertions.LogCaptorAssert
All Implemented Interfaces:
org.assertj.core.api.Assert<LogCaptorAssert, nl.altindag.log.LogCaptor>, org.assertj.core.api.Descriptable<LogCaptorAssert>, org.assertj.core.api.ExtensionPoints<LogCaptorAssert, nl.altindag.log.LogCaptor>

@NullMarked public class LogCaptorAssert extends org.assertj.core.api.AbstractObjectAssert<LogCaptorAssert, nl.altindag.log.LogCaptor>
An assertion class for LogCaptor instances.

This class provides methods to assert various conditions on the logs captured by a LogCaptor. It extends AbstractAssert from AssertJ to provide fluent assertions.

  • Field Summary

    Fields inherited from class org.assertj.core.api.AbstractAssert

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

    Modifier and Type
    Method
    Description
    assertThatLogCaptor(nl.altindag.log.LogCaptor actual)
    Creates a new LogCaptorAssert for the given LogCaptor.
    Gets all logs captured by the LogCaptor.
    Gets all debug logs captured by the LogCaptor.
    Gets all warning logs captured by the LogCaptor.
    Gets all info logs captured by the LogCaptor.
    Gets all trace logs captured by the LogCaptor.
    Gets all warning logs captured by the LogCaptor.
    protected void
    failWithMessage(String errorMessage, Object... arguments)
     
    Verifies that no debug logs were captured.
    Verifies that no error logs were captured.
    Verifies that no info logs were captured.
    Verifies that no logs were captured.
    Verifies that no trace logs were captured.
    Verifies that no warning logs were captured.

    Methods inherited from class org.assertj.core.api.AbstractObjectAssert

    as, as, doesNotReturn, extracting, extracting, extracting, extracting, extracting, extracting, extractingForProxy, getComparatorsByType, hasAllNullFieldsOrProperties, hasAllNullFieldsOrPropertiesExcept, hasFieldOrProperty, hasFieldOrPropertyWithValue, hasNoNullFieldsOrProperties, hasNoNullFieldsOrPropertiesExcept, hasOnlyFields, isEqualToComparingFieldByField, isEqualToComparingFieldByFieldRecursively, isEqualToComparingOnlyGivenFields, isEqualToIgnoringGivenFields, isEqualToIgnoringNullFields, newObjectAssert, returns, usingComparatorForFields, usingComparatorForType, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison

    Methods inherited from class org.assertj.core.api.AbstractAssert

    actual, areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, doesNotMatch, doesNotMatch, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, 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, usingEquals, usingEquals, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.assertj.core.api.Descriptable

    as, describedAs, describedAs
  • Method Details

    • assertThatLogCaptor

      public static LogCaptorAssert assertThatLogCaptor(nl.altindag.log.LogCaptor actual)
      Creates a new LogCaptorAssert for the given LogCaptor.
      Parameters:
      actual - The LogCaptor to create the assertion for.
      Returns:
      A new LogCaptorAssert for the given LogCaptor.
    • failWithMessage

      protected void failWithMessage(String errorMessage, Object... arguments)
      Overrides:
      failWithMessage in class org.assertj.core.api.AbstractAssert<LogCaptorAssert, nl.altindag.log.LogCaptor>
    • atAllLevels

      public LogEventsAssert atAllLevels()
      Gets all logs captured by the LogCaptor. The result may be empty.
      Returns:
      A LogEventsAssert containing the captured log events.
    • atError

      public LogEventsAssert atError()
      Gets all warning logs captured by the LogCaptor. The result may be empty.
      Returns:
      A LogEventsAssert containing the log events at the specified level.
    • atWarn

      public LogEventsAssert atWarn()
      Gets all warning logs captured by the LogCaptor. The result may be empty.
      Returns:
      A LogEventsAssert containing the log events at the specified level.
    • atInfo

      public LogEventsAssert atInfo()
      Gets all info logs captured by the LogCaptor. The result may be empty.
      Returns:
      A LogEventsAssert containing the log events at the specified level.
    • atDebug

      public LogEventsAssert atDebug()
      Gets all debug logs captured by the LogCaptor. The result may be empty.
      Returns:
      A LogEventsAssert containing the log events at the specified level.
    • atTrace

      public LogEventsAssert atTrace()
      Gets all trace logs captured by the LogCaptor. The result may be empty.
      Returns:
      A LogEventsAssert containing the log events at the specified level.
    • hasNoLogs

      public LogCaptorAssert hasNoLogs()
      Verifies that no logs were captured.
      Returns:
      this assertion object
    • hasNoErrorLogs

      public LogCaptorAssert hasNoErrorLogs()
      Verifies that no error logs were captured.
      Returns:
      this assertion object
    • hasNoWarnLogs

      public LogCaptorAssert hasNoWarnLogs()
      Verifies that no warning logs were captured.
      Returns:
      this assertion object
    • hasNoInfoLogs

      public LogCaptorAssert hasNoInfoLogs()
      Verifies that no info logs were captured.
      Returns:
      this assertion object
    • hasNoDebugLogs

      public LogCaptorAssert hasNoDebugLogs()
      Verifies that no debug logs were captured.
      Returns:
      this assertion object
    • hasNoTraceLogs

      public LogCaptorAssert hasNoTraceLogs()
      Verifies that no trace logs were captured.
      Returns:
      this assertion object