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