Java Code Examples for io.reactivex.subscribers.TestSubscriber#assertResult()

The following examples show how to use io.reactivex.subscribers.TestSubscriber#assertResult() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAXRSRxJava2FlowableTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetHelloWorldJson() throws Exception {
    String address = "http://localhost:" + PORT + "/rx2/flowable/textJson";
    List<Object> providers = new LinkedList<>();
    providers.add(new JacksonJsonProvider());
    providers.add(new FlowableRxInvokerProvider());
    WebClient wc = WebClient.create(address, providers);
    Flowable<HelloWorldBean> obs = wc.accept("application/json")
        .rx(FlowableRxInvoker.class)
        .get(HelloWorldBean.class);

    final TestSubscriber<HelloWorldBean> subscriber = new TestSubscriber<>();
    obs.subscribe(subscriber);

    subscriber.await(3, TimeUnit.SECONDS);
    subscriber.assertResult(new HelloWorldBean("Hello", "World"));
}
 
Example 2
Source File: UniToPublisherTest.java    From smallrye-mutiny with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithImmediateValueWithRequest() {
    Publisher<Integer> publisher = Uni.createFrom().item(1).convert().toPublisher();
    assertThat(publisher).isNotNull();
    TestSubscriber<Integer> test = Flowable.fromPublisher(publisher).test(0);
    test.assertSubscribed();
    test.request(1);
    test.assertResult(1);
    test.assertComplete();
}
 
Example 3
Source File: UniToPublisherTest.java    From smallrye-mutiny with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithImmediateValueWithRequests() {
    Publisher<Integer> publisher = Uni.createFrom().item(1).convert().toPublisher();
    assertThat(publisher).isNotNull();
    TestSubscriber<Integer> test = Flowable.fromPublisher(publisher).test(0);
    test.assertSubscribed();
    test.request(20);
    test.assertResult(1);
    test.assertComplete();
}
 
Example 4
Source File: Test_test_operator.java    From Reactive-Programming-With-Java-9 with MIT License 5 votes vote down vote up
@Test
public void testOperator_range() {
	TestSubscriber<Long> test_Subscriber = Flowable.rangeLong(10, 5).test();
	test_Subscriber.assertResult(10L, 11L, 12L, 13L, 14L);
	test_Subscriber.assertValueAt(2, (item) -> {
		return item == 12L;
	});

}
 
Example 5
Source File: LastZipped.java    From akarnokd-misc with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
    PublishProcessor<Integer> pp1 = PublishProcessor.create();
    PublishProcessor<Integer> pp2 = PublishProcessor.create();

    TestSubscriber<Integer> ts = Flowable.zip(pp1.last(1).toFlowable(), pp2.last(2).toFlowable(), (a, b) -> a + b)
    .test();

    pp1.onNext(3);
    pp1.onComplete();
    pp2.onComplete();

    ts.assertResult(5);
}
 
Example 6
Source File: JAXRSRxJava2FlowableTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetHelloWorldAsyncObservable() throws Exception {
    String address = "http://localhost:" + PORT + "/rx2/flowable/textAsync";
    WebClient wc = WebClient.create(address,
                                    Collections.singletonList(new FlowableRxInvokerProvider()));
    Flowable<String> obs = wc.accept("text/plain")
        .rx(FlowableRxInvoker.class)
        .get(String.class);

    final TestSubscriber<String> subscriber = new TestSubscriber<>();
    obs.map(s -> s + s).subscribe(subscriber);
    
    subscriber.await(2, TimeUnit.SECONDS);
    subscriber.assertResult("Hello, world!Hello, world!");
}