MapContext implements ImmutableContext { @Override public String getString(String key) { return options.get(key); } 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 testInitalization() { Map<String, String> options = new HashMap<String, String>(); options.put("testkey", "testvalue"); MapContext mc = new MapContext(options); Assert.assertEquals("testvalue", mc.getString("testkey")); }
@Test public void testGetString() { Map<String, String> options = new HashMap<String, String>(); options.put("testkey", "testvalue"); MapContext mc = new MapContext(options); Assert.assertEquals("testvalue", mc.getString("testkey", "defaultValue")); Assert.assertEquals("defaultValue", mc.getString("wrongKey", "defaultValue")); }