### Question:
ConfigOptionSearchAndRunHandler extends AbstractParseResultHandler<List<Object>> { @VisibleForTesting IDefaultValueProvider createDefaultValueProvider( final CommandLine commandLine, final Optional<File> configFile) { if (configFile.isPresent()) { return new CascadingDefaultProvider( new EnvironmentVariableDefaultProvider(environment), new TomlConfigFileDefaultProvider(commandLine, configFile.get())); } else { return new EnvironmentVariableDefaultProvider(environment); } } ConfigOptionSearchAndRunHandler(
      final AbstractParseResultHandler<List<Object>> resultHandler,
      final CommandLine.IExceptionHandler2<List<Object>> exceptionHandler,
      final String configFileOptionName,
      final Map<String, String> environment); @Override List<Object> handle(final ParseResult parseResult); @Override ConfigOptionSearchAndRunHandler self();  }### Answer:
@Test public void shouldRetrieveConfigFromEnvironmentWhenConfigFileSpecified() throws Exception { final IDefaultValueProvider defaultValueProvider = configParsingHandler.createDefaultValueProvider( mockCommandLine, Optional.of(new File("foo"))); final String value = defaultValueProvider.defaultValue(OptionSpec.builder("--logging").build()); assertThat(value).isEqualTo("ERROR"); }
@Test public void shouldRetrieveConfigFromEnvironmentWhenConfigFileNotSpecified() throws Exception { final IDefaultValueProvider defaultValueProvider = configParsingHandler.createDefaultValueProvider(mockCommandLine, Optional.empty()); final String value = defaultValueProvider.defaultValue(OptionSpec.builder("--logging").build()); assertThat(value).isEqualTo("ERROR"); }