Class EvaluatorTestKit<E extends akka.javasdk.evaluation.Evaluator>

Object
akka.javasdk.testkit.EvaluatorTestKit<E>

public class EvaluatorTestKit<E extends akka.javasdk.evaluation.Evaluator> extends Object
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 Details

    • DEFAULT_EVALUATION_ID

      public static final String 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

      public EvaluatorTestKit<E> withConfig(com.typesafe.config.Config config)
      A testkit whose evaluations see the given configuration through EvaluationContext.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

      public EvaluatorResult evaluate(akka.javasdk.evaluation.Subject subject)
      Run the evaluator's evaluate handler over the given subject, using the DEFAULT_EVALUATION_ID.
      Parameters:
      subject - the interaction to evaluate
      Returns:
      the result of the evaluation
    • evaluate

      public EvaluatorResult evaluate(akka.javasdk.evaluation.Subject subject, String evaluationId)
      Run the evaluator's evaluate handler over the given subject, using the given evaluation id.
      Parameters:
      subject - the interaction to evaluate
      evaluationId - the id of the evaluation
      Returns:
      the result of the evaluation