### Question:
TemplateUtils { public static Collection<InterpolationVariable> extractInterpolationVariables(final String text) { if (text == null || text.length() == 0) { return Collections.emptyList(); } List<InterpolationVariable> interpolationVariableList = new ArrayList<>(); int pos = 0; while ((pos = text.indexOf("@{", pos)) != -1) { int end = text.indexOf('}', pos + 2); if (end != -1) { String varName = text.substring(pos + 2, end); pos = end + 1; InterpolationVariable var = new InterpolationVariable(varName, DataType.TYPE_OBJECT); interpolationVariableList.add(var); } else { break; } } return interpolationVariableList; } private  TemplateUtils(); static Collection<InterpolationVariable> extractInterpolationVariables(final String text); static String substituteTemplateVariable(final String text,
                                                    final Function<String, String> keyToValueFunction);  }### Answer:
@Test public void extractInterpolationVariablesContainsVariables() { String string = "foo bar @{var1} baz @{var2}"; Collection<InterpolationVariable> interpolationVariables = TemplateUtils.extractInterpolationVariables(string); assertEquals(2, interpolationVariables.size()); assertTrue(interpolationVariables.contains(new InterpolationVariable("var1", DataType.TYPE_OBJECT))); assertTrue(interpolationVariables.contains(new InterpolationVariable("var2", DataType.TYPE_OBJECT))); }
@Test public void extractInterpolationVariablesBrokenPattern() { String string = "foo @{zzz bar baz @"; Collection<InterpolationVariable> interpolationVariables = TemplateUtils.extractInterpolationVariables(string); assertTrue(interpolationVariables.isEmpty()); }
@Test public void extractInterpolationVariablesNoVariables() { String string = "foo bar baz"; Collection<InterpolationVariable> interpolationVariables = TemplateUtils.extractInterpolationVariables(string); assertTrue(interpolationVariables.isEmpty()); }