public static boolean getBoolean(final Map<String, Object> configs, final String key, final boolean defaultValue) {
        final Object value = configs.getOrDefault(key, defaultValue);
        if (value instanceof Boolean) {
            return (boolean) value;
        } else if (value instanceof String) {
            return Boolean.parseBoolean((String) value);
        } else {
            log.error("Invalid value (" + value + ") on configuration '" + key + "'. The default value '" + defaultValue + "' will be used instead. Please specify a true/false value.");
            return defaultValue;
        }
    }
@Test
    public void testGetBoolean() {
        String key = "test.key";
        boolean defaultValue = true;

        Map<String, Object> config = new HashMap<>();
        config.put("some.other.key", false);
        assertEquals(defaultValue, ConfigUtils.getBoolean(config, key, defaultValue));

        config = new HashMap<>();
        config.put(key, false);
        assertFalse(ConfigUtils.getBoolean(config, key, defaultValue));

        config = new HashMap<>();
        config.put(key, "false");
        assertFalse(ConfigUtils.getBoolean(config, key, defaultValue));

        config = new HashMap<>();
        config.put(key, "not-a-boolean");
        assertFalse(ConfigUtils.getBoolean(config, key, defaultValue));

        config = new HashMap<>();
        config.put(key, 5);
        assertEquals(defaultValue, ConfigUtils.getBoolean(config, key, defaultValue));
    }