11package com .baeldung .assertj .introduction ;
22
33import com .google .common .base .Optional ;
4+ import com .google .common .collect .ArrayListMultimap ;
45import com .google .common .collect .HashBasedTable ;
56import com .google .common .collect .Multimap ;
67import com .google .common .collect .Multimaps ;
1314import org .junit .Test ;
1415
1516import java .io .File ;
17+ import java .util .ArrayList ;
1618import java .util .HashMap ;
1719
1820import static org .assertj .guava .api .Assertions .assertThat ;
@@ -32,7 +34,7 @@ public void givenTwoEmptyFiles_whenComparingContent_thenEqual() throws Exception
3234
3335 @ Test
3436 public void givenMultimap_whenVerifying_thenCorrect () throws Exception {
35- final Multimap <Integer , String > mmap = Multimaps . newMultimap ( new HashMap <>(), Sets :: newHashSet );
37+ final Multimap <Integer , String > mmap = ArrayListMultimap . create ( );
3638 mmap .put (1 , "one" );
3739 mmap .put (1 , "1" );
3840
@@ -43,6 +45,30 @@ public void givenMultimap_whenVerifying_thenCorrect() throws Exception {
4345 .contains (entry (1 , "1" ));
4446 }
4547
48+ @ Test
49+ public void givenMultimaps_whenVerifyingContent_thenCorrect () throws Exception {
50+ final Multimap <Integer , String > mmap1 = ArrayListMultimap .create ();
51+ mmap1 .put (1 , "one" );
52+ mmap1 .put (1 , "1" );
53+ mmap1 .put (2 , "two" );
54+ mmap1 .put (2 , "2" );
55+
56+ final Multimap <Integer , String > mmap1_clone = Multimaps .newListMultimap (new HashMap <>(), ArrayList ::new );
57+ mmap1_clone .put (1 , "one" );
58+ mmap1_clone .put (1 , "1" );
59+ mmap1_clone .put (2 , "two" );
60+ mmap1_clone .put (2 , "2" );
61+
62+ final Multimap <Integer , String > mmap2 = Multimaps .newMultimap (new HashMap <>(), Sets ::newHashSet );
63+ mmap1 .put (1 , "one" );
64+ mmap1 .put (1 , "1" );
65+
66+ assertThat (mmap1 )
67+ .containsAllEntriesOf (mmap2 )
68+ .hasSameEntriesAs (mmap1_clone )
69+ .isNotEqualTo (mmap1_clone );
70+ }
71+
4672 @ Test
4773 public void givenOptional_whenVerifyingContent_thenShouldBeEqual () throws Exception {
4874 final Optional <String > something = Optional .of ("something" );
0 commit comments