### Question:
PredefinedVariableResolver { public Object resolveVariable(String variableName) throws VariableNotFoundException { final Object resolvedValue = tryResolveVariable(variableName); if (resolvedValue == null) { throw new VariableNotFoundException("No variable '" + variableName + "' among the predefined ones" + (isIncludeKnownVariablesInException()? ": " + knownVariables.keySet() : ".")); } if (newVariableEncounteredListener != null) { newVariableEncounteredListener.handleNewVariableEncountered(variableName); } return resolvedValue; } PredefinedVariableResolver(
            final PredefinedVariableResolver.NewVariableEncounteredListener newVariableEncounteredListener); Object resolveVariable(String variableName); void declareVariable(final String name, final Object value); Map<String, Object> getDeclaredVariables(); void setIncludeKnownVariablesInException(
            boolean includeKnownVariablesInException); boolean isIncludeKnownVariablesInException(); void setUnknownVariableResolver(ElVariableResolver unknownVariableResolver); ElVariableResolver getUnknownVariableResolver();  }### Answer:
@Test(expected = VariableNotFoundException.class) public void should_throw_exception_for_unknown_variable() throws Exception { resolver.resolveVariable("unknown"); }
@Test public void should_not_invoke_its_listener_when_unknown_variable_encountered() throws Exception { try { resolver.resolveVariable("unknownVariable"); } catch (VariableNotFoundException e) { } verifyZeroInteractions(listener); }