PurchaseViewModel implements IPurchaseViewModel { public Observable<Boolean> canSubmit() { return Observable.combineLatest(creditCardValid(), emailValid(), (validCreditCard, validEmail) -> validCreditCard && validEmail); } 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 canSubmit() throws Exception { purchaseViewModel.canSubmit().subscribe(testSubscriber); purchaseViewModel.nextCreditCard("412341234123"); purchaseViewModel.nextEmail("ndc@gmail.com"); testSubscriber.assertNoErrors(); testSubscriber.assertReceivedOnNext(Collections.singletonList(true)); }