Module agentforge4j.testkit
Package com.agentforge4j.testkit.harness
Class WorkflowTestHarness.Builder
java.lang.Object
com.agentforge4j.testkit.harness.WorkflowTestHarness.Builder
- Enclosing class:
- WorkflowTestHarness
Fluent builder for
WorkflowTestHarness. workflowsDir and script are
required; agentsDir is optional (agents bundled inside the workflow need none) and the
clock defaults to a fixed epoch clock for deterministic event timestamps.-
Method Summary
Modifier and TypeMethodDescriptionSets the directory the config-loader scans for standalone agent bundles.build()Builds the harness.Overrides the clock used for deterministic event timestamps.fileSinkDir(Path value) RoutesCREATE_FILEwrites to the productionLocalFileSinkrooted at the given directory — exercising the real path-traversal guard and writing to disk — instead of the defaultCapturingFileSinkthat records writes verbatim without filesystem enforcement.script(FakeScript value) Sets the parsed fake script served to every run.shippedCatalog(boolean value) Loads the real shipped workflow + agent catalog from the classpath (the productionloadShippedWorkflows/loadShippedAgentspath) instead of a fixtures directory.Overrides the tool-invocation tunables, most usefully the authoritative per-invocation timeout — pair a short timeout with a deliberately hanging provider to exercise the timeout arm of the governance chokepoint.toolPolicy(ToolPolicy value) Overrides the tool policy evaluated before a tool invocation.toolProviders(List<ToolProvider> value) Wires in-process tool providers so an agent'sTOOL_INVOCATIONresolves to a real provider without a network transport.workflowsDir(Path value) Sets the directory the config-loader scans for workflow bundles.
-
Method Details
-
workflowsDir
Sets the directory the config-loader scans for workflow bundles. Required unlessshippedCatalog(boolean)is enabled; mutually exclusive with it.- Parameters:
value- workflows directory; must not benull- Returns:
- this builder
-
shippedCatalog
Loads the real shipped workflow + agent catalog from the classpath (the productionloadShippedWorkflows/loadShippedAgentspath) instead of a fixtures directory. Mutually exclusive withworkflowsDir(Path)/agentsDir(Path).- Parameters:
value-trueto verify the genuine shipped catalog- Returns:
- this builder
-
agentsDir
Sets the directory the config-loader scans for standalone agent bundles. Optional — omit when the fixture bundles its agents inside the workflow.- Parameters:
value- agents directory; must not benull- Returns:
- this builder
-
script
Sets the parsed fake script served to every run.- Parameters:
value- the script; must not benull- Returns:
- this builder
-
clock
Overrides the clock used for deterministic event timestamps.- Parameters:
value- the clock; must not benull- Returns:
- this builder
-
fileSinkDir
RoutesCREATE_FILEwrites to the productionLocalFileSinkrooted at the given directory — exercising the real path-traversal guard and writing to disk — instead of the defaultCapturingFileSinkthat records writes verbatim without filesystem enforcement. When set,WorkflowRunResult.captures()carries no captured files; assert against the directory instead.- Parameters:
value- root directory for file writes; must not benull- Returns:
- this builder
-
toolProviders
Wires in-process tool providers so an agent'sTOOL_INVOCATIONresolves to a real provider without a network transport. The capability in the command is matched against each provider'slistTools()descriptors.- Parameters:
value- tool providers; must not benull(defensively copied)- Returns:
- this builder
-
toolPolicy
Overrides the tool policy evaluated before a tool invocation. Defaults to the bootstrap's secure-by-default policy (SecureDefaultToolPolicy) when unset; supplyToolPolicy.allowAll()or a custom policy returningRequireApprovalorDenyto exercise the approval/decision suspend-resume paths.- Parameters:
value- the tool policy; must not benull- Returns:
- this builder
-
toolExecutionOptions
Overrides the tool-invocation tunables, most usefully the authoritative per-invocation timeout — pair a short timeout with a deliberately hanging provider to exercise the timeout arm of the governance chokepoint. Defaults to the bootstrap'sToolExecutionOptions.defaults()when unset.- Parameters:
value- the options; must not benull- Returns:
- this builder
-
build
Builds the harness.- Returns:
- a configured
WorkflowTestHarness
-