Class WireMockStubScanner

java.lang.Object
com.arc_e_tect.gradle.mirage.scan.WireMockStubScanner

public class WireMockStubScanner extends Object
Scans WireMock stub mapping files (*.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.

  • Constructor Details

    • WireMockStubScanner

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

    • scan

      public List<com.arc_e_tect.gradle.detector.core.model.Endpoint> scan(File rootDir) throws IOException
      Scans every .json file under rootDir, 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 Endpoint per stub file that has both a recognised method and URL
      Throws:
      IOException - if a stub file cannot be read