|
| 1 | +/* |
| 2 | + * Copyright 2024 the original author or authors. |
| 3 | + * <p> |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * <p> |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * <p> |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.openrewrite.java.migrate.nio.file; |
| 17 | + |
| 18 | +import org.junit.jupiter.api.Test; |
| 19 | +import org.openrewrite.DocumentExample; |
| 20 | +import org.openrewrite.test.RecipeSpec; |
| 21 | +import org.openrewrite.test.RewriteTest; |
| 22 | + |
| 23 | +import static org.openrewrite.java.Assertions.java; |
| 24 | + |
| 25 | +class PathsGetToPathOfTest implements RewriteTest { |
| 26 | + @Override |
| 27 | + public void defaults(RecipeSpec spec) { |
| 28 | + spec.recipeFromResources("org.openrewrite.java.migrate.Java8toJava11"); |
| 29 | + } |
| 30 | + |
| 31 | + @Test |
| 32 | + @DocumentExample |
| 33 | + void convertPathsGetToPathOf() { |
| 34 | + rewriteRun( |
| 35 | + //language=java |
| 36 | + java( |
| 37 | + """ |
| 38 | + import java.nio.file.Path; |
| 39 | + import java.nio.file.Paths; |
| 40 | + import java.net.URI; |
| 41 | + class A { |
| 42 | + Path pathA = Paths.get("path"); |
| 43 | + Path pathB = Paths.get("path", "subpath"); |
| 44 | + Path pathC = Paths.get(URI.create("file:///path")); |
| 45 | + } |
| 46 | + """, |
| 47 | + """ |
| 48 | + import java.nio.file.Path; |
| 49 | + import java.net.URI; |
| 50 | + class A { |
| 51 | + Path pathA = Path.of("path"); |
| 52 | + Path pathB = Path.of("path", "subpath"); |
| 53 | + Path pathC = Path.of(URI.create("file:///path")); |
| 54 | + } |
| 55 | + """ |
| 56 | + ) |
| 57 | + ); |
| 58 | + } |
| 59 | +} |
0 commit comments