1919import static org .mockito .Mockito .verify ;
2020import static org .mockito .Mockito .verifyNoMoreInteractions ;
2121
22- import java .util .Arrays ;
23-
2422import org .junit .Test ;
2523
2624import rx .Observable ;
2725import rx .Observer ;
2826import rx .functions .Func1 ;
29- import rx .observers .TestSubscriber ;
3027
3128public class OperatorAllTest {
3229
33- final Func1 <String , Boolean > hasLength3 = new Func1 <String , Boolean >() {
34- @ Override
35- public Boolean call (String s ) {
36- return s .length () == 3 ;
37- }
38- };
39-
4030 @ Test
4131 @ SuppressWarnings ("unchecked" )
4232 public void testAll () {
43- Observable <Boolean > obs = Observable .from (Arrays . asList ( "one" , "two" , "six" )). all ( hasLength3 );
33+ Observable <String > obs = Observable .from ("one" , "two" , "six" );
4434
4535 Observer <Boolean > observer = mock (Observer .class );
46- obs .subscribe (new TestSubscriber <Boolean >(observer ));
36+ obs .all (new Func1 <String , Boolean >() {
37+ @ Override
38+ public Boolean call (String s ) {
39+ return s .length () == 3 ;
40+ }
41+ }).subscribe (observer );
4742
4843 verify (observer ).onNext (true );
4944 verify (observer ).onCompleted ();
@@ -53,10 +48,15 @@ public void testAll() {
5348 @ Test
5449 @ SuppressWarnings ("unchecked" )
5550 public void testNotAll () {
56- Observable <Boolean > obs = Observable .from (Arrays . asList ( "one" , "two" , "three" , "six" )). all ( hasLength3 );
51+ Observable <String > obs = Observable .from ("one" , "two" , "three" , "six" );
5752
5853 Observer <Boolean > observer = mock (Observer .class );
59- obs .subscribe (new TestSubscriber <Boolean >(observer ));
54+ obs .all (new Func1 <String , Boolean >() {
55+ @ Override
56+ public Boolean call (String s ) {
57+ return s .length () == 3 ;
58+ }
59+ }).subscribe (observer );
6060
6161 verify (observer ).onNext (false );
6262 verify (observer ).onCompleted ();
@@ -66,10 +66,15 @@ public void testNotAll() {
6666 @ Test
6767 @ SuppressWarnings ("unchecked" )
6868 public void testEmpty () {
69- Observable <Boolean > obs = Observable .< String > empty (). all ( hasLength3 );
69+ Observable <String > obs = Observable .empty ();
7070
7171 Observer <Boolean > observer = mock (Observer .class );
72- obs .subscribe (new TestSubscriber <Boolean >(observer ));
72+ obs .all (new Func1 <String , Boolean >() {
73+ @ Override
74+ public Boolean call (String s ) {
75+ return s .length () == 3 ;
76+ }
77+ }).subscribe (observer );
7378
7479 verify (observer ).onNext (true );
7580 verify (observer ).onCompleted ();
@@ -80,10 +85,15 @@ public void testEmpty() {
8085 @ SuppressWarnings ("unchecked" )
8186 public void testError () {
8287 Throwable error = new Throwable ();
83- Observable <Boolean > obs = Observable .< String > error (error ). all ( hasLength3 );
88+ Observable <String > obs = Observable .error (error );
8489
8590 Observer <Boolean > observer = mock (Observer .class );
86- obs .subscribe (new TestSubscriber <Boolean >(observer ));
91+ obs .all (new Func1 <String , Boolean >() {
92+ @ Override
93+ public Boolean call (String s ) {
94+ return s .length () == 3 ;
95+ }
96+ }).subscribe (observer );
8797
8898 verify (observer ).onError (error );
8999 verifyNoMoreInteractions (observer );
0 commit comments