source: class WorkflowTest {
  
    @Rule public final AndroidSchedulersRule androidSchedulersRuleRx2;
    private final BehaviorSubject<InteractorEvent> interactorLifecycleSubject;
    private final PublishSubject<Step.Data<Object, ActionableItem>> returnValueSubject;
  
    @Test
    public void createSingle_shouldReturnASingleThatRunsTheWorkflow() {
  
target:     ActionableItem actionableItem =
          new ActionableItem() {
            @NonNull
            @Override
            public Observable<InteractorEvent> lifecycle() {
              return interactorLifecycleSubject;
            }
          };
  
      Workflow<Object, ActionableItem> workflow =
          new Workflow<Object, ActionableItem>() {
            @NonNull
            @Override
            protected Step<Object, ActionableItem> getSteps(@NonNull ActionableItem actionableItem) {
              return Step.from(returnValueSubject.singleOrError());
            }
          };
  
      TestObserver<Optional<Object>> testSubscriber = new TestObserver<>();
      workflow.createSingle(actionableItem).subscribe(testSubscriber);
  
      interactorLifecycleSubject.onNext(InteractorEvent.ACTIVE);
      Object returnValue = new Object();
      returnValueSubject.onNext(new Step.Data<>(returnValue, actionableItem));
      returnValueSubject.onComplete();
  
      testSubscriber.assertValueCount(1);
      assertThat(testSubscriber.values().get(0).get()).isEqualTo(returnValue);
      testSubscriber.assertComplete();
      testSubscriber.assertNoErrors();
    }
  
  }