package de.gecheckt.pdf.umbenenner.application.validation.technicaltest;

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

import org.junit.jupiter.api.Test;

import de.gecheckt.pdf.umbenenner.application.port.out.modelcatalog.EffectiveApiKeyDescriptor;
import de.gecheckt.pdf.umbenenner.application.validation.editor.EditorValidationInput;

/**
 * Tests für {@link TechnicalTestRequest}.
 */
class TechnicalTestRequestTest {

    private static EditorValidationInput minimalInput() {
        return new EditorValidationInput(
                "claude", "", "", "", "", "3", "10", "2000", "60",
                "", "model-x", "60", EffectiveApiKeyDescriptor.absent(), "",
                "", "", "60", EffectiveApiKeyDescriptor.absent(), "");
    }

    @Test
    void of_setsEmptyConfigFilePath() {
        var request = TechnicalTestRequest.of(minimalInput());
        assertThat(request.configFilePath()).isEmpty();
        assertThat(request.hasConfigFilePath()).isFalse();
    }

    @Test
    void withConfigFilePath_detectedAsPresent() {
        var request = new TechnicalTestRequest(minimalInput(), "/config/app.properties", "");
        assertThat(request.hasConfigFilePath()).isTrue();
        assertThat(request.configFilePath()).isEqualTo("/config/app.properties");
    }

    @Test
    void nullConfigFilePath_normalisedToEmpty() {
        var request = new TechnicalTestRequest(minimalInput(), null, null);
        assertThat(request.configFilePath()).isEmpty();
        assertThat(request.hasConfigFilePath()).isFalse();
    }

    @Test
    void withLogDirectory_preservedAsIs() {
        var request = new TechnicalTestRequest(minimalInput(), "", "C:/logs");
        assertThat(request.logDirectory()).isEqualTo("C:/logs");
    }

    @Test
    void nullLogDirectory_normalisedToEmpty() {
        var request = new TechnicalTestRequest(minimalInput(), "", null);
        assertThat(request.logDirectory()).isEmpty();
    }

    @Test
    void nullValidationInputThrows() {
        assertThatNullPointerException()
                .isThrownBy(() -> TechnicalTestRequest.of(null));
    }
}
