Search in sources :

Example 1 with MadaniPageProvider

use of com.quran.data.page.provider.madani.MadaniPageProvider in project quran_android by quran.

the class ArabicDatabaseUtilsTest method testHydrateAyahTextEmpty.

@Test
public void testHydrateAyahTextEmpty() {
    ArabicDatabaseUtils arabicDatabaseUtils = new ArabicDatabaseUtils(context, new QuranInfo(new MadaniPageProvider()), mock(QuranFileUtils.class)) {

        @Override
        DatabaseHandler getArabicDatabaseHandler() {
            return arabicHandler;
        }

        @Override
        Map<Integer, String> getAyahTextForAyat(List<Integer> ayat) {
            Map<Integer, String> result = new HashMap<>();
            for (Integer ayahId : ayat) {
                result.put(ayahId, "verse " + ayahId);
            }
            return result;
        }
    };
    List<Bookmark> bookmarks = new ArrayList<>(1);
    bookmarks.add(new Bookmark(1, null, null, 3));
    List<Bookmark> result = arabicDatabaseUtils.hydrateAyahText(bookmarks);
    assertThat(result).hasSize(1);
    assertThat(result.get(0)).isNotInstanceOf(BookmarkWithAyahText.class);
    assertThat(result.get(0).getAyahText()).isNull();
    assertThat(result).isSameAs(bookmarks);
}
Also used : MadaniPageProvider(com.quran.data.page.provider.madani.MadaniPageProvider) Bookmark(com.quran.labs.androidquran.dao.Bookmark) HashMap(java.util.HashMap) QuranInfo(com.quran.labs.androidquran.data.QuranInfo) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) QuranFileUtils(com.quran.labs.androidquran.util.QuranFileUtils) Test(org.junit.Test)

Example 2 with MadaniPageProvider

use of com.quran.data.page.provider.madani.MadaniPageProvider in project quran_android by quran.

the class ArabicDatabaseUtilsTest method testHydrateAyahText.

@Test
public void testHydrateAyahText() {
    ArabicDatabaseUtils arabicDatabaseUtils = new ArabicDatabaseUtils(context, new QuranInfo(new MadaniPageProvider()), mock(QuranFileUtils.class)) {

        @Override
        DatabaseHandler getArabicDatabaseHandler() {
            return arabicHandler;
        }

        @Override
        Map<Integer, String> getAyahTextForAyat(List<Integer> ayat) {
            Map<Integer, String> result = new HashMap<>();
            for (Integer ayahId : ayat) {
                result.put(ayahId, "verse " + ayahId);
            }
            return result;
        }
    };
    List<Bookmark> bookmarks = new ArrayList<>(3);
    bookmarks.add(new Bookmark(1, 1, 1, 1));
    bookmarks.add(new Bookmark(2, null, null, 3));
    bookmarks.add(new Bookmark(3, 114, 6, 604));
    List<Bookmark> result = arabicDatabaseUtils.hydrateAyahText(bookmarks);
    assertThat(result).hasSize(3);
    assertThat(result.get(0)).isInstanceOf(BookmarkWithAyahText.class);
    assertThat(result.get(1)).isNotInstanceOf(BookmarkWithAyahText.class);
    assertThat(result.get(2)).isInstanceOf(BookmarkWithAyahText.class);
    assertThat(result.get(0).getAyahText()).isNotEmpty();
    assertThat(result.get(1).getAyahText()).isNull();
    assertThat(result.get(0).getAyahText()).isNotEmpty();
    assertThat(result).isNotSameAs(bookmarks);
}
Also used : MadaniPageProvider(com.quran.data.page.provider.madani.MadaniPageProvider) Bookmark(com.quran.labs.androidquran.dao.Bookmark) HashMap(java.util.HashMap) QuranInfo(com.quran.labs.androidquran.data.QuranInfo) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) QuranFileUtils(com.quran.labs.androidquran.util.QuranFileUtils) Test(org.junit.Test)

Aggregations

MadaniPageProvider (com.quran.data.page.provider.madani.MadaniPageProvider)2 Bookmark (com.quran.labs.androidquran.dao.Bookmark)2 QuranInfo (com.quran.labs.androidquran.data.QuranInfo)2 QuranFileUtils (com.quran.labs.androidquran.util.QuranFileUtils)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Test (org.junit.Test)2