Search in sources :

Example 46 with CardDao

use of org.liberty.android.fantastischmemo.dao.CardDao in project AnyMemo by helloworld1.

the class CardDaoTest method testGetAllCardWithoutFilteringCategory.

@SmallTest
@Test
public void testGetAllCardWithoutFilteringCategory() throws SQLException {
    setupThreeCategories();
    CardDao cardDao = helper.getCardDao();
    List<Card> cards = cardDao.getAllCards(null);
    assertEquals(28, (int) cards.size());
}
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 47 with CardDao

use of org.liberty.android.fantastischmemo.dao.CardDao in project AnyMemo by helloworld1.

the class CategoryTest method testRemoveCategories.

@SmallTest
@Test
public void testRemoveCategories() throws Exception {
    CardDao cardDao = helper.getCardDao();
    CategoryDao categoryDao = helper.getCategoryDao();
    Category c1 = categoryDao.createOrReturn("c1");
    categoryDao.create(c1);
    Card nc = new Card();
    nc.setCategory(c1);
    cardDao.create(nc);
    categoryDao.refresh(nc.getCategory());
    assertEquals("c1", nc.getCategory().getName());
    categoryDao.removeCategory(c1);
    nc = cardDao.queryForId(nc.getId());
    categoryDao.refresh(nc.getCategory());
    assertEquals("", nc.getCategory().getName());
}
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) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 48 with CardDao

use of org.liberty.android.fantastischmemo.dao.CardDao in project AnyMemo by helloworld1.

the class NewDbTest method testCreateFirstCardWithCorrectOrdinal.

@SmallTest
@Test
public void testCreateFirstCardWithCorrectOrdinal() throws Exception {
    CardDao cardDao = newDbHelper.getCardDao();
    // Create card has null ordinal, append to the end
    Card nc = new Card();
    assertNull(nc.getOrdinal());
    cardDao.create(nc);
    assertEquals(1, (int) nc.getOrdinal());
}
Also used : CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 49 with CardDao

use of org.liberty.android.fantastischmemo.dao.CardDao in project AnyMemo by helloworld1.

the class LearnQueuingManagerTest method testGetNewCardQueuingWithCategory.

@SmallTest
@Test
public void testGetNewCardQueuingWithCategory() throws Exception {
    CardDao cardDao = helper.getCardDao();
    Card c10 = cardDao.queryForId(10);
    assertNotNull(c10);
    Category cat = new Category();
    cat.setName("tt");
    c10.setCategory(cat);
    cardDao.update(c10);
    QueueManager queueManager = new LearnQueueManager.Builder(getContext(), TestHelper.SAMPLE_DB_PATH).setLearnQueueSize(10).setFilterCategory(cat).setCacheSize(50).build();
    Card cqueue = queueManager.dequeue();
    assertEquals(10, (int) cqueue.getId());
    queueManager.release();
}
Also used : Category(org.liberty.android.fantastischmemo.entity.Category) CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) LearnQueueManager(org.liberty.android.fantastischmemo.queue.LearnQueueManager) QueueManager(org.liberty.android.fantastischmemo.queue.QueueManager) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Example 50 with CardDao

use of org.liberty.android.fantastischmemo.dao.CardDao in project AnyMemo by helloworld1.

the class QuizQueuingManagerTest method testFilterCategory.

@SmallTest
@Test
public void testFilterCategory() throws Exception {
    CardDao cardDao = helper.getCardDao();
    Card c10 = cardDao.queryForId(10);
    assertNotNull(c10);
    Category cat = new Category();
    cat.setName("tt");
    c10.setCategory(cat);
    cardDao.update(c10);
    QueueManager queueManager = new QuizQueueManager.Builder().setDbOpenHelper(helper).setFilterCategory(cat).build();
    Card cqueue = queueManager.dequeue();
    assertEquals(10, (int) cqueue.getId());
}
Also used : Category(org.liberty.android.fantastischmemo.entity.Category) QuizQueueManager(org.liberty.android.fantastischmemo.queue.QuizQueueManager) CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card) QuizQueueManager(org.liberty.android.fantastischmemo.queue.QuizQueueManager) QueueManager(org.liberty.android.fantastischmemo.queue.QueueManager) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest) AbstractExistingDBTest(org.liberty.android.fantastischmemo.test.AbstractExistingDBTest) SmallTest(android.support.test.filters.SmallTest)

Aggregations

CardDao (org.liberty.android.fantastischmemo.dao.CardDao)66 Card (org.liberty.android.fantastischmemo.entity.Card)61 SmallTest (android.support.test.filters.SmallTest)37 Test (org.junit.Test)37 AbstractExistingDBTest (org.liberty.android.fantastischmemo.test.AbstractExistingDBTest)37 AnyMemoDBOpenHelper (org.liberty.android.fantastischmemo.common.AnyMemoDBOpenHelper)28 Category (org.liberty.android.fantastischmemo.entity.Category)27 CategoryDao (org.liberty.android.fantastischmemo.dao.CategoryDao)22 LearningData (org.liberty.android.fantastischmemo.entity.LearningData)15 LearningDataDao (org.liberty.android.fantastischmemo.dao.LearningDataDao)13 File (java.io.File)10 ArrayList (java.util.ArrayList)8 IOException (java.io.IOException)6 URL (java.net.URL)5 FileWriter (java.io.FileWriter)4 Date (java.util.Date)4 BufferedWriter (java.io.BufferedWriter)3 PrintWriter (java.io.PrintWriter)3 SAXParser (javax.xml.parsers.SAXParser)3 SAXParserFactory (javax.xml.parsers.SAXParserFactory)3