Ejemplo n.º 1
0
  public void testPutAll_KeyCollection() {
    MultiHashMap map = new MultiHashMap();
    Collection coll = Arrays.asList(new Object[] {"X", "Y", "Z"});

    assertEquals(true, map.putAll("A", coll));
    assertEquals(3, map.size("A"));
    assertEquals(true, map.containsValue("A", "X"));
    assertEquals(true, map.containsValue("A", "Y"));
    assertEquals(true, map.containsValue("A", "Z"));

    assertEquals(false, map.putAll("A", null));
    assertEquals(3, map.size("A"));
    assertEquals(true, map.containsValue("A", "X"));
    assertEquals(true, map.containsValue("A", "Y"));
    assertEquals(true, map.containsValue("A", "Z"));

    assertEquals(false, map.putAll("A", new ArrayList()));
    assertEquals(3, map.size("A"));
    assertEquals(true, map.containsValue("A", "X"));
    assertEquals(true, map.containsValue("A", "Y"));
    assertEquals(true, map.containsValue("A", "Z"));

    coll = Arrays.asList(new Object[] {"M"});
    assertEquals(true, map.putAll("A", coll));
    assertEquals(4, map.size("A"));
    assertEquals(true, map.containsValue("A", "X"));
    assertEquals(true, map.containsValue("A", "Y"));
    assertEquals(true, map.containsValue("A", "Z"));
    assertEquals(true, map.containsValue("A", "M"));
  }
Ejemplo n.º 2
0
  public void testPutAll_Map1() {
    MultiMap original = new MultiHashMap();
    original.put("key", "object1");
    original.put("key", "object2");

    MultiHashMap test = new MultiHashMap();
    test.put("keyA", "objectA");
    test.put("key", "object0");
    test.putAll(original);

    assertEquals(2, test.size());
    assertEquals(4, test.totalSize());
    assertEquals(1, test.getCollection("keyA").size());
    assertEquals(3, test.getCollection("key").size());
    assertEquals(true, test.containsValue("objectA"));
    assertEquals(true, test.containsValue("object0"));
    assertEquals(true, test.containsValue("object1"));
    assertEquals(true, test.containsValue("object2"));
  }