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 ;
78import com .google .common .collect .Range ;
8- import com .google .common .collect .Sets ;
99import com .google .common .collect .Table ;
1010import com .google .common .collect .TreeRangeMap ;
1111import com .google .common .io .Files ;
1414
1515import java .io .File ;
1616import java .util .HashMap ;
17+ import java .util .HashSet ;
1718
1819import static org .assertj .guava .api .Assertions .assertThat ;
1920import static org .assertj .guava .api .Assertions .entry ;
@@ -22,17 +23,17 @@ public class AssertJGuavaTest {
2223
2324 @ Test
2425 public void givenTwoEmptyFiles_whenComparingContent_thenEqual () throws Exception {
25- final File temp = File .createTempFile ("bael" , "dung " );
26+ final File temp1 = File .createTempFile ("bael" , "dung1 " );
2627 final File temp2 = File .createTempFile ("bael" , "dung2" );
2728
28- assertThat (Files .asByteSource (temp ))
29+ assertThat (Files .asByteSource (temp1 ))
2930 .hasSize (0 )
3031 .hasSameContentAs (Files .asByteSource (temp2 ));
3132 }
3233
3334 @ Test
3435 public void givenMultimap_whenVerifying_thenCorrect () throws Exception {
35- final Multimap <Integer , String > mmap = Multimaps . newMultimap ( new HashMap <>(), Sets :: newHashSet );
36+ final Multimap <Integer , String > mmap = ArrayListMultimap . create ( );
3637 mmap .put (1 , "one" );
3738 mmap .put (1 , "1" );
3839
@@ -43,6 +44,30 @@ public void givenMultimap_whenVerifying_thenCorrect() throws Exception {
4344 .contains (entry (1 , "1" ));
4445 }
4546
47+ @ Test
48+ public void givenMultimaps_whenVerifyingContent_thenCorrect () throws Exception {
49+ final Multimap <Integer , String > mmap1 = ArrayListMultimap .create ();
50+ mmap1 .put (1 , "one" );
51+ mmap1 .put (1 , "1" );
52+ mmap1 .put (2 , "two" );
53+ mmap1 .put (2 , "2" );
54+
55+ final Multimap <Integer , String > mmap1_clone = Multimaps .newSetMultimap (new HashMap <>(), HashSet ::new );
56+ mmap1_clone .put (1 , "one" );
57+ mmap1_clone .put (1 , "1" );
58+ mmap1_clone .put (2 , "two" );
59+ mmap1_clone .put (2 , "2" );
60+
61+ final Multimap <Integer , String > mmap2 = Multimaps .newSetMultimap (new HashMap <>(), HashSet ::new );
62+ mmap2 .put (1 , "one" );
63+ mmap2 .put (1 , "1" );
64+
65+ assertThat (mmap1 )
66+ .containsAllEntriesOf (mmap2 )
67+ .containsAllEntriesOf (mmap1_clone )
68+ .hasSameEntriesAs (mmap1_clone );
69+ }
70+
4671 @ Test
4772 public void givenOptional_whenVerifyingContent_thenShouldBeEqual () throws Exception {
4873 final Optional <String > something = Optional .of ("something" );
0 commit comments