Record Class AssertionResult

java.lang.Object
java.lang.Record
dev.agenor.tools.eval.AssertionResult
Record Components:
name - descriptive name of the assertion
passed - true if assertion succeeded
message - description or failure reason
expected - expected value (for comparison assertions)
actual - actual value found
duration - time taken to evaluate (optional)

public record AssertionResult(String name, boolean passed, String message, Object expected, Object actual, Duration duration) extends Record
Result of a single assertion in an evaluation scenario.

Captures whether an assertion passed or failed, along with contextual information for debugging failures.

Since:
0.5.0
  • Constructor Details

    • AssertionResult

      public AssertionResult(String name, boolean passed, String message, Object expected, Object actual, Duration duration)
      Compact constructor with validation.
  • Method Details

    • pass

      public static AssertionResult pass(String name)
      Creates a passed assertion result.
      Parameters:
      name - assertion name
      Returns:
      passed result
    • pass

      public static AssertionResult pass(String name, String message)
      Creates a passed assertion with message.
      Parameters:
      name - assertion name
      message - success message
      Returns:
      passed result
    • fail

      public static AssertionResult fail(String name, String message)
      Creates a failed assertion result.
      Parameters:
      name - assertion name
      message - failure reason
      Returns:
      failed result
    • fail

      public static AssertionResult fail(String name, String message, Object expected, Object actual)
      Creates a failed assertion with expected/actual values.
      Parameters:
      name - assertion name
      message - failure reason
      expected - expected value
      actual - actual value
      Returns:
      failed result
    • withTiming

      public static AssertionResult withTiming(String name, boolean passed, String message, Duration duration)
      Creates an assertion result with timing information.
      Parameters:
      name - assertion name
      passed - whether passed
      message - description
      duration - evaluation time
      Returns:
      result with timing
    • failed

      public boolean failed()
      Checks if this assertion failed.
      Returns:
      true if failed
    • format

      public String format()
      Returns a formatted string for display.
      Returns:
      formatted result string
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • passed

      public boolean passed()
      Returns the value of the passed record component.
      Returns:
      the value of the passed record component
    • message

      public String message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component
    • expected

      public Object expected()
      Returns the value of the expected record component.
      Returns:
      the value of the expected record component
    • actual

      public Object actual()
      Returns the value of the actual record component.
      Returns:
      the value of the actual record component
    • duration

      public Duration duration()
      Returns the value of the duration record component.
      Returns:
      the value of the duration record component