MapContext implements ImmutableContext { @Override public Iterator<Map.Entry<String, String>> iterator() { return options.entrySet().iterator(); } MapContext(Map<String, String> options); @Override String getString(String key); @Override String getString(String key, String defaultValue); @Override boolean getBoolean(String key, boolean defaultValue); @Override long getLong(String key, long defaultValue); @Override int getInt(String key, int defaultValue); Map<String, String> getNestedProperties(String prefix); Map<String, String> getValByRegex(String regex); @Override Iterator<Map.Entry<String, String>> iterator();  }
@Test public void testIterator() { Map<String, String> options = new HashMap<String, String>(); options.put("sqooptest1", "value"); options.put("sqooptest2", "value"); MapContext mc = new MapContext(options); boolean seenSqooptest1 = false; boolean seenSqooptest2 = false; for(Map.Entry<String, String> entry : mc) { if("sqooptest1".equals(entry.getKey()) && "value".equals(entry.getValue())) { seenSqooptest1 = true; } else if("sqooptest2".equals(entry.getKey()) && "value".equals(entry.getValue())) { seenSqooptest2 = true; } else { fail("Found unexpected property: " + entry.getKey() + " with value " + entry.getValue()); } } assertTrue(seenSqooptest1); assertTrue(seenSqooptest2); }