/
marie.sidorkina
/
eye_tracking_java
Обзор
Документация
Войти
/
marie.sidorkina
/
eye_tracking_java
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/test/java/com/example/mydemo1/GazeAnalysisServiceTest.java
95 строк
3 KB
Marie
add tests
14 янв 2026, 11:17
14 янв 2026, 11:17
c2fa01e
Код
Авторство
О чём код?
package com.example.mydemo1; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.jetbrains.annotations.NotNull; import com.example.mydemo1.model.Chunk; import com.example.mydemo1.model.Gaze; import com.example.mydemo1.model.PredictionStatus; import com.example.mydemo1.service.GazeAnalysisService; import com.example.mydemo1.dto.AnalysisResult; import java.time.Instant; import java.util.List; import static org.junit.jupiter.api.Assertions.*; @SpringBootTest class GazeAnalysisServiceTest { private final GazeAnalysisService service = new GazeAnalysisService(); @Test void shouldClassifyRead() { Chunk chunk = chunkWithGazes(List.of( gaze(0, 100, 200), gaze(50, 110, 201), gaze(100, 120, 200), gaze(150, 130, 199), gaze(200, 140, 200) )); AnalysisResult res = service.analyzeChunk(chunk); assertEquals(PredictionStatus.CLASSIFIED_READ, res.getStatus(), "Prediction status should be CLASSIFIED_READ"); } @Test void shouldClassifyRegression() { Chunk chunk = chunkWithGazes(List.of( gaze(0, 200, 200), gaze(60, 210, 200), gaze(120, 220, 200), gaze(180, 190, 200) )); AnalysisResult res = service.analyzeChunk(chunk); assertEquals(PredictionStatus.CLASSIFIED_REGRESSION, res.getStatus(), "Prediction status should be CLASSIFIED_REGRESSION"); } @Test void shouldClassifyDistraction() { Chunk chunk = chunkWithGazes(List.of( gaze(0, 150, 200), gaze(200, 152, 199), gaze(400, 148, 201), gaze(600, 151, 198), gaze(800, 149, 202) )); AnalysisResult res = service.analyzeChunk(chunk); assertEquals(PredictionStatus.CLASSIFIED_DISTRACTION, res.getStatus(), "Prediction status should be CLASSIFIED_DISTRACTION"); } @Test void shouldClassifySaccade() { Chunk chunk = chunkWithGazes(List.of( gaze(0, 100, 200), gaze(10, 450, 200) )); AnalysisResult res = service.analyzeChunk(chunk); assertEquals(PredictionStatus.CLASSIFIED_SACCADE, res.getStatus(), "Prediction status should be CLASSIFIED_SACCADE"); } private @NotNull Chunk chunkWithGazes(List<Gaze> gazes) { Chunk c = new Chunk(); c.setGazes(gazes); return c; } private @NotNull Gaze gaze(long offsetMs, double x, double y) { Instant ts = Instant.ofEpochMilli(1_000_000 + offsetMs); return Gaze.createWithChunk( null, null, ts, x, y ); } }