@@ -30,24 +30,22 @@ public void retryTimesPredicateWithMatchingPredicate() {
3030 final AtomicInteger atomicInteger = new AtomicInteger (3 );
3131 final AtomicInteger numberOfSubscribeCalls = new AtomicInteger (0 );
3232
33- Completable .fromAction (new Action () {
34- @ Override public void run () throws Exception {
35- numberOfSubscribeCalls .incrementAndGet ();
33+ Completable .fromAction (() -> {
34+ numberOfSubscribeCalls .incrementAndGet ();
3635
37- if (atomicInteger .decrementAndGet () != 0 ) {
38- throw new RuntimeException ();
39- }
36+ if (atomicInteger .decrementAndGet () != 0 ) {
37+ throw new RuntimeException ();
38+ }
4039
41- throw new IllegalArgumentException ();
40+ throw new IllegalArgumentException ();
41+ })
42+ .retry (Integer .MAX_VALUE , new Predicate <Throwable >() {
43+ @ Override public boolean test (final Throwable throwable ) throws Exception {
44+ return !(throwable instanceof IllegalArgumentException );
4245 }
4346 })
44- .retry (Integer .MAX_VALUE , new Predicate <Throwable >() {
45- @ Override public boolean test (final Throwable throwable ) throws Exception {
46- return !(throwable instanceof IllegalArgumentException );
47- }
48- })
49- .test ()
50- .assertFailure (IllegalArgumentException .class );
47+ .test ()
48+ .assertFailure (IllegalArgumentException .class );
5149
5250 assertEquals (3 , numberOfSubscribeCalls .get ());
5351 }
@@ -57,18 +55,16 @@ public void retryTimesPredicateWithMatchingRetryAmount() {
5755 final AtomicInteger atomicInteger = new AtomicInteger (3 );
5856 final AtomicInteger numberOfSubscribeCalls = new AtomicInteger (0 );
5957
60- Completable .fromAction (new Action () {
61- @ Override public void run () throws Exception {
62- numberOfSubscribeCalls .incrementAndGet ();
58+ Completable .fromAction (() -> {
59+ numberOfSubscribeCalls .incrementAndGet ();
6360
64- if (atomicInteger .decrementAndGet () != 0 ) {
65- throw new RuntimeException ();
66- }
61+ if (atomicInteger .decrementAndGet () != 0 ) {
62+ throw new RuntimeException ();
6763 }
6864 })
69- .retry (2 , Functions .alwaysTrue ())
70- .test ()
71- .assertResult ();
65+ .retry (2 , Functions .alwaysTrue ())
66+ .test ()
67+ .assertResult ();
7268
7369 assertEquals (3 , numberOfSubscribeCalls .get ());
7470 }
@@ -78,18 +74,16 @@ public void retryTimesPredicateWithNotMatchingRetryAmount() {
7874 final AtomicInteger atomicInteger = new AtomicInteger (3 );
7975 final AtomicInteger numberOfSubscribeCalls = new AtomicInteger (0 );
8076
81- Completable .fromAction (new Action () {
82- @ Override public void run () throws Exception {
83- numberOfSubscribeCalls .incrementAndGet ();
77+ Completable .fromAction (() -> {
78+ numberOfSubscribeCalls .incrementAndGet ();
8479
85- if (atomicInteger .decrementAndGet () != 0 ) {
86- throw new RuntimeException ();
87- }
80+ if (atomicInteger .decrementAndGet () != 0 ) {
81+ throw new RuntimeException ();
8882 }
8983 })
90- .retry (1 , Functions .alwaysTrue ())
91- .test ()
92- .assertFailure (RuntimeException .class );
84+ .retry (1 , Functions .alwaysTrue ())
85+ .test ()
86+ .assertFailure (RuntimeException .class );
9387
9488 assertEquals (2 , numberOfSubscribeCalls .get ());
9589 }
@@ -99,18 +93,16 @@ public void retryTimesPredicateWithZeroRetries() {
9993 final AtomicInteger atomicInteger = new AtomicInteger (2 );
10094 final AtomicInteger numberOfSubscribeCalls = new AtomicInteger (0 );
10195
102- Completable .fromAction (new Action () {
103- @ Override public void run () throws Exception {
104- numberOfSubscribeCalls .incrementAndGet ();
96+ Completable .fromAction (() -> {
97+ numberOfSubscribeCalls .incrementAndGet ();
10598
106- if (atomicInteger .decrementAndGet () != 0 ) {
107- throw new RuntimeException ();
108- }
99+ if (atomicInteger .decrementAndGet () != 0 ) {
100+ throw new RuntimeException ();
109101 }
110102 })
111- .retry (0 , Functions .alwaysTrue ())
112- .test ()
113- .assertFailure (RuntimeException .class );
103+ .retry (0 , Functions .alwaysTrue ())
104+ .test ()
105+ .assertFailure (RuntimeException .class );
114106
115107 assertEquals (1 , numberOfSubscribeCalls .get ());
116108 }
0 commit comments