I have got the java code like this
mDataManager.getObservable(\"hello\").subscribe( subscriber );
and I want to verify
the follow
I found that RxJava provides a class called TestSubject
You can create it like this
private TestScheduler eventsScheduler = new TestScheduler();
private TestSubject eventObservable = TestSubject.create(eventsScheduler);
This will provide you with the method hasObservers()
which returns a boolean.
@Test
public void testSubscription(){
myTestClass.init(eventObservable);
assertTrue(eventObservable.hasObservers());
}
Also the TestSubject allows you to perfectly time when events should be sent.
eventObservable.onNext(new MyEvent());
eventsScheduler.triggerActions();