use of com.quran.labs.androidquran.dao.BookmarkData in project quran_android by quran.
the class BookmarkPresenterTest method testBookmarkObservableMixedBookmarksGroupedByTagWithRecentPage.
@Test
public void testBookmarkObservableMixedBookmarksGroupedByTagWithRecentPage() {
BookmarkModel model = new BookmarkModel(bookmarksAdapter, recentPageModel) {
@Override
public Single<BookmarkData> getBookmarkDataObservable(int sortOrder) {
return Single.zip(Single.just(TAG_LIST), Single.just(MIXED_BOOKMARKS_LIST), Single.just(RECENTS_LIST), 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, plus
// current page header, plus current page
assertThat(result.getRows()).hasSize(MIXED_BOOKMARKS_ROW_COUNT_WHEN_GROUPED_BY_TAG + TAG_LIST.size() + 1 + 2);
}
use of com.quran.labs.androidquran.dao.BookmarkData in project quran_android by quran.
the class BookmarkPresenterTest method testBookmarkObservableMixedBookmarksGroupedByTag.
@Test
public void testBookmarkObservableMixedBookmarksGroupedByTag() {
BookmarkModel model = new BookmarkModel(bookmarksAdapter, recentPageModel) {
@Override
public Single<BookmarkData> getBookmarkDataObservable(int sortOrder) {
return Single.zip(Single.just(TAG_LIST), 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, 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(MIXED_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 testBookmarkObservableMixedBookmarksByDateWithRecentPage.
@Test
public void testBookmarkObservableMixedBookmarksByDateWithRecentPage() {
BookmarkModel model = new BookmarkModel(bookmarksAdapter, recentPageModel) {
@Override
public Single<BookmarkData> getBookmarkDataObservable(int sortOrder) {
return Single.zip(Single.just(TAG_LIST), Single.just(MIXED_BOOKMARKS_LIST), Single.just(RECENTS_LIST), BookmarkData::new);
}
};
when(settings.getLastPage()).thenReturn(42);
BookmarkPresenter presenter = makeBookmarkPresenter(model);
BookmarkResult result = getBookmarkResultByDateAndValidate(presenter, false);
assertThat(result.getTagMap()).hasSize(2);
// 2 for "current page", 1 for "page bookmarks" and 1 for "ayah bookmarks"
assertThat(result.getRows()).hasSize(MIXED_BOOKMARKS_LIST.size() + 4);
}
use of com.quran.labs.androidquran.dao.BookmarkData in project quran_android by quran.
the class BookmarkJsonModelTest method simpleTestToJson.
@Test
public void simpleTestToJson() throws IOException {
BookmarkData data = new BookmarkData(TAGS, new ArrayList<>(), new ArrayList<>());
Buffer output = new Buffer();
jsonModel.toJson(output, data);
String result = output.readUtf8();
assertThat(result).isEqualTo(TAGS_JSON);
}
use of com.quran.labs.androidquran.dao.BookmarkData in project quran_android by quran.
the class BookmarkJsonModelTest method simpleTestFromJson.
@Test
public void simpleTestFromJson() throws IOException {
Buffer buffer = new Buffer().writeUtf8(TAGS_JSON);
BookmarkData data = jsonModel.fromJson(buffer);
assertThat(data).isNotNull();
assertThat(data.getBookmarks()).isEmpty();
assertThat(data.getTags()).hasSize(TAGS.size());
assertThat(data.getTags()).isEqualTo(TAGS);
}
Aggregations