From de414dfa3ace3a5220995de92394c0d7a1f55f83 Mon Sep 17 00:00:00 2001 From: Dusan Jakub Date: Wed, 19 Oct 2022 20:00:44 +0200 Subject: [PATCH] fabric8io/kubernetes-client#4510 Failing tests --- .../crd/example/cyclic/CyclicList.java | 27 +++++++++++++++++++ .../crd/example/cyclic/CyclicListSpec.java | 22 +++++++++++++++ .../fabric8/crd/example/cyclic/RefList.java | 24 +++++++++++++++++ .../crd/generator/CRDGeneratorTest.java | 14 ++++++++++ 4 files changed, 87 insertions(+) create mode 100644 crd-generator/api/src/test/java/io/fabric8/crd/example/cyclic/CyclicList.java create mode 100644 crd-generator/api/src/test/java/io/fabric8/crd/example/cyclic/CyclicListSpec.java create mode 100644 crd-generator/api/src/test/java/io/fabric8/crd/example/cyclic/RefList.java diff --git a/crd-generator/api/src/test/java/io/fabric8/crd/example/cyclic/CyclicList.java b/crd-generator/api/src/test/java/io/fabric8/crd/example/cyclic/CyclicList.java new file mode 100644 index 00000000000..fdc047935e4 --- /dev/null +++ b/crd-generator/api/src/test/java/io/fabric8/crd/example/cyclic/CyclicList.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.crd.example.cyclic; + +import io.fabric8.kubernetes.api.model.Namespaced; +import io.fabric8.kubernetes.client.CustomResource; +import io.fabric8.kubernetes.model.annotation.Group; +import io.fabric8.kubernetes.model.annotation.Version; + +@Group("sample.fabric8.io") +@Version("v1alpha1") +public class CyclicList extends CustomResource implements Namespaced { + +} diff --git a/crd-generator/api/src/test/java/io/fabric8/crd/example/cyclic/CyclicListSpec.java b/crd-generator/api/src/test/java/io/fabric8/crd/example/cyclic/CyclicListSpec.java new file mode 100644 index 00000000000..a5f0798b2a0 --- /dev/null +++ b/crd-generator/api/src/test/java/io/fabric8/crd/example/cyclic/CyclicListSpec.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.crd.example.cyclic; + +import java.util.List; + +public class CyclicListSpec { + private List ref; +} diff --git a/crd-generator/api/src/test/java/io/fabric8/crd/example/cyclic/RefList.java b/crd-generator/api/src/test/java/io/fabric8/crd/example/cyclic/RefList.java new file mode 100644 index 00000000000..f1bd5c9bc25 --- /dev/null +++ b/crd-generator/api/src/test/java/io/fabric8/crd/example/cyclic/RefList.java @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.crd.example.cyclic; + +import java.util.List; + +public class RefList { + + private List ref; + +} diff --git a/crd-generator/api/src/test/java/io/fabric8/crd/generator/CRDGeneratorTest.java b/crd-generator/api/src/test/java/io/fabric8/crd/generator/CRDGeneratorTest.java index 2e8c98c9fa8..43da0e16171 100644 --- a/crd-generator/api/src/test/java/io/fabric8/crd/generator/CRDGeneratorTest.java +++ b/crd-generator/api/src/test/java/io/fabric8/crd/generator/CRDGeneratorTest.java @@ -19,6 +19,7 @@ import io.fabric8.crd.example.basic.BasicSpec; import io.fabric8.crd.example.basic.BasicStatus; import io.fabric8.crd.example.cyclic.Cyclic; +import io.fabric8.crd.example.cyclic.CyclicList; import io.fabric8.crd.example.inherited.*; import io.fabric8.crd.example.joke.Joke; import io.fabric8.crd.example.joke.JokeRequest; @@ -216,6 +217,19 @@ void generatingACycleShouldFail() { "An IllegalArgument Exception hasn't been thrown when generating a CRD with cyclic references"); } + @Test + void generatingACycleInListShouldFail() { + final CRDGenerator generator = new CRDGenerator() + .customResourceClasses(CyclicList.class) + .forCRDVersions("v1", "v1beta1") + .withOutput(output); + + assertThrows( + IllegalArgumentException.class, + () -> generator.detailedGenerate(), + "An IllegalArgument Exception hasn't been thrown when generating a CRD with cyclic references"); + } + @Test void notGeneratingACycleShouldSucceed() { final CRDGenerator generator = new CRDGenerator()