Class PromptBuilder
The prompt produced by this class combines several components into a single instruction payload:
- classification instructions for the AI model
- a controlled security taxonomy definition
- strict output formatting rules
- the fully qualified class name
- the complete source code of the analyzed test class
This revision keeps the full class source as semantic context but removes method discovery from the AI model. The caller supplies the exact list of JUnit test methods that must be classified, optionally with source line anchors.
The resulting prompt is passed to the configured AI provider and instructs the model to produce a deterministic JSON classification result describing security relevance and taxonomy tags for individual test methods.
The prompt enforces a closed taxonomy and strict JSON output rules to ensure that the returned content can be parsed reliably by the application.
This class is a non-instantiable utility holder.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordDeterministically extracted test method descriptor supplied to the prompt. -
Method Summary
-
Method Details
-
build
public static String build(String fqcn, String classSource, String taxonomyText, List<PromptBuilder.TargetMethod> targetMethods, boolean confidence) Builds the complete prompt supplied to an AI provider for security classification of a JUnit test class.The generated prompt contains:
- task instructions describing the classification objective
- the security taxonomy definition controlling allowed tags
- the exact list of target test methods to classify
- strict output rules enforcing JSON-only responses
- a formal JSON schema describing the expected result structure
- the fully qualified class name of the analyzed test class
- the complete class source used as analysis input
The taxonomy text supplied to this method is typically obtained from either
DefaultSecurityTaxonomy.text()orOptimizedSecurityTaxonomy.text(), depending on the selectedAiOptions.TaxonomyMode.The returned prompt is intended to be used as the content of a user message in chat-based inference APIs.
- Parameters:
fqcn- fully qualified class name of the test class being analyzedclassSource- complete source code of the test classtaxonomyText- taxonomy definition guiding classificationtargetMethods- exact list of deterministically discovered JUnit test methods to classifyconfidence- whentrue, the prompt instructs the AI to include aconfidencescore for each method classification- Returns:
- formatted prompt supplied to the AI provider
- See Also:
-