use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class DbTests method testgetAllVideos.
@Test
public void testgetAllVideos() throws Exception {
db.clearDataByUser(username);
db.getAllVideos(username, new DataCallback<List<VideoModel>>() {
@Override
public void onResult(List<VideoModel> result) {
assertNotNull(result);
assertTrue("there should not be any video present in cleared database", result.size() == 0);
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
DownloadEntry de = getDummyVideoModel();
db.addVideoData(de, null);
db.getAllVideos(username, new DataCallback<List<VideoModel>>() {
@Override
public void onResult(List<VideoModel> result) {
assertNotNull(result);
assertTrue(result.size() == 1);
// assertFalse("something is downloading", result);
print("result for getAllVideos :" + result.toString());
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
}
use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class DbTests method testgetVideosCountByChapter.
@Test
public void testgetVideosCountByChapter() throws Exception {
db.clearDataByUser(username);
String enrollmentId = "enrollmentId";
String chapter = "chapter";
db.getVideosCountByChapter(enrollmentId, chapter, new DataCallback<Integer>() {
@Override
public void onResult(Integer result) {
assertTrue(result == 0);
print("Videos Count By Chapter is: " + result.toString());
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
DownloadEntry de = getDummyVideoModel();
de.chapter = "chapter";
de.eid = "enrollmentId";
db.addVideoData(de, null);
db.getVideosCountByChapter(enrollmentId, chapter, new DataCallback<Integer>() {
@Override
public void onResult(Integer result) {
assertTrue(result == 1);
print("Videos Count By Chapter is: " + result.toString());
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
}
use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class DbTests method testDeleteVideo.
@Test
public void testDeleteVideo() throws Exception {
String videoId = "testVideoId";
db.clearDataByUser(username);
DownloadEntry de = getDummyVideoModel();
de.videoId = videoId;
Long rowId = db.addVideoData(de, null);
assertNotNull(rowId);
assertTrue("Row Id must be non zero positive number", rowId > 0);
VideoModel video = db.getVideoEntryByVideoId(videoId, null);
assertNotNull("Should have got one video object", video);
Integer count = db.deleteVideoByVideoId(video, null);
assertNotNull(count);
assertTrue("Should have deleted ONE video only", count == 1);
}
use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class DbTests method testisVideoDownloadingInSection.
@Test
public void testisVideoDownloadingInSection() throws Exception {
db.clearDataByUser(username);
String enrollmentId = "enrollmentId";
String chapter = "chapter";
final String section = "section";
db.isVideoDownloadingInSection(enrollmentId, chapter, section, new DataCallback<Boolean>() {
@Override
public void onResult(Boolean result) {
assertNotNull(result);
assertFalse("Video should not be downloading in section " + section, result);
print("got result for Video Downloading In assertfalse " + result.toString());
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
DownloadEntry de = getDummyVideoModel();
de.chapter = "chapter";
de.section = "section";
de.eid = "enrollmentId";
db.addVideoData(de, null);
db.isVideoDownloadingInSection(enrollmentId, chapter, section, new DataCallback<Boolean>() {
@Override
public void onResult(Boolean result) {
assertNotNull(result);
assertTrue(result);
// assertFalse("Video should not be downloading in section "+ section, result);
print("got result for Video Downloading In assertTrue " + result.toString());
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
}
use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class DbTests method testgetVideoCountByVideoUrl.
@Test
public void testgetVideoCountByVideoUrl() throws Exception {
db.clearDataByUser(username);
String videoUrl = "url";
db.getVideoCountByVideoUrl(videoUrl, new DataCallback<Integer>() {
@Override
public void onResult(Integer result) {
assertNotNull(result);
// assertNull("result should be null", result);
assertTrue(result == 0);
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
DownloadEntry de = getDummyVideoModel();
de.url = "http://fake/url";
db.addVideoData(de, null);
db.getVideoCountByVideoUrl(de.url, new DataCallback<Integer>() {
@Override
public void onResult(Integer result) {
assertNotNull(result);
assertTrue(result == 1);
print("Result for testgetVideoCountByVideoUrl is in 1:" + result);
unlock();
}
@Override
public void onFail(Exception ex) {
fail(ex.getMessage());
}
});
lock();
}
Aggregations