Class CommandSupport
Command implementations.
This utility class centralises provider loading, scan orchestration, AI suggestion resolution, content hashing, and other cross-cutting concerns. All methods are static; this class cannot be instantiated.
Methods marked public (requireUniqueDiscoveryIds(java.util.List<org.egothor.methodatlas.api.TestDiscovery>),
requireUniquePatcherIds(java.util.List<org.egothor.methodatlas.api.SourcePatcher>), computeFilePrefix(java.util.List<java.nio.file.Path>),
buildAiEngine(org.egothor.methodatlas.ai.AiOptions), buildAiCache(java.nio.file.Path), and
loadClassificationOverride(java.nio.file.Path)) are called either by
MethodAtlasApp (a different package) or
directly by unit tests; all other methods are package-private and intended
for use within the org.egothor.methodatlas.command package only.
-
Method Summary
Modifier and TypeMethodDescriptionstatic AiResultCachebuildAiCache(Path cacheFile) Loads the AI result cache from the given CSV file, or returns the empty no-op cache when no cache file is configured.static AiSuggestionEnginebuildAiEngine(AiOptions aiOptions) Creates the AI suggestion engine for the current run.static StringcomputeFilePrefix(List<Path> roots) Derives the file path prefix used in GitHub Actions workflow command annotations from the first configured scan root.static ClassificationOverrideloadClassificationOverride(Path overrideFile) Loads the classification override file, or returns the empty no-op singleton when no override file is configured.static voidrequireUniqueDiscoveryIds(List<org.egothor.methodatlas.api.TestDiscovery> providers) Verifies that everyTestDiscoveryprovider in the list has a uniqueTestDiscovery.pluginId().static voidrequireUniquePatcherIds(List<org.egothor.methodatlas.api.SourcePatcher> patchers) Verifies that everySourcePatcherin the list has a uniqueSourcePatcher.pluginId().
-
Method Details
-
buildAiEngine
Creates the AI suggestion engine for the current run.Returns
nullwhen AI support is disabled. Initialization failures are wrapped in anIllegalStateException.- Parameters:
aiOptions- AI configuration for the current run- Returns:
- initialized AI suggestion engine, or
nullwhen AI is disabled - Throws:
IllegalStateException- if engine initialization fails
-
buildAiCache
Loads the AI result cache from the given CSV file, or returns the empty no-op cache when no cache file is configured.- Parameters:
cacheFile- path to a previous MethodAtlas CSV output, ornull- Returns:
- loaded cache; never
null - Throws:
IllegalArgumentException- if the file exists but cannot be read or parsed
-
loadClassificationOverride
Loads the classification override file, or returns the empty no-op singleton when no override file is configured.- Parameters:
overrideFile- path to the YAML override file, ornull- Returns:
- loaded override set; never
null - Throws:
IllegalArgumentException- if the file exists but cannot be read or contains invalid YAML
-
requireUniqueDiscoveryIds
public static void requireUniqueDiscoveryIds(List<org.egothor.methodatlas.api.TestDiscovery> providers) Verifies that everyTestDiscoveryprovider in the list has a uniqueTestDiscovery.pluginId().- Parameters:
providers- list of configured providers- Throws:
IllegalStateException- if two or more providers share the same ID
-
requireUniquePatcherIds
public static void requireUniquePatcherIds(List<org.egothor.methodatlas.api.SourcePatcher> patchers) Verifies that everySourcePatcherin the list has a uniqueSourcePatcher.pluginId().- Parameters:
patchers- list of configured patchers- Throws:
IllegalStateException- if two or more patchers share the same ID
-
computeFilePrefix
Derives the file path prefix used in GitHub Actions workflow command annotations from the first configured scan root.The prefix is made relative to the current working directory so that the resulting annotation paths (e.g.
src/test/java/com/acme/AuthTest.java) match what GitHub resolves as inline positions in the PR diff.- Parameters:
roots- configured scan roots; may be empty- Returns:
- forward-slash path ending with
/, or empty string whenrootsis empty
-