-
-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathCsvAnalyticsExtractionHelperTest.java
More file actions
175 lines (149 loc) · 9.73 KB
/
CsvAnalyticsExtractionHelperTest.java
File metadata and controls
175 lines (149 loc) · 9.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package ai.elimu.util.csv;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassRelativeResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import ai.elimu.entity.analytics.LetterSoundLearningEvent;
import ai.elimu.entity.analytics.StoryBookLearningEvent;
import ai.elimu.entity.analytics.VideoLearningEvent;
import ai.elimu.entity.analytics.WordAssessmentEvent;
import ai.elimu.entity.analytics.WordLearningEvent;
import ai.elimu.model.v2.enums.analytics.LearningEventType;
public class CsvAnalyticsExtractionHelperTest {
/**
* Test extraction of data from CSV files generated by version 3002014 of the Analytics app:
* https://github.com/elimu-ai/analytics/releases/tag/3.2.14
*/
@Test
public void testExtractLetterSoundLearningEvents_v3002014() throws IOException {
ResourceLoader resourceLoader = new ClassRelativeResourceLoader(CsvAnalyticsExtractionHelper.class);
Resource resource = resourceLoader.getResource("5b7c682a12ecbe2e_3002014_letter-sound-learning-events_2025-05-11.csv");
File csvFile = resource.getFile();
List<LetterSoundLearningEvent> letterSoundLearningEvents = CsvAnalyticsExtractionHelper.extractLetterSoundLearningEvents(csvFile);
assertEquals(6, letterSoundLearningEvents.size());
LetterSoundLearningEvent letterSoundLearningEvent = letterSoundLearningEvents.get(0);
assertEquals(1746952025000L, letterSoundLearningEvent.getTimestamp().getTimeInMillis());
assertEquals("5b7c682a12ecbe2e", letterSoundLearningEvent.getAndroidId());
assertEquals("ai.elimu.herufi.debug", letterSoundLearningEvent.getPackageName());
assertEquals(300, letterSoundLearningEvent.getLetterSoundId());
}
/**
* Test extraction of data from CSV files generated by version 3001030 of the Analytics app:
* https://github.com/elimu-ai/analytics/releases/tag/3.1.30
*/
@Test
public void testExtractWordAssessmentEvents_v3001030() throws IOException {
ResourceLoader resourceLoader = new ClassRelativeResourceLoader(CsvAnalyticsExtractionHelper.class);
Resource resource = resourceLoader.getResource("1bb5b718814899b5_3001030_word-assessment-events_2025-03-19.csv");
File csvFile = resource.getFile();
List<WordAssessmentEvent> wordAssessmentEvents = CsvAnalyticsExtractionHelper.extractWordAssessmentEvents(csvFile);
assertEquals(1, wordAssessmentEvents.size());
WordAssessmentEvent wordAssessmentEvent = wordAssessmentEvents.get(0);
assertEquals(1742402392000L, wordAssessmentEvent.getTimestamp().getTimeInMillis());
assertEquals("1bb5b718814899b5", wordAssessmentEvent.getAndroidId());
assertEquals("ai.elimu.kukariri.debug", wordAssessmentEvent.getPackageName());
assertEquals("aso", wordAssessmentEvent.getWordText());
assertEquals(1, wordAssessmentEvent.getWordId());
assertEquals(1.0F, wordAssessmentEvent.getMasteryScore());
assertEquals(25457, wordAssessmentEvent.getTimeSpentMs());
}
/**
* Test extraction of data from CSV files generated by version 3001018 of the Analytics app:
* https://github.com/elimu-ai/analytics/releases/tag/3.1.18
*/
@Test
public void testExtractVideoLearningEvents_v3001018() throws IOException {
ResourceLoader resourceLoader = new ClassRelativeResourceLoader(CsvAnalyticsExtractionHelper.class);
Resource resource = resourceLoader.getResource("e387e38700000001_3001018_video-learning-events_2024-10-09.csv");
File csvFile = resource.getFile();
List<VideoLearningEvent> videoLearningEvents = CsvAnalyticsExtractionHelper.extractVideoLearningEvents(csvFile);
assertEquals(6, videoLearningEvents.size());
VideoLearningEvent videoLearningEvent = videoLearningEvents.get(0);
assertEquals(1728486312000L, videoLearningEvent.getTimestamp().getTimeInMillis());
assertEquals("e387e38700000001", videoLearningEvent.getAndroidId());
assertEquals("ai.elimu.filamu", videoLearningEvent.getPackageName());
assertEquals("akili and me - the rectangle song", videoLearningEvent.getVideoTitle());
assertEquals(13, videoLearningEvent.getVideoId());
assertEquals(LearningEventType.VIDEO_OPENED, videoLearningEvent.getLearningEventType());
}
/**
* Test extraction of data from CSV files generated by version 3001030 of the Analytics app:
* https://github.com/elimu-ai/analytics/releases/tag/3.1.30
*/
@Test
public void testExtractWordLearningEvents_v3001030() throws IOException {
ResourceLoader resourceLoader = new ClassRelativeResourceLoader(CsvAnalyticsExtractionHelper.class);
Resource resource = resourceLoader.getResource("5b7c682a12ecbe2e_3001030_word-learning-events_2025-03-18.csv");
File csvFile = resource.getFile();
List<WordLearningEvent> wordLearningEvents = CsvAnalyticsExtractionHelper.extractWordLearningEvents(csvFile);
assertEquals(143, wordLearningEvents.size());
WordLearningEvent wordLearningEvent = wordLearningEvents.get(0);
assertEquals(1742293958000L, wordLearningEvent.getTimestamp().getTimeInMillis());
assertEquals("5b7c682a12ecbe2e", wordLearningEvent.getAndroidId());
assertEquals("ai.elimu.vitabu.debug", wordLearningEvent.getPackageName());
assertEquals("ฉัน", wordLearningEvent.getWordText());
// assertEquals(36, wordLearningEvent.getWordId());
assertEquals(LearningEventType.WORD_PRESSED, wordLearningEvent.getLearningEventType());
}
/**
* Test extraction of data from CSV files generated by version 3001030 of the Analytics app:
* https://github.com/elimu-ai/analytics/releases/tag/3.1.30
*/
@Test
public void testExtractStoryBookLearningEvents_v3001030() throws IOException {
ResourceLoader resourceLoader = new ClassRelativeResourceLoader(CsvAnalyticsExtractionHelper.class);
Resource resource = resourceLoader.getResource("5b7c682a12ecbe2e_3001030_storybook-learning-events_2025-03-18.csv");
File csvFile = resource.getFile();
List<StoryBookLearningEvent> storyBookLearningEvents = CsvAnalyticsExtractionHelper.extractStoryBookLearningEvents(csvFile);
assertEquals(8, storyBookLearningEvents.size());
StoryBookLearningEvent storyBookLearningEvent = storyBookLearningEvents.get(0);
assertEquals(1742293901000L, storyBookLearningEvent.getTimestamp().getTimeInMillis());
assertEquals("5b7c682a12ecbe2e", storyBookLearningEvent.getAndroidId());
assertEquals("ai.elimu.vitabu.debug", storyBookLearningEvent.getPackageName());
assertEquals("", storyBookLearningEvent.getStoryBookTitle());
assertEquals(2, storyBookLearningEvent.getStoryBookId());
assertEquals(LearningEventType.STORYBOOK_OPENED, storyBookLearningEvent.getLearningEventType());
}
/**
* Test extraction of data from CSV files generated by version 3002014 of the Analytics app:
* https://github.com/elimu-ai/analytics/releases/tag/3.2.14
*/
@Test
public void testExtractStoryBookLearningEvents_v3002014() throws IOException {
ResourceLoader resourceLoader = new ClassRelativeResourceLoader(CsvAnalyticsExtractionHelper.class);
Resource resource = resourceLoader.getResource("5b7c682a12ecbe2e_3002014_storybook-learning-events_2025-05-26.csv");
File csvFile = resource.getFile();
List<StoryBookLearningEvent> storyBookLearningEvents = CsvAnalyticsExtractionHelper.extractStoryBookLearningEvents(csvFile);
assertEquals(2, storyBookLearningEvents.size());
StoryBookLearningEvent storyBookLearningEvent = storyBookLearningEvents.get(0);
assertEquals(1748252197000L, storyBookLearningEvent.getTimestamp().getTimeInMillis());
assertEquals("5b7c682a12ecbe2e", storyBookLearningEvent.getAndroidId());
assertEquals("ai.elimu.vitabu.debug", storyBookLearningEvent.getPackageName());
assertEquals("", storyBookLearningEvent.getStoryBookTitle());
assertEquals(31, storyBookLearningEvent.getStoryBookId());
assertEquals(LearningEventType.STORYBOOK_OPENED, storyBookLearningEvent.getLearningEventType());
}
/**
* Test extraction of data from CSV files generated by version 3003000 of the Analytics app:
* https://github.com/elimu-ai/analytics/releases/tag/3.3.0
*/
@Test
public void testExtractStoryBookLearningEvents_v3003000() throws IOException {
ResourceLoader resourceLoader = new ClassRelativeResourceLoader(CsvAnalyticsExtractionHelper.class);
Resource resource = resourceLoader.getResource("5b7c682a12ecbe2e_3003000_storybook-learning-events_2025-06-03.csv");
File csvFile = resource.getFile();
List<StoryBookLearningEvent> storyBookLearningEvents = CsvAnalyticsExtractionHelper.extractStoryBookLearningEvents(csvFile);
assertEquals(2, storyBookLearningEvents.size());
StoryBookLearningEvent storyBookLearningEvent = storyBookLearningEvents.get(0);
assertEquals(1748252197000L, storyBookLearningEvent.getTimestamp().getTimeInMillis());
assertEquals("5b7c682a12ecbe2e", storyBookLearningEvent.getAndroidId());
assertEquals("ai.elimu.vitabu.debug", storyBookLearningEvent.getPackageName());
assertEquals("กลโกงเจ้าจิ้งจอก", storyBookLearningEvent.getStoryBookTitle());
assertEquals(31, storyBookLearningEvent.getStoryBookId());
assertEquals(LearningEventType.STORYBOOK_OPENED, storyBookLearningEvent.getLearningEventType());
}
}