use of com.kickstarter.services.apiresponses.AccessTokenEnvelope in project android-oss by kickstarter.
the class SignupViewModelTest method testSignupViewModel_ApiError.
@Test
public void testSignupViewModel_ApiError() {
final ApiClientType apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<AccessTokenEnvelope> signup(@NonNull final String name, @NonNull final String email, @NonNull final String password, @NonNull final String passwordConfirmation, final boolean sendNewsletters) {
return Observable.error(ApiExceptionFactory.badRequestException());
}
};
final Environment environment = environment().toBuilder().apiClient(apiClient).build();
final SignupViewModel vm = new SignupViewModel(environment);
final TestSubscriber<Void> signupSuccessTest = new TestSubscriber<>();
vm.outputs.signupSuccess().subscribe(signupSuccessTest);
final TestSubscriber<String> signupErrorTest = new TestSubscriber<>();
vm.errors.signupError().subscribe(signupErrorTest);
final TestSubscriber<Boolean> formSubmittingTest = new TestSubscriber<>();
vm.outputs.formSubmitting().subscribe(formSubmittingTest);
vm.inputs.fullName("brandon");
vm.inputs.email("hello@kickstarter.com");
vm.inputs.email("incorrect@kickstarter");
vm.inputs.password("danisawesome");
vm.inputs.sendNewslettersClick(true);
vm.inputs.signupClick();
formSubmittingTest.assertValues(true, false);
signupSuccessTest.assertValueCount(0);
signupErrorTest.assertValueCount(1);
koalaTest.assertValues("User Signup", "Signup Newsletter Toggle", "Errored User Signup");
}
use of com.kickstarter.services.apiresponses.AccessTokenEnvelope in project android-oss by kickstarter.
the class TwoFactorViewModelTest method testTwoFactorViewModel_GenericError.
@Test
public void testTwoFactorViewModel_GenericError() {
final ApiClientType apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<AccessTokenEnvelope> login(@NonNull final String email, @NonNull final String password, @NonNull final String code) {
return Observable.error(ApiExceptionFactory.apiError(ErrorEnvelope.builder().httpCode(400).build()));
}
};
final Environment environment = environment().toBuilder().apiClient(apiClient).build();
final Intent intent = new Intent();
intent.putExtra(IntentKey.EMAIL, "gina@kickstarter.com");
intent.putExtra(IntentKey.PASSWORD, "hello");
intent.putExtra(IntentKey.FACEBOOK_LOGIN, false);
intent.putExtra(IntentKey.FACEBOOK_TOKEN, "");
final TwoFactorViewModel vm = new TwoFactorViewModel(environment);
vm.intent(intent);
final TestSubscriber<Void> tfaSuccess = new TestSubscriber<>();
vm.outputs.tfaSuccess().subscribe(tfaSuccess);
final TestSubscriber<Boolean> formSubmitting = new TestSubscriber<>();
vm.outputs.formSubmitting().subscribe(formSubmitting);
final TestSubscriber<Void> genericTfaError = new TestSubscriber<>();
vm.errors.genericTfaError().subscribe(genericTfaError);
vm.inputs.code("88888");
vm.inputs.loginClick();
formSubmitting.assertValues(true, false);
tfaSuccess.assertNoValues();
genericTfaError.assertValueCount(1);
koalaTest.assertValues("Two-factor Authentication Confirm View", "Errored User Login");
}
Aggregations