-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix issues with doOnNextCount() operator, add tests
- Loading branch information
1 parent
632904a
commit e70a0ba
Showing
8 changed files
with
103 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=2.2.0 | ||
version=2.2.2 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Wed Feb 05 12:05:54 CET 2014 | ||
#Sun Nov 26 18:15:25 CST 2017 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=http\://services.gradle.org/distributions/gradle-2.8-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
src/test/java/io/reactivex/rxjavafx/operators/OperatorsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package io.reactivex.rxjavafx.operators; | ||
|
||
import io.reactivex.Flowable; | ||
import io.reactivex.Observable; | ||
import io.reactivex.rxjavafx.transformers.FxFlowableTransformers; | ||
import io.reactivex.rxjavafx.transformers.FxObservableTransformers; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
public final class OperatorsTest { | ||
|
||
@Test | ||
public void testDoOnNextCountObservable() { | ||
|
||
final List<Integer> onNextCounts = new ArrayList<>(); | ||
|
||
Observable.just("Alpha", "Beta", "Gamma") | ||
.compose(FxObservableTransformers.doOnNextCount(onNextCounts::add)) | ||
.subscribe(); | ||
|
||
Assert.assertTrue(onNextCounts.containsAll(Arrays.asList(1, 2, 3))); | ||
} | ||
|
||
@Test | ||
public void testDoOnCompleteCountObservable() { | ||
AtomicInteger onCompleteCount = new AtomicInteger(); | ||
|
||
|
||
Observable.just("Alpha", "Beta", "Gamma") | ||
.compose(FxObservableTransformers.doOnCompleteCount(onCompleteCount::set)) | ||
.subscribe(); | ||
|
||
Assert.assertTrue(onCompleteCount.get() == 3); | ||
} | ||
|
||
@Test | ||
public void testDoOnErrorCountObservable() { | ||
AtomicInteger onErrorCount = new AtomicInteger(); | ||
|
||
|
||
Observable.just(5, 10, 15, 0, 20) | ||
.map(i -> 5 / i) | ||
.compose(FxObservableTransformers.doOnErrorCount(onErrorCount::set)) | ||
.subscribe(); | ||
|
||
Assert.assertTrue(onErrorCount.get() == 3); | ||
} | ||
|
||
|
||
@Test | ||
public void testDoOnNextCountFlowable() { | ||
|
||
final List<Integer> onNextCounts = new ArrayList<>(); | ||
|
||
|
||
Flowable.just("Alpha", "Beta", "Gamma") | ||
.compose(FxFlowableTransformers.doOnNextCount(onNextCounts::add)) | ||
.subscribe(); | ||
|
||
Assert.assertTrue(onNextCounts.containsAll(Arrays.asList(1, 2, 3))); | ||
} | ||
|
||
@Test | ||
public void testDoOnCompleteCountFlowable() { | ||
AtomicInteger onCompleteCount = new AtomicInteger(); | ||
|
||
|
||
Flowable.just("Alpha", "Beta", "Gamma") | ||
.compose(FxFlowableTransformers.doOnCompleteCount(onCompleteCount::set)) | ||
.subscribe(); | ||
|
||
Assert.assertTrue(onCompleteCount.get() == 3); | ||
} | ||
|
||
@Test | ||
public void testDoOnErrorCountFlowable() { | ||
AtomicInteger onErrorCount = new AtomicInteger(); | ||
|
||
|
||
Flowable.just(5, 10, 15, 0, 20) | ||
.map(i -> 5 / i) | ||
.compose(FxFlowableTransformers.doOnErrorCount(onErrorCount::set)) | ||
.subscribe(); | ||
|
||
Assert.assertTrue(onErrorCount.get() == 3); | ||
} | ||
} |