Search in sources :

Example 1 with TodoListItem

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

the class DisplayTodoListPresenterImpl method createSubItemList.

private List<TodoListItemViewModel> createSubItemList(TodoListHeaderViewModel headerVM, List<TodoListItem> items) {
    Collections.sort(items, new PositionComparator());
    List<TodoListItemViewModel> itemVMs = new ArrayList<>();
    for (TodoListItem item : items) {
        itemVMs.add(new TodoListItemViewModel(headerVM, item));
    }
    return itemVMs;
}
Also used : TodoListItemViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListItemViewModel) ArrayList(java.util.ArrayList) PositionComparator(de.djuelg.neuronizer.domain.comparator.PositionComparator) TodoListItem(de.djuelg.neuronizer.domain.model.todolist.TodoListItem)

Example 2 with TodoListItem

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

the class DisplayTodoListPresenterImpl method syncSubItems.

private void syncSubItems(List<ISectionable> subItems) {
    List<ISectionable> reversedItems = Lists.reverse(Optional.fromNullable(subItems).or(new ArrayList<ISectionable>(0)));
    for (ISectionable vm : reversedItems) {
        TodoListItem item = ((TodoListItemViewModel) vm).getItem();
        EditItemInteractor interactor = new EditItemInteractorImpl(mExecutor, mMainThread, this, repository, item.getUuid(), item.getTitle(), reversedItems.indexOf(vm), item.isImportant(), item.getDetails(), item.isDone(), ((TodoListItemViewModel) vm).getHeader().getHeader().getUuid());
        interactor.execute();
    }
}
Also used : EditItemInteractor(de.djuelg.neuronizer.domain.interactors.todolist.EditItemInteractor) TodoListItemViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListItemViewModel) ArrayList(java.util.ArrayList) EditItemInteractorImpl(de.djuelg.neuronizer.domain.interactors.todolist.impl.EditItemInteractorImpl) ISectionable(eu.davidea.flexibleadapter.items.ISectionable) TodoListItem(de.djuelg.neuronizer.domain.model.todolist.TodoListItem)

Example 3 with TodoListItem

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

the class TodoListRepositoryImplTest method testDeleteItemNotExisting.

@Test
public void testDeleteItemNotExisting() {
    TodoListItem item = createItem();
    repository.delete(item);
    Optional<TodoListItem> fromDb = repository.getItemById(item.getUuid());
    assertFalse(fromDb.isPresent());
}
Also used : TodoListItem(de.djuelg.neuronizer.domain.model.todolist.TodoListItem) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 4 with TodoListItem

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

the class TodoListRepositoryImplTest method testUpdateItemAsInsert.

@Test
public void testUpdateItemAsInsert() {
    TodoListItem item = new TodoListItem("InsertTest", 0, false, "", "uuid0", "uuid1");
    repository.update(item);
    Optional<TodoListItem> fromDb = repository.getItemById(item.getUuid());
    assertEquals(item, fromDb.get());
}
Also used : TodoListItem(de.djuelg.neuronizer.domain.model.todolist.TodoListItem) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 5 with TodoListItem

use of de.djuelg.neuronizer.domain.model.todolist.TodoListItem 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)

Aggregations

TodoListItem (de.djuelg.neuronizer.domain.model.todolist.TodoListItem)17 MediumTest (android.support.test.filters.MediumTest)6 Test (org.junit.Test)6 TodoListItemDAO (de.djuelg.neuronizer.storage.model.TodoListItemDAO)5 ArrayList (java.util.ArrayList)5 TodoListHeader (de.djuelg.neuronizer.domain.model.todolist.TodoListHeader)4 TodoList (de.djuelg.neuronizer.domain.model.preview.TodoList)3 TodoListSection (de.djuelg.neuronizer.domain.model.todolist.TodoListSection)3 TodoListItemViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListItemViewModel)3 PositionComparator (de.djuelg.neuronizer.domain.comparator.PositionComparator)2 EditItemInteractor (de.djuelg.neuronizer.domain.interactors.todolist.EditItemInteractor)1 EditItemInteractorImpl (de.djuelg.neuronizer.domain.interactors.todolist.impl.EditItemInteractorImpl)1 TodoListPreview (de.djuelg.neuronizer.domain.model.preview.TodoListPreview)1 TodoListHeaderDAOConverter (de.djuelg.neuronizer.storage.converter.TodoListHeaderDAOConverter)1 TodoListItemDAOConverter (de.djuelg.neuronizer.storage.converter.TodoListItemDAOConverter)1 TodoListHeaderDAO (de.djuelg.neuronizer.storage.model.TodoListHeaderDAO)1 AbstractFlexibleItem (eu.davidea.flexibleadapter.items.AbstractFlexibleItem)1 ISectionable (eu.davidea.flexibleadapter.items.ISectionable)1 Realm (io.realm.Realm)1 InputMismatchException (java.util.InputMismatchException)1