Skip to content

Commit

Permalink
Add tests to CustomResourceInfoTest
Browse files Browse the repository at this point in the history
  • Loading branch information
baloo42 committed Dec 1, 2024
1 parent 930f2a3 commit 20588b0
Showing 1 changed file with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -44,12 +46,33 @@ public static class Status {
@Version(VERSION)
@ShortNames("s")
@Categories("cat")
public static class ClusteredCR extends CustomResource<Spec, Status> {
public static class ClusteredCR extends
io.fabric8.kubernetes.client.CustomResource<Spec, Status> {
}

@Group(GROUP)
@Version(VERSION)
public static class NamespacedCR extends CustomResource<Spec, Status> implements Namespaced {
public static class NamespacedCR extends io.fabric8.kubernetes.client.CustomResource<Spec, Status>
implements Namespaced {
}

@Group(GROUP)
@Version(VERSION)
static class PackagePrivateInnerCustomResource extends
io.fabric8.kubernetes.client.CustomResource<Void, Void> {
}

@Group(GROUP)
@Version(VERSION)
private static class PrivateInnerCustomResource extends
io.fabric8.kubernetes.client.CustomResource<Void, Void> {
}

@Group(GROUP)
@Version(VERSION)
private static class NoDefaultConstructorCustomResource extends CustomResource<Void, Void> {
NoDefaultConstructorCustomResource(String s) {
}
}

@Test
Expand Down Expand Up @@ -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));
}
}

0 comments on commit 20588b0

Please sign in to comment.