### Question:
MappingExpr { static String substitute(String pattern, Map<String, String> vars) { String value = pattern; for (Map.Entry<String, String> entry : vars.entrySet()) { String raw = entry.getValue(); String v = Introspector.decapitalize(raw); value = value.replace("{raw:" + entry.getKey() + "}", raw); value = value.replace("{" + entry.getKey() + "}", v); } return value; } private  MappingExpr();   }### Answer:
@Test public void substituteEmpty() { Map<String, String> vars = new HashMap<>(); String actual = MappingExpr.substitute("", vars); Assertions.assertEquals("", actual); }
@Test public void substituteMissing() { Map<String, String> vars = new HashMap<>(); String actual = MappingExpr.substitute("abc{def}", vars); Assertions.assertEquals("abc{def}", actual); }
@Test public void substituteSingle() { Map<String, String> vars = new HashMap<>(); vars.put("def", "123"); String actual = MappingExpr.substitute("abc{def}", vars); Assertions.assertEquals("abc123", actual); }
@Test public void substituteMultiple() { Map<String, String> vars = new HashMap<>(); vars.put("def", "123"); String actual = MappingExpr.substitute("abc{def}, {def}", vars); Assertions.assertEquals("abc123, 123", actual); }
@Test public void substituteMultiVar() { Map<String, String> vars = new HashMap<>(); vars.put("def", "123"); vars.put("ghi", "456"); String actual = MappingExpr.substitute("abc{def}, {ghi}, {def}", vars); Assertions.assertEquals("abc123, 456, 123", actual); }
@Test public void substituteDecapitalize() { Map<String, String> vars = new HashMap<>(); vars.put("name", "FooBarBaz"); String actual = MappingExpr.substitute("abc.def.{name}", vars); Assertions.assertEquals("abc.def.fooBarBaz", actual); }
@Test public void substituteRaw() { Map<String, String> vars = new HashMap<>(); vars.put("name", "FooBarBaz"); String actual = MappingExpr.substitute("abc.def.{raw:name}", vars); Assertions.assertEquals("abc.def.FooBarBaz", actual); }