-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acb6400
commit db0b5a0
Showing
2 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...hSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/SpringCloudVersionUpgradeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.openrewrite.java.spring.boot3; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.openrewrite.DocumentExample; | ||
import org.openrewrite.config.Environment; | ||
import org.openrewrite.test.RecipeSpec; | ||
import org.openrewrite.test.RewriteTest; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.openrewrite.java.Assertions.mavenProject; | ||
import static org.openrewrite.maven.Assertions.pomXml; | ||
|
||
class SpringCloudVersionUpgradeTest implements RewriteTest { | ||
|
||
@Override | ||
public void defaults(RecipeSpec spec) { | ||
spec | ||
.expectedCyclesThatMakeChanges(2) | ||
.recipe(Environment.builder() | ||
.scanRuntimeClasspath("org.openrewrite.java.spring") | ||
.build() | ||
.activateRecipes("org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_4") | ||
); | ||
} | ||
|
||
@Test | ||
@DocumentExample | ||
void upgradeSpringCloudVersion() { | ||
rewriteRun( | ||
mavenProject("project", | ||
//language=xml | ||
pomXml( | ||
""" | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.example</groupId> | ||
<artifactId>fooservice</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.2.2.RELEASE</version> | ||
<relativePath/> | ||
</parent> | ||
<properties> | ||
<java.version>11</java.version> | ||
<spring-cloud.version>Hoxton.SR9</spring-cloud.version> | ||
<mockito.version>2.18.3</mockito.version> | ||
</properties> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>${spring-cloud.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
</project> | ||
""", | ||
spec -> spec.after(actual -> { | ||
assertThat(actual).containsPattern("<version>3.4.\\d+</version>"); | ||
assertThat(actual).containsPattern("<spring-cloud.version>2023.0.\\d+</spring-cloud.version>"); | ||
return actual; | ||
}) | ||
) | ||
) | ||
); | ||
} | ||
} |