Class WireMockStubScanner
*.json) for the request each one stubs, treating
every stubbed request as an implemented endpoint.
Stub files are data, not code - this is a plain line/regex scan, deliberately without a JSON
parser or the WireMock library itself on the classpath. One file is expected to describe one
stub, the common convention for files stored under a mappings directory: the first
method field and the first url/urlPath/urlPattern/
urlPathPattern field found in the file are used.
urlPattern/urlPathPattern are WireMock regular expressions, not Spring/
OpenAPI path templates - see normalizePattern(String) for how a regex path-variable
segment (e.g. "[0-9]+") is recognised and rewritten into the "{id}"-style
placeholder a declared/implemented endpoint's path actually uses, so this scanner's stub
evidence can be recognised as evidence for that endpoint instead of accumulating as a
permanently unmatched, orphaned path in its own right. url/urlPath are literal
WireMock matchers, never regular expressions, and are used as-is (beyond
PathTemplates.normalize(String)'s own formatting normalisation).
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
WireMockStubScanner
public WireMockStubScanner()Creates a newWireMockStubScanner.
-
-
Method Details
-
scan
public List<com.arc_e_tect.gradle.detector.core.model.Endpoint> scan(File rootDir) throws IOException Scans every.jsonfile underrootDir, recursively, for the stubbed method and URL.- Parameters:
rootDir- directory to search; may not exist, in which case an empty list is returned- Returns:
- one
Endpointper stub file that has both a recognised method and URL - Throws:
IOException- if a stub file cannot be read
-