|
22 | 22 | import org.openrewrite.test.RewriteTest; |
23 | 23 | import org.openrewrite.test.SourceSpec; |
24 | 24 |
|
| 25 | +import java.util.regex.Matcher; |
| 26 | +import java.util.regex.Pattern; |
| 27 | + |
| 28 | +import static org.assertj.core.api.Assertions.assertThat; |
25 | 29 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
26 | 30 | import static org.openrewrite.java.Assertions.mavenProject; |
27 | 31 | import static org.openrewrite.maven.Assertions.pomXml; |
@@ -3329,33 +3333,39 @@ void versionNotDroppedWhenDependencyExcludedByOtherDependency() { |
3329 | 3333 | </dependencies> |
3330 | 3334 | </project> |
3331 | 3335 | """, |
3332 | | - """ |
3333 | | - <project> |
3334 | | - <modelVersion>4.0.0</modelVersion> |
3335 | | - <groupId>com.mycompany.app</groupId> |
3336 | | - <artifactId>my-app</artifactId> |
3337 | | - <version>1</version> |
3338 | | - <dependencies> |
3339 | | - <dependency> |
3340 | | - <groupId>io.swagger.core.v3</groupId> |
3341 | | - <artifactId>swagger-jaxrs2</artifactId> |
3342 | | - <version>2.2.20</version> |
3343 | | - <scope>provided</scope> |
3344 | | - <exclusions> |
3345 | | - <exclusion> |
3346 | | - <groupId>com.fasterxml.jackson.jaxrs</groupId> |
3347 | | - <artifactId>*</artifactId> |
3348 | | - </exclusion> |
3349 | | - </exclusions> |
3350 | | - </dependency> |
3351 | | - <dependency> |
3352 | | - <groupId>com.fasterxml.jackson.jakarta.rs</groupId> |
3353 | | - <artifactId>jackson-jakarta-rs-json-provider</artifactId> |
3354 | | - <version>2.21.0</version> |
3355 | | - </dependency> |
3356 | | - </dependencies> |
3357 | | - </project> |
3358 | | - """ |
| 3336 | + spec -> spec.after(after -> { |
| 3337 | + Matcher matcher = Pattern.compile("jackson-jakarta-rs-json-provider</artifactId>\\s*<version>(.+)</version>").matcher(after); |
| 3338 | + assertThat(matcher.find()).isTrue(); |
| 3339 | + String version = matcher.group(1); |
| 3340 | + assertThat(version).matches("2\\.\\d+\\.\\d+"); |
| 3341 | + return """ |
| 3342 | + <project> |
| 3343 | + <modelVersion>4.0.0</modelVersion> |
| 3344 | + <groupId>com.mycompany.app</groupId> |
| 3345 | + <artifactId>my-app</artifactId> |
| 3346 | + <version>1</version> |
| 3347 | + <dependencies> |
| 3348 | + <dependency> |
| 3349 | + <groupId>io.swagger.core.v3</groupId> |
| 3350 | + <artifactId>swagger-jaxrs2</artifactId> |
| 3351 | + <version>2.2.20</version> |
| 3352 | + <scope>provided</scope> |
| 3353 | + <exclusions> |
| 3354 | + <exclusion> |
| 3355 | + <groupId>com.fasterxml.jackson.jaxrs</groupId> |
| 3356 | + <artifactId>*</artifactId> |
| 3357 | + </exclusion> |
| 3358 | + </exclusions> |
| 3359 | + </dependency> |
| 3360 | + <dependency> |
| 3361 | + <groupId>com.fasterxml.jackson.jakarta.rs</groupId> |
| 3362 | + <artifactId>jackson-jakarta-rs-json-provider</artifactId> |
| 3363 | + <version>%s</version> |
| 3364 | + </dependency> |
| 3365 | + </dependencies> |
| 3366 | + </project> |
| 3367 | + """.formatted(version); |
| 3368 | + }) |
3359 | 3369 | ) |
3360 | 3370 | ); |
3361 | 3371 | } |
@@ -3405,33 +3415,39 @@ void versionNotDroppedWhenTransitiveDependencyHasManagedVersion() { |
3405 | 3415 | </dependencies> |
3406 | 3416 | </project> |
3407 | 3417 | """, |
3408 | | - """ |
3409 | | - <project> |
3410 | | - <modelVersion>4.0.0</modelVersion> |
3411 | | - <groupId>com.mycompany.app</groupId> |
3412 | | - <artifactId>my-app</artifactId> |
3413 | | - <version>1</version> |
3414 | | - <dependencies> |
3415 | | - <dependency> |
3416 | | - <groupId>io.swagger.core.v3</groupId> |
3417 | | - <artifactId>swagger-jaxrs2-jakarta</artifactId> |
3418 | | - <version>2.2.20</version> |
3419 | | - <scope>provided</scope> |
3420 | | - <exclusions> |
3421 | | - <exclusion> |
3422 | | - <groupId>com.fasterxml.jackson.jaxrs</groupId> |
3423 | | - <artifactId>*</artifactId> |
3424 | | - </exclusion> |
3425 | | - </exclusions> |
3426 | | - </dependency> |
3427 | | - <dependency> |
3428 | | - <groupId>com.fasterxml.jackson.jakarta.rs</groupId> |
3429 | | - <artifactId>jackson-jakarta-rs-json-provider</artifactId> |
3430 | | - <version>2.21.0</version> |
3431 | | - </dependency> |
3432 | | - </dependencies> |
3433 | | - </project> |
3434 | | - """ |
| 3418 | + spec -> spec.after(after -> { |
| 3419 | + Matcher matcher = Pattern.compile("jackson-jakarta-rs-json-provider</artifactId>\\s*<version>(.+)</version>").matcher(after); |
| 3420 | + assertThat(matcher.find()).isTrue(); |
| 3421 | + String version = matcher.group(1); |
| 3422 | + assertThat(version).matches("2\\.\\d+\\.\\d+"); |
| 3423 | + return """ |
| 3424 | + <project> |
| 3425 | + <modelVersion>4.0.0</modelVersion> |
| 3426 | + <groupId>com.mycompany.app</groupId> |
| 3427 | + <artifactId>my-app</artifactId> |
| 3428 | + <version>1</version> |
| 3429 | + <dependencies> |
| 3430 | + <dependency> |
| 3431 | + <groupId>io.swagger.core.v3</groupId> |
| 3432 | + <artifactId>swagger-jaxrs2-jakarta</artifactId> |
| 3433 | + <version>2.2.20</version> |
| 3434 | + <scope>provided</scope> |
| 3435 | + <exclusions> |
| 3436 | + <exclusion> |
| 3437 | + <groupId>com.fasterxml.jackson.jaxrs</groupId> |
| 3438 | + <artifactId>*</artifactId> |
| 3439 | + </exclusion> |
| 3440 | + </exclusions> |
| 3441 | + </dependency> |
| 3442 | + <dependency> |
| 3443 | + <groupId>com.fasterxml.jackson.jakarta.rs</groupId> |
| 3444 | + <artifactId>jackson-jakarta-rs-json-provider</artifactId> |
| 3445 | + <version>%s</version> |
| 3446 | + </dependency> |
| 3447 | + </dependencies> |
| 3448 | + </project> |
| 3449 | + """.formatted(version); |
| 3450 | + }) |
3435 | 3451 | ) |
3436 | 3452 | ); |
3437 | 3453 | } |
@@ -3574,33 +3590,39 @@ void exclusionUpdatedWhenDependencyGroupIdChanges() { |
3574 | 3590 | </dependencies> |
3575 | 3591 | </project> |
3576 | 3592 | """, |
3577 | | - """ |
3578 | | - <project> |
3579 | | - <modelVersion>4.0.0</modelVersion> |
3580 | | - <groupId>com.mycompany.app</groupId> |
3581 | | - <artifactId>my-app</artifactId> |
3582 | | - <version>1</version> |
3583 | | - <dependencies> |
3584 | | - <dependency> |
3585 | | - <groupId>io.swagger.core.v3</groupId> |
3586 | | - <artifactId>swagger-jaxrs2-jakarta</artifactId> |
3587 | | - <version>2.2.20</version> |
3588 | | - <scope>provided</scope> |
3589 | | - <exclusions> |
3590 | | - <exclusion> |
3591 | | - <groupId>com.fasterxml.jackson.jakarta.rs</groupId> |
3592 | | - <artifactId>jackson-jakarta-rs-json-provider</artifactId> |
3593 | | - </exclusion> |
3594 | | - </exclusions> |
3595 | | - </dependency> |
3596 | | - <dependency> |
3597 | | - <groupId>com.fasterxml.jackson.jakarta.rs</groupId> |
3598 | | - <artifactId>jackson-jakarta-rs-json-provider</artifactId> |
3599 | | - <version>2.21.0</version> |
3600 | | - </dependency> |
3601 | | - </dependencies> |
3602 | | - </project> |
3603 | | - """ |
| 3593 | + spec -> spec.after(after -> { |
| 3594 | + Matcher matcher = Pattern.compile("jackson-jakarta-rs-json-provider</artifactId>\\s*<version>(.+)</version>").matcher(after); |
| 3595 | + assertThat(matcher.find()).isTrue(); |
| 3596 | + String version = matcher.group(1); |
| 3597 | + assertThat(version).matches("2\\.\\d+\\.\\d+"); |
| 3598 | + return """ |
| 3599 | + <project> |
| 3600 | + <modelVersion>4.0.0</modelVersion> |
| 3601 | + <groupId>com.mycompany.app</groupId> |
| 3602 | + <artifactId>my-app</artifactId> |
| 3603 | + <version>1</version> |
| 3604 | + <dependencies> |
| 3605 | + <dependency> |
| 3606 | + <groupId>io.swagger.core.v3</groupId> |
| 3607 | + <artifactId>swagger-jaxrs2-jakarta</artifactId> |
| 3608 | + <version>2.2.20</version> |
| 3609 | + <scope>provided</scope> |
| 3610 | + <exclusions> |
| 3611 | + <exclusion> |
| 3612 | + <groupId>com.fasterxml.jackson.jakarta.rs</groupId> |
| 3613 | + <artifactId>jackson-jakarta-rs-json-provider</artifactId> |
| 3614 | + </exclusion> |
| 3615 | + </exclusions> |
| 3616 | + </dependency> |
| 3617 | + <dependency> |
| 3618 | + <groupId>com.fasterxml.jackson.jakarta.rs</groupId> |
| 3619 | + <artifactId>jackson-jakarta-rs-json-provider</artifactId> |
| 3620 | + <version>%s</version> |
| 3621 | + </dependency> |
| 3622 | + </dependencies> |
| 3623 | + </project> |
| 3624 | + """.formatted(version); |
| 3625 | + }) |
3604 | 3626 | ) |
3605 | 3627 | ); |
3606 | 3628 | } |
|
0 commit comments