ReadOnlyEnumerationMap implements Map<String, V> { public int size() { return enumerationSize(request.getKeys()); } ReadOnlyEnumerationMap(HasKeys<V> request); void clear(); boolean containsKey(Object key); @SuppressWarnings("unchecked") boolean containsValue(Object value); Set<Map.Entry<String, V>> entrySet(); V get(Object key); boolean isEmpty(); Set<String> keySet(); V put(String key, V value); void putAll(Map<? extends String, ? extends V> map); V remove(Object key); int size(); Collection<V> values(); @SuppressWarnings("unchecked") @Override boolean equals(Object o); @Override int hashCode();  }
@SuppressWarnings("unchecked") @Test public void testSize() { Enumeration<String> keys = createMock(Enumeration.class); expect(extractor.getKeys()).andReturn(keys); expect(keys.hasMoreElements()).andReturn(true); expect(keys.nextElement()).andReturn("one"); expect(keys.hasMoreElements()).andReturn(true); expect(keys.nextElement()).andReturn("two"); expect(keys.hasMoreElements()).andReturn(false); replay(extractor, keys); assertEquals(2, map.size()); verify(extractor, keys); }