diff --git a/fleetd/src/test/java/dev/ltms/fleet/rest/RestRouteInventoryTest.java b/fleetd/src/test/java/dev/ltms/fleet/rest/RestRouteInventoryTest.java index 2b2f552..dd1ef7a 100644 --- a/fleetd/src/test/java/dev/ltms/fleet/rest/RestRouteInventoryTest.java +++ b/fleetd/src/test/java/dev/ltms/fleet/rest/RestRouteInventoryTest.java @@ -7,6 +7,7 @@ import java.util.Locale; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -68,6 +69,32 @@ class RestRouteInventoryTest { "GET /tasks/{ticket}" ); + private static final Pattern ROUTE_CALL = + Pattern.compile("app\\.(get|post|delete|put|patch)\\(\\s*\"([^\"]+)\""); + + /** + * Drop whole-line comments before scraping. Without this the scrape reads commented-out code as + * live: a registration disabled with {@code //} still matched, so the route stayed in the + * inventory while the server no longer served it — a silent false PASS, measured on 2026-09-03 + * by commenting out {@code app.get("/tasks/{ticket}", ...)} and watching this test stay green. + * Deleting the same line was caught correctly, so only the commented-out shape was blind. + * + *
Only lines whose first non-blank characters are {@code //}, {@code *} or {@code /*} are
+ * dropped — deliberately NOT every {@code //} anywhere on a line, because that would also cut a
+ * string literal containing {@code //} (a URL) and could silently delete a real registration
+ * sharing that line. The remaining gap is a trailing comment on the same line as real code; no
+ * registration in this file has that shape, and the vacuity test below would catch a scrape that
+ * lost registrations wholesale.
+ */
+ private static String withoutCommentLines(String source) {
+ return source.lines()
+ .filter(line -> {
+ String t = line.stripLeading();
+ return !(t.startsWith("//") || t.startsWith("*") || t.startsWith("/*"));
+ })
+ .collect(Collectors.joining("\n"));
+ }
+
/**
* Every {@code app.