package pa1;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
 * Sample test class for AccessibilityAssessment.
 * Students should use these examples as reference to write additional test cases
 * that achieve full statement and branch coverage.
 */
class AccessibilityAssessmentTest {
    private AccessibilityAssessment aa1;
    private final static String[] RESULT_VALUES = { "error", "error_paid", "warning", "manual", "identified", "notfound" };
    private static final String DESC_1 = "Content: Plain language is not used";

    @BeforeEach
    void setUp() throws Exception {
        // Example: Create test objects with known values
        aa1 = new AccessibilityAssessment(RESULT_VALUES[0], RESULT_VALUES[1], RESULT_VALUES[2], RESULT_VALUES[3], DESC_1);
    }

    @Test
    void testConstructorAndAccessors() {
        // Example: Test that constructor stores values correctly and accessors return them
        assertEquals(RESULT_VALUES[0], aa1.getGoogleResult(), "getGoogleResult() should match first constructor arg");
        assertEquals(RESULT_VALUES[1], aa1.getWaveResult(), "getWaveResult() should match second constructor arg");
        assertEquals(DESC_1, aa1.getDescription(), "getDescription() should match fifth constructor arg");

        // TODO: Students should add tests for getSortsiteResult() and getAslintResult()
        // TODO: Students should test with different constructor parameter combinations
    }

    @Test
    void testConstructorValidation() {
        // Example: Test that constructor properly validates parameters
        assertThrows(IllegalArgumentException.class, () ->
            new AccessibilityAssessment(null, "error", "warning", "notfound", "desc"),
            "Constructor should reject null parameters");

        assertThrows(IllegalArgumentException.class, () ->
            new AccessibilityAssessment("invalid", "error", "warning", "notfound", "desc"),
            "Constructor should reject invalid checker results");

        // TODO: Students should test null validation for all parameters
        // TODO: Students should test invalid values for all checker result parameters
        // TODO: Students should test that all valid results are accepted
    }

    @Test
    void testFoundError() {
        // Example: Test foundError method with various scenarios
        AccessibilityAssessment aa = new AccessibilityAssessment("notfound", "error", "error_paid", "warning", "Test description");

        // Test that it finds errors correctly
        assertFalse(aa.foundError("google"), "Google has 'notfound', should return false");
        assertTrue(aa.foundError("wave"), "WAVE has 'error', should return true");
        assertTrue(aa.foundError("sortsite"), "SortSite has 'error_paid', should return true");
        assertFalse(aa.foundError("aslint"), "ASLint has 'warning', should return false");

        // Test case insensitivity and partial matching
        assertTrue(aa.foundError("WAVE"), "Should be case insensitive");
        assertTrue(aa.foundError("sort"), "Should work with partial names");

        // Test invalid checker name
        assertThrows(IllegalArgumentException.class, () -> aa.foundError("invalid"),
            "Should throw exception for invalid checker name");

        // TODO: Students should test foundError with null parameter
        // TODO: Students should test all valid checker names and partial names
        // TODO: Students should test the "first match" behavior when partial names match multiple checkers
        // TODO: Students should verify the exception message is "Invalid String Parameter"
    }

    // TODO: Students should add tests for:
    // - toString() method (verify exact format)
    // - equals() method (same object, same values, different values, null, different class)
    // - Edge cases and comprehensive parameter validation
    // - All valid checker result values are accepted by constructor

}
