@VisibleForTesting
    static Map<String, ExternalResourceDriver> externalResourceDriversFromConfig(
            Configuration config, PluginManager pluginManager) {
        final Set<String> resourceSet = getExternalResourceSet(config);

        if (resourceSet.isEmpty()) {
            return Collections.emptyMap();
        }

        final Iterator<ExternalResourceDriverFactory> factoryIterator =
                pluginManager.load(ExternalResourceDriverFactory.class);
        final Map<String, ExternalResourceDriverFactory> externalResourceFactories =
                new HashMap<>();
        factoryIterator.forEachRemaining(
                externalResourceDriverFactory ->
                        externalResourceFactories.put(
                                externalResourceDriverFactory.getClass().getName(),
                                externalResourceDriverFactory));

        final Map<String, ExternalResourceDriver> externalResourceDrivers = new HashMap<>();
        for (String resourceName : resourceSet) {
            final ConfigOption<String> driverClassOption =
                    key(ExternalResourceOptions
                                    .getExternalResourceDriverFactoryConfigOptionForResource(
                                            resourceName))
                            .stringType()
                            .noDefaultValue();
            final String driverFactoryClassName = config.get(driverClassOption);
            if (StringUtils.isNullOrWhitespaceOnly(driverFactoryClassName)) {
                LOG.warn(
                        "Could not find driver class name for {}. Please make sure {} is configured.",
                        resourceName,
                        driverClassOption.key());
                continue;
            }

            ExternalResourceDriverFactory externalResourceDriverFactory =
                    externalResourceFactories.get(driverFactoryClassName);
            if (externalResourceDriverFactory != null) {
                DelegatingConfiguration delegatingConfiguration =
                        new DelegatingConfiguration(
                                config,
                                ExternalResourceOptions
                                        .getExternalResourceParamConfigPrefixForResource(
                                                resourceName));
                try {
                    externalResourceDrivers.put(
                            resourceName,
                            externalResourceDriverFactory.createExternalResourceDriver(
                                    delegatingConfiguration));
                    LOG.info("Add external resources driver for {}.", resourceName);
                } catch (Exception e) {
                    LOG.warn(
                            "Could not instantiate driver with factory {} for {}. {}",
                            driverFactoryClassName,
                            resourceName,
                            e);
                }
            } else {
                LOG.warn(
                        "Could not find factory class {} for {}.",
                        driverFactoryClassName,
                        resourceName);
            }
        }

        return externalResourceDrivers;
    }
@Test
    public void testConstructExternalResourceDriversFromConfig() {
        final Configuration config = new Configuration();
        final String driverFactoryClassName = TestingExternalResourceDriverFactory.class.getName();
        final Map<Class<?>, Iterator<?>> plugins = new HashMap<>();
        plugins.put(
                ExternalResourceDriverFactory.class,
                IteratorUtils.singletonIterator(new TestingExternalResourceDriverFactory()));
        final PluginManager testingPluginManager = new TestingPluginManager(plugins);

        config.set(
                ExternalResourceOptions.EXTERNAL_RESOURCE_LIST,
                Collections.singletonList(RESOURCE_NAME_1));
        config.setString(
                ExternalResourceOptions.getExternalResourceDriverFactoryConfigOptionForResource(
                        RESOURCE_NAME_1),
                driverFactoryClassName);

        final Map<String, ExternalResourceDriver> externalResourceDrivers =
                ExternalResourceUtils.externalResourceDriversFromConfig(
                        config, testingPluginManager);

        assertThat(externalResourceDrivers.size(), is(1));
        assertThat(
                externalResourceDrivers.get(RESOURCE_NAME_1),
                instanceOf(TestingExternalResourceDriver.class));
    }