### Question:
ReactiveStreamsAdapters { public static <T> Publisher<T> fromReactiveStreamsPublisher(org.reactivestreams.Publisher<T> source) { return new RsToStPublisher<>(source); } private  ReactiveStreamsAdapters(); static Publisher<T> fromReactiveStreamsPublisher(org.reactivestreams.Publisher<T> source); static org.reactivestreams.Publisher<T> toReactiveStreamsPublisher(Publisher<T> publisher); static org.reactivestreams.Publisher<T> toReactiveStreamsPublisher(PublisherSource<T> source);  }### Answer:
@Test public void fromRSSuccess() throws Exception { Publisher<Integer> rsPublisher = newMockRsPublisher((subscriber, __) -> { subscriber.onNext(1); subscriber.onComplete(); }); Integer result = fromReactiveStreamsPublisher(rsPublisher).firstOrElse(() -> null).toFuture().get(); assertThat("Unexpected result", result, is(1)); }
@Test public void fromRSError() throws Exception { Publisher<Integer> rsPublisher = newMockRsPublisher((subscriber, __) -> subscriber.onError(DELIBERATE_EXCEPTION)); Future<Integer> future = fromReactiveStreamsPublisher(rsPublisher).firstOrElse(() -> null).toFuture(); expectedException.expect(instanceOf(ExecutionException.class)); expectedException.expectCause(sameInstance(DELIBERATE_EXCEPTION)); future.get(); }
@Test public void fromRSCancel() { AtomicReference<Subscription> receivedSubscription = new AtomicReference<>(); Publisher<Integer> rsPublisher = newMockRsPublisher((__, subscription) -> receivedSubscription.set(subscription)); fromReactiveStreamsPublisher(rsPublisher).firstOrElse(() -> null).toFuture().cancel(true); Subscription subscription = receivedSubscription.get(); assertThat("Subscription not received.", subscription, is(notNullValue())); verify(subscription).cancel(); }