KubernetesApiProvider buildKubernetesApiUrlProvider() {
        try {
            String endpointSlicesUrlString =
                    String.format("%s/apis/discovery.k8s.io/v1/namespaces/%s/endpointslices", kubernetesMaster, namespace);
            callGet(endpointSlicesUrlString);
            LOGGER.finest("Using EndpointSlices API to discover endpoints.");
        } catch (Exception e) {
            LOGGER.finest("EndpointSlices are not available, using Endpoints API to discover endpoints.");
            return new KubernetesApiEndpointProvider();
        }
        return new KubernetesApiEndpointSlicesProvider();
    }
@Test
    public void buildKubernetesApiUrlProviderReturnsEndpointProvider() {
        //language=JSON
        String endpointSlicesResponse = """
                {
                  "kind": "Status",
                  "apiVersion": "v1",
                  "metadata": {
                   \s
                  },
                  "status": "Failure",
                  "message": "the server could not find the requested resource",
                  "reason":"NotFound",
                  "details": {
                   \s
                  },
                  "code": 404
                }""";
        stub(String.format("/apis/discovery.k8s.io/v1/namespaces/%s/endpointslices", NAMESPACE),
                HttpURLConnection.HTTP_NOT_FOUND, endpointSlicesResponse);
        assertThat(kubernetesClient.buildKubernetesApiUrlProvider()).isInstanceOf(KubernetesApiEndpointProvider.class);
    }