22
22
import java .sql .Timestamp ;
23
23
import java .sql .Types ;
24
24
import java .time .Instant ;
25
- import java .time .temporal .ChronoUnit ;
26
25
import java .util .Collections ;
27
26
import java .util .List ;
28
27
import java .util .Set ;
56
55
import static org .assertj .core .api .Assertions .assertThat ;
57
56
import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
58
57
import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
59
- import static org .assertj .core .api .Assertions .within ;
60
58
import static org .mockito .ArgumentMatchers .any ;
61
59
import static org .mockito .ArgumentMatchers .anyInt ;
62
60
import static org .mockito .BDDMockito .given ;
@@ -176,15 +174,14 @@ public void loadAuthorizedClientWhenExistsThenReturnAuthorizedClient() {
176
174
.isEqualTo (expected .getAccessToken ().getTokenType ());
177
175
assertThat (authorizedClient .getAccessToken ().getTokenValue ())
178
176
.isEqualTo (expected .getAccessToken ().getTokenValue ());
179
- assertThat (authorizedClient .getAccessToken ().getIssuedAt ()).isCloseTo (expected .getAccessToken ().getIssuedAt (),
180
- within (1 , ChronoUnit .MILLIS ));
181
- assertThat (authorizedClient .getAccessToken ().getExpiresAt ()).isCloseTo (expected .getAccessToken ().getExpiresAt (),
182
- within (1 , ChronoUnit .MILLIS ));
177
+ assertThat (authorizedClient .getAccessToken ().getIssuedAt ()).isEqualTo (expected .getAccessToken ().getIssuedAt ());
178
+ assertThat (authorizedClient .getAccessToken ().getExpiresAt ())
179
+ .isEqualTo (expected .getAccessToken ().getExpiresAt ());
183
180
assertThat (authorizedClient .getAccessToken ().getScopes ()).isEqualTo (expected .getAccessToken ().getScopes ());
184
181
assertThat (authorizedClient .getRefreshToken ().getTokenValue ())
185
182
.isEqualTo (expected .getRefreshToken ().getTokenValue ());
186
- assertThat (authorizedClient .getRefreshToken ().getIssuedAt ()). isCloseTo ( expected . getRefreshToken (). getIssuedAt (),
187
- within ( 1 , ChronoUnit . MILLIS ));
183
+ assertThat (authorizedClient .getRefreshToken ().getIssuedAt ())
184
+ . isEqualTo ( expected . getRefreshToken (). getIssuedAt ( ));
188
185
}
189
186
190
187
@ Test
@@ -231,15 +228,14 @@ public void saveAuthorizedClientWhenSaveThenLoadReturnsSaved() {
231
228
.isEqualTo (expected .getAccessToken ().getTokenType ());
232
229
assertThat (authorizedClient .getAccessToken ().getTokenValue ())
233
230
.isEqualTo (expected .getAccessToken ().getTokenValue ());
234
- assertThat (authorizedClient .getAccessToken ().getIssuedAt ()).isCloseTo (expected .getAccessToken ().getIssuedAt (),
235
- within (1 , ChronoUnit .MILLIS ));
236
- assertThat (authorizedClient .getAccessToken ().getExpiresAt ()).isCloseTo (expected .getAccessToken ().getExpiresAt (),
237
- within (1 , ChronoUnit .MILLIS ));
231
+ assertThat (authorizedClient .getAccessToken ().getIssuedAt ()).isEqualTo (expected .getAccessToken ().getIssuedAt ());
232
+ assertThat (authorizedClient .getAccessToken ().getExpiresAt ())
233
+ .isEqualTo (expected .getAccessToken ().getExpiresAt ());
238
234
assertThat (authorizedClient .getAccessToken ().getScopes ()).isEqualTo (expected .getAccessToken ().getScopes ());
239
235
assertThat (authorizedClient .getRefreshToken ().getTokenValue ())
240
236
.isEqualTo (expected .getRefreshToken ().getTokenValue ());
241
- assertThat (authorizedClient .getRefreshToken ().getIssuedAt ()). isCloseTo ( expected . getRefreshToken (). getIssuedAt (),
242
- within ( 1 , ChronoUnit . MILLIS ));
237
+ assertThat (authorizedClient .getRefreshToken ().getIssuedAt ())
238
+ . isEqualTo ( expected . getRefreshToken (). getIssuedAt ( ));
243
239
// Test save/load of NOT NULL attributes only
244
240
principal = createPrincipal ();
245
241
expected = createAuthorizedClient (principal , this .clientRegistration , true );
@@ -253,10 +249,9 @@ public void saveAuthorizedClientWhenSaveThenLoadReturnsSaved() {
253
249
.isEqualTo (expected .getAccessToken ().getTokenType ());
254
250
assertThat (authorizedClient .getAccessToken ().getTokenValue ())
255
251
.isEqualTo (expected .getAccessToken ().getTokenValue ());
256
- assertThat (authorizedClient .getAccessToken ().getIssuedAt ()).isCloseTo (expected .getAccessToken ().getIssuedAt (),
257
- within (1 , ChronoUnit .MILLIS ));
258
- assertThat (authorizedClient .getAccessToken ().getExpiresAt ()).isCloseTo (expected .getAccessToken ().getExpiresAt (),
259
- within (1 , ChronoUnit .MILLIS ));
252
+ assertThat (authorizedClient .getAccessToken ().getIssuedAt ()).isEqualTo (expected .getAccessToken ().getIssuedAt ());
253
+ assertThat (authorizedClient .getAccessToken ().getExpiresAt ())
254
+ .isEqualTo (expected .getAccessToken ().getExpiresAt ());
260
255
assertThat (authorizedClient .getAccessToken ().getScopes ()).isEmpty ();
261
256
assertThat (authorizedClient .getRefreshToken ()).isNull ();
262
257
}
@@ -280,15 +275,14 @@ public void saveAuthorizedClientWhenSaveClientWithExistingPrimaryKeyThenUpdate()
280
275
.isEqualTo (updatedClient .getAccessToken ().getTokenType ());
281
276
assertThat (savedClient .getAccessToken ().getTokenValue ())
282
277
.isEqualTo (updatedClient .getAccessToken ().getTokenValue ());
283
- assertThat (savedClient .getAccessToken ().getIssuedAt ()).isCloseTo (updatedClient .getAccessToken ().getIssuedAt (),
284
- within (1 , ChronoUnit .MILLIS ));
285
- assertThat (savedClient .getAccessToken ().getExpiresAt ()).isCloseTo (updatedClient .getAccessToken ().getExpiresAt (),
286
- within (1 , ChronoUnit .MILLIS ));
278
+ assertThat (savedClient .getAccessToken ().getIssuedAt ()).isEqualTo (updatedClient .getAccessToken ().getIssuedAt ());
279
+ assertThat (savedClient .getAccessToken ().getExpiresAt ())
280
+ .isEqualTo (updatedClient .getAccessToken ().getExpiresAt ());
287
281
assertThat (savedClient .getAccessToken ().getScopes ()).isEqualTo (updatedClient .getAccessToken ().getScopes ());
288
282
assertThat (savedClient .getRefreshToken ().getTokenValue ())
289
283
.isEqualTo (updatedClient .getRefreshToken ().getTokenValue ());
290
- assertThat (savedClient .getRefreshToken ().getIssuedAt ()). isCloseTo ( updatedClient . getRefreshToken (). getIssuedAt (),
291
- within ( 1 , ChronoUnit . MILLIS ));
284
+ assertThat (savedClient .getRefreshToken ().getIssuedAt ())
285
+ . isEqualTo ( updatedClient . getRefreshToken (). getIssuedAt ( ));
292
286
}
293
287
294
288
@ Test
0 commit comments