Class ScenarioScriptLoader

java.lang.Object
com.agentforge4j.testkit.scenario.ScenarioScriptLoader

public final class ScenarioScriptLoader extends Object
Loads a scenario's fake-llm script into a FakeScript from a JSON string, a filesystem path, or a classpath resource. The catalog scenario script.json is the fake-llm script schema verbatim, so it is parsed directly by FakeScriptParser with no adapter.
  • Constructor Details

    • ScenarioScriptLoader

      public ScenarioScriptLoader()
      Creates a loader with a default FakeScriptParser.
    • ScenarioScriptLoader

      public ScenarioScriptLoader(FakeScriptParser parser)
      Creates a loader over the given parser.
      Parameters:
      parser - the script parser; must not be null
  • Method Details

    • fromJson

      public FakeScript fromJson(String json)
      Parses a script from a JSON string.
      Parameters:
      json - the script JSON; must not be blank
      Returns:
      the parsed script
      Throws:
      IllegalArgumentException - if the JSON is malformed or violates the script schema
    • fromPath

      public FakeScript fromPath(Path path)
      Reads and parses a script from a filesystem path.
      Parameters:
      path - the script file; must not be null
      Returns:
      the parsed script
    • fromClasspath

      public FakeScript fromClasspath(String resource)
      Reads and parses a script from a classpath resource.
      Parameters:
      resource - the absolute classpath resource path (e.g. /scenarios/x/script.json); must not be blank
      Returns:
      the parsed script