Skip to content

Commit

Permalink
Relocate UpgradeVersionProperty
Browse files Browse the repository at this point in the history
Rewrite test in java. Issue #4.
  • Loading branch information
sghill committed Jun 29, 2023
1 parent ca774d7 commit f20ce76
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 113 deletions.
6 changes: 0 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ tasks.test {
jvmArgs = listOf("-XX:+UnlockDiagnosticVMOptions", "-XX:+ShowHiddenFrames")
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

configure<ContactsExtension> {
val j = Contact("sghill.dev@gmail.com")
j.moniker("Steve Hill")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.sghill.jenkins.rewrite;
package org.openrewrite.jenkins;

import lombok.EqualsAndHashCode;
import lombok.Value;
Expand All @@ -22,9 +22,7 @@
import org.openrewrite.Preconditions;
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
import org.openrewrite.marker.Markers;
import org.openrewrite.marker.SearchResult;
import org.openrewrite.maven.MavenIsoVisitor;
import org.openrewrite.maven.MavenVisitor;
import org.openrewrite.semver.Semver;
import org.openrewrite.semver.VersionComparator;
Expand All @@ -35,8 +33,6 @@
import java.util.Collections;
import java.util.Optional;

import static org.openrewrite.Tree.randomId;

/**
* Updates the version property unless it is already greater than minimumVersion
*/
Expand Down
102 changes: 102 additions & 0 deletions src/test/java/org/openrewrite/jenkins/UpgradeVersionPropertyTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright 2023 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.jenkins;

import org.junit.jupiter.api.Test;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.maven.Assertions.pomXml;

public class UpgradeVersionPropertyTest implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new UpgradeVersionProperty("jenkins.version", "2.364.1"));
}

@Test
void shouldUpgrade() {
rewriteRun(pomXml(
"""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.40</version>
<relativePath/>
</parent>
<artifactId>example-plugin</artifactId>
<version>0.8-SNAPSHOT</version>
<properties>
<jenkins.version>2.303.1</jenkins.version>
</properties>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
</project>
""",
"""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.40</version>
<relativePath/>
</parent>
<artifactId>example-plugin</artifactId>
<version>0.8-SNAPSHOT</version>
<properties>
<jenkins.version>2.364.1</jenkins.version>
</properties>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
</project>
"""));
}

@Test
void shouldNotDowngrade() {
rewriteRun(pomXml(
"""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.40</version>
<relativePath/>
</parent>
<artifactId>example-plugin</artifactId>
<version>0.8-SNAPSHOT</version>
<properties>
<jenkins.version>2.387.1</jenkins.version>
</properties>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
</project>
"""));
}
}

This file was deleted.

0 comments on commit f20ce76

Please sign in to comment.