Skip to content

Commit

Permalink
enhance UpgradeDependencyVersionTest
Browse files Browse the repository at this point in the history
  • Loading branch information
sullis committed Dec 16, 2024
1 parent d449490 commit 80ff146
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,62 @@ void guava() {
);
}

@Test
void mockito() {
rewriteRun(recipeSpec -> {
recipeSpec.beforeRecipe(withToolingApi())
.recipe(new UpgradeDependencyVersion("org.mockito", "*", "4.x", null));
},
buildGradle(
"""
plugins {
id 'java-library'
}
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.mockito:mockito-junit-jupiter:3.12.4")
}
""",
"""
plugins {
id 'java-library'
}
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.mockito:mockito-junit-jupiter:4.11.0")
}
""",
spec -> spec.afterRecipe(after -> {
Optional<GradleProject> maybeGp = after.getMarkers().findFirst(GradleProject.class);
assertThat(maybeGp).isPresent();
GradleProject gp = maybeGp.get();
GradleDependencyConfiguration testCompileClasspath = gp.getConfiguration("testCompileClasspath");
assertThat(testCompileClasspath).isNotNull();
assertThat(
testCompileClasspath.getRequested().stream()
.filter(dep -> "org.mockito".equals(dep.getGroupId()) && "mockito-junit-jupiter".equals(dep.getArtifactId()))
.findAny())
.as("GradleProject requested dependencies should have been updated with the new version of mockito")
.isPresent();
assertThat(
testCompileClasspath.getResolved().stream()
.filter(dep -> "org.mockito".equals(dep.getGroupId()) && "mockito-junit-jupiter".equals(dep.getArtifactId()) && "4.11.0".equals(dep.getVersion()))
.findAny())
.as("GradleProject resolved dependencies should have been updated with the new version of mockito")
.isPresent();
})
)
);
}

@Test
void updateVersionInVariable() {
rewriteRun(
Expand Down

0 comments on commit 80ff146

Please sign in to comment.