Package akka.javasdk.testkit
Class EvaluatorTestKit<E extends akka.javasdk.evaluation.Evaluator>
Object
akka.javasdk.testkit.EvaluatorTestKit<E>
Evaluator Testkit for use in unit tests for Evaluators.
To test an Evaluator create a testkit instance by calling of(Supplier). The returned testkit can be used as many times as you want; it
doesn't preserve any state between invocations.
The factory supplies the evaluator under test — construct it with whatever
collaborators the test needs (for example a stubbed ComponentClient for LLM-as-judge
calls, or an in-memory ledger client). Use the evaluate methods to run the
evaluate handler over a chosen Subject and assert on the returned EvaluatorResult. An evaluator that reads EvaluationContext.config() gets the configuration given to withConfig(Config), empty by default.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default evaluation id used when one is not supplied. -
Method Summary
Modifier and TypeMethodDescriptionevaluate(akka.javasdk.evaluation.Subject subject) Run the evaluator'sevaluatehandler over the given subject, using theDEFAULT_EVALUATION_ID.Run the evaluator'sevaluatehandler over the given subject, using the given evaluation id.static <E extends akka.javasdk.evaluation.Evaluator>
EvaluatorTestKit<E> Create a testkit for the evaluator supplied by the given factory.withConfig(com.typesafe.config.Config config) A testkit whose evaluations see the given configuration throughEvaluationContext.config().
-
Field Details
-
DEFAULT_EVALUATION_ID
The default evaluation id used when one is not supplied.- See Also:
-
-
Method Details
-
of
public static <E extends akka.javasdk.evaluation.Evaluator> EvaluatorTestKit<E> of(Supplier<E> evaluatorFactory) Create a testkit for the evaluator supplied by the given factory. -
withConfig
A testkit whose evaluations see the given configuration throughEvaluationContext.config(). In a running service this is the binding that the runtime used for the agent, with the evaluator entry as fallback.- Parameters:
config- the configuration for the evaluations- Returns:
- a testkit with the configuration
-
evaluate
Run the evaluator'sevaluatehandler over the given subject, using theDEFAULT_EVALUATION_ID.- Parameters:
subject- the interaction to evaluate- Returns:
- the result of the evaluation
-
evaluate
Run the evaluator'sevaluatehandler over the given subject, using the given evaluation id.- Parameters:
subject- the interaction to evaluateevaluationId- the id of the evaluation- Returns:
- the result of the evaluation
-