Repository: apache/kafka
File: storage/src/test/java/org/apache/kafka/server/log/remote/metadata/storage/TopicBasedRemoteLogMetadataManagerConfigTest.java (Java)

Code before:
        config.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, "keystorePassword");
        config.put(SslConfigs.SSL_KEY_PASSWORD_CONFIG, "keyPassword");
        config.put(SslConfigs.SSL_KEYSTORE_KEY_CONFIG, "keystoreKey");
        config.put(SslConfigs.SSL_KEYSTORE_CERTIFICATE_CHAIN_CONFIG, "keystoreCertificate");
        config.put(SslConfigs.SSL_TRUSTSTORE_CERTIFICATES_CONFIG, "truststoreCertificate");
        config.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "truststorePassword");
        config.put(SaslConfigs.SASL_JAAS_CONFIG, "saslJaas");
    }

    private void assertMaskedSensitiveConfigurations(String configString) {
        String[] sensitiveConfigKeys = {
            SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG,
            SslConfigs.SSL_KEY_PASSWORD_CONFIG,
            SslConfigs.SSL_KEYSTORE_KEY_CONFIG,
            SslConfigs.SSL_KEYSTORE_CERTIFICATE_CHAIN_CONFIG,
            SslConfigs.SSL_TRUSTSTORE_CERTIFICATES_CONFIG,
            SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG,
            SaslConfigs.SASL_JAAS_CONFIG
        };
        Arrays.stream(sensitiveConfigKeys)
                .forEach(config -> assertTrue(configString.contains(config + "=(redacted)")));
    }

    @Test
    public void testDefaultMinIsr() {
        Map<String, Object> props = createValidConfigProps(new HashMap<>(), new HashMap<>(), new HashMap<>());
        TopicBasedRemoteLogMetadataManagerConfig rlmmConfig = new TopicBasedRemoteLogMetadataManagerConfig(props);
        assertEquals(DEFAULT_REMOTE_LOG_METADATA_TOPIC_MIN_ISR, rlmmConfig.metadataTopicMinIsr());
    }

    @Test
    public void testCustomMinIsr() {
        Map<String, Object> props = createValidConfigProps(new HashMap<>(), new HashMap<>(), new HashMap<>());
        short customMinIsr = 3;
        props.put(REMOTE_LOG_METADATA_TOPIC_MIN_ISR_PROP, customMinIsr);
        TopicBasedRemoteLogMetadataManagerConfig rlmmConfig = new TopicBasedRemoteLogMetadataManagerConfig(props);
        assertEquals(customMinIsr, rlmmConfig.metadataTopicMinIsr());
    }
}

Review comment (suggestion):
Instead of `new HashMap<>`, can it be replaced with `Collections.emptyMap`


```suggestion
        Map<String, Object> props = createValidConfigProps(Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap());
```

Code after:

    /**
     * Sample properties marked with {@link org.apache.kafka.common.config.ConfigDef.Type#PASSWORD} in the configuration.
     */
    private void addPasswordTypeConfigurationProperties(Map<String, Object> config) {
        config.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, "keystorePassword");
        config.put(SslConfigs.SSL_KEY_PASSWORD_CONFIG, "keyPassword");
        config.put(SslConfigs.SSL_KEYSTORE_KEY_CONFIG, "keystoreKey");
        config.put(SslConfigs.SSL_KEYSTORE_CERTIFICATE_CHAIN_CONFIG, "keystoreCertificate");
        config.put(SslConfigs.SSL_TRUSTSTORE_CERTIFICATES_CONFIG, "truststoreCertificate");
        config.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "truststorePassword");
        config.put(SaslConfigs.SASL_JAAS_CONFIG, "saslJaas");
    }

    private void assertMaskedSensitiveConfigurations(String configString) {
        String[] sensitiveConfigKeys = {
            SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG,
            SslConfigs.SSL_KEY_PASSWORD_CONFIG,
            SslConfigs.SSL_KEYSTORE_KEY_CONFIG,
            SslConfigs.SSL_KEYSTORE_CERTIFICATE_CHAIN_CONFIG,
            SslConfigs.SSL_TRUSTSTORE_CERTIFICATES_CONFIG,
            SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG,
            SaslConfigs.SASL_JAAS_CONFIG
        };
        Arrays.stream(sensitiveConfigKeys)
                .forEach(config -> assertTrue(configString.contains(config + "=(redacted)")));
    }

    @Test
    public void testDefaultMinIsr() {
        Map<String, Object> props = createValidConfigProps();
        TopicBasedRemoteLogMetadataManagerConfig rlmmConfig = new TopicBasedRemoteLogMetadataManagerConfig(props);
        assertEquals(DEFAULT_REMOTE_LOG_METADATA_TOPIC_MIN_ISR, rlmmConfig.metadataTopicMinIsr());
    }

    @Test
    public void testCustomMinIsr() {
        Map<String, Object> props = createValidConfigProps();
        short customMinIsr = 3;
        props.put(REMOTE_LOG_METADATA_TOPIC_MIN_ISR_PROP, customMinIsr);
        TopicBasedRemoteLogMetadataManagerConfig rlmmConfig = new TopicBasedRemoteLogMetadataManagerConfig(props);
        assertEquals(customMinIsr, rlmmConfig.metadataTopicMinIsr());
    }
}