Skip to content

Commit

Permalink
Relocate ChangeJenkinsVersion
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 6d88a3e commit d9aaa09
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 34 deletions.
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 Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/rewrite/rewrite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ recipeList:
type: specs.openrewrite.org/v1beta/recipe
name: net.sghill.jenkins.ModernizePlugin
recipeList:
- net.sghill.jenkins.rewrite.ChangeJenkinsVersion:
- org.openrewrite.jenkins.ChangeJenkinsVersion:
parentPomVersion: "4.64"
jenkinsVersion: "2.332.1"
- net.sghill.jenkins.rewrite.AddPluginsBom:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.sghill.jenkins.rewrite
package org.openrewrite.jenkins;

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

class ChangeJenkinsVersionTest: RewriteTest {
import static org.openrewrite.maven.Assertions.pomXml;

override fun defaults(spec: RecipeSpec) {
spec
.recipe(ChangeJenkinsVersion("4.40", "2.303.3"))
class ChangeJenkinsVersionTest implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new ChangeJenkinsVersion("4.40", "2.303.3"));
}

@Test
fun majorVersionUpgrade() = rewriteRun(
pomXml(
"""
void shouldDoMajorVersionUpgrade() {
rewriteRun(pomXml(
"""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -49,7 +49,8 @@ fun majorVersionUpgrade() = rewriteRun(
</repository>
</repositories>
</project>
""", """
""".stripIndent(),
"""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -68,14 +69,13 @@ fun majorVersionUpgrade() = rewriteRun(
</repository>
</repositories>
</project>
"""
)
)

""".stripIndent()));
}

@Test
fun addPropertyIfMissing() = rewriteRun(
pomXml(
"""
void shouldAddPropertyIfMissing() {
rewriteRun(pomXml(
"""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -93,7 +93,8 @@ fun addPropertyIfMissing() = rewriteRun(
</repository>
</repositories>
</project>
""", """
""".stripIndent(),
"""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -112,14 +113,14 @@ fun addPropertyIfMissing() = rewriteRun(
</repository>
</repositories>
</project>
"""
)
)
""".stripIndent()
));
}

@Test
fun addPropertyIfNoProperties() = rewriteRun(
pomXml(
"""
void shouldAddPropertyIfNoProperties() {
rewriteRun(pomXml(
"""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -135,7 +136,8 @@ fun addPropertyIfNoProperties() = rewriteRun(
</repository>
</repositories>
</project>
""", """
""".stripIndent(),
"""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -154,7 +156,7 @@ fun addPropertyIfNoProperties() = rewriteRun(
</repository>
</repositories>
</project>
"""
)
)
""".stripIndent()
));
}
}

0 comments on commit d9aaa09

Please sign in to comment.