public static Map<String, String> getExternalResourceConfigurationKeys(
            Configuration config, String suffix) {
        final Set<String> resourceSet = getExternalResourceSet(config);
        final Map<String, String> configKeysToResourceNameMap = new HashMap<>();
        LOG.info("Enabled external resources: {}", resourceSet);

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

        final Map<String, String> externalResourceConfigs = new HashMap<>();
        for (String resourceName : resourceSet) {
            final ConfigOption<String> configKeyOption =
                    key(ExternalResourceOptions.getSystemConfigKeyConfigOptionForResource(
                                    resourceName, suffix))
                            .stringType()
                            .noDefaultValue();
            final String configKey = config.get(configKeyOption);

            if (StringUtils.isNullOrWhitespaceOnly(configKey)) {
                LOG.warn(
                        "Could not find valid {} for {}. Will ignore that resource.",
                        configKeyOption.key(),
                        resourceName);
            } else {
                configKeysToResourceNameMap.compute(
                        configKey,
                        (ignored, previousResource) -> {
                            if (previousResource != null) {
                                LOG.warn(
                                        "Duplicate config key {} occurred for external resources, the one named {} will overwrite the value.",
                                        configKey,
                                        resourceName);
                                externalResourceConfigs.remove(previousResource);
                            }
                            return resourceName;
                        });
                externalResourceConfigs.put(resourceName, configKey);
            }
        }

        return externalResourceConfigs;
    }
@Test
    public void testGetExternalResourceConfigurationKeysWithConflictConfigKey() {
        final Configuration config = new Configuration();

        config.set(ExternalResourceOptions.EXTERNAL_RESOURCE_LIST, RESOURCE_LIST);
        config.setString(
                ExternalResourceOptions.getSystemConfigKeyConfigOptionForResource(
                        RESOURCE_NAME_1, SUFFIX),
                RESOURCE_CONFIG_KEY_1);
        config.setString(
                ExternalResourceOptions.getSystemConfigKeyConfigOptionForResource(
                        RESOURCE_NAME_2, SUFFIX),
                RESOURCE_CONFIG_KEY_1);

        final Map<String, String> configMap =
                ExternalResourceUtils.getExternalResourceConfigurationKeys(config, SUFFIX);

        // Only one of the resource name would be kept.
        assertThat(configMap.size(), is(1));
        assertThat(configMap.values(), contains(RESOURCE_CONFIG_KEY_1));
    }