@@ -311,18 +311,18 @@ void redisSessionGetAttributes() {
311311 }
312312
313313 @ Test
314- @ SuppressWarnings ("unchecked" )
315314 void delete () {
316315 String attrName = "attrName" ;
317316 MapSession expected = new MapSession ();
318317 expected .setLastAccessedTime (Instant .now ().minusSeconds (60 ));
319318 expected .setAttribute (attrName , "attrValue" );
320319 given (this .redisOperations .<String , Object >boundHashOps (anyString ())).willReturn (this .boundHashOperations );
321320 given (this .redisOperations .boundSetOps (anyString ())).willReturn (this .boundSetOperations );
322- Map map = map (RedisIndexedSessionRepository .getSessionAttrNameKey (attrName ), expected .getAttribute (attrName ),
323- RedisSessionMapper .CREATION_TIME_KEY , expected .getCreationTime ().toEpochMilli (),
324- RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY , (int ) expected .getMaxInactiveInterval ().getSeconds (),
325- RedisSessionMapper .LAST_ACCESSED_TIME_KEY , expected .getLastAccessedTime ().toEpochMilli ());
321+ Map <String , Object > map = map (RedisIndexedSessionRepository .getSessionAttrNameKey (attrName ),
322+ expected .getAttribute (attrName ), RedisSessionMapper .CREATION_TIME_KEY ,
323+ expected .getCreationTime ().toEpochMilli (), RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY ,
324+ (int ) expected .getMaxInactiveInterval ().getSeconds (), RedisSessionMapper .LAST_ACCESSED_TIME_KEY ,
325+ expected .getLastAccessedTime ().toEpochMilli ());
326326 given (this .boundHashOperations .entries ()).willReturn (map );
327327 given (this .redisOperations .boundSetOps (anyString ())).willReturn (this .boundSetOperations );
328328
@@ -345,7 +345,6 @@ void deleteNullSession() {
345345 }
346346
347347 @ Test
348- @ SuppressWarnings ("unchecked" )
349348 void getSessionNotFound () {
350349 String id = "abc" ;
351350 given (this .redisOperations .<String , Object >boundHashOps (getKey (id ))).willReturn (this .boundHashOperations );
@@ -355,7 +354,6 @@ void getSessionNotFound() {
355354 }
356355
357356 @ Test
358- @ SuppressWarnings ("unchecked" )
359357 void getSessionFound () {
360358 String attribute1 = "attribute1" ;
361359 String attribute2 = "attribute2" ;
@@ -365,7 +363,7 @@ void getSessionFound() {
365363 expected .setAttribute (attribute2 , null );
366364 given (this .redisOperations .<String , Object >boundHashOps (getKey (expected .getId ())))
367365 .willReturn (this .boundHashOperations );
368- Map map = map (RedisIndexedSessionRepository .getSessionAttrNameKey (attribute1 ),
366+ Map < String , Object > map = map (RedisIndexedSessionRepository .getSessionAttrNameKey (attribute1 ),
369367 expected .getAttribute (attribute1 ), RedisIndexedSessionRepository .getSessionAttrNameKey (attribute2 ),
370368 expected .getAttribute (attribute2 ), RedisSessionMapper .CREATION_TIME_KEY ,
371369 expected .getCreationTime ().toEpochMilli (), RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY ,
@@ -386,27 +384,27 @@ void getSessionFound() {
386384 }
387385
388386 @ Test
389- @ SuppressWarnings ("unchecked" )
390387 void getSessionExpired () {
391388 String expiredId = "expired-id" ;
392389 given (this .redisOperations .<String , Object >boundHashOps (getKey (expiredId )))
393390 .willReturn (this .boundHashOperations );
394- Map map = map (RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY , 1 , RedisSessionMapper .LAST_ACCESSED_TIME_KEY ,
391+ Map <String , Object > map = map (RedisSessionMapper .CREATION_TIME_KEY , Instant .EPOCH .toEpochMilli (),
392+ RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY , 1 , RedisSessionMapper .LAST_ACCESSED_TIME_KEY ,
395393 Instant .now ().minus (5 , ChronoUnit .MINUTES ).toEpochMilli ());
396394 given (this .boundHashOperations .entries ()).willReturn (map );
397395
398396 assertThat (this .redisRepository .findById (expiredId )).isNull ();
399397 }
400398
401399 @ Test
402- @ SuppressWarnings ("unchecked" )
403400 void findByPrincipalNameExpired () {
404401 String expiredId = "expired-id" ;
405402 given (this .redisOperations .boundSetOps (anyString ())).willReturn (this .boundSetOperations );
406403 given (this .boundSetOperations .members ()).willReturn (Collections .singleton (expiredId ));
407404 given (this .redisOperations .<String , Object >boundHashOps (getKey (expiredId )))
408405 .willReturn (this .boundHashOperations );
409- Map map = map (RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY , 1 , RedisSessionMapper .LAST_ACCESSED_TIME_KEY ,
406+ Map <String , Object > map = map (RedisSessionMapper .CREATION_TIME_KEY , Instant .EPOCH .toEpochMilli (),
407+ RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY , 1 , RedisSessionMapper .LAST_ACCESSED_TIME_KEY ,
410408 Instant .now ().minus (5 , ChronoUnit .MINUTES ).toEpochMilli ());
411409 given (this .boundHashOperations .entries ()).willReturn (map );
412410
@@ -416,7 +414,6 @@ void findByPrincipalNameExpired() {
416414 }
417415
418416 @ Test
419- @ SuppressWarnings ("unchecked" )
420417 void findByPrincipalName () {
421418 Instant lastAccessed = Instant .now ().minusMillis (10 );
422419 Instant createdTime = lastAccessed .minusMillis (10 );
@@ -426,7 +423,7 @@ void findByPrincipalName() {
426423 given (this .boundSetOperations .members ()).willReturn (Collections .singleton (sessionId ));
427424 given (this .redisOperations .<String , Object >boundHashOps (getKey (sessionId )))
428425 .willReturn (this .boundHashOperations );
429- Map map = map (RedisSessionMapper .CREATION_TIME_KEY , createdTime .toEpochMilli (),
426+ Map < String , Object > map = map (RedisSessionMapper .CREATION_TIME_KEY , createdTime .toEpochMilli (),
430427 RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY , (int ) maxInactive .getSeconds (),
431428 RedisSessionMapper .LAST_ACCESSED_TIME_KEY , lastAccessed .toEpochMilli ());
432429 given (this .boundHashOperations .entries ()).willReturn (map );
@@ -468,7 +465,10 @@ void onMessageCreated() {
468465 String channel = "spring:session:event:0:created:" + session .getId ();
469466 JdkSerializationRedisSerializer defaultSerailizer = new JdkSerializationRedisSerializer ();
470467 this .redisRepository .setDefaultSerializer (defaultSerailizer );
471- byte [] body = defaultSerailizer .serialize (new HashMap ());
468+ Map <String , Object > map = map (RedisSessionMapper .CREATION_TIME_KEY , Instant .EPOCH .toEpochMilli (),
469+ RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY , 0 , RedisSessionMapper .LAST_ACCESSED_TIME_KEY ,
470+ System .currentTimeMillis () - TimeUnit .MINUTES .toMillis (5 ));
471+ byte [] body = defaultSerailizer .serialize (map );
472472 DefaultMessage message = new DefaultMessage (channel .getBytes (StandardCharsets .UTF_8 ), body );
473473
474474 this .redisRepository .setApplicationEventPublisher (this .publisher );
@@ -485,7 +485,10 @@ void onMessageCreatedCustomSerializer() {
485485 byte [] pattern = "" .getBytes (StandardCharsets .UTF_8 );
486486 byte [] body = new byte [0 ];
487487 String channel = "spring:session:event:0:created:" + session .getId ();
488- given (this .defaultSerializer .deserialize (body )).willReturn (new HashMap <String , Object >());
488+ Map <String , Object > map = map (RedisSessionMapper .CREATION_TIME_KEY , Instant .EPOCH .toEpochMilli (),
489+ RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY , 0 , RedisSessionMapper .LAST_ACCESSED_TIME_KEY ,
490+ System .currentTimeMillis () - TimeUnit .MINUTES .toMillis (5 ));
491+ given (this .defaultSerializer .deserialize (body )).willReturn (map );
489492 DefaultMessage message = new DefaultMessage (channel .getBytes (StandardCharsets .UTF_8 ), body );
490493 this .redisRepository .setApplicationEventPublisher (this .publisher );
491494
@@ -497,12 +500,12 @@ void onMessageCreatedCustomSerializer() {
497500 }
498501
499502 @ Test
500- @ SuppressWarnings ("unchecked" )
501503 void onMessageDeletedSessionFound () {
502504 String deletedId = "deleted-id" ;
503505 given (this .redisOperations .<String , Object >boundHashOps (getKey (deletedId )))
504506 .willReturn (this .boundHashOperations );
505- Map map = map (RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY , 0 , RedisSessionMapper .LAST_ACCESSED_TIME_KEY ,
507+ Map <String , Object > map = map (RedisSessionMapper .CREATION_TIME_KEY , Instant .EPOCH .toEpochMilli (),
508+ RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY , 0 , RedisSessionMapper .LAST_ACCESSED_TIME_KEY ,
506509 System .currentTimeMillis () - TimeUnit .MINUTES .toMillis (5 ));
507510 given (this .boundHashOperations .entries ()).willReturn (map );
508511
@@ -525,7 +528,6 @@ void onMessageDeletedSessionFound() {
525528 }
526529
527530 @ Test
528- @ SuppressWarnings ("unchecked" )
529531 void onMessageDeletedSessionNotFound () {
530532 String deletedId = "deleted-id" ;
531533 given (this .redisOperations .<String , Object >boundHashOps (getKey (deletedId )))
@@ -549,12 +551,12 @@ void onMessageDeletedSessionNotFound() {
549551 }
550552
551553 @ Test
552- @ SuppressWarnings ("unchecked" )
553554 void onMessageExpiredSessionFound () {
554555 String expiredId = "expired-id" ;
555556 given (this .redisOperations .<String , Object >boundHashOps (getKey (expiredId )))
556557 .willReturn (this .boundHashOperations );
557- Map map = map (RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY , 1 , RedisSessionMapper .LAST_ACCESSED_TIME_KEY ,
558+ Map <String , Object > map = map (RedisSessionMapper .CREATION_TIME_KEY , Instant .EPOCH .toEpochMilli (),
559+ RedisSessionMapper .MAX_INACTIVE_INTERVAL_KEY , 1 , RedisSessionMapper .LAST_ACCESSED_TIME_KEY ,
558560 System .currentTimeMillis () - TimeUnit .MINUTES .toMillis (5 ));
559561 given (this .boundHashOperations .entries ()).willReturn (map );
560562
@@ -577,7 +579,6 @@ void onMessageExpiredSessionFound() {
577579 }
578580
579581 @ Test
580- @ SuppressWarnings ("unchecked" )
581582 void onMessageExpiredSessionNotFound () {
582583 String expiredId = "expired-id" ;
583584 given (this .redisOperations .<String , Object >boundHashOps (getKey (expiredId )))
@@ -813,7 +814,7 @@ void onMessageCreatedInOtherDatabase() {
813814
814815 MapSession session = this .cached ;
815816 String channel = "spring:session:event:created:1:" + session .getId ();
816- byte [] body = serializer .serialize (new HashMap ());
817+ byte [] body = serializer .serialize (new HashMap <> ());
817818 DefaultMessage message = new DefaultMessage (channel .getBytes (StandardCharsets .UTF_8 ), body );
818819
819820 this .redisRepository .onMessage (message , "" .getBytes (StandardCharsets .UTF_8 ));
@@ -913,7 +914,7 @@ private String getKey(String id) {
913914 return "spring:session:sessions:" + id ;
914915 }
915916
916- private Map map (Object ... objects ) {
917+ private Map < String , Object > map (Object ... objects ) {
917918 Map <String , Object > result = new HashMap <>();
918919 if (objects == null ) {
919920 return result ;
0 commit comments