Object[] values = getSampleValues();
for (int i = 0; i < keys.length; i++) {
MultiKeyMap multimap = new MultiKeyMap();
MultiKey key = keys[i];
Object value = values[i];
switch (key.size()) {
case 2:
assertEquals(null, multimap.put(key.getKey(0), key.getKey(1), value));
assertEquals(1, multimap.size());
assertEquals(value, multimap.get(key.getKey(0), key.getKey(1)));
assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1)));
assertEquals(true, multimap.containsKey(new MultiKey(key.getKey(0), key.getKey(1))));
assertEquals(value, multimap.put(key.getKey(0), key.getKey(1), null));
assertEquals(1, multimap.size());
assertEquals(null, multimap.get(key.getKey(0), key.getKey(1)));
assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1)));
break;
case 3:
assertEquals(null, multimap.put(key.getKey(0), key.getKey(1), key.getKey(2), value));
assertEquals(1, multimap.size());
assertEquals(value, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2)));
assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2)));
assertEquals(true, multimap.containsKey(new MultiKey(key.getKey(0), key.getKey(1), key.getKey(2))));
assertEquals(value, multimap.put(key.getKey(0), key.getKey(1), key.getKey(2), null));
assertEquals(1, multimap.size());
assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2)));
assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2)));
break;
case 4:
assertEquals(null, multimap.put(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), value));
assertEquals(1, multimap.size());
assertEquals(value, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
assertEquals(true, multimap.containsKey(new MultiKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3))));
assertEquals(value, multimap.put(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), null));
assertEquals(1, multimap.size());
assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
break;
case 5:
assertEquals(null, multimap.put(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4), value));
assertEquals(1, multimap.size());
assertEquals(value, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
assertEquals(true, multimap.containsKey(new MultiKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4))));
assertEquals(value, multimap.put(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4), null));
assertEquals(1, multimap.size());
assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
break;
default:
fail("Invalid key size");
}
}