001package com.studentgui.test;
002
003import static org.junit.jupiter.api.Assertions.assertNotNull;
004
005import java.time.LocalDate;
006import java.util.List;
007
008import org.junit.jupiter.api.Test;
009
010import com.studentgui.apphelpers.Helpers;
011import com.studentgui.apphelpers.SqlGenerate;
012import com.studentgui.apppages.JLineGraph;
013
014/**
015 * JUnit replacement for the legacy Braille smoke main. Exercises the
016 * normalized database APIs and invokes JLineGraph.updateWithData(...) to
017 * verify plumbing without launching the full GUI.
018 */
019public class BrailleSmokeTest {
020
021    @Test
022    /**
023     * Basic smoke test validating database initialization and graph rendering
024     * for a minimal usage scenario. Ensures no exceptions are thrown.
025     */
026
027    public void smokeTestDatabaseAndGraph() throws Exception {
028        Helpers.createFolderHierarchy();
029        SqlGenerate.initializeDatabase();
030
031        int studentId = com.studentgui.apphelpers.Database.getOrCreateStudent("JUnit Smoke Student");
032        int ptId = com.studentgui.apphelpers.Database.getOrCreateProgressType("Braille");
033
034        String[] codes = new String[28];
035        int[] scores = new int[28];
036        for (int i = 0; i < 28; i++) { codes[i] = "P" + (i+1); scores[i] = (i % 5) + 1; }
037        com.studentgui.apphelpers.Database.ensureAssessmentParts(ptId, codes);
038        int sessionId = com.studentgui.apphelpers.Database.createProgressSession(studentId, ptId, LocalDate.now());
039        com.studentgui.apphelpers.Database.insertAssessmentResults(sessionId, ptId, codes, scores);
040
041        List<List<Integer>> allSkillValues = com.studentgui.apphelpers.Database.fetchLatestAssessmentResults("JUnit Smoke Student", "Braille", 5);
042        assertNotNull(allSkillValues);
043
044        JLineGraph graph = new JLineGraph();
045        graph.updateWithData(allSkillValues);
046    }
047}