Search in sources :

Example 1 with TodoListHeader

use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.

the class DisplayTodoListPresenterImpl method syncTodoList.

@Override
public void syncTodoList(FlexibleAdapter<AbstractFlexibleItem> adapter) {
    List<IHeader> reversedHeaders = Lists.reverse(Optional.fromNullable(Lists.newArrayList(adapter.getHeaderItems())).or(new ArrayList<IHeader>(0)));
    for (IHeader iHeader : reversedHeaders) {
        TodoListHeaderViewModel vm = (TodoListHeaderViewModel) iHeader;
        TodoListHeader header = vm.getHeader();
        syncHeader(header, reversedHeaders.indexOf(vm), vm.isExpanded());
        syncSubItems(Lists.newArrayList(adapter.getSectionItems(iHeader)));
    }
}
Also used : IHeader(eu.davidea.flexibleadapter.items.IHeader) TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) ArrayList(java.util.ArrayList) TodoListHeaderViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel)

Example 2 with TodoListHeader

use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.

the class TodoListRepositoryImplTest method testHeaderDelete.

@Test
public void testHeaderDelete() {
    TodoListHeader header = createHeader();
    repository.insert(header);
    repository.delete(header);
    Optional<TodoListHeader> fromDb = repository.getHeaderById(header.getUuid());
    assertFalse(fromDb.isPresent());
}
Also used : TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 3 with TodoListHeader

use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.

the class TodoListRepositoryImplTest method testUpdateHeaderAsInsert.

@Test
public void testUpdateHeaderAsInsert() {
    TodoListHeader header = createHeader();
    repository.update(header);
    Optional<TodoListHeader> fromDb = repository.getHeaderById(header.getUuid());
    assertEquals(header, fromDb.get());
}
Also used : TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 4 with TodoListHeader

use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.

the class TodoListRepositoryImplTest method testTodoListHeaderInsertTwice.

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

Example 5 with TodoListHeader

use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.

the class TodoListRepositoryImplTest method testUpdateHeader.

@Test
public void testUpdateHeader() throws InterruptedException {
    TodoListHeader header = createHeader();
    repository.insert(header);
    Thread.sleep(200);
    repository.update(header.update("New Title", 0, false));
    Optional<TodoListHeader> fromDb = repository.getHeaderById(header.getUuid());
    assertEquals(header.getCreatedAt(), fromDb.get().getCreatedAt());
    assertNotEquals(header.getChangedAt(), fromDb.get().getChangedAt());
    assertNotEquals(header.getTitle(), fromDb.get().getTitle());
}
Also used : TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Aggregations

TodoListHeader (de.djuelg.neuronizer.domain.model.todolist.TodoListHeader)18 MediumTest (android.support.test.filters.MediumTest)6 Test (org.junit.Test)6 TodoList (de.djuelg.neuronizer.domain.model.preview.TodoList)5 TodoListHeaderDAO (de.djuelg.neuronizer.storage.model.TodoListHeaderDAO)5 TodoListItem (de.djuelg.neuronizer.domain.model.todolist.TodoListItem)4 ArrayList (java.util.ArrayList)3 TodoListHeaderViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel)2 TodoListHeaderDAOConverter (de.djuelg.neuronizer.storage.converter.TodoListHeaderDAOConverter)2 Realm (io.realm.Realm)2 InputMismatchException (java.util.InputMismatchException)2 ArrayAdapter (android.widget.ArrayAdapter)1 TodoListPreview (de.djuelg.neuronizer.domain.model.preview.TodoListPreview)1 TodoListSection (de.djuelg.neuronizer.domain.model.todolist.TodoListSection)1 TodoListItemDAO (de.djuelg.neuronizer.storage.model.TodoListItemDAO)1 IHeader (eu.davidea.flexibleadapter.items.IHeader)1