Search in sources :

Example 31 with Card

use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.

the class CardDaoTest method testSearchPrevCard.

@SmallTest
@Test
public void testSearchPrevCard() throws Exception {
    CardDao cardDao = helper.getCardDao();
    Card c = cardDao.searchPrevCard("mouth", 10);
    assertEquals(8, (int) c.getId());
    c = cardDao.searchPrevCard("%oreille%", 28);
    assertEquals(11, (int) c.getId());
    c = cardDao.searchPrevCard("whatever", 27);
    assertNull(c);
    c = cardDao.searchPrevCard("mouth", 8);
    assertNull(c);
}
Also used : CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 32 with Card

use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.

the class CardDaoTest method testDeleteCardMaintainOrdinal.

@SmallTest
@Test
public void testDeleteCardMaintainOrdinal() throws Exception {
    CardDao cardDao = helper.getCardDao();
    Card c13 = cardDao.queryForId(13);
    Card c14 = cardDao.queryForId(14);
    Card c15 = cardDao.queryForId(15);
    assertEquals(13, (int) c13.getOrdinal());
    assertEquals(14, (int) c14.getOrdinal());
    assertEquals(15, (int) c15.getOrdinal());
    cardDao.delete(c14);
    c13 = cardDao.queryForId(13);
    c15 = cardDao.queryForId(15);
    assertEquals(13, (int) c13.getOrdinal());
    assertEquals(14, (int) c15.getOrdinal());
}
Also used : CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 33 with Card

use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.

the class CardDaoTest method testQueryPrevCardWithCategory.

@SmallTest
@Test
public void testQueryPrevCardWithCategory() throws Exception {
    setupThreeCategories();
    CardDao cardDao = helper.getCardDao();
    CategoryDao categoryDao = helper.getCategoryDao();
    List<Category> cts = categoryDao.queryForEq("name", "My category");
    Category ct = cts.get(0);
    Card c5 = cardDao.queryForId(5);
    Card c2 = cardDao.queryPrevCard(c5, ct);
    assertEquals(2, (int) c2.getId());
    Card c8 = cardDao.queryPrevCard(c2, ct);
    assertEquals(8, (int) c8.getId());
}
Also used : Category(org.liberty.android.fantastischmemo.entity.Category) CategoryDao(org.liberty.android.fantastischmemo.dao.CategoryDao) CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 34 with Card

use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.

the class CardDaoTest method testGetById.

@SmallTest
@Test
public void testGetById() {
    CardDao cardDao = helper.getCardDao();
    Card card = cardDao.getById(3);
    assertEquals(3, (int) card.getId());
}
Also used : CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 35 with Card

use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.

the class CardDaoTest method testGetCardsForReviewExclusionList.

@SmallTest
@Test
public void testGetCardsForReviewExclusionList() {
    // Setup cards that is schedule for review
    CardDao cardDao = helper.getCardDao();
    Card c13 = cardDao.queryForId(13);
    Card c14 = cardDao.queryForId(14);
    Card c15 = cardDao.queryForId(15);
    LearningDataDao learningDataDao = helper.getLearningDataDao();
    Date testDate = new Date((new Date().getTime() - 1));
    learningDataDao.refresh(c13.getLearningData());
    LearningData c13Ld = c13.getLearningData();
    c13Ld.setAcqReps(1);
    c13Ld.setNextLearnDate(testDate);
    c13Ld.setEasiness((float) 2.8);
    learningDataDao.update(c13Ld);
    learningDataDao.refresh(c14.getLearningData());
    LearningData c14Ld = c14.getLearningData();
    c14Ld.setAcqReps(1);
    c14Ld.setNextLearnDate(testDate);
    c14Ld.setEasiness((float) 2.6);
    learningDataDao.update(c14Ld);
    learningDataDao.refresh(c15.getLearningData());
    LearningData c15Ld = c15.getLearningData();
    c15Ld.setAcqReps(1);
    c15Ld.setNextLearnDate(testDate);
    c15Ld.setEasiness((float) 2.6);
    learningDataDao.update(c15Ld);
    // Create exclusion list
    List<Card> exclusionList = new ArrayList<Card>();
    exclusionList.add(c13);
    exclusionList.add(c15);
    List<Card> cards = cardDao.getCardsForReview(null, exclusionList, 50, ReviewOrdering.HardestFirst);
    // Only card 14 is there
    assertEquals(1, cards.size());
    assertEquals(14, (int) cards.get(0).getId());
}
Also used : ArrayList(java.util.ArrayList) LearningDataDao(org.liberty.android.fantastischmemo.dao.LearningDataDao) LearningData(org.liberty.android.fantastischmemo.entity.LearningData) CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Date(java.util.Date) Card(org.liberty.android.fantastischmemo.entity.Card) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Aggregations

Card (org.liberty.android.fantastischmemo.entity.Card)95 CardDao (org.liberty.android.fantastischmemo.dao.CardDao)61 SmallTest (android.support.test.filters.SmallTest)43 Test (org.junit.Test)43 AbstractExistingDBTest (org.liberty.android.fantastischmemo.test.AbstractExistingDBTest)41 Category (org.liberty.android.fantastischmemo.entity.Category)30 AnyMemoDBOpenHelper (org.liberty.android.fantastischmemo.common.AnyMemoDBOpenHelper)28 LearningData (org.liberty.android.fantastischmemo.entity.LearningData)25 CategoryDao (org.liberty.android.fantastischmemo.dao.CategoryDao)20 LearningDataDao (org.liberty.android.fantastischmemo.dao.LearningDataDao)13 File (java.io.File)12 ArrayList (java.util.ArrayList)11 SQLException (java.sql.SQLException)9 QueueManager (org.liberty.android.fantastischmemo.queue.QueueManager)9 IOException (java.io.IOException)6 Date (java.util.Date)6 LearnQueueManager (org.liberty.android.fantastischmemo.queue.LearnQueueManager)6 URL (java.net.URL)5 FileWriter (java.io.FileWriter)4 Scheduler (org.liberty.android.fantastischmemo.scheduler.Scheduler)4