Search in sources :

Example 6 with TodoListItemDAO

use of de.djuelg.neuronizer.storage.model.TodoListItemDAO in project Neuronizer by djuelg.

the class TodoListRepositoryImplTest method fillRealm.

private void fillRealm() {
    final TodoListDAO todoListDAO = new TodoListDAO("uuid0", "Todo List 1", 0, 0, 0, 0);
    final TodoListHeaderDAO headerDAO = new TodoListHeaderDAO("uuid1", "Header 1", 0, 0, 0, false, "uuid0");
    final TodoListItemDAO itemDAO = new TodoListItemDAO("uuid2", "Item 1", 0, 0, 0, false, "", false, "uuid0", "uuid1");
    final TodoListHeaderDAO headerDAO2 = new TodoListHeaderDAO("uuid3", "Header 2", 0, 0, 0, false, "uuid3");
    final TodoListItemDAO itemDAO2 = new TodoListItemDAO("uuid4", "Item 2", 0, 0, 0, false, "", false, "uuid0", "uuid3");
    final TodoListItemDAO itemDAO3 = new TodoListItemDAO("uuid5", "Item 3", 0, 0, 0, false, "", false, "uuid0", "uuid3");
    realm.executeTransaction(new Realm.Transaction() {

        @Override
        public void execute(Realm realm) {
            realm.copyToRealm(todoListDAO);
            realm.copyToRealm(headerDAO);
            realm.copyToRealm(headerDAO2);
            realm.copyToRealm(itemDAO);
            realm.copyToRealm(itemDAO2);
            realm.copyToRealm(itemDAO3);
        }
    });
}
Also used : TodoListHeaderDAO(de.djuelg.neuronizer.storage.model.TodoListHeaderDAO) Realm(io.realm.Realm) TodoListDAO(de.djuelg.neuronizer.storage.model.TodoListDAO) TodoListItemDAO(de.djuelg.neuronizer.storage.model.TodoListItemDAO)

Example 7 with TodoListItemDAO

use of de.djuelg.neuronizer.storage.model.TodoListItemDAO in project Neuronizer by djuelg.

the class TodoListRepositoryImplTest method testTodoListItemInsert.

@Test
public void testTodoListItemInsert() {
    TodoListItem item = createItem();
    boolean success = repository.insert(item);
    assertTrue(success);
    TodoListItemDAO dao = realm.where(TodoListItemDAO.class).equalTo("uuid", item.getUuid()).findFirst();
    assertNotNull(dao);
}
Also used : TodoListItem(de.djuelg.neuronizer.domain.model.todolist.TodoListItem) TodoListItemDAO(de.djuelg.neuronizer.storage.model.TodoListItemDAO) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 8 with TodoListItemDAO

use of de.djuelg.neuronizer.storage.model.TodoListItemDAO in project Neuronizer by djuelg.

the class TodoListRepositoryImpl method update.

@Override
public void update(TodoListItem updatedItem) {
    Realm realm = Realm.getInstance(configuration);
    final TodoListItemDAO dao = RealmConverter.convert(updatedItem);
    realm.executeTransaction(new Realm.Transaction() {

        @Override
        public void execute(@NonNull Realm realm) {
            realm.copyToRealmOrUpdate(dao);
        }
    });
    realm.close();
}
Also used : Realm(io.realm.Realm) TodoListItemDAO(de.djuelg.neuronizer.storage.model.TodoListItemDAO)

Example 9 with TodoListItemDAO

use of de.djuelg.neuronizer.storage.model.TodoListItemDAO in project Neuronizer by djuelg.

the class PreviewRepositoryImplTest method fillRealm.

private void fillRealm() {
    final TodoListDAO todoListDAO = new TodoListDAO("uuid0", "Todo List 1", 0, 0, 0, 0);
    final TodoListHeaderDAO headerDAO = new TodoListHeaderDAO("uuid1", "Header 1", 0, 0, 0, false, "uuid0");
    final TodoListItemDAO itemDAO = new TodoListItemDAO("uuid2", "Item 1", 0, 0, 0, false, "", false, "uuid0", "uuid1");
    final TodoListHeaderDAO headerDAO2 = new TodoListHeaderDAO("uuid3", "Header 2", 0, 0, 0, false, "uuid3");
    final TodoListItemDAO itemDAO2 = new TodoListItemDAO("uuid4", "Item 2", 0, 0, 0, false, "", false, "uuid0", "uuid3");
    final TodoListItemDAO itemDAO3 = new TodoListItemDAO("uuid5", "Item 3", 0, 0, 0, false, "", false, "uuid0", "uuid3");
    realm.executeTransaction(new Realm.Transaction() {

        @Override
        public void execute(Realm realm) {
            realm.copyToRealm(todoListDAO);
            realm.copyToRealm(headerDAO);
            realm.copyToRealm(headerDAO2);
            realm.copyToRealm(itemDAO);
            realm.copyToRealm(itemDAO2);
            realm.copyToRealm(itemDAO3);
        }
    });
}
Also used : TodoListHeaderDAO(de.djuelg.neuronizer.storage.model.TodoListHeaderDAO) Realm(io.realm.Realm) TodoListDAO(de.djuelg.neuronizer.storage.model.TodoListDAO) TodoListItemDAO(de.djuelg.neuronizer.storage.model.TodoListItemDAO)

Example 10 with TodoListItemDAO

use of de.djuelg.neuronizer.storage.model.TodoListItemDAO in project Neuronizer by djuelg.

the class TodoListRepositoryImplTest method testTodoListItemInsertTwice.

@Test
public void testTodoListItemInsertTwice() {
    clearRealm();
    TodoListItem item = createItem();
    repository.insert(item);
    boolean success = repository.insert(item);
    assertFalse(success);
    TodoListItemDAO dao = realm.where(TodoListItemDAO.class).equalTo("uuid", item.getUuid()).findFirst();
    assertNotNull(dao);
    fillRealm();
}
Also used : TodoListItem(de.djuelg.neuronizer.domain.model.todolist.TodoListItem) TodoListItemDAO(de.djuelg.neuronizer.storage.model.TodoListItemDAO) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Aggregations

TodoListItemDAO (de.djuelg.neuronizer.storage.model.TodoListItemDAO)10 Realm (io.realm.Realm)6 TodoListItem (de.djuelg.neuronizer.domain.model.todolist.TodoListItem)5 MediumTest (android.support.test.filters.MediumTest)2 TodoListDAO (de.djuelg.neuronizer.storage.model.TodoListDAO)2 TodoListHeaderDAO (de.djuelg.neuronizer.storage.model.TodoListHeaderDAO)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 TodoListHeader (de.djuelg.neuronizer.domain.model.todolist.TodoListHeader)1 TodoListSection (de.djuelg.neuronizer.domain.model.todolist.TodoListSection)1 TodoListItemDAOConverter (de.djuelg.neuronizer.storage.converter.TodoListItemDAOConverter)1