PurchaseViewModel implements IPurchaseViewModel { public Observable<Boolean> submit() { return mPurchaseApi.submitPurchase(mCreditCard.getValue().toString(), mEmail.getValue().toString()) .timeout(TIME_OUT, TimeUnit.SECONDS) .retry(RETRY); } PurchaseViewModel(@NonNull IPurchaseApi purchaseApi); Observable<Boolean> creditCardValid(); Observable<Boolean> emailValid(); Observable<Boolean> canSubmit(); void nextCreditCard(CharSequence creditCard); void nextEmail(CharSequence email); Observable<Boolean> submit();  }
@Test public void submit() throws Exception { purchaseViewModel.nextCreditCard("412341234123"); purchaseViewModel.nextEmail("ndc@gmail.com"); purchaseViewModel.submit().subscribe(testSubscriber); testSubscriber.assertReceivedOnNext(Collections.singletonList(true)); verify(purchaseApi).submitPurchase("412341234123", "ndc@gmail.com"); }