MapContext implements ImmutableContext { @Override public long getLong(String key, long defaultValue) { if (!options.containsKey(key)) { return defaultValue; } String value = options.get(key); return Long.parseLong(value); } 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 testGetLong() { Map<String, String> options = new HashMap<String, String>(); options.put("testkey", "123"); MapContext mc = new MapContext(options); Assert.assertEquals(123l, mc.getLong("testkey", 456l)); Assert.assertEquals(456l, mc.getLong("wrongKey", 456l)); }