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 testThrowsExceptionWhenListSizeExceedsLimit() {
        final ConfigException exception = assertThrows(ConfigException.class, () -> new ConfigDef().define("lst",
                                                                                                           Type.LIST,
                                                                                                           asList("a", "b"),
                                                                                                           ListSize.atMostOfSize(1),
                                                                                                           Importance.HIGH,
                                                                                                           "lst doc"));
        assertEquals("Invalid value [a, b] for configuration lst: exceeds maximum list size of [1].",
                     exception.getMessage());
    }