From f67d7f9e81fa4f85e7caf8ab84934358a1e58ca7 Mon Sep 17 00:00:00 2001 From: Jonathan Schneider Date: Tue, 12 May 2026 11:04:03 -0400 Subject: [PATCH 1/2] Fix DevCenter cards silently emitting zero rows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The five dependency-version cards — LibraryUpgrade, GroovyVersionUpgrade, KotlinVersionUpgrade, ScalaVersionUpgrade, ParentPomUpgrade — read dependency versions by running a sibling recipe (DependencyInsight / ParentPomInsight) for the side effect of writing a data-table row, then fishing the row back out via DataTableRowWatcher. DependencyInsight's MarkIndividualDependency sub-visitor adds SearchResult markers, forcing OpenRewrite to schedule cycle 2. On cycle 2, `DataTable#insertRow` silently drops every write that doesn't override `allowWritingInThisCycle`. `DependenciesInUse` / `ParentPomsInUse` don't override it, so the watcher's getRows() snapshot diff is always zero and the cards emit no rows. This worked before the DataTableRowWatcher was retrofitted (#61) to read from the new `DataTableStore` interface — the previous implementation read from the ungated `org.openrewrite.dataTables` context-message bag. Replace the sibling-recipe + watcher pattern with direct reads from LST markers: `MavenResolutionResult.findDependencies(...)` and `ResolvedDependency.findDependencies(...)`. ParentPomUpgrade reads `Pom.getParent()` for immediate-parent matching (drops the recursive ancestor walk that ParentPomInsight did via MavenPomDownloader — DevCenter cards typically want immediate-parent matches anyway). DependencyVulnerabilityCheck uses the new `DependencyVulnerabilityCheckBase#vulnerabilities(Accumulator)` accessor exposed in rewrite-java-security to avoid the same coupling. The DataTableRowWatcher class itself is deleted. Tests were asserting on the ` - com.fasterxml.jackson.module - jackson-module-parameter-names - %1$s - - - """.formatted(currentVersion) ) ); diff --git a/src/test/java/io/moderne/devcenter/ParentPomUpgradeTest.java b/src/test/java/io/moderne/devcenter/ParentPomUpgradeTest.java index 0a37133..7a311ec 100644 --- a/src/test/java/io/moderne/devcenter/ParentPomUpgradeTest.java +++ b/src/test/java/io/moderne/devcenter/ParentPomUpgradeTest.java @@ -74,18 +74,6 @@ void minorUpgrade(String targetVersion, String currentVersion, SemverMeasure sem %s - """.formatted(currentVersion), - """ - - com.example - example - 1.0-SNAPSHOT - - org.springframework.boot - spring-boot-parent - %s - - """.formatted(currentVersion) ) ); diff --git a/src/test/java/io/moderne/devcenter/ScalaVersionUpgradeTest.java b/src/test/java/io/moderne/devcenter/ScalaVersionUpgradeTest.java index c4cf52d..daef888 100644 --- a/src/test/java/io/moderne/devcenter/ScalaVersionUpgradeTest.java +++ b/src/test/java/io/moderne/devcenter/ScalaVersionUpgradeTest.java @@ -36,25 +36,23 @@ class ScalaVersionUpgradeTest implements RewriteTest { private static Stream scalaVersions() { return Stream.of( - Arguments.of(3, "org.scala-lang", "scala-library", "2.11.12", Scala211Plus, 1), - Arguments.of(3, "org.scala-lang", "scala-library", "2.12.18", Scala212Plus, 1), - Arguments.of(3, "org.scala-lang", "scala-library", "2.13.12", Scala213Plus, 1), - Arguments.of(3, "org.scala-lang", "scala3-library_3", "3.3.1", Completed, 2), - Arguments.of(3, "org.scala-lang", "scala3-library_3", "3.5.0", Completed, 2), - Arguments.of(4, "org.scala-lang", "scala3-library_3", "3.5.0", Scala3Plus, 2) + Arguments.of(3, "org.scala-lang", "scala-library", "2.11.12", Scala211Plus), + Arguments.of(3, "org.scala-lang", "scala-library", "2.12.18", Scala212Plus), + Arguments.of(3, "org.scala-lang", "scala-library", "2.13.12", Scala213Plus), + Arguments.of(3, "org.scala-lang", "scala3-library_3", "3.3.1", Completed), + Arguments.of(3, "org.scala-lang", "scala3-library_3", "3.5.0", Completed), + Arguments.of(4, "org.scala-lang", "scala3-library_3", "3.5.0", Scala3Plus) ); } @MethodSource("scalaVersions") @ParameterizedTest void detectsScalaVersion(int targetVersion, String groupId, String artifactId, - String currentVersion, ScalaVersionUpgrade.Measure measure, - int expectedCycles) { + String currentVersion, ScalaVersionUpgrade.Measure measure) { var recipe = new ScalaVersionUpgrade(targetVersion, null); rewriteRun( spec -> spec .recipe(recipe) - .expectedCyclesThatMakeChanges(expectedCycles) .dataTable(UpgradesAndMigrations.Row.class, rows -> assertThat(rows).containsExactly( new UpgradesAndMigrations.Row("Move to Scala " + targetVersion, @@ -75,11 +73,7 @@ void detectsScalaVersion(int targetVersion, String groupId, String artifactId, - """.formatted(groupId, artifactId, currentVersion), - spec -> spec.after(after -> { - assertThat(after).isNotNull(); - return after; - }) + """.formatted(groupId, artifactId, currentVersion) ) ); } From c5be9f2cc8baab15710bde523e3fbe382dd9d25a Mon Sep 17 00:00:00 2001 From: Jonathan Schneider Date: Tue, 12 May 2026 13:47:47 -0400 Subject: [PATCH 2/2] Drop SearchResult marker assertions from remaining tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same pattern as the per-card test fixes earlier on this branch: `UpgradesAndMigrationsTest` and `DevCenterTest#devcenterWithMultipleLibraryUpgradeRecipesHasCorrectData` were asserting on the `` / `~~(...)~~` `SearchResult` markers that `ParentPomInsight` and `DependencyInsight.MarkIndividualDependency` previously left on the source — those sub-recipes are no longer invoked after the cycle-gate refactor, so the markers don't get added and the expected-after assertions fail with "Recipe was expected to make a change but made no changes". Convert two-arg `pomXml(before, after, ...)` / `buildGradle(before, after)` to the single-arg `pomXml(before, ...)` / `buildGradle(before)` form; the `UpgradesAndMigrations.Row` data-table assertions remain and are the right test for the bug. --- .../io/moderne/devcenter/DevCenterTest.java | 16 +----------- .../table/UpgradesAndMigrationsTest.java | 26 +++---------------- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/src/test/java/io/moderne/devcenter/DevCenterTest.java b/src/test/java/io/moderne/devcenter/DevCenterTest.java index 417c730..4ea752b 100644 --- a/src/test/java/io/moderne/devcenter/DevCenterTest.java +++ b/src/test/java/io/moderne/devcenter/DevCenterTest.java @@ -428,21 +428,7 @@ void devcenterWithMultipleLibraryUpgradeRecipesHasCorrectData() { implementation "org.springframework.boot:spring-boot-starter-web" implementation "commons-collections:commons-collections:2.0" } - """, - """ - plugins { - id "java" - id 'org.springframework.boot' version '2.7.18' - id 'io.spring.dependency-management' version '1.1.7' - } - repositories { - mavenCentral() - } - dependencies { - /*~~(org.springframework.boot:spring-boot-autoconfigure:2.7.18,org.springframework.boot:spring-boot-starter-json:2.7.18,org.springframework.boot:spring-boot-starter-logging:2.7.18,org.springframework.boot:spring-boot-starter-tomcat:2.7.18,org.springframework.boot:spring-boot-starter-web:2.7.18,org.springframework.boot:spring-boot-starter:2.7.18,org.springframework.boot:spring-boot:2.7.18)~~>*/implementation "org.springframework.boot:spring-boot-starter-web" - /*~~(commons-collections:commons-collections:2.0)~~>*/implementation "commons-collections:commons-collections:2.0" - } - """ + """ ) ); } diff --git a/src/test/java/io/moderne/devcenter/table/UpgradesAndMigrationsTest.java b/src/test/java/io/moderne/devcenter/table/UpgradesAndMigrationsTest.java index 2b170b7..fb832c4 100644 --- a/src/test/java/io/moderne/devcenter/table/UpgradesAndMigrationsTest.java +++ b/src/test/java/io/moderne/devcenter/table/UpgradesAndMigrationsTest.java @@ -39,10 +39,8 @@ void leastOrdinalRetained() { assertThat(rows).containsExactly( new UpgradesAndMigrations.Row("Spring Boot", Major.ordinal(), "Major", "2.7.0") )), - pomXml(pom("2.7.0"), expected("2.7.0"), - spec -> spec.path(Path.of("module1/pom.xml"))), - pomXml(pom("3.2.0"), expected("3.2.0"), - spec -> spec.path(Path.of("module2/pom.xml"))) + pomXml(pom("2.7.0"), spec -> spec.path(Path.of("module1/pom.xml"))), + pomXml(pom("3.2.0"), spec -> spec.path(Path.of("module2/pom.xml"))) ); } @@ -56,10 +54,8 @@ void leastVersionRetainedAtSameOrdinal() { assertThat(rows).containsExactly( new UpgradesAndMigrations.Row("Spring Boot", Minor.ordinal(), "Minor", "3.1.0") )), - pomXml(pom("3.1.0"), expected("3.1.0"), - spec -> spec.path(Path.of("module1/pom.xml"))), - pomXml(pom("3.2.0"), expected("3.2.0"), - spec -> spec.path(Path.of("module2/pom.xml"))) + pomXml(pom("3.1.0"), spec -> spec.path(Path.of("module1/pom.xml"))), + pomXml(pom("3.2.0"), spec -> spec.path(Path.of("module2/pom.xml"))) ); } @@ -86,18 +82,4 @@ private static String pom(String version) { """.formatted(version); } - private static String expected(String version) { - return """ - - com.example - example - 1.0-SNAPSHOT - - org.springframework.boot - spring-boot-parent - %s - - - """.formatted(version); - } }