use of com.armueller.fluxytodo.actions.DataBundle in project FluxyAndroidTodo by armueller.
the class TodoListManagerTest method editTodoTest.
@Test(timeout = 100)
public void editTodoTest() throws InterruptedException {
final AtomicBoolean testDone = new AtomicBoolean(false);
final ArrayList<TodoItem> todoItems = new ArrayList<TodoItem>();
createTodos(1);
dataBus.register(new Object() {
@Subscribe
public void onListUpdated(RawTodoList rawTodoList) {
todoItems.clear();
todoItems.addAll(rawTodoList.list);
if (todoItems.get(0).getDescription().equals("Testing 0")) {
DataBundle<TodoAction.DataKeys> bundle = new DataBundle<>();
bundle.put(TodoAction.DataKeys.ID, todoItems.get(0).getId());
bundle.put(TodoAction.DataKeys.DESCRIPTION, "New Todo Description");
actionBus.post(new TodoAction(TodoAction.ActionTypes.EDIT, bundle));
} else {
assertThat(todoItems.get(0).getDescription()).isEqualTo("New Todo Description");
testDone.set(true);
}
}
});
// Wait for test to finish or timeout
while (!testDone.get()) ;
}
use of com.armueller.fluxytodo.actions.DataBundle in project FluxyAndroidTodo by armueller.
the class TodoListManagerTest method deleteAllCompleteTodosTest.
@Test(timeout = 100)
public void deleteAllCompleteTodosTest() throws InterruptedException {
final AtomicBoolean testDone = new AtomicBoolean(false);
final AtomicBoolean checkedTodo1 = new AtomicBoolean(false);
final AtomicBoolean checkedTodo3 = new AtomicBoolean(false);
final AtomicBoolean deleted = 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 (!deleted.get() && checkedTodo1.get() && checkedTodo3.get()) {
deleted.set(true);
actionBus.post(new TodoAction(TodoAction.ActionTypes.DELETE_ALL));
return;
}
if (deleted.get()) {
assertThat(todoItems.size()).isEqualTo(2);
testDone.set(true);
}
}
});
// Wait for test to finish or timeout
while (!testDone.get()) ;
}
use of com.armueller.fluxytodo.actions.DataBundle in project FluxyAndroidTodo by armueller.
the class TodosActivityStoreTest method setEditModeInactiveForTodoIdTest.
@Test(timeout = 100)
public void setEditModeInactiveForTodoIdTest() {
final AtomicBoolean testDone = new AtomicBoolean(false);
dataBus.register(new Object() {
@Subscribe
public void onListUpdated(TodoAction todoAction) {
assertThat(todoAction.getType()).isEqualTo(TodoAction.ActionTypes.EDIT);
assertThat(todoAction.getData().get(TodoAction.DataKeys.ID, -1)).isEqualTo(2);
assertThat(todoAction.getData().get(TodoAction.DataKeys.DESCRIPTION, "")).isEqualTo("Test");
testDone.set(true);
}
});
DataBundle<TodoAction.DataKeys> bundle = new DataBundle<>();
bundle.put(TodoAction.DataKeys.ID, 2);
bundle.put(TodoAction.DataKeys.DESCRIPTION, "Test");
dataBus.post(new TodoAction(TodoAction.ActionTypes.EDIT, bundle));
// Wait for test to finish or timeout
while (!testDone.get()) ;
}
Aggregations