Code example for ImmutableMultimap.Builder

Methods: build, put

0
 */ 
@GwtCompatible(emulated = true) 
public class ImmutableMultimapTest extends TestCase {
 
  public void testBuilder_withImmutableEntry() { 
    ImmutableMultimap<String, Integer> multimap = new Builder<String, Integer>()
        .put(Maps.immutableEntry("one", 1))
        .build();
    assertEquals(Arrays.asList(1), multimap.get("one"));
  } 
 
  public void testBuilder_withImmutableEntryAndNullContents() { 
    Builder<String, Integer> builder = new Builder<String, Integer>();
    try { 
      builder.put(Maps.immutableEntry("one", (Integer) null));
      fail();
    } catch (NullPointerException expected) {
    } 
    try { 
      builder.put(Maps.immutableEntry((String) null, 1));
      fail();