use of de.djuelg.neuronizer.domain.model.todolist.TodoListItem in project Neuronizer by djuelg.
the class TodoListRepositoryImplTest method testUpdateItem.
@Test
public void testUpdateItem() throws InterruptedException {
TodoListItem item = createItem();
repository.insert(item);
Thread.sleep(200);
repository.update(item.update("New Title", 0, false, "", false, "uuid1"));
Optional<TodoListItem> fromDb = repository.getItemById(item.getUuid());
assertEquals(item.getCreatedAt(), fromDb.get().getCreatedAt());
assertNotEquals(item.getChangedAt(), fromDb.get().getChangedAt());
assertNotEquals(item.getTitle(), fromDb.get().getTitle());
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListItem in project Neuronizer by djuelg.
the class TodoListRepositoryImplTest method testItemDelete.
@Test
public void testItemDelete() {
TodoListItem item = createItem();
repository.insert(item);
repository.delete(item);
Optional<TodoListItem> fromDb = repository.getItemById(item.getUuid());
assertFalse(fromDb.isPresent());
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListItem in project Neuronizer by djuelg.
the class EditItemInteractorImpl method run.
@Override
public void run() {
final Optional<TodoListHeader> header = repository.todoList().getHeaderById(parentHeaderUuid);
final Optional<TodoListItem> outDatedItem = repository.todoList().getItemById(uuid);
if (!header.isPresent() || !outDatedItem.isPresent()) {
throw new InputMismatchException("Header, or Item were not existing!");
}
final TodoListItem updatedItem = outDatedItem.get().update(title, position, important, details, done, parentHeaderUuid);
repository.todoList().update(updatedItem);
final Optional<TodoList> todoList = repository.todoList().getTodoListById(updatedItem.getParentTodoListUuid());
final TodoListItem itemFromUI = new TodoListItem(uuid, title, outDatedItem.get().getCreatedAt(), outDatedItem.get().getChangedAt(), position, important, details, done, outDatedItem.get().getParentTodoListUuid(), parentHeaderUuid);
if (todoList.isPresent() && !outDatedItem.get().equals(itemFromUI))
repository.todoList().update(todoList.get().updateLastChange());
mMainThread.post(new Runnable() {
@Override
public void run() {
callback.onItemUpdated(updatedItem);
}
});
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListItem in project Neuronizer by djuelg.
the class WidgetListFactory method onDataSetChanged.
@Override
public void onDataSetChanged() {
itemList.clear();
List<TodoListSection> sections = Lists.newArrayList(repository.getSectionsOfTodoListId(uuid));
Collections.sort(sections, new PositionComparator());
for (TodoListSection section : sections) {
itemList.add(section.getHeader());
List<TodoListItem> items = Lists.newArrayList(section.getItems());
Collections.sort(items, new PositionComparator());
itemList.addAll(items);
}
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListItem in project Neuronizer by djuelg.
the class PreviewRepositoryImpl method constructPreview.
private TodoListPreview constructPreview(Realm realm, TodoListDAO todoListDAO, ItemsPerPreview itemsPerPreview) {
TodoList todoList = RealmConverter.convert(todoListDAO);
Optional<TodoListHeaderDAO> headerDAO = Optional.fromNullable(realm.where(TodoListHeaderDAO.class).equalTo("parentTodoListUuid", todoListDAO.getUuid()).findAllSorted("position", Sort.DESCENDING).where().findFirst());
TodoListHeader header = headerDAO.transform(new TodoListHeaderDAOConverter()).orNull();
List<TodoListItem> items = getItemPreviewOfHeader(realm, header, itemsPerPreview);
return new TodoListPreview(todoList, header, items);
}
Aggregations