From 24c352270a50a88474bffb5090250f69d12cdc58 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Fri, 15 Nov 2024 11:19:23 +0100 Subject: [PATCH] fix: removed SupportTestingClient interface Signed-off-by: Marc Nuri --- CHANGELOG.md | 3 +- doc/MIGRATION-v7.md | 9 ++ extensions/chaosmesh/client/pom.xml | 5 -- .../client/DefaultChaosMeshClient.java | 7 +- .../client/ChaosMeshClientAdaptTest.java | 81 ------------------ extensions/istio/client/pom.xml | 5 -- .../istio/client/DefaultIstioClient.java | 8 +- .../istio/client/IstioClientAdaptTest.java | 81 ------------------ .../org.mockito.plugins.MockMaker | 1 - extensions/knative/client/pom.xml | 5 -- .../knative/client/DefaultKnativeClient.java | 8 +- .../client/KnativeClientAdaptTest.java | 81 ------------------ .../org.mockito.plugins.MockMaker | 1 - .../open-cluster-management/client/pom.xml | 5 -- .../DefaultOpenClusterManagementClient.java | 8 +- .../OpenClusterManagementClientAdaptTest.java | 81 ------------------ .../org.mockito.plugins.MockMaker | 1 - .../open-virtual-network/client/pom.xml | 5 -- .../OpenVirtualNetworkingClientAdaptTest.java | 82 ------------------- .../org.mockito.plugins.MockMaker | 1 - extensions/tekton/client/pom.xml | 5 -- .../tekton/client/DefaultTektonClient.java | 8 +- .../tekton/client/TektonClientAdaptTest.java | 81 ------------------ .../org.mockito.plugins.MockMaker | 1 - .../verticalpodautoscaler/client/pom.xml | 5 -- .../DefaultVerticalPodAutoscalerClient.java | 8 +- .../VerticalPodAutoscalerClientAdaptTest.java | 81 ------------------ .../org.mockito.plugins.MockMaker | 1 - extensions/volcano/client/pom.xml | 5 -- .../volcano/client/DefaultVolcanoClient.java | 8 +- .../client/VolcanoClientAdaptTest.java | 81 ------------------ .../org.mockito.plugins.MockMaker | 1 - extensions/volumesnapshot/client/pom.xml | 5 -- .../client/DefaultVolumeSnapshotClient.java | 8 +- .../client/VolumeSnapshotClientAdaptTest.java | 81 ------------------ .../org.mockito.plugins.MockMaker | 1 - .../io/fabric8/kubernetes/client/Client.java | 2 +- .../extension/SupportTestingClient.java | 45 ---------- .../kubernetes/client/impl/BaseClient.java | 8 +- .../client/mock/KubernetesMockServerTest.java | 4 +- .../NamespacedOpenShiftClientAdapter.java | 5 -- .../openshift/client/OpenShiftClient.java | 5 +- .../client/impl/OpenShiftClientImpl.java | 25 ------ .../impl/OpenShiftExtensionAdapterTest.java | 41 ---------- 44 files changed, 25 insertions(+), 968 deletions(-) delete mode 100644 extensions/chaosmesh/client/src/test/java/io/fabric8/chaosmesh/client/ChaosMeshClientAdaptTest.java delete mode 100644 extensions/istio/client/src/test/java/io/fabric8/istio/client/IstioClientAdaptTest.java delete mode 100644 extensions/istio/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker delete mode 100644 extensions/knative/client/src/test/java/io/fabric8/knative/client/KnativeClientAdaptTest.java delete mode 100644 extensions/knative/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker delete mode 100644 extensions/open-cluster-management/client/src/test/java/io/fabric8/openclustermanagement/client/OpenClusterManagementClientAdaptTest.java delete mode 100644 extensions/open-cluster-management/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker delete mode 100644 extensions/open-virtual-network/client/src/test/java/io/fabric8/ovn/client/OpenVirtualNetworkingClientAdaptTest.java delete mode 100644 extensions/open-virtual-network/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker delete mode 100644 extensions/tekton/client/src/test/java/io/fabric8/tekton/client/TektonClientAdaptTest.java delete mode 100644 extensions/tekton/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker delete mode 100644 extensions/verticalpodautoscaler/client/src/test/java/io/fabric8/verticalpodautoscaler/client/VerticalPodAutoscalerClientAdaptTest.java delete mode 100644 extensions/verticalpodautoscaler/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker delete mode 100644 extensions/volcano/client/src/test/java/io/fabric8/volcano/client/VolcanoClientAdaptTest.java delete mode 100644 extensions/volcano/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker delete mode 100644 extensions/volumesnapshot/client/src/test/java/io/fabric8/volumesnapshot/client/VolumeSnapshotClientAdaptTest.java delete mode 100644 extensions/volumesnapshot/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker delete mode 100644 kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/SupportTestingClient.java delete mode 100644 openshift-client/src/test/java/io/fabric8/openshift/client/impl/OpenShiftExtensionAdapterTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eec9a6d1e9..6c7d23c5a7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,10 +28,11 @@ #### _**Note**_: Breaking changes * Check detailed migration documentation for breaking changes in [7.0.0](./doc/MIGRATION-v7.md) +* Fix #4659: Removed `SupportTestingClient` interface * Fix #5264: `Config.errorMessages` has been removed. Please use Kubernetes status messages directly. +* Fix #5351: Removed deprecated `io.fabric8:openshift-server-mock` artifact * Fix #6081: Moved Java baseline from 8 (1.8) to 11 * Fix #6138: Removed unused `io:fabric8:kubernetes-model` artifact -* Fix #5351: Removed deprecated `io.fabric8:openshift-server-mock` artifact * Fix #6156: Removed deprecated extension `io:fabric8:service-catalog` * Fix #6158: Removed deprecated methods from `io.fabric8.kubernetes.client.utils.IOHelpers` * Fix #6361: Renamed SettableBeanPropertyDelegate to SettableBeanPropertyDelegating diff --git a/doc/MIGRATION-v7.md b/doc/MIGRATION-v7.md index ec589b3ece9..90c47bf0b98 100644 --- a/doc/MIGRATION-v7.md +++ b/doc/MIGRATION-v7.md @@ -24,6 +24,7 @@ - [Deprecations and Removals](#deprecations-and-removals) - [Apache Felix SCR Annotations removed](#apache-felix-scr-annotations) - [OpenShift Server Mock removed](#openshift-server-mock-removed) + - [SupportTestingClient removed](#supporttestingclient-removed) - [Service Catalog API (extension) removed](#service-catalog-extension) @@ -272,6 +273,14 @@ The usage of the `@EnableOpenShiftMockClient` annotation should be replaced with The use of the `OpenShiftMockServer` class should be replaced with the `KubernetesMockServer` class. +### SupportTestingClient removed + +The deprecated interface `SupportTestingClient` has been removed from the project. + +The method `client.isSupported` is no longer available. +You can replace it with the `Client.hasApiGroup` method or one of the `Client.supports` alternative methods. +For OpenShift, you can also leverage the `OpenShiftClient.supportsOpenShiftAPIGroup` method. + ### Service Catalog API (extension) removed The Service Catalog API extension has been removed. diff --git a/extensions/chaosmesh/client/pom.xml b/extensions/chaosmesh/client/pom.xml index 276963067d0..ba8ca88ff52 100644 --- a/extensions/chaosmesh/client/pom.xml +++ b/extensions/chaosmesh/client/pom.xml @@ -67,11 +67,6 @@ kubernetes-client runtime - - org.mockito - mockito-core - test - diff --git a/extensions/chaosmesh/client/src/main/java/io/fabric8/chaosmesh/client/DefaultChaosMeshClient.java b/extensions/chaosmesh/client/src/main/java/io/fabric8/chaosmesh/client/DefaultChaosMeshClient.java index f0b5ae614ae..5ba58e26f64 100644 --- a/extensions/chaosmesh/client/src/main/java/io/fabric8/chaosmesh/client/DefaultChaosMeshClient.java +++ b/extensions/chaosmesh/client/src/main/java/io/fabric8/chaosmesh/client/DefaultChaosMeshClient.java @@ -47,10 +47,9 @@ import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; public class DefaultChaosMeshClient extends ExtensionRootClientAdapter - implements NamespacedChaosMeshClient, SupportTestingClient { + implements NamespacedChaosMeshClient { public DefaultChaosMeshClient() { super(); @@ -134,8 +133,4 @@ public MixedOperation> awsChaos() { return resources(AWSChaos.class, AWSChaosList.class); } - @Override - public boolean isSupported() { - return hasApiGroup("chaos-mesh.org", false); - } } diff --git a/extensions/chaosmesh/client/src/test/java/io/fabric8/chaosmesh/client/ChaosMeshClientAdaptTest.java b/extensions/chaosmesh/client/src/test/java/io/fabric8/chaosmesh/client/ChaosMeshClientAdaptTest.java deleted file mode 100644 index 878da3d1bf8..00000000000 --- a/extensions/chaosmesh/client/src/test/java/io/fabric8/chaosmesh/client/ChaosMeshClientAdaptTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.chaosmesh.client; - -import io.fabric8.kubernetes.api.model.APIGroup; -import io.fabric8.kubernetes.api.model.APIGroupBuilder; -import io.fabric8.kubernetes.api.model.APIGroupList; -import io.fabric8.kubernetes.api.model.APIGroupListBuilder; -import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.ConfigBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.dsl.internal.OperationSupport; -import io.fabric8.kubernetes.client.http.HttpClient; -import io.fabric8.kubernetes.client.impl.KubernetesClientImpl; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.MockedConstruction; -import org.mockito.Mockito; - -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mockConstruction; -import static org.mockito.Mockito.when; - -class ChaosMeshClientAdaptTest { - private KubernetesClient kubernetesClient; - - @BeforeEach - public void setUp() { - HttpClient mockClient = Mockito.mock(HttpClient.class, Mockito.RETURNS_DEEP_STUBS); - Config config = new ConfigBuilder().withMasterUrl("https://localhost:8443/").build(); - kubernetesClient = new KubernetesClientImpl(mockClient, config); - } - - @AfterEach - void tearDown() { - kubernetesClient.close(); - kubernetesClient = null; - } - - @ParameterizedTest - @MethodSource("getInputData") - void isSupported_withGivenApiGroup_shouldValidateSupport(String apiGroupName, boolean expectedResult) { - try (MockedConstruction ignored = mockConstruction(OperationSupport.class, (mock, ctx) -> { - givenApiGroupsCallReturns(mock, new APIGroupBuilder().withName(apiGroupName).build()); - })) { - assertThat(kubernetesClient.isAdaptable(ChaosMeshClient.class)).isEqualTo(expectedResult); - } - } - - private static Stream getInputData() { - return Stream.of( - Arguments.of("chaos-mesh.org", true), - Arguments.of("test.chaos-mesh.org", true), - Arguments.of("tekton.dev", false)); - } - - private void givenApiGroupsCallReturns(OperationSupport operationSupport, APIGroup apiGroup) { - when(operationSupport.restCall(APIGroupList.class, "/apis")) - .thenReturn(new APIGroupListBuilder() - .addToGroups(apiGroup) - .build()); - } -} diff --git a/extensions/istio/client/pom.xml b/extensions/istio/client/pom.xml index cc27b8b226a..b30fde06c04 100755 --- a/extensions/istio/client/pom.xml +++ b/extensions/istio/client/pom.xml @@ -65,11 +65,6 @@ kubernetes-client runtime - - org.mockito - mockito-core - test - diff --git a/extensions/istio/client/src/main/java/io/fabric8/istio/client/DefaultIstioClient.java b/extensions/istio/client/src/main/java/io/fabric8/istio/client/DefaultIstioClient.java index ce374f15ee6..e9d8b3f984d 100644 --- a/extensions/istio/client/src/main/java/io/fabric8/istio/client/DefaultIstioClient.java +++ b/extensions/istio/client/src/main/java/io/fabric8/istio/client/DefaultIstioClient.java @@ -21,10 +21,9 @@ import io.fabric8.kubernetes.client.WithRequestCallable; import io.fabric8.kubernetes.client.dsl.FunctionCallable; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; public class DefaultIstioClient extends ExtensionRootClientAdapter - implements NamespacedIstioClient, SupportTestingClient { + implements NamespacedIstioClient { public DefaultIstioClient() { super(); @@ -57,9 +56,4 @@ public V1alpha3APIGroupDSL v1alpha3() { public V1beta1APIGroupDSL v1beta1() { return adapt(V1beta1APIGroupClient.class); } - - @Override - public boolean isSupported() { - return hasApiGroup("istio.io", false); - } } diff --git a/extensions/istio/client/src/test/java/io/fabric8/istio/client/IstioClientAdaptTest.java b/extensions/istio/client/src/test/java/io/fabric8/istio/client/IstioClientAdaptTest.java deleted file mode 100644 index da41ffcfc5f..00000000000 --- a/extensions/istio/client/src/test/java/io/fabric8/istio/client/IstioClientAdaptTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.istio.client; - -import io.fabric8.kubernetes.api.model.APIGroup; -import io.fabric8.kubernetes.api.model.APIGroupBuilder; -import io.fabric8.kubernetes.api.model.APIGroupList; -import io.fabric8.kubernetes.api.model.APIGroupListBuilder; -import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.ConfigBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.dsl.internal.OperationSupport; -import io.fabric8.kubernetes.client.http.HttpClient; -import io.fabric8.kubernetes.client.impl.KubernetesClientImpl; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.MockedConstruction; -import org.mockito.Mockito; - -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mockConstruction; -import static org.mockito.Mockito.when; - -class IstioClientAdaptTest { - private KubernetesClient kubernetesClient; - - @BeforeEach - public void setUp() { - HttpClient mockClient = Mockito.mock(HttpClient.class, Mockito.RETURNS_DEEP_STUBS); - Config config = new ConfigBuilder().withMasterUrl("https://localhost:8443/").build(); - kubernetesClient = new KubernetesClientImpl(mockClient, config); - } - - @AfterEach - void tearDown() { - kubernetesClient.close(); - kubernetesClient = null; - } - - @ParameterizedTest - @MethodSource("getInputData") - void isSupported_withGivenApiGroup_shouldValidateSupport(String apiGroupName, boolean expectedResult) { - try (MockedConstruction ignored = mockConstruction(OperationSupport.class, (mock, ctx) -> { - givenApiGroupsCallReturns(mock, new APIGroupBuilder().withName(apiGroupName).build()); - })) { - assertThat(kubernetesClient.isAdaptable(IstioClient.class)).isEqualTo(expectedResult); - } - } - - private static Stream getInputData() { - return Stream.of( - Arguments.of("istio.io", true), - Arguments.of("security.istio.io", true), - Arguments.of("tekton.dev", false)); - } - - private void givenApiGroupsCallReturns(OperationSupport operationSupport, APIGroup apiGroup) { - when(operationSupport.restCall(APIGroupList.class, "/apis")) - .thenReturn(new APIGroupListBuilder() - .addToGroups(apiGroup) - .build()); - } -} diff --git a/extensions/istio/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/extensions/istio/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker deleted file mode 100644 index 1f0955d450f..00000000000 --- a/extensions/istio/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ /dev/null @@ -1 +0,0 @@ -mock-maker-inline diff --git a/extensions/knative/client/pom.xml b/extensions/knative/client/pom.xml index a069daf6885..4befad300e5 100755 --- a/extensions/knative/client/pom.xml +++ b/extensions/knative/client/pom.xml @@ -65,11 +65,6 @@ kubernetes-client runtime - - org.mockito - mockito-core - test - diff --git a/extensions/knative/client/src/main/java/io/fabric8/knative/client/DefaultKnativeClient.java b/extensions/knative/client/src/main/java/io/fabric8/knative/client/DefaultKnativeClient.java index cd2431729ee..2eec1be9265 100644 --- a/extensions/knative/client/src/main/java/io/fabric8/knative/client/DefaultKnativeClient.java +++ b/extensions/knative/client/src/main/java/io/fabric8/knative/client/DefaultKnativeClient.java @@ -77,10 +77,9 @@ import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; public class DefaultKnativeClient extends ExtensionRootClientAdapter - implements NamespacedKnativeClient, SupportTestingClient { + implements NamespacedKnativeClient { public DefaultKnativeClient() { super(); @@ -238,9 +237,4 @@ public MixedOperation> kafka public MixedOperation> kafkaBindings() { return resources(KafkaBinding.class, KafkaBindingList.class); } - - @Override - public boolean isSupported() { - return hasApiGroup("knative.dev", false); - } } diff --git a/extensions/knative/client/src/test/java/io/fabric8/knative/client/KnativeClientAdaptTest.java b/extensions/knative/client/src/test/java/io/fabric8/knative/client/KnativeClientAdaptTest.java deleted file mode 100644 index 83dc3d342f2..00000000000 --- a/extensions/knative/client/src/test/java/io/fabric8/knative/client/KnativeClientAdaptTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.knative.client; - -import io.fabric8.kubernetes.api.model.APIGroup; -import io.fabric8.kubernetes.api.model.APIGroupBuilder; -import io.fabric8.kubernetes.api.model.APIGroupList; -import io.fabric8.kubernetes.api.model.APIGroupListBuilder; -import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.ConfigBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.dsl.internal.OperationSupport; -import io.fabric8.kubernetes.client.http.HttpClient; -import io.fabric8.kubernetes.client.impl.KubernetesClientImpl; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.MockedConstruction; -import org.mockito.Mockito; - -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mockConstruction; -import static org.mockito.Mockito.when; - -class KnativeClientAdaptTest { - private KubernetesClient kubernetesClient; - - @BeforeEach - public void setUp() { - HttpClient mockClient = Mockito.mock(HttpClient.class, Mockito.RETURNS_DEEP_STUBS); - Config config = new ConfigBuilder().withMasterUrl("https://localhost:8443/").build(); - kubernetesClient = new KubernetesClientImpl(mockClient, config); - } - - @AfterEach - void tearDown() { - kubernetesClient.close(); - kubernetesClient = null; - } - - @ParameterizedTest - @MethodSource("getInputData") - void isSupported_withGivenApiGroup_shouldValidateSupport(String apiGroupName, boolean expectedResult) { - try (MockedConstruction ignored = mockConstruction(OperationSupport.class, (mock, ctx) -> { - givenApiGroupsCallReturns(mock, new APIGroupBuilder().withName(apiGroupName).build()); - })) { - assertThat(kubernetesClient.isAdaptable(KnativeClient.class)).isEqualTo(expectedResult); - } - } - - private static Stream getInputData() { - return Stream.of( - Arguments.of("knative.dev", true), - Arguments.of("serving.knative.dev", true), - Arguments.of("tekton.dev", false)); - } - - private void givenApiGroupsCallReturns(OperationSupport operationSupport, APIGroup apiGroup) { - when(operationSupport.restCall(APIGroupList.class, "/apis")) - .thenReturn(new APIGroupListBuilder() - .addToGroups(apiGroup) - .build()); - } -} diff --git a/extensions/knative/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/extensions/knative/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker deleted file mode 100644 index 1f0955d450f..00000000000 --- a/extensions/knative/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ /dev/null @@ -1 +0,0 @@ -mock-maker-inline diff --git a/extensions/open-cluster-management/client/pom.xml b/extensions/open-cluster-management/client/pom.xml index 55093a10c9d..c604c0b3b6c 100644 --- a/extensions/open-cluster-management/client/pom.xml +++ b/extensions/open-cluster-management/client/pom.xml @@ -67,11 +67,6 @@ kubernetes-client runtime - - org.mockito - mockito-core - test - diff --git a/extensions/open-cluster-management/client/src/main/java/io/fabric8/openclustermanagement/client/DefaultOpenClusterManagementClient.java b/extensions/open-cluster-management/client/src/main/java/io/fabric8/openclustermanagement/client/DefaultOpenClusterManagementClient.java index f21d69db279..3a3f0323bbc 100644 --- a/extensions/open-cluster-management/client/src/main/java/io/fabric8/openclustermanagement/client/DefaultOpenClusterManagementClient.java +++ b/extensions/open-cluster-management/client/src/main/java/io/fabric8/openclustermanagement/client/DefaultOpenClusterManagementClient.java @@ -21,7 +21,6 @@ import io.fabric8.kubernetes.client.WithRequestCallable; import io.fabric8.kubernetes.client.dsl.FunctionCallable; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; import io.fabric8.openclustermanagement.client.dsl.OpenClusterManagementAgentAPIGroupDSL; import io.fabric8.openclustermanagement.client.dsl.OpenClusterManagementAppsAPIGroupDSL; import io.fabric8.openclustermanagement.client.dsl.OpenClusterManagementClustersAPIGroupDSL; @@ -31,7 +30,7 @@ import io.fabric8.openclustermanagement.client.dsl.OpenClusterManagementSearchAPIGroupDSL; public class DefaultOpenClusterManagementClient extends ExtensionRootClientAdapter - implements NamespacedOpenClusterManagementClient, SupportTestingClient { + implements NamespacedOpenClusterManagementClient { public DefaultOpenClusterManagementClient() { super(); @@ -94,9 +93,4 @@ public OpenClusterManagementPolicyAPIGroupDSL policy() { public OpenClusterManagementSearchAPIGroupDSL search() { return adapt(OpenClusterManagementSearchAPIGroupClient.class); } - - @Override - public boolean isSupported() { - return hasApiGroup("open-cluster-management.io", false); - } } diff --git a/extensions/open-cluster-management/client/src/test/java/io/fabric8/openclustermanagement/client/OpenClusterManagementClientAdaptTest.java b/extensions/open-cluster-management/client/src/test/java/io/fabric8/openclustermanagement/client/OpenClusterManagementClientAdaptTest.java deleted file mode 100644 index 7932c474e9e..00000000000 --- a/extensions/open-cluster-management/client/src/test/java/io/fabric8/openclustermanagement/client/OpenClusterManagementClientAdaptTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.openclustermanagement.client; - -import io.fabric8.kubernetes.api.model.APIGroup; -import io.fabric8.kubernetes.api.model.APIGroupBuilder; -import io.fabric8.kubernetes.api.model.APIGroupList; -import io.fabric8.kubernetes.api.model.APIGroupListBuilder; -import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.ConfigBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.dsl.internal.OperationSupport; -import io.fabric8.kubernetes.client.http.HttpClient; -import io.fabric8.kubernetes.client.impl.KubernetesClientImpl; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.MockedConstruction; -import org.mockito.Mockito; - -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mockConstruction; -import static org.mockito.Mockito.when; - -class OpenClusterManagementClientAdaptTest { - private KubernetesClient kubernetesClient; - - @BeforeEach - public void setUp() { - HttpClient mockClient = Mockito.mock(HttpClient.class, Mockito.RETURNS_DEEP_STUBS); - Config config = new ConfigBuilder().withMasterUrl("https://localhost:8443/").build(); - kubernetesClient = new KubernetesClientImpl(mockClient, config); - } - - @AfterEach - void tearDown() { - kubernetesClient.close(); - kubernetesClient = null; - } - - @ParameterizedTest - @MethodSource("getInputData") - void isSupported_withGivenApiGroup_shouldValidateSupport(String apiGroupName, boolean expectedResult) { - try (MockedConstruction ignored = mockConstruction(OperationSupport.class, (mock, ctx) -> { - givenApiGroupsCallReturns(mock, new APIGroupBuilder().withName(apiGroupName).build()); - })) { - assertThat(kubernetesClient.isAdaptable(OpenClusterManagementClient.class)).isEqualTo(expectedResult); - } - } - - private static Stream getInputData() { - return Stream.of( - Arguments.of("open-cluster-management.io", true), - Arguments.of("operator.open-cluster-management.io", true), - Arguments.of("tekton.dev", false)); - } - - private void givenApiGroupsCallReturns(OperationSupport operationSupport, APIGroup apiGroup) { - when(operationSupport.restCall(APIGroupList.class, "/apis")) - .thenReturn(new APIGroupListBuilder() - .addToGroups(apiGroup) - .build()); - } -} diff --git a/extensions/open-cluster-management/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/extensions/open-cluster-management/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker deleted file mode 100644 index 1f0955d450f..00000000000 --- a/extensions/open-cluster-management/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ /dev/null @@ -1 +0,0 @@ -mock-maker-inline diff --git a/extensions/open-virtual-network/client/pom.xml b/extensions/open-virtual-network/client/pom.xml index 6ae4dd8ffad..3f748321083 100644 --- a/extensions/open-virtual-network/client/pom.xml +++ b/extensions/open-virtual-network/client/pom.xml @@ -100,11 +100,6 @@ junit-jupiter-params test - - org.mockito - mockito-core - test - org.assertj assertj-core diff --git a/extensions/open-virtual-network/client/src/test/java/io/fabric8/ovn/client/OpenVirtualNetworkingClientAdaptTest.java b/extensions/open-virtual-network/client/src/test/java/io/fabric8/ovn/client/OpenVirtualNetworkingClientAdaptTest.java deleted file mode 100644 index 053dadcdbcb..00000000000 --- a/extensions/open-virtual-network/client/src/test/java/io/fabric8/ovn/client/OpenVirtualNetworkingClientAdaptTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.ovn.client; - -import io.fabric8.kubernetes.api.model.APIGroup; -import io.fabric8.kubernetes.api.model.APIGroupBuilder; -import io.fabric8.kubernetes.api.model.APIGroupList; -import io.fabric8.kubernetes.api.model.APIGroupListBuilder; -import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.ConfigBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.dsl.internal.OperationSupport; -import io.fabric8.kubernetes.client.http.HttpClient; -import io.fabric8.kubernetes.client.impl.KubernetesClientImpl; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.MockedConstruction; -import org.mockito.Mockito; - -import java.util.Optional; -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mockConstruction; -import static org.mockito.Mockito.when; - -class OpenVirtualNetworkingClientAdaptTest { - private KubernetesClient kubernetesClient; - - @BeforeEach - public void setUp() { - HttpClient mockClient = Mockito.mock(HttpClient.class, Mockito.RETURNS_DEEP_STUBS); - Config config = new ConfigBuilder().withMasterUrl("https://localhost:8443/").build(); - kubernetesClient = new KubernetesClientImpl(mockClient, config); - } - - @AfterEach - void tearDown() { - kubernetesClient.close(); - kubernetesClient = null; - } - - @ParameterizedTest - @MethodSource("getInputData") - void isSupported_withGivenApiGroup_shouldValidateSupport(String apiGroupName, boolean expectedResult) { - try (MockedConstruction ignored = mockConstruction(OperationSupport.class, (mock, ctx) -> { - givenApiGroupsCallReturns(mock, new APIGroupBuilder().withName(apiGroupName).build()); - })) { - assertThat(Optional.ofNullable(kubernetesClient.adapt(OpenVirtualNetworkingClient.class)).isPresent()) - .isEqualTo(expectedResult); - } - } - - private static Stream getInputData() { - return Stream.of( - Arguments.of("k8s.ovn.org", true), - Arguments.of("unknown-apigroup.io", false)); - } - - private void givenApiGroupsCallReturns(OperationSupport operationSupport, APIGroup apiGroup) { - when(operationSupport.restCall(APIGroupList.class, "/apis")) - .thenReturn(new APIGroupListBuilder() - .addToGroups(apiGroup) - .build()); - } -} diff --git a/extensions/open-virtual-network/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/extensions/open-virtual-network/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker deleted file mode 100644 index 1f0955d450f..00000000000 --- a/extensions/open-virtual-network/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ /dev/null @@ -1 +0,0 @@ -mock-maker-inline diff --git a/extensions/tekton/client/pom.xml b/extensions/tekton/client/pom.xml index 86717bd59b1..8463fbe4ada 100644 --- a/extensions/tekton/client/pom.xml +++ b/extensions/tekton/client/pom.xml @@ -65,10 +65,5 @@ kubernetes-client runtime - - org.mockito - mockito-core - test - diff --git a/extensions/tekton/client/src/main/java/io/fabric8/tekton/client/DefaultTektonClient.java b/extensions/tekton/client/src/main/java/io/fabric8/tekton/client/DefaultTektonClient.java index cc0a2143501..ab6f8735290 100644 --- a/extensions/tekton/client/src/main/java/io/fabric8/tekton/client/DefaultTektonClient.java +++ b/extensions/tekton/client/src/main/java/io/fabric8/tekton/client/DefaultTektonClient.java @@ -21,13 +21,12 @@ import io.fabric8.kubernetes.client.WithRequestCallable; import io.fabric8.kubernetes.client.dsl.FunctionCallable; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; import io.fabric8.tekton.client.dsl.V1APIGroupDSL; import io.fabric8.tekton.client.dsl.V1alpha1APIGroupDSL; import io.fabric8.tekton.client.dsl.V1beta1APIGroupDSL; public class DefaultTektonClient extends ExtensionRootClientAdapter - implements NamespacedTektonClient, SupportTestingClient { + implements NamespacedTektonClient { public DefaultTektonClient() { super(); @@ -66,9 +65,4 @@ public V1alpha1APIGroupDSL v1alpha1() { return adapt(V1alpha1APIGroupClient.class); } - @Override - public boolean isSupported() { - return hasApiGroup("tekton.dev", false); - } - } diff --git a/extensions/tekton/client/src/test/java/io/fabric8/tekton/client/TektonClientAdaptTest.java b/extensions/tekton/client/src/test/java/io/fabric8/tekton/client/TektonClientAdaptTest.java deleted file mode 100644 index 24ac2246a9b..00000000000 --- a/extensions/tekton/client/src/test/java/io/fabric8/tekton/client/TektonClientAdaptTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.tekton.client; - -import io.fabric8.kubernetes.api.model.APIGroup; -import io.fabric8.kubernetes.api.model.APIGroupBuilder; -import io.fabric8.kubernetes.api.model.APIGroupList; -import io.fabric8.kubernetes.api.model.APIGroupListBuilder; -import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.ConfigBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.dsl.internal.OperationSupport; -import io.fabric8.kubernetes.client.http.HttpClient; -import io.fabric8.kubernetes.client.impl.KubernetesClientImpl; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.MockedConstruction; -import org.mockito.Mockito; - -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mockConstruction; -import static org.mockito.Mockito.when; - -class TektonClientAdaptTest { - private KubernetesClient kubernetesClient; - - @BeforeEach - public void setUp() { - HttpClient mockClient = Mockito.mock(HttpClient.class, Mockito.RETURNS_DEEP_STUBS); - Config config = new ConfigBuilder().withMasterUrl("https://localhost:8443/").build(); - kubernetesClient = new KubernetesClientImpl(mockClient, config); - } - - @AfterEach - void tearDown() { - kubernetesClient.close(); - kubernetesClient = null; - } - - @ParameterizedTest - @MethodSource("getInputData") - void isSupported_withGivenApiGroup_shouldValidateSupport(String apiGroupName, boolean expectedResult) { - try (MockedConstruction ignored = mockConstruction(OperationSupport.class, (mock, ctx) -> { - givenApiGroupsCallReturns(mock, new APIGroupBuilder().withName(apiGroupName).build()); - })) { - assertThat(kubernetesClient.isAdaptable(TektonClient.class)).isEqualTo(expectedResult); - } - } - - private static Stream getInputData() { - return Stream.of( - Arguments.of("tekton.dev", true), - Arguments.of("triggers.tekton.dev", true), - Arguments.of("knative.dev", false)); - } - - private void givenApiGroupsCallReturns(OperationSupport operationSupport, APIGroup apiGroup) { - when(operationSupport.restCall(APIGroupList.class, "/apis")) - .thenReturn(new APIGroupListBuilder() - .addToGroups(apiGroup) - .build()); - } -} diff --git a/extensions/tekton/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/extensions/tekton/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker deleted file mode 100644 index 1f0955d450f..00000000000 --- a/extensions/tekton/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ /dev/null @@ -1 +0,0 @@ -mock-maker-inline diff --git a/extensions/verticalpodautoscaler/client/pom.xml b/extensions/verticalpodautoscaler/client/pom.xml index ee1c564a40f..c887be2d816 100644 --- a/extensions/verticalpodautoscaler/client/pom.xml +++ b/extensions/verticalpodautoscaler/client/pom.xml @@ -66,10 +66,5 @@ kubernetes-client runtime - - org.mockito - mockito-core - test - diff --git a/extensions/verticalpodautoscaler/client/src/main/java/io/fabric8/verticalpodautoscaler/client/DefaultVerticalPodAutoscalerClient.java b/extensions/verticalpodautoscaler/client/src/main/java/io/fabric8/verticalpodautoscaler/client/DefaultVerticalPodAutoscalerClient.java index 7a9ef1f2bab..a2f1ee7b89a 100644 --- a/extensions/verticalpodautoscaler/client/src/main/java/io/fabric8/verticalpodautoscaler/client/DefaultVerticalPodAutoscalerClient.java +++ b/extensions/verticalpodautoscaler/client/src/main/java/io/fabric8/verticalpodautoscaler/client/DefaultVerticalPodAutoscalerClient.java @@ -21,11 +21,10 @@ import io.fabric8.kubernetes.client.WithRequestCallable; import io.fabric8.kubernetes.client.dsl.FunctionCallable; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; import io.fabric8.verticalpodautoscaler.client.dsl.V1APIGroupDSL; public class DefaultVerticalPodAutoscalerClient extends ExtensionRootClientAdapter - implements NamespacedVerticalPodAutoscalerClient, SupportTestingClient { + implements NamespacedVerticalPodAutoscalerClient { public DefaultVerticalPodAutoscalerClient() { super(); @@ -54,9 +53,4 @@ public V1APIGroupDSL v1() { return adapt(V1APIGroupClient.class); } - @Override - public boolean isSupported() { - return getClient().hasApiGroup(VerticalPodAutoscalerExtensionAdapter.API_GROUP, false); - } - } diff --git a/extensions/verticalpodautoscaler/client/src/test/java/io/fabric8/verticalpodautoscaler/client/VerticalPodAutoscalerClientAdaptTest.java b/extensions/verticalpodautoscaler/client/src/test/java/io/fabric8/verticalpodautoscaler/client/VerticalPodAutoscalerClientAdaptTest.java deleted file mode 100644 index 9042763b5eb..00000000000 --- a/extensions/verticalpodautoscaler/client/src/test/java/io/fabric8/verticalpodautoscaler/client/VerticalPodAutoscalerClientAdaptTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.verticalpodautoscaler.client; - -import io.fabric8.kubernetes.api.model.APIGroup; -import io.fabric8.kubernetes.api.model.APIGroupBuilder; -import io.fabric8.kubernetes.api.model.APIGroupList; -import io.fabric8.kubernetes.api.model.APIGroupListBuilder; -import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.ConfigBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.dsl.internal.OperationSupport; -import io.fabric8.kubernetes.client.http.HttpClient; -import io.fabric8.kubernetes.client.impl.KubernetesClientImpl; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.MockedConstruction; -import org.mockito.Mockito; - -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mockConstruction; -import static org.mockito.Mockito.when; - -class VerticalPodAutoscalerClientAdaptTest { - private KubernetesClient kubernetesClient; - - @BeforeEach - public void setUp() { - HttpClient mockClient = Mockito.mock(HttpClient.class, Mockito.RETURNS_DEEP_STUBS); - Config config = new ConfigBuilder().withMasterUrl("https://localhost:8443/").build(); - kubernetesClient = new KubernetesClientImpl(mockClient, config); - } - - @AfterEach - void tearDown() { - kubernetesClient.close(); - kubernetesClient = null; - } - - @ParameterizedTest - @MethodSource("getInputData") - void isSupported_withGivenApiGroup_shouldValidateSupport(String apiGroupName, boolean expectedResult) { - try (MockedConstruction ignored = mockConstruction(OperationSupport.class, (mock, ctx) -> { - givenApiGroupsCallReturns(mock, new APIGroupBuilder().withName(apiGroupName).build()); - })) { - assertThat(kubernetesClient.isAdaptable(VerticalPodAutoscalerClient.class)).isEqualTo(expectedResult); - } - } - - private static Stream getInputData() { - return Stream.of( - Arguments.of("autoscaling.k8s.io", true), - Arguments.of("test.autoscaling.k8s.io", true), - Arguments.of("tekton.dev", false)); - } - - private void givenApiGroupsCallReturns(OperationSupport operationSupport, APIGroup apiGroup) { - when(operationSupport.restCall(APIGroupList.class, "/apis")) - .thenReturn(new APIGroupListBuilder() - .addToGroups(apiGroup) - .build()); - } -} diff --git a/extensions/verticalpodautoscaler/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/extensions/verticalpodautoscaler/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker deleted file mode 100644 index 1f0955d450f..00000000000 --- a/extensions/verticalpodautoscaler/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ /dev/null @@ -1 +0,0 @@ -mock-maker-inline diff --git a/extensions/volcano/client/pom.xml b/extensions/volcano/client/pom.xml index d5622a93807..83e2e55cc4b 100644 --- a/extensions/volcano/client/pom.xml +++ b/extensions/volcano/client/pom.xml @@ -66,10 +66,5 @@ kubernetes-client runtime - - org.mockito - mockito-core - test - diff --git a/extensions/volcano/client/src/main/java/io/fabric8/volcano/client/DefaultVolcanoClient.java b/extensions/volcano/client/src/main/java/io/fabric8/volcano/client/DefaultVolcanoClient.java index 593a2a942e8..ebf4b43f626 100644 --- a/extensions/volcano/client/src/main/java/io/fabric8/volcano/client/DefaultVolcanoClient.java +++ b/extensions/volcano/client/src/main/java/io/fabric8/volcano/client/DefaultVolcanoClient.java @@ -23,7 +23,6 @@ import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; import io.fabric8.volcano.api.model.scheduling.v1beta1.PodGroup; import io.fabric8.volcano.api.model.scheduling.v1beta1.PodGroupList; import io.fabric8.volcano.api.model.scheduling.v1beta1.Queue; @@ -31,7 +30,7 @@ import io.fabric8.volcano.client.dsl.V1beta1APIGroupDSL; public class DefaultVolcanoClient extends ExtensionRootClientAdapter - implements NamespacedVolcanoClient, SupportTestingClient { + implements NamespacedVolcanoClient { public DefaultVolcanoClient() { super(); @@ -72,9 +71,4 @@ public V1beta1APIGroupDSL v1beta1() { // User can specify client.v1beta1().podGroups() to use v1beta1 API return adapt(V1beta1APIGroupClient.class); } - - @Override - public boolean isSupported() { - return getClient().hasApiGroup(VolcanoExtensionAdapter.API_GROUP, false); - } } diff --git a/extensions/volcano/client/src/test/java/io/fabric8/volcano/client/VolcanoClientAdaptTest.java b/extensions/volcano/client/src/test/java/io/fabric8/volcano/client/VolcanoClientAdaptTest.java deleted file mode 100644 index 4938a817c8f..00000000000 --- a/extensions/volcano/client/src/test/java/io/fabric8/volcano/client/VolcanoClientAdaptTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.volcano.client; - -import io.fabric8.kubernetes.api.model.APIGroup; -import io.fabric8.kubernetes.api.model.APIGroupBuilder; -import io.fabric8.kubernetes.api.model.APIGroupList; -import io.fabric8.kubernetes.api.model.APIGroupListBuilder; -import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.ConfigBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.dsl.internal.OperationSupport; -import io.fabric8.kubernetes.client.http.HttpClient; -import io.fabric8.kubernetes.client.impl.KubernetesClientImpl; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.MockedConstruction; -import org.mockito.Mockito; - -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mockConstruction; -import static org.mockito.Mockito.when; - -class VolcanoClientAdaptTest { - private KubernetesClient kubernetesClient; - - @BeforeEach - public void setUp() { - HttpClient mockClient = Mockito.mock(HttpClient.class, Mockito.RETURNS_DEEP_STUBS); - Config config = new ConfigBuilder().withMasterUrl("https://localhost:8443/").build(); - kubernetesClient = new KubernetesClientImpl(mockClient, config); - } - - @AfterEach - void tearDown() { - kubernetesClient.close(); - kubernetesClient = null; - } - - @ParameterizedTest - @MethodSource("getInputData") - void isSupported_withGivenApiGroup_shouldValidateSupport(String apiGroupName, boolean expectedResult) { - try (MockedConstruction ignored = mockConstruction(OperationSupport.class, (mock, ctx) -> { - givenApiGroupsCallReturns(mock, new APIGroupBuilder().withName(apiGroupName).build()); - })) { - assertThat(kubernetesClient.isAdaptable(VolcanoClient.class)).isEqualTo(expectedResult); - } - } - - private static Stream getInputData() { - return Stream.of( - Arguments.of("scheduling.volcano.sh", true), - Arguments.of("test.scheduling.volcano.sh", true), - Arguments.of("tekton.dev", false)); - } - - private void givenApiGroupsCallReturns(OperationSupport operationSupport, APIGroup apiGroup) { - when(operationSupport.restCall(APIGroupList.class, "/apis")) - .thenReturn(new APIGroupListBuilder() - .addToGroups(apiGroup) - .build()); - } -} diff --git a/extensions/volcano/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/extensions/volcano/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker deleted file mode 100644 index 1f0955d450f..00000000000 --- a/extensions/volcano/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ /dev/null @@ -1 +0,0 @@ -mock-maker-inline diff --git a/extensions/volumesnapshot/client/pom.xml b/extensions/volumesnapshot/client/pom.xml index c790e620c48..fe87f57af40 100644 --- a/extensions/volumesnapshot/client/pom.xml +++ b/extensions/volumesnapshot/client/pom.xml @@ -67,11 +67,6 @@ kubernetes-client runtime - - org.mockito - mockito-core - test - diff --git a/extensions/volumesnapshot/client/src/main/java/io/fabric8/volumesnapshot/client/DefaultVolumeSnapshotClient.java b/extensions/volumesnapshot/client/src/main/java/io/fabric8/volumesnapshot/client/DefaultVolumeSnapshotClient.java index 0918480bd25..f3e825555f8 100644 --- a/extensions/volumesnapshot/client/src/main/java/io/fabric8/volumesnapshot/client/DefaultVolumeSnapshotClient.java +++ b/extensions/volumesnapshot/client/src/main/java/io/fabric8/volumesnapshot/client/DefaultVolumeSnapshotClient.java @@ -23,7 +23,6 @@ import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; import io.fabric8.volumesnapshot.api.model.VolumeSnapshot; import io.fabric8.volumesnapshot.api.model.VolumeSnapshotClass; import io.fabric8.volumesnapshot.api.model.VolumeSnapshotClassList; @@ -32,7 +31,7 @@ import io.fabric8.volumesnapshot.api.model.VolumeSnapshotList; public class DefaultVolumeSnapshotClient extends ExtensionRootClientAdapter - implements NamespacedVolumeSnapshotClient, SupportTestingClient { + implements NamespacedVolumeSnapshotClient { public DefaultVolumeSnapshotClient() { super(); @@ -70,9 +69,4 @@ public MixedOperation withRequestConfig(RequestConfig requestConfig) { return new WithRequestCallable<>(this, requestConfig); } - - @Override - public boolean isSupported() { - return getClient().hasApiGroup(VolumeSnapshotExtensionAdapter.API_GROUP, false); - } } diff --git a/extensions/volumesnapshot/client/src/test/java/io/fabric8/volumesnapshot/client/VolumeSnapshotClientAdaptTest.java b/extensions/volumesnapshot/client/src/test/java/io/fabric8/volumesnapshot/client/VolumeSnapshotClientAdaptTest.java deleted file mode 100644 index 8973f459e74..00000000000 --- a/extensions/volumesnapshot/client/src/test/java/io/fabric8/volumesnapshot/client/VolumeSnapshotClientAdaptTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.volumesnapshot.client; - -import io.fabric8.kubernetes.api.model.APIGroup; -import io.fabric8.kubernetes.api.model.APIGroupBuilder; -import io.fabric8.kubernetes.api.model.APIGroupList; -import io.fabric8.kubernetes.api.model.APIGroupListBuilder; -import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.ConfigBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.dsl.internal.OperationSupport; -import io.fabric8.kubernetes.client.http.HttpClient; -import io.fabric8.kubernetes.client.impl.KubernetesClientImpl; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.MockedConstruction; -import org.mockito.Mockito; - -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mockConstruction; -import static org.mockito.Mockito.when; - -class VolumeSnapshotClientAdaptTest { - private KubernetesClient kubernetesClient; - - @BeforeEach - public void setUp() { - HttpClient mockClient = Mockito.mock(HttpClient.class, Mockito.RETURNS_DEEP_STUBS); - Config config = new ConfigBuilder().withMasterUrl("https://localhost:8443/").build(); - kubernetesClient = new KubernetesClientImpl(mockClient, config); - } - - @AfterEach - void tearDown() { - kubernetesClient.close(); - kubernetesClient = null; - } - - @ParameterizedTest - @MethodSource("getInputData") - void isSupported_withGivenApiGroup_shouldValidateSupport(String apiGroupName, boolean expectedResult) { - try (MockedConstruction ignored = mockConstruction(OperationSupport.class, (mock, ctx) -> { - givenApiGroupsCallReturns(mock, new APIGroupBuilder().withName(apiGroupName).build()); - })) { - assertThat(kubernetesClient.isAdaptable(VolumeSnapshotClient.class)).isEqualTo(expectedResult); - } - } - - private static Stream getInputData() { - return Stream.of( - Arguments.of("snapshot.storage.k8s.io", true), - Arguments.of("serving.snapshot.storage.k8s.io", true), - Arguments.of("tekton.dev", false)); - } - - private void givenApiGroupsCallReturns(OperationSupport operationSupport, APIGroup apiGroup) { - when(operationSupport.restCall(APIGroupList.class, "/apis")) - .thenReturn(new APIGroupListBuilder() - .addToGroups(apiGroup) - .build()); - } -} diff --git a/extensions/volumesnapshot/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/extensions/volumesnapshot/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker deleted file mode 100644 index 1f0955d450f..00000000000 --- a/extensions/volumesnapshot/client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ /dev/null @@ -1 +0,0 @@ -mock-maker-inline diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java index fef95d5e022..dab9a4fc0b7 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java @@ -33,7 +33,7 @@ public interface Client extends Closeable { /** - * Checks if the client can be adapted to an other client type and if that target client is supported. + * Checks if the client can be adapted to another client type and if that target client is supported. * * @param type The target client class. * @param The target client type. diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/SupportTestingClient.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/SupportTestingClient.java deleted file mode 100644 index d66a74626ae..00000000000 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/SupportTestingClient.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.kubernetes.client.extension; - -import io.fabric8.kubernetes.client.Client; - -/** - * Marks the client as being able to test for its own support. - *

- * Moving forward only clients with special support needs, such as - * the openshift client should implement this interface. For those classes, - * this interface can be part of the public contract. - * - * @deprecated will be removed in future versions - */ -@Deprecated -public interface SupportTestingClient extends Client { - - /** - * Tests if the client is supported. - *
- * Implementations will use - * {@link Client#hasApiGroup(String, boolean)} to be compatible with mock support - * - * @return true if supported - * - * @deprecated use {@link Client#supports(Class)} or {@link Client#supports(String, String)} instead - */ - @Deprecated - boolean isSupported(); - -} diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/BaseClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/BaseClient.java index 45b0da8550e..fa29f1016ff 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/BaseClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/BaseClient.java @@ -36,7 +36,6 @@ import io.fabric8.kubernetes.client.dsl.internal.OperationContext; import io.fabric8.kubernetes.client.dsl.internal.OperationSupport; import io.fabric8.kubernetes.client.extension.ExtensionAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; import io.fabric8.kubernetes.client.http.HttpClient; import io.fabric8.kubernetes.client.utils.ApiVersionUtil; import io.fabric8.kubernetes.client.utils.KubernetesSerialization; @@ -219,12 +218,7 @@ public boolean hasApiGroup(String apiGroup, boolean exact) { @Override public Boolean isAdaptable(Class type) { - // if type is an instanceof SupportTestingClient, then it's a proper - // test, otherwise it could be legacy support on an extension client - C toTest = adapt(type); - if (toTest instanceof SupportTestingClient) { - return ((SupportTestingClient) toTest).isSupported(); - } + adapt(type); return true; } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/KubernetesMockServerTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/KubernetesMockServerTest.java index caf91df33f4..aaef96666af 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/KubernetesMockServerTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/KubernetesMockServerTest.java @@ -63,11 +63,11 @@ void testReset() { void testOpenShiftSupport() { server.setUnsupported("openshift.io"); assertFalse(client.isAdaptable(OpenShiftClient.class)); - assertFalse(client.adapt(OpenShiftClient.class).isSupported()); assertFalse(client.supports(Route.class)); assertTrue(client.supports(Pod.class)); server.reset(); - assertTrue(client.adapt(OpenShiftClient.class).isSupported()); + assertTrue(client.isAdaptable(OpenShiftClient.class)); + assertTrue(client.supports(Route.class)); } @Version("v1") diff --git a/openshift-client-api/src/main/java/io/fabric8/openshift/client/NamespacedOpenShiftClientAdapter.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/NamespacedOpenShiftClientAdapter.java index d679c499a04..60ef524c573 100644 --- a/openshift-client-api/src/main/java/io/fabric8/openshift/client/NamespacedOpenShiftClientAdapter.java +++ b/openshift-client-api/src/main/java/io/fabric8/openshift/client/NamespacedOpenShiftClientAdapter.java @@ -512,11 +512,6 @@ public NonNamespaceOperation