### Question:
PropertyEvaluator { public void eval(Map<String, String> data) { boolean dirty; do { dirty = false; for (Map.Entry<String, String> e : data.entrySet()) { dirty |= eval(e.getKey(), e.getValue(), data, sources); } } while (dirty); }  void addDefaultSources(); @SuppressWarnings("unchecked") void addDefaultSources(String sys, String env); void addSource(String prefix, Map<String, String> source); void addSource(String prefix, Properties source); void eval(Map<String, String> data); String eval(String value);  }### Answer:
@Test public void testEval() throws Exception { Map.Entry<String, String> firstEnvEntry = System.getenv().entrySet().iterator().next(); String envKey = firstEnvEntry.getKey(); String envValue = firstEnvEntry.getValue(); assertNotNull(envValue); Map<String, String> source = new HashMap<String, String>(); source.put("key", "replacedValue"); eval.addSource("source", source); Map<String, String> data = new HashMap<String, String>(); data.put("key", "${source.key}"); data.put("envKey", "${env." + envKey + "}"); data.put("sysKey", "${sys.user.home}"); data.put("self", "${key}"); data.put("partial", "other eval: <${key}>"); data.put("multi", "other eval: <${key}> and <${self}>"); data.put("selfreferencing", "${selfreferencing}"); data.put("missing", "${nothere}"); data.put("invalid", "${invalid"); eval.eval(data); assertEquals("replacedValue", data.get("key")); assertEquals(envValue, data.get("envKey")); assertEquals(System.getProperty("user.home"), data.get("sysKey")); assertEquals("replacedValue", data.get("self")); assertEquals("other eval: <replacedValue>", data.get("partial")); assertEquals("other eval: <replacedValue> and <replacedValue>", data.get("multi")); assertEquals("${selfreferencing}", data.get("selfreferencing")); assertEquals("${nothere}", data.get("missing")); assertEquals("${invalid", data.get("invalid")); }