コード例 #1
0
 public void testContainsValue_Key() {
   MultiHashMap map = new MultiHashMap();
   assertEquals(false, map.containsValue("A", "AA"));
   assertEquals(false, map.containsValue("B", "BB"));
   map.put("A", "AA");
   assertEquals(true, map.containsValue("A", "AA"));
   assertEquals(false, map.containsValue("A", "AB"));
 }
コード例 #2
0
  public void testContainsValue() {
    MultiHashMap map = new MultiHashMap();
    loadMap(map);

    assertTrue(map.containsValue("uno"));
    assertTrue(map.containsValue("quatro"));
    assertTrue(map.containsValue("two"));

    assertTrue(!map.containsValue("uggaBugga"));

    map.clear();
  }
コード例 #3
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"));
  }
コード例 #4
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"));
  }