Class ApiTestRenderer
java.lang.Object
com.shaft.capture.generate.api.ApiTestRenderer
Renders a compiling
SHAFT.API TestNG class from recorded, classified, and correlated
API transactions. Mirrors com.shaft.capture.generate.CaptureGenerator's
validate->analyze->render staging, scoped to API transactions rather than UI events.
One SHAFT.API field is rendered per origin (scheme://host[:port]); headers common to
every transaction of an origin are hoisted into @BeforeClass as session-level headers,
and any sensitive header (a secret-ref:<ENV_NAME> token from
com.shaft.capture.network.SecretHeaderReplacer) is replayed via a generated
requiredEnvironment(String) helper rather than ever being written to source as a
literal.
Correlation (see TransactionCorrelator) only ever chains values within the same
rendered @Test method -- a variable extracted in one method is not visible from another,
so correlation is computed and applied per origin group (one SCENARIO method), never
across origins or across PER_REQUEST methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic RenderedApiTestrender(String packageName, String className, List<ApiTransaction> transactions, ApiCodegenStyle style, ApiValidationDepth depth) Renders one API test class from a set of already-filtered, renderable transactions.static RenderedApiTestrender(String packageName, String className, List<ApiTransaction> transactions, ApiCodegenStyle style, ApiValidationDepth depth, Map<Long, List<String>> uiActionsBySequence) Renders one API test class, asrender(String, String, List, ApiCodegenStyle, ApiValidationDepth), additionally accepting pre-rendered UI action source lines forApiCodegenStyle.HYBRID_UI_API.static RenderedApiTestrender(String packageName, String className, List<ApiTransaction> transactions, ApiCodegenStyle style, ApiValidationDepth depth, Map<Long, List<String>> uiActionsBySequence, Set<String> pinnedJsonPaths) Renders one API test class, asrender(String, String, List, ApiCodegenStyle, ApiValidationDepth, Map), additionally accepting an explicit set of response JSON paths to force-assert asApiValidationDepth.BUSINESSbusiness assertions even when their leaf is classifiedVOLATILEorCORRELATED(issue #3530 pinned-path render gate).
-
Method Details
-
render
public static RenderedApiTest render(String packageName, String className, List<ApiTransaction> transactions, ApiCodegenStyle style, ApiValidationDepth depth) Renders one API test class from a set of already-filtered, renderable transactions.- Parameters:
packageName- generated class packageclassName- generated class nametransactions- renderable transactions (already filtered to XHR/FETCH-like requests with a real response) in recorded orderstyle- how transactions are grouped into test methodsdepth- how thoroughly each response is validated- Returns:
- generated source, any test-data artifacts (schema/golden files) it references, and any transaction IDs skipped because SHAFT.API has no builder for their HTTP method
-
render
public static RenderedApiTest render(String packageName, String className, List<ApiTransaction> transactions, ApiCodegenStyle style, ApiValidationDepth depth, Map<Long, List<String>> uiActionsBySequence, Set<String> pinnedJsonPaths) Renders one API test class, asrender(String, String, List, ApiCodegenStyle, ApiValidationDepth, Map), additionally accepting an explicit set of response JSON paths to force-assert asApiValidationDepth.BUSINESSbusiness assertions even when their leaf is classifiedVOLATILEorCORRELATED(issue #3530 pinned-path render gate). ASENSITIVEleaf or a blank-value leaf is never asserted, regardless of pinning.- Parameters:
packageName- generated class packageclassName- generated class nametransactions- renderable transactions in recorded orderstyle- how transactions are grouped into test methodsdepth- how thoroughly each response is validateduiActionsBySequence- forApiCodegenStyle.HYBRID_UI_APIonly: seerender(String, String, List, ApiCodegenStyle, ApiValidationDepth, Map)pinnedJsonPaths- response JSON paths (e.g.$.status) to force-include as business assertions atBUSINESSdepth; ignored at every other depth.nullis treated as empty.- Returns:
- generated source, any test-data artifacts it references, and any transaction IDs skipped because SHAFT.API has no builder for their HTTP method
-
render
public static RenderedApiTest render(String packageName, String className, List<ApiTransaction> transactions, ApiCodegenStyle style, ApiValidationDepth depth, Map<Long, List<String>> uiActionsBySequence) Renders one API test class, asrender(String, String, List, ApiCodegenStyle, ApiValidationDepth), additionally accepting pre-rendered UI action source lines forApiCodegenStyle.HYBRID_UI_API.- Parameters:
packageName- generated class packageclassName- generated class nametransactions- renderable transactions in recorded orderstyle- how transactions are grouped into test methodsdepth- how thoroughly each response is validateduiActionsBySequence- forApiCodegenStyle.HYBRID_UI_APIonly: caller-supplied UI action source lines (e.g.driver.element().click(...);) keyed by the capture-session sequence number they were recorded at. Ignored by every other style. May be empty, in which case the hybrid method still renders deterministically -- it degrades to API-only assertions with no interleaved UI lines.- Returns:
- generated source, any test-data artifacts it references, and any transaction IDs skipped because SHAFT.API has no builder for their HTTP method
-