|
| 1 | +/* |
| 2 | + * Copyright The OpenTelemetry Authors |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +package io.opentelemetry.gradle.customchecks; |
| 7 | + |
| 8 | +import com.google.errorprone.CompilationTestHelper; |
| 9 | +import org.junit.jupiter.api.Test; |
| 10 | + |
| 11 | +class OtelImplJavadocTest { |
| 12 | + |
| 13 | + @Test |
| 14 | + void positiveCases() { |
| 15 | + CompilationTestHelper.newInstance(OtelImplJavadoc.class, OtelImplJavadocTest.class) |
| 16 | + .addSourceLines( |
| 17 | + "impl/ImplJavadocPositiveCases.java", |
| 18 | + "/*", |
| 19 | + " * Copyright The OpenTelemetry Authors", |
| 20 | + " * SPDX-License-Identifier: Apache-2.0", |
| 21 | + " */", |
| 22 | + "package io.opentelemetry.gradle.customchecks.impl;", |
| 23 | + "// BUG: Diagnostic contains: missing the required javadoc disclaimer", |
| 24 | + "public class ImplJavadocPositiveCases {", |
| 25 | + " // BUG: Diagnostic contains: missing the required javadoc disclaimer", |
| 26 | + " public static class One {}", |
| 27 | + " /** Doesn't have the disclaimer. */", |
| 28 | + " // BUG: Diagnostic contains: missing the required javadoc disclaimer", |
| 29 | + " public static class Two {}", |
| 30 | + "}") |
| 31 | + .doTest(); |
| 32 | + } |
| 33 | + |
| 34 | + @Test |
| 35 | + void negativeCases() { |
| 36 | + CompilationTestHelper.newInstance(OtelImplJavadoc.class, OtelImplJavadocTest.class) |
| 37 | + .addSourceLines( |
| 38 | + "impl/ImplJavadocNegativeCases.java", |
| 39 | + "/*", |
| 40 | + " * Copyright The OpenTelemetry Authors", |
| 41 | + " * SPDX-License-Identifier: Apache-2.0", |
| 42 | + " */", |
| 43 | + "package io.opentelemetry.gradle.customchecks.impl;", |
| 44 | + "/**", |
| 45 | + " * This class is not intended for use by application developers. Its API is stable and", |
| 46 | + " * will not be changed or removed in a backwards-incompatible manner.", |
| 47 | + " */", |
| 48 | + "public class ImplJavadocNegativeCases {", |
| 49 | + " /**", |
| 50 | + " * This class is not intended for use by application developers. Its API is stable", |
| 51 | + " * and will not be changed or removed in a backwards-incompatible manner.", |
| 52 | + " */", |
| 53 | + " public static class One {}", |
| 54 | + " // Non-public class without disclaimer is fine.", |
| 55 | + " static class Two {}", |
| 56 | + "}") |
| 57 | + .doTest(); |
| 58 | + } |
| 59 | + |
| 60 | + @Test |
| 61 | + void nonImplPackageIgnored() { |
| 62 | + CompilationTestHelper.newInstance(OtelImplJavadoc.class, OtelImplJavadocTest.class) |
| 63 | + .addSourceLines( |
| 64 | + "other/NonImplPackageCases.java", |
| 65 | + "/*", |
| 66 | + " * Copyright The OpenTelemetry Authors", |
| 67 | + " * SPDX-License-Identifier: Apache-2.0", |
| 68 | + " */", |
| 69 | + "package io.opentelemetry.gradle.customchecks.other;", |
| 70 | + "public class NonImplPackageCases {", |
| 71 | + " public static class One {}", |
| 72 | + "}") |
| 73 | + .doTest(); |
| 74 | + } |
| 75 | +} |
0 commit comments