Package nl.pim16aap2.testing.logging
Class LogAssertionsUtil.LogAssertion.LogAssertionBuilder
java.lang.Object
nl.pim16aap2.testing.logging.LogAssertionsUtil.LogAssertion.LogAssertionBuilder
- Enclosing class:
LogAssertionsUtil.LogAssertion
Builder class for
LogAssertionsUtil.LogAssertion.-
Method Summary
Modifier and TypeMethodDescriptionvoidRuns the assertions on the log event as specified by this builder.build()comparisonMethod(LogAssertionsUtil.MessageComparisonMethod comparisonMethod) The method to use when comparing the expected and actual messages.formattedMessage(@Nullable String formattedMessage) The fully formatted message that was logged, with all arguments substituted.Sets the expected log level of the log event.logCaptor(@Nullable nl.altindag.log.LogCaptor logCaptor) The log captor to get the log event from.Sets both the raw message and the arguments.The position of the log event to check. 0 means the first (oldest) log event, 1 means the second, etc.toString()
-
Method Details
-
message
public LogAssertionsUtil.LogAssertion.LogAssertionBuilder message(String message, @Nullable @Nullable Object... arguments) Sets both the raw message and the arguments.Note that this method will not set the formatted message.
- Parameters:
message- The message to set. E.g. "Hello, %s!"arguments- The arguments to set.- Returns:
- This builder.
-
level
Sets the expected log level of the log event.This method will convert the provided log level to a Log4j
Level.Only the standard log levels are supported. If a custom log level is provided, it will be converted to the closest standard log level.
- Parameters:
level- The log level to set.- Returns:
- This builder.
-
assertLogged
public void assertLogged()Runs the assertions on the log event as specified by this builder. -
logCaptor
public LogAssertionsUtil.LogAssertion.LogAssertionBuilder logCaptor(@Nullable @Nullable nl.altindag.log.LogCaptor logCaptor) The log captor to get the log event from.This field is required.
- Returns:
this.
-
position
public LogAssertionsUtil.LogAssertion.LogAssertionBuilder position(@Nullable @Nullable Integer position) The position of the log event to check. 0 means the first (oldest) log event, 1 means the second, etc.If the position is negative, the position will be relative to the end of the log events. For example, -1 will get the last log event, -2 will get the second to last, etc.
When
null, all log events will be checked until the first one that matches the conditions.Default:
null- Returns:
this.
-
formattedMessage
public LogAssertionsUtil.LogAssertion.LogAssertionBuilder formattedMessage(@Nullable @Nullable String formattedMessage) The fully formatted message that was logged, with all arguments substituted.When
null, the message will not be checked.Default:
null- Returns:
this.
-
comparisonMethod
public LogAssertionsUtil.LogAssertion.LogAssertionBuilder comparisonMethod(LogAssertionsUtil.MessageComparisonMethod comparisonMethod) The method to use when comparing the expected and actual messages.- Returns:
this.
-
build
-
toString
-