FailedPublisherStageFactory implements PublisherStageFactory<Stage.Failed> { @Override public <O> PublisherStage<O> create(Engine engine, Stage.Failed stage) { Throwable error = Objects.requireNonNull(Objects.requireNonNull(stage).getError()); return () -> Flowable.error(error); }  @Override PublisherStage<O> create(Engine engine, Stage.Failed stage);  }
@Test public void createWithError() { Exception failure = new Exception("Boom"); PublisherStage<Object> boom = factory.create(null, () -> failure); TestSubscriber<Object> test = boom.get().test(); test.assertError(failure); }
@Test(expected = NullPointerException.class) public void createWithoutError() { factory.create(null, () -> null); }
@Test(expected = NullPointerException.class) public void createWithoutStage() { factory.create(null, null); }