Subscriptions { public static Subscription create(final Action0 unsubscribe) { return new SafeObservableSubscription(new Subscription() { private volatile boolean unsubscribed = false; @Override public void unsubscribe() { unsubscribed = true; unsubscribe.call(); } @Override public boolean isUnsubscribed() { return unsubscribed; } }); }  static Subscription empty(); static Subscription create(final Action0 unsubscribe); static Subscription from(final Future<?> f); static CompositeSubscription from(Subscription... subscriptions);  }
@Test public void testUnsubscribeOnlyOnce() { Action0 unsubscribe = mock(Action0.class); Subscription subscription = create(unsubscribe); subscription.unsubscribe(); subscription.unsubscribe(); verify(unsubscribe, times(1)).call(); }