FindFirstStageFactory implements TerminalStageFactory<Stage.FindFirst> { @SuppressWarnings("unchecked") @Override public <I, O> TerminalStage<I, O> create(Engine engine, Stage.FindFirst stage) { Objects.requireNonNull(stage); return (TerminalStage<I, O>) INSTANCE; }  @SuppressWarnings("unchecked") @Override TerminalStage<I, O> create(Engine engine, Stage.FindFirst stage);  }
@Test public void create() { Flowable<Integer> flowable = Flowable.fromArray(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) .subscribeOn(Schedulers.computation()); Optional<Integer> optional = ReactiveStreams.fromPublisher(flowable).filter(i -> i > 5) .findFirst().run().toCompletableFuture().join(); assertThat(optional).contains(6); }
@Test(expected = NullPointerException.class) public void createWithoutStage() { factory.create(null, null); }