public ConfigDef define(ConfigKey key) {
        if (configKeys.containsKey(key.name)) {
            throw new ConfigException("Configuration " + key.name + " is defined twice.");
        }
        if (key.group != null && !groups.contains(key.group)) {
            groups.add(key.group);
        }
        configKeys.put(key.name, key);
        return this;
    }
@Test
    public void testDefinedTwice() {
        assertThrows(ConfigException.class, () -> new ConfigDef().define("a", Type.STRING,
            Importance.HIGH, "docs").define("a", Type.INT, Importance.HIGH, "docs"));
    }