Skip to content

Commit

Permalink
Merge pull request #190 from prabirshrestha/chainDematerialize
Browse files Browse the repository at this point in the history
update dematerialize so can chain correctly
  • Loading branch information
benjchristensen committed Mar 13, 2013
2 parents bdd91eb + cda38ea commit 22b2e47
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions rxjava-core/src/main/java/rx/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -2598,8 +2598,8 @@ public Observable<Notification<T>> materialize() {
* if attempted on Observable not of type {@code Observable<Notification<T>>}.
*/
@SuppressWarnings("unchecked")
public Observable<T> dematerialize() {
return dematerialize((Observable<Notification<T>>) this);
public <T2> Observable<T2> dematerialize() {
return dematerialize((Observable<Notification<T2>>)this);
}

/**
Expand Down Expand Up @@ -3461,6 +3461,19 @@ public void testLastEmptyObservable() {
assertNull(obs.last());
}

@Test
public void testMaterializeDematerializeChaining() {
Observable<Integer> obs = Observable.just(1);
Observable<Integer> chained = obs.materialize().dematerialize();

Observer<Integer> observer = mock(Observer.class);
chained.subscribe(observer);

verify(observer, times(1)).onNext(1);
verify(observer, times(1)).onCompleted();
verify(observer, times(0)).onError(any(Exception.class));
}

private static class TestException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
Expand Down

0 comments on commit 22b2e47

Please sign in to comment.