KeySet implements Set<String> { @Override public Iterator<String> iterator() { return new KeySetIterator(); } KeySet(HasKeys<?> request); @Override boolean add(String e); @Override boolean addAll(Collection<? extends String> c); @Override void clear(); @Override boolean contains(Object o); @SuppressWarnings("unchecked") @Override boolean containsAll(Collection<?> c); @Override boolean isEmpty(); @Override Iterator<String> iterator(); @Override boolean remove(Object o); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override int size(); @Override Object[] toArray(); @Override T[] toArray(T[] a);  }
@SuppressWarnings("unchecked") @Test public void testIterator() { Enumeration<String> keys = createMock(Enumeration.class); Enumeration<String> values2 = createMock(Enumeration.class); expect(extractor.getKeys()).andReturn(keys); expect(keys.hasMoreElements()).andReturn(true); expect(keys.nextElement()).andReturn("two"); replay(extractor, keys, values2); Iterator<String> entryIt = entrySet.iterator(); assertTrue(entryIt.hasNext()); assertEquals("two", entryIt.next()); verify(extractor, keys, values2); }