Skip to content

Commit

Permalink
Relocate DisableLocalResolutionForParentPom
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 0ce13dd commit 281d2cc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 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 @@ -211,7 +211,7 @@ recipeList:
- net.sghill.jenkins.rewrite.AddPluginsBom:
bomName: bom-2.332.x
bomVersion: "1763.v092b_8980a_f5e"
- net.sghill.jenkins.rewrite.DisableLocalResolutionForParentPom
- org.openrewrite.jenkins.DisableLocalResolutionForParentPom
- org.openrewrite.maven.RemoveProperty:
# as of parent pom 4.40 this is deprecated and unused
propertyName: java.level
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 DisableLocalResolutionForParentPomTest: RewriteTest {
import static org.openrewrite.maven.Assertions.pomXml;

override fun defaults(spec: RecipeSpec) {
spec
.recipe(DisableLocalResolutionForParentPom())
class DisableLocalResolutionForParentPomTest implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new DisableLocalResolutionForParentPom());
}

@Test
fun missing() = rewriteRun(
pomXml(
"""
void shouldAddRelativePathIfMissing() {
rewriteRun(pomXml(
"""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -47,7 +47,8 @@ fun missing() = rewriteRun(
</repository>
</repositories>
</project>
""", """
""".stripIndent(),
"""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -65,14 +66,14 @@ fun missing() = rewriteRun(
</repository>
</repositories>
</project>
"""
)
)
""".stripIndent()
));
}

@Test
fun alreadyPresent() = rewriteRun(
pomXml(
"""
void shouldNoOpIfRelativePathAlreadyPresent() {
rewriteRun(pomXml(
"""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -90,6 +91,7 @@ fun alreadyPresent() = rewriteRun(
</repository>
</repositories>
</project>
""")
)
""".stripIndent()
));
}
}

0 comments on commit 281d2cc

Please sign in to comment.