Class TestLedgerClient

Object
akka.javasdk.testkit.TestLedgerClient
All Implemented Interfaces:
akka.javasdk.ledger.LedgerClient

public final class TestLedgerClient extends Object implements akka.javasdk.ledger.LedgerClient
An in-memory LedgerClient for unit tests.

Seed it with InteractionRecords via seed(InteractionRecord), or with EvaluationRecords via seed(EvaluationRecord), and pass it to the component under test (for example an Evaluator constructed by an EvaluatorTestKit) to assert it fetches and uses them, with no database.

  • Constructor Details

    • TestLedgerClient

      public TestLedgerClient()
  • Method Details

    • create

      public static TestLedgerClient create()
      Create an empty in-memory ledger client.
    • seed

      public TestLedgerClient seed(akka.javasdk.ledger.InteractionRecord record)
      Seed a record, keyed by its InteractionRecord.interactionId(). Replaces any existing record with the same id.
      Parameters:
      record - the record to seed
      Returns:
      this client, for chaining
    • getInteraction

      public akka.javasdk.ledger.InteractionRecord getInteraction(String interactionId)
      Specified by:
      getInteraction in interface akka.javasdk.ledger.LedgerClient
    • getInteractionAsync

      public CompletionStage<akka.javasdk.ledger.InteractionRecord> getInteractionAsync(String interactionId)
      Specified by:
      getInteractionAsync in interface akka.javasdk.ledger.LedgerClient
    • seed

      public TestLedgerClient seed(akka.javasdk.ledger.EvaluationRecord record)
      Seed an evaluation record, keyed by its EvaluationRecord.evaluationId(). Replaces any existing record with the same id.
      Parameters:
      record - the record to seed
      Returns:
      this client, for chaining
    • getEvaluation

      public akka.javasdk.ledger.EvaluationRecord getEvaluation(String evaluationId)
      Specified by:
      getEvaluation in interface akka.javasdk.ledger.LedgerClient
    • getEvaluationAsync

      public CompletionStage<akka.javasdk.ledger.EvaluationRecord> getEvaluationAsync(String evaluationId)
      Specified by:
      getEvaluationAsync in interface akka.javasdk.ledger.LedgerClient
    • getEvaluations

      public List<akka.javasdk.ledger.EvaluationRecord> getEvaluations(String interactionId)
      Specified by:
      getEvaluations in interface akka.javasdk.ledger.LedgerClient
    • getEvaluationsAsync

      public CompletionStage<List<akka.javasdk.ledger.EvaluationRecord>> getEvaluationsAsync(String interactionId)
      Specified by:
      getEvaluationsAsync in interface akka.javasdk.ledger.LedgerClient