@@ -531,14 +531,14 @@ public void testSize_Key() {
531531 @ SuppressWarnings ("unchecked" )
532532 public void testContainsValue_Key () {
533533 final MultiValuedMap <K , V > map = makeFullMap ();
534- assertEquals ( true , map .containsMapping ("one" , "uno" ));
535- assertEquals ( false , map .containsMapping ("two" , "2" ));
534+ assertTrue ( map .containsMapping ("one" , "uno" ));
535+ assertFalse ( map .containsMapping ("two" , "2" ));
536536 if (!isAddSupported ()) {
537537 return ;
538538 }
539539 map .put ((K ) "A" , (V ) "AA" );
540- assertEquals ( true , map .containsMapping ("A" , "AA" ));
541- assertEquals ( false , map .containsMapping ("A" , "AB" ));
540+ assertTrue ( map .containsMapping ("A" , "AA" ));
541+ assertFalse ( map .containsMapping ("A" , "AB" ));
542542 }
543543
544544 @ SuppressWarnings ("unchecked" )
@@ -567,10 +567,10 @@ public void testPutAll_Map1() {
567567 assertEquals (4 , test .size ());
568568 assertEquals (1 , test .get ((K ) "keyA" ).size ());
569569 assertEquals (3 , test .get ((K ) "key" ).size ());
570- assertEquals ( true , test .containsValue ("objectA" ));
571- assertEquals ( true , test .containsValue ("object0" ));
572- assertEquals ( true , test .containsValue ("object1" ));
573- assertEquals ( true , test .containsValue ("object2" ));
570+ assertTrue ( test .containsValue ("objectA" ));
571+ assertTrue ( test .containsValue ("object0" ));
572+ assertTrue ( test .containsValue ("object1" ));
573+ assertTrue ( test .containsValue ("object2" ));
574574 }
575575
576576 @ SuppressWarnings ("unchecked" )
@@ -600,10 +600,10 @@ public void testPutAll_Map2() {
600600 assertEquals (1 , test .get ((K ) "keyA" ).size ());
601601 assertEquals (2 , test .get ((K ) "keyX" ).size ());
602602 assertEquals (1 , test .get ((K ) "keyY" ).size ());
603- assertEquals ( true , test .containsValue ("objectA" ));
604- assertEquals ( true , test .containsValue ("object0" ));
605- assertEquals ( true , test .containsValue ("object1" ));
606- assertEquals ( true , test .containsValue ("object2" ));
603+ assertTrue ( test .containsValue ("objectA" ));
604+ assertTrue ( test .containsValue ("object0" ));
605+ assertTrue ( test .containsValue ("object1" ));
606+ assertTrue ( test .containsValue ("object2" ));
607607 }
608608
609609 @ SuppressWarnings ("unchecked" )
@@ -614,11 +614,11 @@ public void testPutAll_KeyIterable() {
614614 final MultiValuedMap <K , V > map = makeObject ();
615615 Collection <V > coll = (Collection <V >) Arrays .asList ("X" , "Y" , "Z" );
616616
617- assertEquals ( true , map .putAll ((K ) "A" , coll ));
617+ assertTrue ( map .putAll ((K ) "A" , coll ));
618618 assertEquals (3 , map .get ((K ) "A" ).size ());
619- assertEquals ( true , map .containsMapping ("A" , "X" ));
620- assertEquals ( true , map .containsMapping ("A" , "Y" ));
621- assertEquals ( true , map .containsMapping ("A" , "Z" ));
619+ assertTrue ( map .containsMapping ("A" , "X" ));
620+ assertTrue ( map .containsMapping ("A" , "Y" ));
621+ assertTrue ( map .containsMapping ("A" , "Z" ));
622622
623623 try {
624624 map .putAll ((K ) "A" , null );
@@ -628,23 +628,23 @@ public void testPutAll_KeyIterable() {
628628 }
629629
630630 assertEquals (3 , map .get ((K ) "A" ).size ());
631- assertEquals ( true , map .containsMapping ("A" , "X" ));
632- assertEquals ( true , map .containsMapping ("A" , "Y" ));
633- assertEquals ( true , map .containsMapping ("A" , "Z" ));
631+ assertTrue ( map .containsMapping ("A" , "X" ));
632+ assertTrue ( map .containsMapping ("A" , "Y" ));
633+ assertTrue ( map .containsMapping ("A" , "Z" ));
634634
635- assertEquals ( false , map .putAll ((K ) "A" , new ArrayList <V >()));
635+ assertFalse ( map .putAll ((K ) "A" , new ArrayList <V >()));
636636 assertEquals (3 , map .get ((K ) "A" ).size ());
637- assertEquals ( true , map .containsMapping ("A" , "X" ));
638- assertEquals ( true , map .containsMapping ("A" , "Y" ));
639- assertEquals ( true , map .containsMapping ("A" , "Z" ));
637+ assertTrue ( map .containsMapping ("A" , "X" ));
638+ assertTrue ( map .containsMapping ("A" , "Y" ));
639+ assertTrue ( map .containsMapping ("A" , "Z" ));
640640
641641 coll = (Collection <V >) Arrays .asList ("M" );
642- assertEquals ( true , map .putAll ((K ) "A" , coll ));
642+ assertTrue ( map .putAll ((K ) "A" , coll ));
643643 assertEquals (4 , map .get ((K ) "A" ).size ());
644- assertEquals ( true , map .containsMapping ("A" , "X" ));
645- assertEquals ( true , map .containsMapping ("A" , "Y" ));
646- assertEquals ( true , map .containsMapping ("A" , "Z" ));
647- assertEquals ( true , map .containsMapping ("A" , "M" ));
644+ assertTrue ( map .containsMapping ("A" , "X" ));
645+ assertTrue ( map .containsMapping ("A" , "Y" ));
646+ assertTrue ( map .containsMapping ("A" , "Z" ));
647+ assertTrue ( map .containsMapping ("A" , "M" ));
648648 }
649649
650650 @ SuppressWarnings ("unchecked" )
@@ -656,11 +656,11 @@ public void testRemove_KeyItem() {
656656 map .put ((K ) "A" , (V ) "AA" );
657657 map .put ((K ) "A" , (V ) "AB" );
658658 map .put ((K ) "A" , (V ) "AC" );
659- assertEquals ( false , map .removeMapping ("C" , "CA" ));
660- assertEquals ( false , map .removeMapping ("A" , "AD" ));
661- assertEquals ( true , map .removeMapping ("A" , "AC" ));
662- assertEquals ( true , map .removeMapping ("A" , "AB" ));
663- assertEquals ( true , map .removeMapping ("A" , "AA" ));
659+ assertFalse ( map .removeMapping ("C" , "CA" ));
660+ assertFalse ( map .removeMapping ("A" , "AD" ));
661+ assertTrue ( map .removeMapping ("A" , "AC" ));
662+ assertTrue ( map .removeMapping ("A" , "AB" ));
663+ assertTrue ( map .removeMapping ("A" , "AA" ));
664664 //assertEquals(new MultiValuedHashMap<K, V>(), map);
665665 }
666666
@@ -748,6 +748,50 @@ public void testAsMapRemove() {
748748 assertEquals (4 , getMap ().size ());
749749 }
750750
751+ public void testAsMapValues () {
752+ if (!isAddSupported () || isHashSetValue ()) {
753+ return ;
754+ }
755+ final MultiValuedMap <K , V > multiMap = makeObject ();
756+ multiMap .put ((K ) "A" , (V ) "W" );
757+ multiMap .put ((K ) "A" , (V ) "X" );
758+ multiMap .put ((K ) "A" , (V ) "F" );
759+ multiMap .put ((K ) "B" , (V ) "Q" );
760+ multiMap .put ((K ) "B" , (V ) "Q" );
761+ multiMap .put ((K ) "B" , (V ) "L" );
762+ assertEquals ("{A=[W, X, F], B=[Q, Q, L]}" , multiMap .toString ());
763+ for (Collection <V > list : multiMap .asMap ().values ()) {
764+ for (Iterator <V > it = list .iterator (); it .hasNext ();) {
765+ it .next ();
766+ it .remove ();
767+ }
768+ }
769+ assertEquals ("{A=[], B=[]}" , multiMap .toString ());
770+ }
771+
772+ public void testAsMapEntrySet () {
773+ if (!isAddSupported () || isHashSetValue ()) {
774+ return ;
775+ }
776+
777+ final MultiValuedMap <K , V > multiMap = makeObject ();
778+ multiMap .put ((K ) "A" , (V ) "W" );
779+ multiMap .put ((K ) "A" , (V ) "X" );
780+ multiMap .put ((K ) "A" , (V ) "F" );
781+ multiMap .put ((K ) "B" , (V ) "Q" );
782+ multiMap .put ((K ) "B" , (V ) "Q" );
783+ multiMap .put ((K ) "B" , (V ) "L" );
784+ assertEquals ("{A=[W, X, F], B=[Q, Q, L]}" , multiMap .toString ());
785+ Map <K , Collection <V >> asMap = multiMap .asMap ();
786+ for (Map .Entry <K , Collection <V >> entry : asMap .entrySet ()) {
787+ for (Iterator <V > it = entry .getValue ().iterator (); it .hasNext ();) {
788+ it .next ();
789+ it .remove ();
790+ }
791+ }
792+ assertEquals ("{A=[], B=[]}" , multiMap .toString ());
793+ }
794+
751795 public void testMapIterator () {
752796 resetEmpty ();
753797 MapIterator <K , V > mapIt = getMap ().mapIterator ();
@@ -810,7 +854,7 @@ public void testMultiValuedMapIterator() {
810854 }
811855
812856 if (!isHashSetValue () && isAddSupported ()) {
813- assertTrue (it .hasNext () );
857+ assertTrue (it .hasNext ());
814858 assertEquals ("one" , it .next ());
815859 assertEquals ("one" , it .getKey ());
816860 assertEquals ("uno" , it .getValue ());
@@ -1198,7 +1242,7 @@ public Collection<V>[] getSampleValues() {
11981242 final V [] sampleValues = AbstractMultiValuedMapTest .this .getSampleValues ();
11991243 final Collection <V >[] colArr = new Collection [3 ];
12001244 for (int i = 0 ; i < 3 ; i ++) {
1201- final Collection <V > coll = Arrays .asList (sampleValues [i * 2 ], sampleValues [i * 2 + 1 ]);
1245+ final Collection <V > coll = Arrays .asList (sampleValues [i * 2 ], sampleValues [i * 2 + 1 ]);
12021246 colArr [i ] = isSetValuedMap ? new HashSet <>(coll ) : coll ;
12031247 }
12041248 return colArr ;
@@ -1210,7 +1254,7 @@ public Collection<V>[] getNewSampleValues() {
12101254 // See comment in getSampleValues() to understand why we are calling makeObject() and not
12111255 // getMap(). See COLLECTIONS-661 for more.
12121256 final boolean isSetValuedMap = AbstractMultiValuedMapTest .this .makeObject () instanceof SetValuedMap ;
1213- final Object [] sampleValues = { "ein" , "ek" , "zwei" , "duey" , "drei" , "teen" };
1257+ final Object [] sampleValues = { "ein" , "ek" , "zwei" , "duey" , "drei" , "teen" };
12141258 final Collection <V >[] colArr = new Collection [3 ];
12151259 for (int i = 0 ; i < 3 ; i ++) {
12161260 final Collection <V > coll = Arrays .asList ((V ) sampleValues [i * 2 ], (V ) sampleValues [i * 2 + 1 ]);
0 commit comments