Class StatusCodeDetector
java.lang.Object
com.arc_e_tect.gradle.doppelganger.scan.StatusCodeDetector
Best-effort detection of the HTTP status code a test method asserts, from the same
List<MethodCallExpr> a ContractVerificationSource
AST scanner already collects
for that method - not exhaustive, since a test can assert a response's status in ways this
cannot recognise (a variable, a helper method, a custom matcher); such tests still count towards
an endpoint's overall contract test count, they simply contribute no evidence to any specific
response code's count.
Recognises three independent shapes, matched by simple method name only, the same way the scanners that use this class already match request-builder calls:
- MockMvc:
status().isOk()/status().isNotFound()/ ... (a fixed set of well-knownorg.springframework.test.web.servlet.result.StatusResultMatchersmethod names), or the numericstatus().is(404). - REST Assured:
.statusCode(404). - WebTestClient:
.expectStatus().isNotFound(), or the numeric.expectStatus().isEqualTo(404).
-
Method Summary
Modifier and TypeMethodDescriptionDetects the status code asserted anywhere amongcalls, orOptional.empty()when none of the recognised shapes are present.
-
Method Details
-
detect
Detects the status code asserted anywhere amongcalls, orOptional.empty()when none of the recognised shapes are present.- Parameters:
calls- every method call expression found in a test method's body- Returns:
- the detected status code, e.g.
"404", orOptional.empty()
-