use of com.example.android.architecture.blueprints.todoapp.data.Task in project todo-mvp-rxjava by albertizzy.
the class TaskDetailPresenterTest method activateTask.
@Test
public void activateTask() {
// Given an initialized presenter with a completed task
Task task = new Task(TITLE_TEST, DESCRIPTION_TEST, true);
mTaskDetailPresenter = new TaskDetailPresenter(task.getId(), mTasksRepository, mTaskDetailView, mSchedulerProvider);
setTaskAvailable(task);
mTaskDetailPresenter.subscribe();
// When the presenter is asked to activate the task
mTaskDetailPresenter.activateTask();
// Then a request is sent to the task repository and the UI is updated
verify(mTasksRepository).activateTask(task.getId());
verify(mTaskDetailView).showTaskMarkedActive();
}
use of com.example.android.architecture.blueprints.todoapp.data.Task in project todo-mvp-rxjava by albertizzy.
the class TasksPresenterTest method clickOnTask_ShowsDetailUi.
@Test
public void clickOnTask_ShowsDetailUi() {
// Given a stubbed active task
Task requestedTask = new Task("Details Requested", "For this task");
// When open task details is requested
mTasksPresenter.openTaskDetails(requestedTask);
// Then task detail UI is shown
verify(mTasksView).showTaskDetailsUi(any(String.class));
}
use of com.example.android.architecture.blueprints.todoapp.data.Task in project todo-mvp-rxjava by albertizzy.
the class TasksPresenterTest method completeTask_ShowsTaskMarkedComplete.
@Test
public void completeTask_ShowsTaskMarkedComplete() {
// Given a stubbed task
Task task = new Task("Details Requested", "For this task");
// And no tasks available in the repository
when(mTasksRepository.getTasks()).thenReturn(Flowable.empty());
// When task is marked as complete
mTasksPresenter.completeTask(task);
// Then repository is called and task marked complete UI is shown
verify(mTasksRepository).completeTask(task);
verify(mTasksView).showTaskMarkedComplete();
}
use of com.example.android.architecture.blueprints.todoapp.data.Task in project todo-mvp-rxjava by albertizzy.
the class TasksPresenterTest method setupTasksPresenter.
@Before
public void setupTasksPresenter() {
// Mockito has a very convenient way to inject mocks by using the @Mock annotation. To
// inject the mocks in the test the initMocks method needs to be called.
MockitoAnnotations.initMocks(this);
// Make the sure that all schedulers are immediate.
mSchedulerProvider = new ImmediateSchedulerProvider();
// Get a reference to the class under test
mTasksPresenter = new TasksPresenter(mTasksRepository, mTasksView, mSchedulerProvider);
// The presenter won't update the view unless it's active.
when(mTasksView.isActive()).thenReturn(true);
// We subscribe the tasks to 3, with one active and two completed
TASKS = Lists.newArrayList(new Task("Title1", "Description1"), new Task("Title2", "Description2", true), new Task("Title3", "Description3", true));
}
use of com.example.android.architecture.blueprints.todoapp.data.Task in project todo-mvp-rxjava by albertizzy.
the class TasksPresenterTest method activateTask_ShowsTaskMarkedActive.
@Test
public void activateTask_ShowsTaskMarkedActive() {
// Given a stubbed completed task
Task task = new Task("Details Requested", "For this task", true);
// And no tasks available in the repository
when(mTasksRepository.getTasks()).thenReturn(Flowable.empty());
mTasksPresenter.loadTasks(true);
// When task is marked as activated
mTasksPresenter.activateTask(task);
// Then repository is called and task marked active UI is shown
verify(mTasksRepository).activateTask(task);
verify(mTasksView).showTaskMarkedActive();
}
Aggregations