Package dev.agenor.tools.eval
Record Class AssertionResult
java.lang.Object
java.lang.Record
dev.agenor.tools.eval.AssertionResult
- Record Components:
name- descriptive name of the assertionpassed- true if assertion succeededmessage- description or failure reasonexpected- expected value (for comparison assertions)actual- actual value foundduration- 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionactual()Returns the value of theactualrecord component.duration()Returns the value of thedurationrecord component.final booleanIndicates whether some other object is "equal to" this one.expected()Returns the value of theexpectedrecord component.static AssertionResultCreates a failed assertion result.static AssertionResultCreates a failed assertion with expected/actual values.booleanfailed()Checks if this assertion failed.format()Returns a formatted string for display.final inthashCode()Returns a hash code value for this object.message()Returns the value of themessagerecord component.name()Returns the value of thenamerecord component.static AssertionResultCreates a passed assertion result.static AssertionResultCreates a passed assertion with message.booleanpassed()Returns the value of thepassedrecord component.toString()Returns a string representation of this record class.static AssertionResultwithTiming(String name, boolean passed, String message, Duration duration) Creates an assertion result with timing information.
-
Constructor Details
-
Method Details
-
pass
Creates a passed assertion result.- Parameters:
name- assertion name- Returns:
- passed result
-
pass
Creates a passed assertion with message.- Parameters:
name- assertion namemessage- success message- Returns:
- passed result
-
fail
Creates a failed assertion result.- Parameters:
name- assertion namemessage- failure reason- Returns:
- failed result
-
fail
Creates a failed assertion with expected/actual values.- Parameters:
name- assertion namemessage- failure reasonexpected- expected valueactual- 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 namepassed- whether passedmessage- descriptionduration- evaluation time- Returns:
- result with timing
-
failed
public boolean failed()Checks if this assertion failed.- Returns:
- true if failed
-
format
Returns a formatted string for display.- Returns:
- formatted result 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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
passed
public boolean passed()Returns the value of thepassedrecord component.- Returns:
- the value of the
passedrecord component
-
message
Returns the value of themessagerecord component.- Returns:
- the value of the
messagerecord component
-
expected
Returns the value of theexpectedrecord component.- Returns:
- the value of the
expectedrecord component
-
actual
Returns the value of theactualrecord component.- Returns:
- the value of the
actualrecord component
-
duration
Returns the value of thedurationrecord component.- Returns:
- the value of the
durationrecord component
-