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, considering every declared response code including 5xx ones.analyze(List<com.arc_e_tect.gradle.detector.core.openapi.DescribedEndpoint> declaredAndImplemented, List<VerifiedContractTest> verifiedTests, boolean includeResponseCoverage, boolean ignore5xx) 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, considering every declared response code including 5xx ones. Equivalent toanalyze(declaredAndImplemented, verifiedTests, includeResponseCoverage, false).- 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
-
analyze
public List<EndpointResponseCoverage> analyze(List<com.arc_e_tect.gradle.detector.core.openapi.DescribedEndpoint> declaredAndImplemented, List<VerifiedContractTest> verifiedTests, boolean includeResponseCoverage, boolean ignore5xx) 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 computedignore5xx- whether to exclude 5xx response codes - both an exact code (e.g."500") and the"5XX"range wildcard - from consideration entirely: neither the row'sEndpointResponseCoverage.declaredResponseCodes()nor itsEndpointResponseCoverage.testCountByResponseCode()include one, and a test detected to assert a 5xx status contributes to neither a specific code's count norEndpointResponseCoverage.untrackedTestCount()- though it's still counted inEndpointResponseCoverage.contractTestCount()- Returns:
- one
EndpointResponseCoverageper candidate, indeclaredAndImplemented's order
-