From 5bbdecf14d7c123227d47e027f627b20a1180343 Mon Sep 17 00:00:00 2001 From: lnnery <31188425+lnnery@users.noreply.github.com> Date: Wed, 10 Jan 2024 09:50:46 +0000 Subject: [PATCH] Update FindPluginsTest.java Added a new unit test using variables in plugins section, because there was an error caused by that. --- .../gradle/search/FindPluginsTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/rewrite-gradle/src/test/java/org/openrewrite/gradle/search/FindPluginsTest.java b/rewrite-gradle/src/test/java/org/openrewrite/gradle/search/FindPluginsTest.java index 3b15478858b..76112efb0b6 100644 --- a/rewrite-gradle/src/test/java/org/openrewrite/gradle/search/FindPluginsTest.java +++ b/rewrite-gradle/src/test/java/org/openrewrite/gradle/search/FindPluginsTest.java @@ -55,4 +55,36 @@ void findPlugin() { ) ); } + + @Test + void findPluginWithVariable() { + rewriteRun( + buildGradle( + """ + plugins { + id 'com.jfrog.bintray' + id 'com.jfrog.bintray' version "${jfrogBintrayVersion}" + } + """, + """ + plugins { + /*~~>*/id 'com.jfrog.bintray' + /*~~>*/id 'com.jfrog.bintray' version "${jfrogBintrayVersion}" + } + """, + spec -> spec.beforeRecipe(cu -> assertThat(FindPlugins.find(cu, "com.jfrog.bintray")) + .isNotEmpty() + .anySatisfy(p -> { + assertThat(p.getPluginId()).isEqualTo("com.jfrog.bintray"); + assertThat(p.getVersion()).isEqualTo("1.8.5"); + })) + ), + properties( + """ + jfrogBintrayVersion=1.8.5 + """, + spec -> spec.path("gradle.properties") + ) + ); + } }