use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class ProjectUpdatesViewModelTest method testStartUpdateActivity.
@Test
public void testStartUpdateActivity() {
final Update update = UpdateFactory.update();
final List<Update> updates = Collections.singletonList(update);
final Project project = ProjectFactory.project();
setUpEnvironment(environment().toBuilder().apiClient(new MockApiClient() {
@NonNull
@Override
public Observable<UpdatesEnvelope> fetchUpdates(@NonNull final Project project) {
return Observable.just(UpdatesEnvelope.builder().updates(updates).urls(urlsEnvelope()).build());
}
}).build(), project, ProjectDataFactory.Companion.project(project));
this.vm.inputs.updateClicked(update);
this.startUpdateActivity.assertValues(Pair.create(project, update));
}
use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class ProjectUpdatesViewModelTest method test_projectAndUpdates_whenUpdatesListIsEmpty.
@Test
public void test_projectAndUpdates_whenUpdatesListIsEmpty() {
final Project project = ProjectFactory.project();
setUpEnvironment(environment().toBuilder().apiClient(new MockApiClient() {
@NonNull
@Override
public Observable<UpdatesEnvelope> fetchUpdates(@NonNull final Project project) {
return Observable.just(UpdatesEnvelope.builder().updates(Collections.emptyList()).urls(urlsEnvelope()).build());
}
}).build(), project, ProjectDataFactory.Companion.project(project));
this.projectAndUpdates.assertValues(Pair.create(project, Collections.emptyList()));
this.isFetchingUpdates.assertValues(true, false);
this.horizontalProgressBarIsGone.assertValues(false, true);
}
use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class MessagesViewModelTest method testBackingInfo_NoBacking.
@Test
public void testBackingInfo_NoBacking() {
final Project project = ProjectFactory.project().toBuilder().isBacking(false).build();
final MessageThread messageThread = MessageThreadFactory.messageThread().toBuilder().project(project).backing(null).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<Backing> fetchProjectBacking(@NonNull final Project project, @NonNull final User user) {
return Observable.error(ApiExceptionFactory.badRequestException());
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(new MockCurrentUser(UserFactory.user())).build());
// Start the view model with a message thread.
this.vm.intent(messagesContextIntent(messageThread));
this.backingAndProject.assertNoValues();
this.backingInfoViewIsGone.assertValues(true);
}
use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class MessagesViewModelTest method testSuccessfullyMarkedAsRead.
@Test
public void testSuccessfullyMarkedAsRead() {
final MessageThread messageThread = MessageThreadFactory.messageThread();
final MockApiClient apiClient = new MockApiClient() {
@NonNull
@Override
public Observable<MessageThread> markAsRead(@NonNull final MessageThread thread) {
return Observable.just(messageThread);
}
};
setUpEnvironment(environment().toBuilder().currentUser(new MockCurrentUser(UserFactory.user())).apiClient(apiClient).build());
this.vm.intent(messagesContextIntent(messageThread));
this.successfullyMarkedAsRead.assertValueCount(1);
}
use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class MessagesViewModelTest method testBackingAndProject_Participant.
@Test
public void testBackingAndProject_Participant() {
final Project project = ProjectFactory.project().toBuilder().isBacking(false).build();
final Backing backing = BackingFactory.backing().toBuilder().project(project).build();
final MessageThread messageThread = MessageThreadFactory.messageThread().toBuilder().project(project).backing(backing).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForThread(@NonNull final MessageThread messageThread) {
return Observable.just(MessageThreadEnvelopeFactory.messageThreadEnvelope());
}
@Override
@NonNull
public Observable<Backing> fetchProjectBacking(@NonNull final Project project, @NonNull final User user) {
return Observable.just(backing);
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(new MockCurrentUser(UserFactory.user())).build());
// Start the view model with a message thread.
this.vm.intent(messagesContextIntent(messageThread));
this.backingAndProject.assertValues(Pair.create(backing, backing.project()));
this.backingInfoViewIsGone.assertValues(false);
}
Aggregations