use of com.armueller.fluxytodo.data.RawTodoList in project FluxyAndroidTodo by armueller.
the class TodoListManager method reactToTodoAction.
@Subscribe
public void reactToTodoAction(TodoAction action) {
DataBundle<TodoAction.DataKeys> data = action.getData();
long id = (long) data.get(TodoAction.DataKeys.ID, -1L);
String description = (String) data.get(TodoAction.DataKeys.DESCRIPTION, "");
switch(action.getType()) {
case ADD:
addTodo(description);
break;
case TOGGLE:
toggleTodoComplete(id);
break;
case TOGGLE_ALL:
toggleAllTodosComplete();
break;
case EDIT:
editTodo(id, description);
break;
case DELETE:
deleteTodo(id);
break;
case DELETE_ALL:
deleteAllCompleteTodos();
break;
case UNDO_DELETE_ALL:
undoDeleteCompleteAllTodos();
break;
}
dataBus.post(new RawTodoList(todoItems));
}
use of com.armueller.fluxytodo.data.RawTodoList in project FluxyAndroidTodo by armueller.
the class TodoListManagerTest method createMultipleTodosTest.
@Test(timeout = 100)
public void createMultipleTodosTest() throws InterruptedException {
final AtomicBoolean testDone = new AtomicBoolean(false);
createTodos(4);
dataBus.register(new Object() {
@Subscribe
public void onListUpdated(RawTodoList rawTodoList) {
assertThat(rawTodoList.list.size()).isEqualTo(4);
testDone.set(true);
}
});
// Wait for test to finish or timeout
while (!testDone.get()) ;
}
use of com.armueller.fluxytodo.data.RawTodoList in project FluxyAndroidTodo by armueller.
the class TodosActivityStoreTest method updateRawTodoListConnectedTest.
//Test:
//todoActionPerformed
@Test(timeout = 100)
public void updateRawTodoListConnectedTest() {
final AtomicBoolean testDone = new AtomicBoolean(false);
RawTodoList rawTodoList = new RawTodoList();
dataBus.register(new Object() {
@Subscribe
public void onListUpdated(FilteredTodoList filteredTodoList) {
assertThat(filteredTodoList.list.size()).isEqualTo(0);
testDone.set(true);
}
});
dataBus.post(rawTodoList);
// Wait for test to finish or timeout
while (!testDone.get()) ;
}
use of com.armueller.fluxytodo.data.RawTodoList in project FluxyAndroidTodo by armueller.
the class TodosActivityStoreTest method changeActiveFilterToAllTest.
@Test(timeout = 100)
public void changeActiveFilterToAllTest() {
final AtomicBoolean testDone = new AtomicBoolean(false);
ArrayList<TodoItem> list = new ArrayList<TodoItem>();
list.add(new TodoItem(1, "Test", false));
list.add(new TodoItem(2, "Test", true));
list.add(new TodoItem(3, "Test", false));
RawTodoList rawTodoList = new RawTodoList(list);
dataBus.post(rawTodoList);
dataBus.register(new Object() {
@Subscribe
public void onListUpdated(FilteredTodoList filteredTodoList) {
assertThat(filteredTodoList.list.size()).isEqualTo(3);
assertThat(filteredTodoList.filter).isEqualTo(FilteredTodoList.Filter.ALL);
testDone.set(true);
}
});
dataBus.post(new ViewAction(ViewAction.ActionTypes.VIEW_ALL));
// Wait for test to finish or timeout
while (!testDone.get()) ;
}
use of com.armueller.fluxytodo.data.RawTodoList in project FluxyAndroidTodo by armueller.
the class TodoListManagerTest method undoDeleteAllCompleteTodosTest.
@Test(timeout = 100)
public void undoDeleteAllCompleteTodosTest() throws InterruptedException {
final AtomicBoolean testDone = new AtomicBoolean(false);
final AtomicBoolean checkedTodo1 = new AtomicBoolean(false);
final AtomicBoolean checkedTodo3 = new AtomicBoolean(false);
final AtomicBoolean deletedTodos = new AtomicBoolean(false);
final AtomicBoolean undidDelete = new AtomicBoolean(false);
final ArrayList<TodoItem> todoItems = new ArrayList<TodoItem>();
createTodos(4);
dataBus.register(new Object() {
@Subscribe
public void onListUpdated(RawTodoList rawTodoList) {
todoItems.clear();
todoItems.addAll(rawTodoList.list);
if (!checkedTodo1.get()) {
checkedTodo1.set(true);
DataBundle<TodoAction.DataKeys> bundle = new DataBundle<>();
bundle.put(TodoAction.DataKeys.ID, todoItems.get(1).getId());
actionBus.post(new TodoAction(TodoAction.ActionTypes.TOGGLE, bundle));
return;
}
if (!checkedTodo3.get()) {
checkedTodo3.set(true);
DataBundle<TodoAction.DataKeys> bundle = new DataBundle<>();
bundle.put(TodoAction.DataKeys.ID, todoItems.get(3).getId());
actionBus.post(new TodoAction(TodoAction.ActionTypes.TOGGLE, bundle));
return;
}
if (!deletedTodos.get() && checkedTodo1.get() && checkedTodo3.get()) {
deletedTodos.set(true);
actionBus.post(new TodoAction(TodoAction.ActionTypes.DELETE_ALL));
return;
}
if (!undidDelete.get() && deletedTodos.get()) {
undidDelete.set(true);
actionBus.post(new TodoAction(TodoAction.ActionTypes.UNDO_DELETE_ALL));
return;
}
if (undidDelete.get() && deletedTodos.get()) {
assertThat(todoItems.size()).isEqualTo(4);
testDone.set(true);
}
}
});
// Wait for test to finish or timeout
while (!testDone.get()) ;
}
Aggregations