diff --git a/crd-generator/api-v2/src/test/java/io/fabric8/crdv2/generator/CustomResourceInfoTest.java b/crd-generator/api-v2/src/test/java/io/fabric8/crdv2/generator/CustomResourceInfoTest.java index d7d908b95c..ad441c0e1c 100644 --- a/crd-generator/api-v2/src/test/java/io/fabric8/crdv2/generator/CustomResourceInfoTest.java +++ b/crd-generator/api-v2/src/test/java/io/fabric8/crdv2/generator/CustomResourceInfoTest.java @@ -27,6 +27,8 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; public class CustomResourceInfoTest { @@ -44,12 +46,33 @@ public static class Status { @Version(VERSION) @ShortNames("s") @Categories("cat") - public static class ClusteredCR extends CustomResource { + public static class ClusteredCR extends + io.fabric8.kubernetes.client.CustomResource { } @Group(GROUP) @Version(VERSION) - public static class NamespacedCR extends CustomResource implements Namespaced { + public static class NamespacedCR extends io.fabric8.kubernetes.client.CustomResource + implements Namespaced { + } + + @Group(GROUP) + @Version(VERSION) + static class PackagePrivateInnerCustomResource extends + io.fabric8.kubernetes.client.CustomResource { + } + + @Group(GROUP) + @Version(VERSION) + private static class PrivateInnerCustomResource extends + io.fabric8.kubernetes.client.CustomResource { + } + + @Group(GROUP) + @Version(VERSION) + private static class NoDefaultConstructorCustomResource extends CustomResource { + NoDefaultConstructorCustomResource(String s) { + } } @Test @@ -92,4 +115,22 @@ void shouldProperlyCreateCustomResourceInfo() { assertTrue(info.storage()); assertEquals(HasMetadata.getKind(ClusteredCR.class), info.kind()); } + + @Test + void shouldCreateCustomResourceInfoFromPackagePrivateClass() { + CustomResourceInfo info = CustomResourceInfo.fromClass(PackagePrivateInnerCustomResource.class); + assertNotNull(info); + } + + @Test + void shouldCreateCustomResourceInfoFromPrivateClass() { + CustomResourceInfo info = CustomResourceInfo.fromClass(PrivateInnerCustomResource.class); + assertNotNull(info); + } + + @Test + void shouldFailForMissingDefaultConstructor() { + assertThrows(IllegalStateException.class, + () -> CustomResourceInfo.fromClass(NoDefaultConstructorCustomResource.class)); + } }