Skip to content

Commit

Permalink
Namespace filter for service discover - fix checkstyle (issue spring-…
Browse files Browse the repository at this point in the history
  • Loading branch information
mbialkowski1 committed Oct 19, 2022
1 parent 78e090f commit bfc54c1
Showing 1 changed file with 12 additions and 10 deletions.
Expand Up @@ -24,9 +24,9 @@

import io.fabric8.kubernetes.api.model.Endpoints;
import io.fabric8.kubernetes.api.model.EndpointsBuilder;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.ServiceBuilder;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
Expand Down Expand Up @@ -153,25 +153,27 @@ public void getEndPointsListTest() {
@Test
public void getEndPointsListTestAllNamespaces() {

final var namespace1="ns1";
final var namespace2="ns2";
final var namespace1 = "ns1";
final var namespace2 = "ns2";

Endpoints endPoint1 = new EndpointsBuilder().withNewMetadata().withName("endpoint").withNamespace(namespace1)
.endMetadata().build();
Endpoints endPoint1 = new EndpointsBuilder().withNewMetadata()
.withName("endpoint").withNamespace(namespace1).endMetadata().build();

Endpoints endPoint2 = new EndpointsBuilder().withNewMetadata().withName("endpoint").withNamespace(namespace2)
.endMetadata().build();
Endpoints endPoint2 = new EndpointsBuilder().withNewMetadata()
.withName("endpoint").withNamespace(namespace2).endMetadata().build();

mockClient.endpoints().inNamespace(namespace1).create(endPoint1);
mockClient.endpoints().inNamespace(namespace2).create(endPoint2);

final KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties();
properties.setAllNamespaces(true);

final KubernetesDiscoveryClient discoveryClient = new KubernetesDiscoveryClient(mockClient, properties,
KubernetesClient::services, new ServicePortSecureResolver(properties));
final KubernetesDiscoveryClient discoveryClient = new KubernetesDiscoveryClient(
mockClient, properties, KubernetesClient::services,
new ServicePortSecureResolver(properties));

final List<Endpoints> result_endpoints = discoveryClient.getEndPointsList("endpoint");
final List<Endpoints> result_endpoints = discoveryClient
.getEndPointsList("endpoint");

assertThat(result_endpoints).hasSize(2);
}
Expand Down

0 comments on commit bfc54c1

Please sign in to comment.