use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.
the class TodoListRepositoryImplTest method testDeleteHeaderNotExisting.
@Test
public void testDeleteHeaderNotExisting() {
TodoListHeader header = createHeader();
repository.delete(header);
Optional<TodoListHeader> fromDb = repository.getHeaderById(header.getUuid());
assertFalse(fromDb.isPresent());
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.
the class AddHeaderInteractorImpl method run.
@Override
public void run() {
final Optional<TodoList> todoList = repository.todoList().getTodoListById(parentTodoListUuid);
final int position = repository.todoList().getHeaderCountOfTodoList(parentTodoListUuid);
if (!todoList.isPresent()) {
callback.onParentNotFound();
return;
}
// try to insert with new UUID on failure
TodoListHeader header = new TodoListHeader(title, position, parentTodoListUuid);
while (!repository.todoList().insert(header)) {
header = new TodoListHeader(title, position, parentTodoListUuid);
}
repository.todoList().update(todoList.get().updateLastChange());
// notify on the main thread that we have inserted this item
mMainThread.post(new Runnable() {
@Override
public void run() {
callback.onHeaderAdded();
}
});
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.
the class AddItemInteractorImpl method run.
@Override
public void run() {
final Optional<TodoList> todoList = repository.todoList().getTodoListById(parentTodoListUuid);
final Optional<TodoListHeader> header = repository.todoList().getHeaderById(parentHeaderUuid);
final int position = repository.todoList().getSubItemCountOfHeader(parentHeaderUuid);
if (!todoList.isPresent() || !header.isPresent()) {
callback.onParentNotFound();
return;
}
// try to insert with new UUID on failure
TodoListItem item = new TodoListItem(title, position, important, details, parentTodoListUuid, parentHeaderUuid);
while (!repository.todoList().insert(item)) {
item = new TodoListItem(title, position, important, details, parentTodoListUuid, parentHeaderUuid);
}
repository.todoList().update(todoList.get().updateLastChange());
// notify on the main thread that we have inserted this item
mMainThread.post(new Runnable() {
@Override
public void run() {
callback.onItemAdded();
}
});
}
Aggregations