1616
1717package org .springframework .util ;
1818
19- import java .util .AbstractMap ;
2019import java .util .Collection ;
2120import java .util .HashMap ;
2221import java .util .HashSet ;
3635import org .springframework .util .ConcurrentReferenceHashMap .Restructure ;
3736
3837import static org .assertj .core .api .Assertions .assertThat ;
38+ import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
3939import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
4040import static org .assertj .core .api .Assertions .assertThatIllegalStateException ;
4141import static org .assertj .core .api .Assertions .assertThatNoException ;
42- import static org .assertj .core .api .Assertions .assertThatThrownBy ;
42+ import static org .assertj .core .api .Assertions .entry ;
4343
4444/**
4545 * Tests for {@link ConcurrentReferenceHashMap}.
@@ -450,15 +450,15 @@ void keySet() {
450450 assertThat (this .map .keySet ()).isEqualTo (expected );
451451 }
452452
453- @ Test
453+ @ Test // gh-35817
454454 void keySetContains () {
455455 this .map .put (123 , "123" );
456456 this .map .put (456 , null );
457457 this .map .put (null , "789" );
458458 assertThat (this .map .keySet ()).containsExactlyInAnyOrder (123 , 456 , null );
459459 }
460460
461- @ Test
461+ @ Test // gh-35817
462462 void keySetRemove () {
463463 this .map .put (123 , "123" );
464464 this .map .put (456 , null );
@@ -468,7 +468,7 @@ void keySetRemove() {
468468 assertThat (this .map .keySet ().remove (123 )).isFalse ();
469469 }
470470
471- @ Test
471+ @ Test // gh-35817
472472 void keySetIterator () {
473473 this .map .put (123 , "123" );
474474 this .map .put (456 , null );
@@ -478,7 +478,7 @@ void keySetIterator() {
478478 assertThat (it ).isExhausted ();
479479 }
480480
481- @ Test
481+ @ Test // gh-35817
482482 void keySetIteratorRemove () {
483483 this .map .put (123 , "123" );
484484 this .map .put (456 , null );
@@ -493,7 +493,7 @@ void keySetIteratorRemove() {
493493 assertThat (this .map ).containsOnlyKeys (123 , null );
494494 }
495495
496- @ Test
496+ @ Test // gh-35817
497497 void keySetClear () {
498498 this .map .put (123 , "123" );
499499 this .map .put (456 , null );
@@ -503,14 +503,13 @@ void keySetClear() {
503503 assertThat (this .map .keySet ()).isEmpty ();
504504 }
505505
506- @ Test
506+ @ Test // gh-35817
507507 void keySetAdd () {
508- assertThatThrownBy (() ->
509- this .map .keySet ().add (12345 )
510- ).isInstanceOf (UnsupportedOperationException .class );
508+ assertThatExceptionOfType (UnsupportedOperationException .class )
509+ .isThrownBy (() -> this .map .keySet ().add (12345 ));
511510 }
512511
513- @ Test
512+ @ Test // gh-35817
514513 void keySetStream () {
515514 this .map .put (123 , "123" );
516515 this .map .put (456 , null );
@@ -519,7 +518,7 @@ void keySetStream() {
519518 assertThat (keys ).containsExactlyInAnyOrder (123 , 456 , null );
520519 }
521520
522- @ Test
521+ @ Test // gh-35817
523522 void keySetSpliteratorCharacteristics () {
524523 this .map .put (123 , "123" );
525524 this .map .put (456 , null );
@@ -538,26 +537,25 @@ void valuesCollection() {
538537 assertThat (this .map .values ()).containsExactlyInAnyOrder ("123" , null , "789" );
539538 }
540539
541- @ Test
540+ @ Test // gh-35817
542541 void valuesCollectionAdd () {
543- assertThatThrownBy (() ->
544- this .map .values ().add ("12345" )
545- ).isInstanceOf (UnsupportedOperationException .class );
542+ assertThatExceptionOfType (UnsupportedOperationException .class )
543+ .isThrownBy (() -> this .map .values ().add ("12345" ));
546544 }
547545
548- @ Test
546+ @ Test // gh-35817
549547 void valuesCollectionClear () {
550548 Collection <String > values = this .map .values ();
551549 this .map .put (123 , "123" );
552550 this .map .put (456 , null );
553551 this .map .put (null , "789" );
554- assertThat (values ).isNotEmpty ( );
552+ assertThat (values ).hasSize ( 3 );
555553 values .clear ();
556554 assertThat (values ).isEmpty ();
557555 assertThat (this .map ).isEmpty ();
558556 }
559557
560- @ Test
558+ @ Test // gh-35817
561559 void valuesCollectionRemoval () {
562560 Collection <String > values = this .map .values ();
563561 assertThat (values ).isEmpty ();
@@ -567,14 +565,14 @@ void valuesCollectionRemoval() {
567565 assertThat (values ).containsExactlyInAnyOrder ("123" , null , "789" );
568566 values .remove (null );
569567 assertThat (values ).containsExactlyInAnyOrder ("123" , "789" );
570- assertThat (map ).containsOnly (new AbstractMap . SimpleEntry <> (123 , "123" ), new AbstractMap . SimpleEntry <> (null , "789" ));
568+ assertThat (map ).containsOnly (entry (123 , "123" ), entry (null , "789" ));
571569 values .remove ("123" );
572570 values .remove ("789" );
573571 assertThat (values ).isEmpty ();
574572 assertThat (map ).isEmpty ();
575573 }
576574
577- @ Test
575+ @ Test // gh-35817
578576 void valuesCollectionIterator () {
579577 Iterator <String > iterator = this .map .values ().iterator ();
580578 assertThat (iterator ).isExhausted ();
@@ -585,7 +583,7 @@ void valuesCollectionIterator() {
585583 assertThat (iterator ).toIterable ().containsExactlyInAnyOrder ("123" , null , "789" );
586584 }
587585
588- @ Test
586+ @ Test // gh-35817
589587 void valuesCollectionIteratorRemoval () {
590588 this .map .put (123 , "123" );
591589 this .map .put (456 , null );
@@ -602,16 +600,16 @@ void valuesCollectionIteratorRemoval() {
602600 assertThat (this .map ).containsOnlyKeys (123 , 456 );
603601 }
604602
605- @ Test
603+ @ Test // gh-35817
606604 void valuesCollectionStream () {
607605 this .map .put (123 , "123" );
608606 this .map .put (456 , null );
609607 this .map .put (null , "789" );
610- List <String > values = this .map .values ().stream ().collect ( Collectors . toList () );
608+ List <String > values = this .map .values ().stream ().toList ();
611609 assertThat (values ).containsExactlyInAnyOrder ("123" , null , "789" );
612610 }
613611
614- @ Test
612+ @ Test // gh-35817
615613 void valuesCollectionSpliteratorCharacteristics () {
616614 this .map .put (123 , "123" );
617615 this .map .put (456 , null );
@@ -698,7 +696,7 @@ void containsViaEntrySet() {
698696 copy .forEach (entry -> assertThat (entrySet ).doesNotContain (entry ));
699697 }
700698
701- @ Test
699+ @ Test // gh-35817
702700 void entrySetSpliteratorCharacteristics () {
703701 this .map .put (1 , "1" );
704702 this .map .put (2 , "2" );
0 commit comments