|
| 1 | +package eu.solven.cleanthat.engine.java.refactorer.cases.do_not_format_me; |
| 2 | + |
| 3 | +import org.junit.jupiter.api.Disabled; |
| 4 | + |
| 5 | +import eu.solven.cleanthat.engine.java.refactorer.annotations.CompareCompilationUnitsAsResources; |
| 6 | +import eu.solven.cleanthat.engine.java.refactorer.annotations.CompareCompilationUnitsAsStrings; |
| 7 | +import eu.solven.cleanthat.engine.java.refactorer.annotations.UnmodifiedCompilationUnitAsString; |
| 8 | +import eu.solven.cleanthat.engine.java.refactorer.meta.IJavaparserAstMutator; |
| 9 | +import eu.solven.cleanthat.engine.java.refactorer.mutators.ImportQualifiedTokens; |
| 10 | +import eu.solven.cleanthat.engine.java.refactorer.test.AJavaparserRefactorerCases; |
| 11 | + |
| 12 | +@Disabled("TODO") |
| 13 | +public class TestImportQualifiedTokensCases extends AJavaparserRefactorerCases { |
| 14 | + static final String PREFIX = "source/do_not_format_me/ImportQualifiedTokens/"; |
| 15 | + |
| 16 | + @Override |
| 17 | + public IJavaparserAstMutator getTransformer() { |
| 18 | + return new ImportQualifiedTokens(); |
| 19 | + } |
| 20 | + |
| 21 | + @CompareCompilationUnitsAsResources(pre = PREFIX + "NoWildcardImport_IsImported_Pre.java", |
| 22 | + post = PREFIX + "NoWildcardImport_IsImported_Post.java") |
| 23 | + public static class NoWildcardImport_IsImported { |
| 24 | + } |
| 25 | + |
| 26 | + @CompareCompilationUnitsAsResources(pre = PREFIX + "NoWildcardImport_IsNotImported_Pre.java", |
| 27 | + post = PREFIX + "NoWildcardImport_IsNotImported_Post.java") |
| 28 | + public static class NoWildcardImport_IsNotImported { |
| 29 | + } |
| 30 | + |
| 31 | + // We do not turn `java.time.LocalDate` into `LocalDate` as there is an ambiguity in which package would import it |
| 32 | + @UnmodifiedCompilationUnitAsString(pre = "package eu.solven.cleanthat.engine.java.refactorer;\n" + "\n" |
| 33 | + + "import java.time.*;\n" |
| 34 | + + "import other.time.*;\n" |
| 35 | + + "\n" |
| 36 | + + "public class NoWildcardImport_IsNotImported_Pre {\n" |
| 37 | + + " public static boolean isEmpty(java.time.LocalDate date) {\n" |
| 38 | + + " return date.isLeapYear();\n" |
| 39 | + + " }\n" |
| 40 | + + "}\n") |
| 41 | + public static class WithWildcardImport { |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * A wildcard-import is present, which does not prevent to qualification. |
| 46 | + */ |
| 47 | + @CompareCompilationUnitsAsStrings( |
| 48 | + pre = "package eu.solven.cleanthat.engine.java.refactorer;\n" + "\n" |
| 49 | + + "import static some.pkg.ImportedClass.*;\n" |
| 50 | + + "\n" |
| 51 | + + "public class NoWildcardImport_IsNotImported_Pre {\n" |
| 52 | + + " public static boolean isLeapYear(java.time.LocalDate date) {\n" |
| 53 | + + " return date.isLeapYear();\n" |
| 54 | + + " }\n" |
| 55 | + + "}\n", |
| 56 | + post = "package eu.solven.cleanthat.engine.java.refactorer;\n" + "\n" |
| 57 | + + "import static some.pkg.ImportedClass.*;\n" |
| 58 | + + "import static java.time.LocalDate;\n" |
| 59 | + + "\n" |
| 60 | + + "public class NoWildcardImport_IsNotImported_Pre {\n" |
| 61 | + + " public static boolean isLeapYear(LocalDate date) {\n" |
| 62 | + + " return date.isLeapYear();\n" |
| 63 | + + " }\n" |
| 64 | + + "}\n") |
| 65 | + public static class WithWildcardImport_qualify { |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * A fully qualified name may exist to prevent a conflict with a not-qualified same name. |
| 70 | + * |
| 71 | + * With a wildcard. |
| 72 | + */ |
| 73 | + @UnmodifiedCompilationUnitAsString(pre = "package eu.solven.cleanthat.engine.java.refactorer;\n" + "\n" |
| 74 | + + "import static some.pkg.ImportedClass.*;\n" |
| 75 | + + "\n" |
| 76 | + + "public class NoWildcardImport_IsNotImported_Pre {\n" |
| 77 | + + " public static boolean isLeapYearFromJavaTime(java.time.LocalDate date) {\n" |
| 78 | + + " return date.isLeapYear();\n" |
| 79 | + + " }\n" |
| 80 | + + " public static boolean isLeapYearFromImportedClass(LocalDate date) {\n" |
| 81 | + + " return date.isLeapYear();\n" |
| 82 | + + " }\n" |
| 83 | + + "}\n") |
| 84 | + public static class WithWildcardImport_conflictWithWildcard { |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * A fully qualified name may exist to prevent a conflict with a not-qualified same name. |
| 89 | + * |
| 90 | + * With a wildcard. |
| 91 | + */ |
| 92 | + @UnmodifiedCompilationUnitAsString(pre = "package eu.solven.cleanthat.engine.java.refactorer;\n" + "\n" |
| 93 | + + "import static some.pkg.ImportedClass.LocalDate;\n" |
| 94 | + + "\n" |
| 95 | + + "public class NoWildcardImport_IsNotImported_Pre {\n" |
| 96 | + + " public static boolean isLeapYearFromJavaTime(java.time.LocalDate date) {\n" |
| 97 | + + " return date.isLeapYear();\n" |
| 98 | + + " }\n" |
| 99 | + + " public static boolean isLeapYearFromImportedClass(LocalDate date) {\n" |
| 100 | + + " return date.isLeapYear();\n" |
| 101 | + + " }\n" |
| 102 | + + "}\n") |
| 103 | + public static class WithWildcardImport_conflictWithoutWildcard { |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * Nominal case where an import can be introduced. No wildcard is present. |
| 108 | + */ |
| 109 | + @CompareCompilationUnitsAsStrings( |
| 110 | + pre = "package eu.solven.cleanthat.engine.java.refactorer;\n" + "\n" |
| 111 | + + "\n" |
| 112 | + + "public class NoWildcardImport_IsNotImported_Pre {\n" |
| 113 | + + " public static boolean isLeapYear(java.time.LocalDate date) {\n" |
| 114 | + + " return date.isLeapYear();\n" |
| 115 | + + " }\n" |
| 116 | + + "}\n", |
| 117 | + post = "package eu.solven.cleanthat.engine.java.refactorer;\n" + "\n" |
| 118 | + + "import static java.time.LocalDate;\n" |
| 119 | + + "\n" |
| 120 | + + "public class NoWildcardImport_IsNotImported_Pre {\n" |
| 121 | + + " public static boolean isLeapYear(LocalDate date) {\n" |
| 122 | + + " return date.isLeapYear();\n" |
| 123 | + + " }\n" |
| 124 | + + "}\n") |
| 125 | + public static class WithoutWildcardImport_qualify { |
| 126 | + } |
| 127 | + |
| 128 | +} |
0 commit comments