AuthSubscription { public void cancelPreviousSubscription() { if (subscription != null && !subscription.isUnsubscribed()) { subscription.unsubscribe(); } subscription = null; } AuthSubscription(); AuthSubscription setEmail(String email); AuthSubscription setAccount(Account account); AuthSubscription setScope(String scope); AuthSubscription setActivity(Activity activity); AuthSubscription setCallback(AuthCallback callback); Subscription buildAndSubscribe(); void cancelPreviousSubscription();  }
@Test public void shouldCancelSubscription() throws Exception { Subscription mockSubscription = mock(Subscription.class); sut.subscription = mockSubscription; sut.cancelPreviousSubscription(); verify(mockSubscription).unsubscribe(); assertNull(sut.subscription); }