use of com.quran.labs.androidquran.dao.BookmarkData in project quran_android by quran.
the class BookmarkImportExportModelTest method testReadInvalidBookmarks.
@Test
public void testReadInvalidBookmarks() {
TestObserver<BookmarkData> testObserver = new TestObserver<>();
Buffer source = new Buffer();
source.writeUtf8(")");
bookmarkImportExportModel.readBookmarks(source).subscribe(testObserver);
testObserver.awaitTerminalEvent();
testObserver.assertValueCount(0);
testObserver.assertError(IOException.class);
}
use of com.quran.labs.androidquran.dao.BookmarkData in project quran_android by quran.
the class BookmarkPresenterTest method testBookmarkObservableAyahBookmarksGroupedByTag.
@Test
public void testBookmarkObservableAyahBookmarksGroupedByTag() {
BookmarkModel model = new BookmarkModel(bookmarksAdapter, recentPageModel) {
@Override
public Single<BookmarkData> getBookmarkDataObservable(int sortOrder) {
return Single.zip(Single.just(TAG_LIST), Single.just(AYAH_BOOKMARKS_LIST), Single.just(new ArrayList<>()), (Function3<List<Tag>, List<Bookmark>, List<RecentPage>, BookmarkData>) BookmarkData::new);
}
};
BookmarkPresenter presenter = makeBookmarkPresenter(model);
BookmarkResult result = getBookmarkResultByDateAndValidate(presenter, true);
assertThat(result.getTagMap()).hasSize(2);
// number of tags (or 1) for each bookmark, plus number of tags (headers), plus unsorted
assertThat(result.getRows()).hasSize(AYAH_BOOKMARKS_ROW_COUNT_WHEN_GROUPED_BY_TAG + TAG_LIST.size() + 1);
}
use of com.quran.labs.androidquran.dao.BookmarkData in project quran_android by quran.
the class BookmarkPresenterTest method testBookmarkObservableMixedBookmarksByDate.
@Test
public void testBookmarkObservableMixedBookmarksByDate() {
BookmarkModel model = new BookmarkModel(bookmarksAdapter, recentPageModel) {
@Override
public Single<BookmarkData> getBookmarkDataObservable(int sortOrder) {
return Single.zip(Single.just(new ArrayList<>()), Single.just(MIXED_BOOKMARKS_LIST), Single.just(new ArrayList<>()), (Function3<List<Tag>, List<Bookmark>, List<RecentPage>, BookmarkData>) BookmarkData::new);
}
};
BookmarkPresenter presenter = makeBookmarkPresenter(model);
BookmarkResult result = getBookmarkResultByDateAndValidate(presenter, false);
assertThat(result.getTagMap()).isEmpty();
// 1 for "page bookmarks" and 1 for "ayah bookmarks"
assertThat(result.getRows()).hasSize(MIXED_BOOKMARKS_LIST.size() + 2);
}
use of com.quran.labs.androidquran.dao.BookmarkData in project quran_android by quran.
the class BookmarkImportExportModelTest method testReadBookmarks.
@Test
public void testReadBookmarks() {
Buffer buffer = new Buffer().writeUtf8(TAGS_JSON);
TestObserver<BookmarkData> testObserver = new TestObserver<>();
bookmarkImportExportModel.readBookmarks(buffer).subscribe(testObserver);
testObserver.awaitTerminalEvent();
testObserver.assertValueCount(1);
testObserver.assertNoErrors();
}
use of com.quran.labs.androidquran.dao.BookmarkData in project quran_android by quran.
the class BookmarkPresenterTest method testBookmarkObservableAyahBookmarksByDate.
@Test
public void testBookmarkObservableAyahBookmarksByDate() {
BookmarkModel model = new BookmarkModel(bookmarksAdapter, recentPageModel) {
@Override
public Single<BookmarkData> getBookmarkDataObservable(int sortOrder) {
return Single.zip(Single.just(new ArrayList<>()), Single.just(AYAH_BOOKMARKS_LIST), Single.just(new ArrayList<>()), (Function3<List<Tag>, List<Bookmark>, List<RecentPage>, BookmarkData>) BookmarkData::new);
}
};
BookmarkPresenter presenter = makeBookmarkPresenter(model);
BookmarkResult result = getBookmarkResultByDateAndValidate(presenter, false);
assertThat(result.getTagMap()).isEmpty();
// 1 for the header, plus one row per item
assertThat(result.getRows()).hasSize(AYAH_BOOKMARKS_LIST.size() + 1);
}
Aggregations