package com.lingniu.ingest.sink.kafka;

import org.junit.jupiter.api.Test;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;

import static org.assertj.core.api.Assertions.assertThat;

class KafkaSinkPropertiesTest {

    @Test
    void defaultKafkaBrokerUsesProductionAddressButCanStillBeOverriddenByConfigBinding() {
        KafkaSinkProperties props = new KafkaSinkProperties();

        assertThat(props.getBootstrapServers()).isEqualTo("114.55.58.251:9092");

        props.setBootstrapServers("kafka.internal:9092");
        assertThat(props.getBootstrapServers()).isEqualTo("kafka.internal:9092");
    }

    @Test
    void exposesNoBackendTypeBecauseKafkaIsTheOnlySink() {
        assertThat(Arrays.stream(KafkaSinkProperties.class.getMethods()).map(method -> method.getName()))
                .doesNotContain("getType", "setType");
    }

    @Test
    void sourceCommentsDoNotDescribeKafkaDisabledAsNoopEventDropping() throws Exception {
        String source = Files.readString(Path.of(
                "src/main/java/com/lingniu/ingest/sink/kafka/KafkaSinkProperties.java"));

        assertThat(source)
                .doesNotContain("Noop")
                .doesNotContain("吞掉")
                .doesNotContain("外部 sink");
    }
}
