2020import java .time .Duration ;
2121import java .time .Instant ;
2222import java .time .ZoneId ;
23+ import java .util .Collections ;
24+ import java .util .List ;
2325
2426import io .micrometer .core .instrument .MeterRegistry ;
2527import io .micrometer .core .instrument .simple .SimpleMeterRegistry ;
3436import org .springframework .boot .ssl .jks .JksSslStoreDetails ;
3537
3638import static org .assertj .core .api .Assertions .assertThat ;
37- import java . util . List ;
38-
39+ import static org . mockito . BDDMockito . given ;
40+ import static org . mockito . BDDMockito . then ;
3941import static org .mockito .Mockito .atLeast ;
4042import static org .mockito .Mockito .mock ;
41- import static org .mockito .Mockito .verify ;
42- import static org .mockito .Mockito .when ;
4343
4444/**
4545 * Tests for {@link SslMeterBinder}.
@@ -73,25 +73,25 @@ void shouldRegisterChainExpiryMetrics() {
7373 void shouldWatchUpdatesForBundlesRegisteredAfterConstruction () {
7474 DefaultSslBundleRegistry sslBundleRegistry = new DefaultSslBundleRegistry ();
7575 SslInfo sslInfo = mock (SslInfo .class );
76- when (sslInfo .getBundles ()).thenReturn ( List . of ());
76+ given (sslInfo .getBundles ()).willReturn ( Collections . emptyList ());
7777
7878 SslInfo .BundleInfo bundleInfo = mock (SslInfo .BundleInfo .class );
7979 SslInfo .CertificateChainInfo chainInfo = mock (SslInfo .CertificateChainInfo .class );
8080 SslInfo .CertificateInfo certificateInfo = mock (SslInfo .CertificateInfo .class );
8181 SslInfo .CertificateValidityInfo validityInfo = mock (SslInfo .CertificateValidityInfo .class );
8282
83- when (sslInfo .getBundle ("dynamic" )).thenReturn (bundleInfo );
84- when (bundleInfo .getName ()).thenReturn ("dynamic" );
85- when (bundleInfo .getCertificateChains ()).thenReturn (List .of (chainInfo ));
86- when (chainInfo .getAlias ()).thenReturn ("server" );
87- when (chainInfo .getCertificates ()).thenReturn (List .of (certificateInfo ));
88- when (certificateInfo .getSerialNumber ()).thenReturn ("serial" );
83+ given (sslInfo .getBundle ("dynamic" )).willReturn (bundleInfo );
84+ given (bundleInfo .getName ()).willReturn ("dynamic" );
85+ given (bundleInfo .getCertificateChains ()).willReturn (List .of (chainInfo ));
86+ given (chainInfo .getAlias ()).willReturn ("server" );
87+ given (chainInfo .getCertificates ()).willReturn (List .of (certificateInfo ));
88+ given (certificateInfo .getSerialNumber ()).willReturn ("serial" );
8989
9090 Instant expiry = CLOCK .instant ().plus (Duration .ofDays (365 ));
91- when (certificateInfo .getValidityEnds ()).thenReturn (expiry );
92- when (certificateInfo .getValidity ()).thenReturn (validityInfo );
93- when (validityInfo .getStatus ()).thenReturn (SslInfo .CertificateValidityInfo .Status .VALID );
94- when (validityInfo .getMessage ()).thenReturn (null );
91+ given (certificateInfo .getValidityEnds ()).willReturn (expiry );
92+ given (certificateInfo .getValidity ()).willReturn (validityInfo );
93+ given (validityInfo .getStatus ()).willReturn (SslInfo .CertificateValidityInfo .Status .VALID );
94+ given (validityInfo .getMessage ()).willReturn (null );
9595
9696 SslMeterBinder binder = new SslMeterBinder (sslInfo , sslBundleRegistry , CLOCK );
9797 SimpleMeterRegistry meterRegistry = new SimpleMeterRegistry ();
@@ -101,7 +101,7 @@ void shouldWatchUpdatesForBundlesRegisteredAfterConstruction() {
101101 sslBundleRegistry .registerBundle ("dynamic" , bundle );
102102 sslBundleRegistry .updateBundle ("dynamic" , bundle );
103103
104- verify (sslInfo , atLeast (2 )).getBundle ("dynamic" );
104+ then (sslInfo ). should ( atLeast (2 )).getBundle ("dynamic" );
105105 }
106106
107107 private static long findExpiryGauge (MeterRegistry meterRegistry , String chain , String certificateSerialNumber ) {
0 commit comments