### Question:
RuleAnalyzer { public static Set<String> getReferencedVariables(final String elString) { final NameGatheringVariableMapper variableMapper = new NameGatheringVariableMapper(); final ELResolver elResolver = new CompositeELResolver(); final FunctionMapper functionMapper = RuleEvaluator.defaultFunctionMapperBuilder().build(); ExpressionFactory.newInstance().createValueExpression( new ELContext() { @Override public ELResolver getELResolver() { return elResolver; } @Override public FunctionMapper getFunctionMapper() { return functionMapper; } @Override public VariableMapper getVariableMapper() { return variableMapper; } }, elString, Void.class ); return variableMapper.getGatheredVariables(); }  static Set<String> getReferencedVariables(final String elString);  }### Answer:
@Test public void testIsReferencedInString() { final String variableName = "application"; assertThat(RuleAnalyzer.getReferencedVariables("${application == 'ExampleApplication'}")).contains(variableName); assertThat(RuleAnalyzer.getReferencedVariables("${foo == bar && application == 'ExampleApplication'}")).contains("foo", "bar", variableName); assertThat(RuleAnalyzer.getReferencedVariables("${ua.name == 'ie9' && application == 'ExampleApplication'}")).contains(variableName); assertThat(RuleAnalyzer.getReferencedVariables("${false && application == 'ExampleApplication'}")).contains(variableName); assertThat(RuleAnalyzer.getReferencedVariables("${nested.array[1] == 7 && application == 'ExampleApplication'}")).contains(variableName); assertThat(RuleAnalyzer.getReferencedVariables("${nested.array[1] == 7 && foo == bar}")).doesNotContain(variableName); assertThat(RuleAnalyzer.getReferencedVariables("${nested.array[1] == 'application' && foo == bar}")).doesNotContain(variableName); assertThat(RuleAnalyzer.getReferencedVariables("${null}")).isEmpty(); }