Skip to content

Commit

Permalink
Relocate CreateIndexJelly
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 d9aaa09 commit f0fb5bb
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.sghill.jenkins.rewrite;
package org.openrewrite.jenkins;

import net.sghill.jenkins.rewrite.Jenkins;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Preconditions;
import org.openrewrite.ScanningRecipe;
Expand Down
134 changes: 134 additions & 0 deletions src/test/java/org/openrewrite/jenkins/CreateIndexJellyTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* 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.Disabled;
import org.junit.jupiter.api.Test;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.java.Assertions.mavenProject;
import static org.openrewrite.java.Assertions.srcMainResources;
import static org.openrewrite.maven.Assertions.pomXml;
import static org.openrewrite.test.SourceSpecs.other;
import static org.openrewrite.test.SourceSpecs.text;

@Disabled // TODO port to rewrite 8.x
class CreateIndexJellyTest implements RewriteTest {

@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new CreateIndexJelly());
}

@Test
void shouldNoOpIfIndexJellyAlreadyExists() {
rewriteRun(other("peanut butter and...", spec ->
spec.path("src/main/resources/index.jelly")));
}

@Test
void shouldCreateIndexJelly() {
rewriteRun(mavenProject("plugin",
pomXml("""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.40</version>
</parent>
<artifactId>my-plugin</artifactId>
<description>This is my plugin's description</description>
<version>0.1</version>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
</project>
""".stripIndent()),
srcMainResources(
text(null, """
<?jelly escape-by-default='true'?>
<div>
This is my plugin's description
</div>
""".stripIndent(), spec -> spec.path("index.jelly"))
)));
}

@Test
void shouldCreateIndexJellyEmptyDescription() {
rewriteRun(mavenProject("plugin",
pomXml("""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.40</version>
</parent>
<artifactId>my-plugin</artifactId>
<description/>
<version>0.1</version>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
</project>
""".stripIndent()),
srcMainResources(
text(null, """
<?jelly escape-by-default='true'?>
<div>
my-plugin
</div>
""".stripIndent(), spec -> spec.path("index.jelly"))
)));
}

@Test
void shouldCreateIndexJellyNoDescription() {
rewriteRun(mavenProject("plugin",
pomXml("""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.40</version>
</parent>
<artifactId>my-plugin</artifactId>
<version>0.1</version>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
</project>
""".stripIndent()),
srcMainResources(
text(null, """
<?jelly escape-by-default='true'?>
<div>
my-plugin
</div>
""".stripIndent(), spec -> spec.path("index.jelly"))
)));
}
}
140 changes: 0 additions & 140 deletions src/test/kotlin/net/sghill/jenkins/rewrite/CreateIndexJellyTest.kt

This file was deleted.

0 comments on commit f0fb5bb

Please sign in to comment.