Class RestDocsScanner

java.lang.Object
com.arc_e_tect.gradle.doppelganger.scan.RestDocsScanner
All Implemented Interfaces:
ContractVerificationSource

public class RestDocsScanner extends Object implements ContractVerificationSource
ContractVerificationSource for Spring RestDocs: a test method whose call chain contains a mockMvc.perform(get(...)/post(...)/put(...)/delete(...)/patch(...)) call and also includes .andDo(document(...)) somewhere in the same method body.

Matches by simple method name only, the same way ControllerScanner matches mapping annotations by simple name, so this scanner needs neither Spring MVC Test nor Spring RestDocs on its own classpath.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new RestDocsScanner.
  • Method Summary

    Modifier and Type
    Method
    Description
    List<com.arc_e_tect.gradle.detector.core.model.Endpoint>
    scan(File rootDir)
    Scans rootDir recursively and returns every endpoint this source found verification evidence for.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RestDocsScanner

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

    • scan

      public List<com.arc_e_tect.gradle.detector.core.model.Endpoint> scan(File rootDir) throws IOException
      Scans rootDir recursively and returns every endpoint this source found verification evidence for.

      The returned Endpoint.declaringClass() and Endpoint.methodSignature() identify the test (or contract file) that supplied the evidence, not a production @RestController.

      Specified by:
      scan in interface ContractVerificationSource
      Parameters:
      rootDir - the directory to scan recursively; scanning a non-existent or non-directory path returns an empty list rather than failing
      Returns:
      possibly-empty list of verified endpoints, never null
      Throws:
      IOException - if a file under rootDir cannot be read