2525import io .kubernetes .client .openapi .models .V1ServicePort ;
2626import io .kubernetes .client .openapi .models .V1ServicePortBuilder ;
2727import io .kubernetes .client .openapi .models .V1ServiceSpecBuilder ;
28- import org .junit . jupiter .api .Assertions ;
28+ import org .assertj . core .api .Assertions ;
2929import org .junit .jupiter .api .Test ;
3030import org .junit .jupiter .api .extension .ExtendWith ;
3131
@@ -116,9 +116,9 @@ void testEmptyPorts(CapturedOutput output) {
116116 List <V1ServicePort > servicePorts = List .of ();
117117 V1Service service = createService ("database" , "default" , annotations , labels , servicePorts );
118118 KubernetesServiceInstance serviceInstance = mapper .map (service );
119- Assertions .assertNull (serviceInstance );
120- Assertions .assertTrue (output .getOut ()
121- . contains ( "service : database does not have any ServicePort(s), will not consider it for load balancing" ) );
119+ Assertions .assertThat (serviceInstance ). isNull ( );
120+ Assertions .assertThat (output .getOut ()). contains (
121+ "service : database does not have any ServicePort(s), will not consider it for load balancing" );
122122 }
123123
124124 @ Test
@@ -133,10 +133,10 @@ void singlePortNameMatchesProperty(CapturedOutput output) {
133133 List <V1ServicePort > servicePorts = List .of (new V1ServicePortBuilder ().withName ("http" ).withPort (80 ).build ());
134134 V1Service service = createService ("database" , "default" , annotations , labels , servicePorts );
135135 KubernetesServiceInstance serviceInstance = mapper .map (service );
136- Assertions .assertNotNull (serviceInstance );
137- Assertions .assertTrue (output .getOut ()
136+ Assertions .assertThat (serviceInstance ). isNotNull ( );
137+ Assertions .assertThat (output .getOut () )
138138 .contains ("single ServicePort found, "
139- + "will use it as-is (without checking 'spring.cloud.kubernetes.loadbalancer.portName')" )) ;
139+ + "will use it as-is (without checking 'spring.cloud.kubernetes.loadbalancer.portName')" );
140140 }
141141
142142 @ Test
@@ -151,10 +151,10 @@ void singlePortNameDoesNotMatchProperty(CapturedOutput output) {
151151 List <V1ServicePort > servicePorts = List .of (new V1ServicePortBuilder ().withName ("http" ).withPort (80 ).build ());
152152 V1Service service = createService ("database" , "default" , annotations , labels , servicePorts );
153153 KubernetesServiceInstance serviceInstance = mapper .map (service );
154- Assertions .assertNotNull (serviceInstance );
155- Assertions .assertTrue (output .getOut ()
154+ Assertions .assertThat (serviceInstance ). isNotNull ( );
155+ Assertions .assertThat (output .getOut () )
156156 .contains ("single ServicePort found, "
157- + "will use it as-is (without checking 'spring.cloud.kubernetes.loadbalancer.portName')" )) ;
157+ + "will use it as-is (without checking 'spring.cloud.kubernetes.loadbalancer.portName')" );
158158 }
159159
160160 @ Test
@@ -170,9 +170,9 @@ void multiplePortsNameMatchesProperty(CapturedOutput output) {
170170 new V1ServicePortBuilder ().withName ("https" ).withPort (443 ).build ());
171171 V1Service service = createService ("database" , "default" , annotations , labels , servicePorts );
172172 KubernetesServiceInstance serviceInstance = mapper .map (service );
173- Assertions .assertNotNull (serviceInstance );
174- Assertions .assertTrue (output .getOut ().contains ("found port name that matches : http" ) );
175- Assertions .assertEquals (serviceInstance .getPort (), 80 );
173+ Assertions .assertThat (serviceInstance ). isNotNull ( );
174+ Assertions .assertThat (output .getOut ()) .contains ("found port name that matches : http" );
175+ Assertions .assertThat (serviceInstance .getPort ()). isEqualTo ( 80 );
176176 }
177177
178178 @ Test
@@ -188,10 +188,10 @@ void multiplePortsNameDoesNotMatchProperty(CapturedOutput output) {
188188 new V1ServicePortBuilder ().withName ("https" ).withPort (443 ).build ());
189189 V1Service service = createService ("database" , "default" , annotations , labels , servicePorts );
190190 KubernetesServiceInstance serviceInstance = mapper .map (service );
191- Assertions .assertNotNull (serviceInstance );
192- Assertions .assertTrue (output .getOut ().contains ("Did not find a port name that is equal to the value http" ) );
193- Assertions .assertTrue (output .getOut ().contains ("Will return 'first' port found, which is non-deterministic" ) );
194- Assertions .assertTrue (serviceInstance .getPort () == 80 || serviceInstance . getPort () == 443 );
191+ Assertions .assertThat (serviceInstance ). isNotNull ( );
192+ Assertions .assertThat (output .getOut ()) .contains ("Did not find a port name that is equal to the value http" );
193+ Assertions .assertThat (output .getOut ()) .contains ("Will return 'first' port found, which is non-deterministic" );
194+ Assertions .assertThat (serviceInstance .getPort ()). isIn ( 80 , 443 );
195195 }
196196
197197 @ Test
@@ -207,10 +207,10 @@ void multiPortsEmptyPortNameProperty(CapturedOutput output) {
207207 new V1ServicePortBuilder ().withName ("https" ).withPort (443 ).build ());
208208 V1Service service = createService ("database" , "default" , annotations , labels , servicePorts );
209209 KubernetesServiceInstance serviceInstance = mapper .map (service );
210- Assertions .assertNotNull (serviceInstance );
211- Assertions .assertTrue (output .getOut ().contains ("'spring.cloud.kubernetes.loadbalancer.portName' is not set" ) );
212- Assertions .assertTrue (output .getOut ().contains ("Will return 'first' port found, which is non-deterministic" ) );
213- Assertions .assertTrue (serviceInstance .getPort () == 80 || serviceInstance . getPort () == 443 );
210+ Assertions .assertThat (serviceInstance ). isNotNull ( );
211+ Assertions .assertThat (output .getOut ()) .contains ("'spring.cloud.kubernetes.loadbalancer.portName' is not set" );
212+ Assertions .assertThat (output .getOut ()) .contains ("Will return 'first' port found, which is non-deterministic" );
213+ Assertions .assertThat (serviceInstance .getPort ()). isIn ( 80 , 443 );
214214 }
215215
216216 private V1Service createService (String name , String namespace , Map <String , String > annotations ,
0 commit comments