001/***************************************************
002 * Licensed under MIT No Attribution (SPDX: MIT-0) *
003 ***************************************************/
004package org.reactivestreams.tck.flow;
005
006import org.reactivestreams.FlowAdapters;
007import org.reactivestreams.Subscriber;
008import org.reactivestreams.tck.SubscriberWhiteboxVerification;
009import org.reactivestreams.tck.TestEnvironment;
010import org.reactivestreams.tck.flow.support.SubscriberWhiteboxVerificationRules;
011
012import java.util.concurrent.Flow;
013
014/**
015 * Provides whitebox style tests for verifying {@link java.util.concurrent.Flow.Subscriber}
016 * and {@link java.util.concurrent.Flow.Subscription} specification rules.
017 *
018 * @see java.util.concurrent.Flow.Subscriber
019 * @see java.util.concurrent.Flow.Subscription
020 */
021public abstract class FlowSubscriberWhiteboxVerification<T> extends SubscriberWhiteboxVerification<T>
022  implements SubscriberWhiteboxVerificationRules {
023
024  protected FlowSubscriberWhiteboxVerification(TestEnvironment env) {
025    super(env);
026  }
027
028  @Override
029  final public Subscriber<T> createSubscriber(WhiteboxSubscriberProbe<T> probe) {
030    return FlowAdapters.toSubscriber(createFlowSubscriber(probe));
031  }
032  /**
033   * This is the main method you must implement in your test incarnation.
034   * It must create a new {@link org.reactivestreams.Subscriber} instance to be subjected to the testing logic.
035   *
036   * In order to be meaningfully testable your Subscriber must inform the given
037   * `WhiteboxSubscriberProbe` of the respective events having been received.
038   */
039  protected abstract Flow.Subscriber<T> createFlowSubscriber(WhiteboxSubscriberProbe<T> probe);
040}