MapContext implements ImmutableContext { @Override public boolean getBoolean(String key, boolean defaultValue) { String value = getString(key); boolean result = defaultValue; if (value != null) { result = Boolean.valueOf(value); } return result; } 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 testGetBoolean() { Map<String, String> options = new HashMap<String, String>(); options.put("testkey", "true"); MapContext mc = new MapContext(options); Assert.assertEquals(true, mc.getBoolean("testkey", false)); Assert.assertEquals(false, mc.getBoolean("wrongKey", false)); }