Skip to content

Commit

Permalink
Unit testing what happens when the number of arguments doesn't match …
Browse files Browse the repository at this point in the history
…the number of observables.
  • Loading branch information
abersnaze committed Jun 5, 2013
1 parent 5a35bb2 commit 8345dc7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion rxjava-core/src/main/java/rx/operators/OperationZip.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static <T0, T1, T2, T3, R> Func1<Observer<R>, Subscription> zip(Observabl
@SuppressWarnings("unchecked")
public static <R> Func1<Observer<R>, Subscription> zip(Collection<Observable<?>> ws, FuncN<R> zipFunction) {
Aggregator a = new Aggregator(zipFunction);
for (Observable<?> w : ws) {
for (Observable w : ws) {
ZipObserver zipObserver = new ZipObserver(a, w);
a.addObserver(zipObserver);
}
Expand Down Expand Up @@ -281,6 +281,23 @@ private void stop() {
}

public static class UnitTest {

@SuppressWarnings("unchecked")
@Test
public void testCollectionSizeDifferentThanFunction() {
FuncN<String> zipr = Functions.from(getConcatStringIntegerIntArrayZipr());

/* define a Observer to receive aggregated events */
Observer<String> aObserver = mock(Observer.class);

Collection ws = java.util.Collections.singleton(Observable.from("one", "two"));
Observable<String> w = Observable.create(zip(ws, zipr));
w.subscribe(aObserver);

verify(aObserver, times(1)).onError(any(Exception.class));
verify(aObserver, never()).onCompleted();
verify(aObserver, never()).onNext(any(String.class));
}

@SuppressWarnings("unchecked")
/* mock calls don't do generics */
Expand Down

0 comments on commit 8345dc7

Please sign in to comment.