Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.baeldung.assertj.introduction;

import com.google.common.base.Optional;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
Expand All @@ -13,6 +14,7 @@
import org.junit.Test;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;

import static org.assertj.guava.api.Assertions.assertThat;
Expand All @@ -32,7 +34,7 @@ public void givenTwoEmptyFiles_whenComparingContent_thenEqual() throws Exception

@Test
public void givenMultimap_whenVerifying_thenCorrect() throws Exception {
final Multimap<Integer, String> mmap = Multimaps.newMultimap(new HashMap<>(), Sets::newHashSet);
final Multimap<Integer, String> mmap = ArrayListMultimap.create();
mmap.put(1, "one");
mmap.put(1, "1");

Expand All @@ -43,6 +45,30 @@ public void givenMultimap_whenVerifying_thenCorrect() throws Exception {
.contains(entry(1, "1"));
}

@Test
public void givenMultimaps_whenVerifyingContent_thenCorrect() throws Exception {
final Multimap<Integer, String> mmap1 = ArrayListMultimap.create();
mmap1.put(1, "one");
mmap1.put(1, "1");
mmap1.put(2, "two");
mmap1.put(2, "2");

final Multimap<Integer, String> mmap1_clone = Multimaps.newListMultimap(new HashMap<>(), ArrayList::new);
mmap1_clone.put(1, "one");
mmap1_clone.put(1, "1");
mmap1_clone.put(2, "two");
mmap1_clone.put(2, "2");

final Multimap<Integer, String> mmap2 = Multimaps.newMultimap(new HashMap<>(), Sets::newHashSet);
mmap1.put(1, "one");
mmap1.put(1, "1");

assertThat(mmap1)
.containsAllEntriesOf(mmap2)
.hasSameEntriesAs(mmap1_clone)
.isNotEqualTo(mmap1_clone);
}

@Test
public void givenOptional_whenVerifyingContent_thenShouldBeEqual() throws Exception {
final Optional<String> something = Optional.of("something");
Expand Down