Skip to content

Commit

Permalink
test(dao): video learning event dao
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-elimu committed Oct 23, 2024
1 parent e81b357 commit 88ab0c7
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/test/java/ai/elimu/dao/VideoLearningEventDaoJpaTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package ai.elimu.dao;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.util.Calendar;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

import ai.elimu.model.analytics.VideoLearningEvent;

@SpringJUnitConfig(locations = {
"file:src/main/webapp/WEB-INF/spring/applicationContext.xml",
"file:src/main/webapp/WEB-INF/spring/applicationContext-jpa.xml"
})
public class VideoLearningEventDaoJpaTest {

private Logger logger = LogManager.getLogger();

@Autowired
private VideoLearningEventDao videoLearningEventDao;

@Test
public void testRead() {
Calendar timestamp = Calendar.getInstance();
String androidId = "e387e38700000001";
String packageName = "ai.elimu.filamu";
String videoTitle = "akili and me - the rectangle song";

VideoLearningEvent existingEvent = videoLearningEventDao.read(
timestamp,
androidId,
packageName,
videoTitle
);
assertNull(existingEvent);

VideoLearningEvent event = new VideoLearningEvent();
event.setTimestamp(timestamp);
event.setAndroidId(androidId);
event.setPackageName(packageName);
event.setVideoTitle(videoTitle);
videoLearningEventDao.create(event);

existingEvent = videoLearningEventDao.read(
timestamp,
androidId,
packageName,
videoTitle
);
assertNotNull(existingEvent);
}
}

0 comments on commit 88ab0c7

Please sign in to comment.