Class ProgressHistoryStore

java.lang.Object
com.arc_e_tect.gradle.gherkin.progress.ProgressHistoryStore

public class ProgressHistoryStore extends Object
Reads and writes ScenarioProgressRecords as newline-delimited JSON (NDJSON), one record per line, sorted by ScenarioProgressRecord.fingerprint() so that git diffs of the persisted file are minimal and stable regardless of scenario reordering or scenarios moving between feature files.

The schema is fixed and flat, so the serializer/parser is hand-rolled (no JSON library dependency) - only ScenarioProgressRecord.scenarioName() and ScenarioProgressRecord.featureTitle() are free text and need escaping.

  • Constructor Details

    • ProgressHistoryStore

      public ProgressHistoryStore()
      Creates a new ProgressHistoryStore.
  • Method Details

    • load

      public Map<String,ScenarioProgressRecord> load(File file)
      Loads the progress history from file.
      Parameters:
      file - the NDJSON history file; need not exist
      Returns:
      the records keyed by fingerprint; empty when file doesn't exist. A line that fails to parse is skipped with a WARN-level log message identifying the line number - it never fails the build.
    • save

      public void save(File file, Collection<ScenarioProgressRecord> records)
      Writes records to file as NDJSON, sorted by ScenarioProgressRecord.fingerprint(), overwriting any existing content.
      Parameters:
      file - the NDJSON history file to write
      records - the records to persist