KubernetesDiscoveryClient implements DiscoveryClient { public List<Endpoints> getEndPointsList(String serviceId) { return this.properties.isAllNamespaces() ? this.client.endpoints().inAnyNamespace().withField("metadata.name", serviceId) .withLabels(properties.getServiceLabels()).list().getItems() : this.client.endpoints().withField("metadata.name", serviceId) .withLabels(properties.getServiceLabels()).list().getItems(); } KubernetesDiscoveryClient(KubernetesClient client,
			KubernetesDiscoveryProperties kubernetesDiscoveryProperties,
			KubernetesClientServicesFunction kubernetesClientServicesFunction);   KubernetesDiscoveryClient(KubernetesClient client, KubernetesDiscoveryProperties kubernetesDiscoveryProperties,
			KubernetesClientServicesFunction kubernetesClientServicesFunction,
			DefaultIsServicePortSecureResolver isServicePortSecureResolver); KubernetesClient getClient(); void setClient(KubernetesClient client); @Override String description(); @Override List<ServiceInstance> getInstances(String serviceId); List<Endpoints> getEndPointsList(String serviceId); @Override List<String> getServices(); List<String> getServices(Predicate<Service> filter); @Override int getOrder();  }
@Test public void getEndPointsListTest() { Map<String, String> labels = new HashMap(); labels.put("l", "v"); Endpoints endPoint = new EndpointsBuilder().withNewMetadata().withName("endpoint").withNamespace("test") .withLabels(labels).endMetadata().addNewSubset().addNewAddress().withIp("ip1").withNewTargetRef() .withUid("30").endTargetRef().endAddress().addNewPort("http", "http_tcp", 80, "TCP").endSubset() .build(); List<Endpoints> endpointsList = new ArrayList<>(); endpointsList.add(endPoint); EndpointsList endpoints = new EndpointsList(); endpoints.setItems(endpointsList); mockServer.expect().get() .withPath( "/api/v1/namespaces/test/endpoints?labelSelector=l%3Dv&fieldSelector=metadata.name%3Dendpoint") .andReturn(200, endpoints).once(); final KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties(); properties.setServiceLabels(labels); final KubernetesDiscoveryClient discoveryClient = new KubernetesDiscoveryClient(mockClient, properties, KubernetesClient::services, new DefaultIsServicePortSecureResolver(properties)); final List<Endpoints> result_endpoints = discoveryClient.getEndPointsList("endpoint"); assertThat(result_endpoints).hasSize(1); }