Test Case
// Build map
Map<String, String> valuesMap = new HashMap<>();
valuesMap.put("animal", "quick brown fox");
valuesMap.put("target", "lazy dog");
String templateString = "The ${animal} jumped ${ over the ${target}.%";
// Build StringSubstitutor
StringSubstitutor sub = new StringSubstitutor(valuesMap);
// Replace
String resolvedString = sub.replace(templateString);
assertThat( resolvedString, is( "The quick brown fox jumped ${ over the lazy dog.%" ) );
The Failure
- ${target} variable is not being replaced:
java.lang.AssertionError:
Expected: is "The quick brown fox jumped ${ over the lazy dog.%"
but: was "The quick brown fox jumped ${ over the ${target}.%"