public Item getItem(int id) { return items.get(id); }
@Test public void testReadableMap() { final IterableMap<String, Integer> map = SplitMapUtils.readableMap(transformedMap); // basic for (int i = 0; i < 10; i++) { assertFalse(map.containsValue(String.valueOf(i))); assertEquals(i, map.get(String.valueOf(i)).intValue()); } // mapIterator final MapIterator<String, Integer> it = map.mapIterator(); while (it.hasNext()) { final String k = it.next(); assertEquals(k, it.getKey()); assertEquals(Integer.valueOf(k), it.getValue()); } // unmodifiable assertTrue(map instanceof Unmodifiable); // check individual operations int sz = map.size(); attemptPutOperation( new Runnable() { public void run() { map.clear(); } }); assertEquals(sz, map.size()); attemptPutOperation( new Runnable() { public void run() { map.put("foo", 100); } }); final HashMap<String, Integer> m = new HashMap<String, Integer>(); m.put("foo", 100); m.put("bar", 200); m.put("baz", 300); attemptPutOperation( new Runnable() { public void run() { map.putAll(m); } }); // equals, hashcode final IterableMap<String, Integer> other = SplitMapUtils.readableMap(transformedMap); assertEquals(other, map); assertEquals(other.hashCode(), map.hashCode()); // remove for (int i = 0; i < 10; i++) { assertEquals(i, map.remove(String.valueOf(i)).intValue()); assertEquals(--sz, map.size()); } assertTrue(map.isEmpty()); assertSame(map, SplitMapUtils.readableMap(map)); }