Class ResponseCoverageAnalyzer
java.lang.Object
com.arc_e_tect.gradle.doppelganger.detect.ResponseCoverageAnalyzer
Computes, for every endpoint both declared in the OpenAPI documentation and implemented by a
@RestController method, how many contract tests exist for it and - only when requested -
how many of those tests cover each of its declared response codes.
A verified test's status code is matched against a declared response code by exact
string equality only: a test detected to assert "404" counts towards a declared
"404" response, never towards a declared "4XX" range wildcard or a
"default" response, even though either might, in the OpenAPI document's own semantics,
legitimately cover that same test. Resolving that would require interpreting the OpenAPI
response-matching rules themselves, not just comparing two strings - the same kind of imprecision
PathMatcher.matchesConcrete(String, String)
already documents for path matching.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionanalyze(List<com.arc_e_tect.gradle.detector.core.openapi.DescribedEndpoint> declaredAndImplemented, List<VerifiedContractTest> verifiedTests, boolean includeResponseCoverage) Computes the coverage rows fordeclaredAndImplemented.
-
Constructor Details
-
ResponseCoverageAnalyzer
public ResponseCoverageAnalyzer()Creates a newResponseCoverageAnalyzer.
-
-
Method Details
-
analyze
public List<EndpointResponseCoverage> analyze(List<com.arc_e_tect.gradle.detector.core.openapi.DescribedEndpoint> declaredAndImplemented, List<VerifiedContractTest> verifiedTests, boolean includeResponseCoverage) Computes the coverage rows fordeclaredAndImplemented.- Parameters:
declaredAndImplemented- the candidate endpoints - declared in the OpenAPI documentation and implemented by a@RestControllermethod - carrying their declared response codesverifiedTests- every piece of verification evidence gathered from the enabledContractVerificationSourcesincludeResponseCoverage- whether to compute the per-response-code breakdown at all; whenfalse,EndpointResponseCoverage.testCountByResponseCode()is empty andEndpointResponseCoverage.untrackedTestCount()is0for every row - the breakdown is not merely hidden, it is never computed- Returns:
- one
EndpointResponseCoverageper candidate, indeclaredAndImplemented's order
-