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 java.util.ArrayList;
import java.util.List;

import org.junit.jupiter.api.Test;

/**
 * Tests für {@link CorrectionPlan}.
 */
class CorrectionPlanTest {

    @Test
    void empty_hasNoCorrections() {
        var plan = CorrectionPlan.empty();
        assertThat(plan.hasCorrections()).isFalse();
        assertThat(plan.size()).isZero();
        assertThat(plan.suggestions()).isEmpty();
    }

    @Test
    void plan_withSuggestions_hasCorrections() {
        var s = new CorrectionSuggestion.CreateDirectory("/path", "desc");
        var plan = new CorrectionPlan(List.of(s));
        assertThat(plan.hasCorrections()).isTrue();
        assertThat(plan.size()).isEqualTo(1);
    }

    @Test
    void suggestionsListIsImmutable() {
        var mutable = new ArrayList<CorrectionSuggestion>();
        mutable.add(new CorrectionSuggestion.CreateDirectory("/a", "d1"));
        var plan = new CorrectionPlan(mutable);
        mutable.add(new CorrectionSuggestion.CreatePromptFile("/b", "d2", 60));
        assertThat(plan.suggestions()).hasSize(1);
    }

    @Test
    void nullSuggestionsThrows() {
        assertThatNullPointerException()
                .isThrownBy(() -> new CorrectionPlan(null));
    }

    @Test
    void plan_equality() {
        var s = new CorrectionSuggestion.CreateDirectory("/path", "desc");
        var a = new CorrectionPlan(List.of(s));
        var b = new CorrectionPlan(List.of(s));
        assertThat(a).isEqualTo(b);
    }
}
