2222
2323import io .kubernetes .client .informer .cache .Cache ;
2424import io .kubernetes .client .informer .cache .Lister ;
25+ import io .kubernetes .client .openapi .apis .CoreV1Api ;
2526import io .kubernetes .client .openapi .models .CoreV1EndpointPort ;
2627import io .kubernetes .client .openapi .models .CoreV1EndpointPortBuilder ;
2728import io .kubernetes .client .openapi .models .V1Endpoints ;
3637import org .junit .jupiter .api .BeforeEach ;
3738import org .junit .jupiter .api .Test ;
3839
40+ import org .mockito .Mockito ;
3941import org .springframework .cloud .client .ServiceInstance ;
4042import org .springframework .cloud .kubernetes .commons .discovery .KubernetesDiscoveryProperties ;
43+ import org .testcontainers .shaded .org .checkerframework .checker .units .qual .C ;
4144
4245import static java .util .Map .entry ;
4346import static java .util .stream .Collectors .toList ;
@@ -62,6 +65,8 @@ class KubernetesDiscoveryClientFilterMetadataTest {
6265
6366 private Lister <V1Endpoints > endpointsLister ;
6467
68+ private static final CoreV1Api CORE_V1_API = Mockito .mock (CoreV1Api .class );
69+
6570 @ BeforeEach
6671 void beforeEach () {
6772 servicesCache = new Cache <>();
@@ -80,8 +85,9 @@ void testAllExtraMetadataDisabled() {
8085 KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties (true , false , Set .of (), true , 60 ,
8186 false , null , Set .of (), Map .of (), null , metadata , 0 , true );
8287
83- KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (STUB , servicesLister ,
84- endpointsLister , SERVICE_SHARED_INFORMER_STUB , ENDPOINTS_SHARED_INFORMER_STUB , properties );
88+ KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (List .of (STUB ),
89+ List .of (servicesLister ), List .of (endpointsLister ), List .of (SERVICE_SHARED_INFORMER_STUB ),
90+ List .of (ENDPOINTS_SHARED_INFORMER_STUB ), properties , CORE_V1_API );
8591
8692 setup (serviceId , "ns" , Map .of ("l1" , "lab" ), Map .of ("l1" , "lab" ), Map .of (80 , "http" , 5555 , "" ));
8793
@@ -99,8 +105,9 @@ void testLabelsEnabled() {
99105 KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties (true , false , Set .of (), true , 60 ,
100106 false , null , Set .of (), Map .of (), null , metadata , 0 , true );
101107
102- KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (STUB , servicesLister ,
103- endpointsLister , SERVICE_SHARED_INFORMER_STUB , ENDPOINTS_SHARED_INFORMER_STUB , properties );
108+ KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (List .of (STUB ),
109+ List .of (servicesLister ), List .of (endpointsLister ), List .of (SERVICE_SHARED_INFORMER_STUB ),
110+ List .of (ENDPOINTS_SHARED_INFORMER_STUB ), properties , CORE_V1_API );
104111
105112 setup (serviceId , "ns" , Map .of ("l1" , "v1" , "l2" , "v2" ), Map .of ("l1" , "lab" ), Map .of (80 , "http" , 5555 , "" ));
106113
@@ -119,8 +126,9 @@ void testLabelsEnabledWithPrefix() {
119126 KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties (true , false , Set .of (), true , 60 ,
120127 false , null , Set .of (), Map .of (), null , metadata , 0 , true );
121128
122- KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (STUB , servicesLister ,
123- endpointsLister , SERVICE_SHARED_INFORMER_STUB , ENDPOINTS_SHARED_INFORMER_STUB , properties );
129+ KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (List .of (STUB ),
130+ List .of (servicesLister ), List .of (endpointsLister ), List .of (SERVICE_SHARED_INFORMER_STUB ),
131+ List .of (ENDPOINTS_SHARED_INFORMER_STUB ), properties , CORE_V1_API );
124132
125133 setup (serviceId , "ns" , Map .of ("l1" , "v1" , "l2" , "v2" ), Map .of ("l1" , "lab" ), Map .of (80 , "http" , 5555 , "" ));
126134
@@ -139,8 +147,9 @@ void testAnnotationsEnabled() {
139147 KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties (true , false , Set .of (), true , 60 ,
140148 false , null , Set .of (), Map .of (), null , metadata , 0 , true );
141149
142- KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (STUB , servicesLister ,
143- endpointsLister , SERVICE_SHARED_INFORMER_STUB , ENDPOINTS_SHARED_INFORMER_STUB , properties );
150+ KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (List .of (STUB ),
151+ List .of (servicesLister ), List .of (endpointsLister ), List .of (SERVICE_SHARED_INFORMER_STUB ),
152+ List .of (ENDPOINTS_SHARED_INFORMER_STUB ), properties , CORE_V1_API );
144153
145154 setup (serviceId , "ns" , Map .of ("l1" , "v1" ), Map .of ("a1" , "v1" , "a2" , "v2" ), Map .of (80 , "http" , 5555 , "" ));
146155
@@ -159,8 +168,9 @@ void testAnnotationsEnabledWithPrefix() {
159168 KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties (true , false , Set .of (), true , 60 ,
160169 false , null , Set .of (), Map .of (), null , metadata , 0 , true );
161170
162- KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (STUB , servicesLister ,
163- endpointsLister , SERVICE_SHARED_INFORMER_STUB , ENDPOINTS_SHARED_INFORMER_STUB , properties );
171+ KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (List .of (STUB ),
172+ List .of (servicesLister ), List .of (endpointsLister ), List .of (SERVICE_SHARED_INFORMER_STUB ),
173+ List .of (ENDPOINTS_SHARED_INFORMER_STUB ), properties , CORE_V1_API );
164174
165175 setup (serviceId , "ns" , Map .of ("l1" , "v1" ), Map .of ("a1" , "v1" , "a2" , "v2" ), Map .of (80 , "http" , 5555 , "" ));
166176
@@ -179,8 +189,9 @@ void testPortsEnabled() {
179189 KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties (true , false , Set .of (), true , 60 ,
180190 false , null , Set .of (), Map .of (), null , metadata , 0 , true );
181191
182- KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (STUB , servicesLister ,
183- endpointsLister , SERVICE_SHARED_INFORMER_STUB , ENDPOINTS_SHARED_INFORMER_STUB , properties );
192+ KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (List .of (STUB ),
193+ List .of (servicesLister ), List .of (endpointsLister ), List .of (SERVICE_SHARED_INFORMER_STUB ),
194+ List .of (ENDPOINTS_SHARED_INFORMER_STUB ), properties , CORE_V1_API );
184195
185196 setup (serviceId , "test" , Map .of ("l1" , "v1" ), Map .of ("a1" , "v1" , "a2" , "v2" ), Map .of (80 , "http" , 5555 , "" ));
186197
@@ -199,8 +210,9 @@ void testPortsEnabledWithPrefix() {
199210 KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties (true , false , Set .of (), true , 60 ,
200211 false , null , Set .of (), Map .of (), null , metadata , 0 , true );
201212
202- KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (STUB , servicesLister ,
203- endpointsLister , SERVICE_SHARED_INFORMER_STUB , ENDPOINTS_SHARED_INFORMER_STUB , properties );
213+ KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (List .of (STUB ),
214+ List .of (servicesLister ), List .of (endpointsLister ), List .of (SERVICE_SHARED_INFORMER_STUB ),
215+ List .of (ENDPOINTS_SHARED_INFORMER_STUB ), properties , CORE_V1_API );
204216
205217 setup (serviceId , "ns" , Map .of ("l1" , "v1" ), Map .of ("a1" , "v1" , "a2" , "v2" ), Map .of (80 , "http" , 5555 , "" ));
206218
@@ -219,8 +231,9 @@ void testLabelsAndAnnotationsAndPortsEnabledWithPrefix() {
219231 KubernetesDiscoveryProperties properties = new KubernetesDiscoveryProperties (true , false , Set .of (), true , 60 ,
220232 false , null , Set .of (), Map .of (), null , metadata , 0 , true );
221233
222- KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (STUB , servicesLister ,
223- endpointsLister , SERVICE_SHARED_INFORMER_STUB , ENDPOINTS_SHARED_INFORMER_STUB , properties );
234+ KubernetesInformerDiscoveryClient discoveryClient = new KubernetesInformerDiscoveryClient (List .of (STUB ),
235+ List .of (servicesLister ), List .of (endpointsLister ), List .of (SERVICE_SHARED_INFORMER_STUB ),
236+ List .of (ENDPOINTS_SHARED_INFORMER_STUB ), properties , CORE_V1_API );
224237
225238 setup (serviceId , "ns" , Map .of ("l1" , "la1" ), Map .of ("a1" , "an1" , "a2" , "an2" ), Map .of (80 , "http" , 5555 , "" ));
226239
0 commit comments