Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.x: add fluent requestMore to TestSubscriber #4838

Merged
merged 1 commit into from
Nov 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/main/java/io/reactivex/subscribers/TestSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

import org.reactivestreams.*;

import io.reactivex.annotations.Experimental;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.internal.fuseable.QueueSubscription;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import io.reactivex.internal.util.*;
import io.reactivex.internal.util.ExceptionHelper;
import io.reactivex.observers.BaseTestConsumer;

/**
Expand Down Expand Up @@ -403,6 +404,18 @@ public final TestSubscriber<T> assertOf(Consumer<? super TestSubscriber<T>> chec
return this;
}

/**
* Calls {@link #request(long)} and returns this.
* @param n the request amount
* @return this
* @since 2.0.1 - experimental
*/
@Experimental
public final TestSubscriber<T> requestMore(long n) {
request(n);
return this;
}

/**
* A subscriber that ignores all events and does not report errors.
*/
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/io/reactivex/subscribers/TestSubscriberTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1707,4 +1707,16 @@ public void assertValueAtInvalidIndex() {
}
});
}

@Test
public void requestMore() {
Flowable.range(1, 5)
.test(0)
.requestMore(1)
.assertValue(1)
.requestMore(2)
.assertValues(1, 2, 3)
.requestMore(3)
.assertResult(1, 2, 3, 4, 5);
}
}