Class CapturingFileSink

java.lang.Object
com.agentforge4j.testkit.capture.CapturingFileSink
All Implemented Interfaces:
FileSink

public final class CapturingFileSink extends Object implements FileSink
In-memory FileSink that captures every write instead of touching disk, so a test can assert which files a run produced.

Writes are captured verbatim — including any path-traversal attempt — because there is no filesystem to protect; traversal rejection is exercised at the command layer, not here.

  • Constructor Details

    • CapturingFileSink

      public CapturingFileSink()
  • Method Details

    • write

      public void write(String runId, String stepId, String path, String content)
      Description copied from interface: FileSink
      Accept a file produced by an agent. Implementations are responsible for their own path-traversal protection when the target is a real filesystem.
      Specified by:
      write in interface FileSink
      Parameters:
      runId - id of the owning run — useful for scoping outputs per run
      stepId - id of the producing step
      path - the path the agent requested
      content - the file content
    • capturedFiles

      public List<CapturedFile> capturedFiles()
      Returns the captured writes in the order they occurred.
      Returns:
      an immutable snapshot of the captured files