MapContext implements ImmutableContext { public Map<String, String> getNestedProperties(String prefix) { Map<String, String> subProps = new HashMap<String, String>(); for (String key : options.keySet()) { if (key.startsWith(prefix)) { subProps.put(key.substring(prefix.length()), options.get(key)); } } return subProps; } 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 testGetNestedProperties() { Map<String, String> options = new HashMap<String, String>(); options.put("sqooptest1", "value"); options.put("sqooptest2", "value"); options.put("testsqoop1", "value"); options.put("testsqoop1", "value"); MapContext mc = new MapContext(options); Map<String, String> result = mc.getNestedProperties("sqoop"); Assert.assertEquals(2, result.size()); Assert.assertTrue(result.containsKey("test1")); Assert.assertTrue(result.containsKey("test2")); Assert.assertFalse(result.containsKey("testsqoop1")); Assert.assertFalse(result.containsKey("testsqoop2")); }