Skip to content

Commit 0f4a3b9

Browse files
slievrlyakarnokd
authored andcommitted
simplify junit (#6546)
1 parent 0df3285 commit 0f4a3b9

31 files changed

+83
-83
lines changed

src/test/java/io/reactivex/NotificationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public void valueOfOnCompleteIsNull() {
4141
@Test
4242
public void notEqualsToObject() {
4343
Notification<Integer> n1 = Notification.createOnNext(0);
44-
assertFalse(n1.equals(0));
44+
assertNotEquals(0, n1);
4545
Notification<Integer> n2 = Notification.createOnError(new TestException());
46-
assertFalse(n2.equals(0));
46+
assertNotEquals(0, n2);
4747
Notification<Integer> n3 = Notification.createOnComplete();
48-
assertFalse(n3.equals(0));
48+
assertNotEquals(0, n3);
4949
}
5050

5151
@Test

src/test/java/io/reactivex/completable/CompletableTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4326,7 +4326,7 @@ public boolean test(Throwable t) {
43264326
Assert.assertEquals(2, errors.size());
43274327

43284328
Assert.assertTrue(errors.get(0).toString(), errors.get(0) instanceof TestException);
4329-
Assert.assertEquals(errors.get(0).toString(), null, errors.get(0).getMessage());
4329+
Assert.assertNull(errors.get(0).toString(), errors.get(0).getMessage());
43304330
Assert.assertTrue(errors.get(1).toString(), errors.get(1) instanceof TestException);
43314331
Assert.assertEquals(errors.get(1).toString(), "Forced inner failure", errors.get(1).getMessage());
43324332
}

src/test/java/io/reactivex/exceptions/OnNextValueTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void onError(Throwable e) {
7171

7272
assertTrue(trace, trace.contains("OnNextValue"));
7373

74-
assertTrue("No Cause on throwable" + e, e.getCause() != null);
74+
assertNotNull("No Cause on throwable" + e, e.getCause());
7575
// assertTrue(e.getCause().getClass().getSimpleName() + " no OnNextValue",
7676
// e.getCause() instanceof OnErrorThrowable.OnNextValue);
7777
}

src/test/java/io/reactivex/flowable/FlowableMergeTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void testMergeCovariance3() {
6969

7070
assertTrue(values.get(0) instanceof HorrorMovie);
7171
assertTrue(values.get(1) instanceof Movie);
72-
assertTrue(values.get(2) != null);
72+
assertNotNull(values.get(2));
7373
assertTrue(values.get(3) instanceof HorrorMovie);
7474
}
7575

@@ -92,7 +92,7 @@ public Publisher<Movie> call() {
9292

9393
assertTrue(values.get(0) instanceof HorrorMovie);
9494
assertTrue(values.get(1) instanceof Movie);
95-
assertTrue(values.get(2) != null);
95+
assertNotNull(values.get(2));
9696
assertTrue(values.get(3) instanceof HorrorMovie);
9797
}
9898

src/test/java/io/reactivex/flowable/FlowableNotificationTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,58 +23,58 @@ public class FlowableNotificationTest {
2323
public void testOnNextIntegerNotificationDoesNotEqualNullNotification() {
2424
final Notification<Integer> integerNotification = Notification.createOnNext(1);
2525
final Notification<Integer> nullNotification = Notification.createOnNext(null);
26-
Assert.assertFalse(integerNotification.equals(nullNotification));
26+
Assert.assertNotEquals(integerNotification, nullNotification);
2727
}
2828

2929
@Test(expected = NullPointerException.class)
3030
public void testOnNextNullNotificationDoesNotEqualIntegerNotification() {
3131
final Notification<Integer> integerNotification = Notification.createOnNext(1);
3232
final Notification<Integer> nullNotification = Notification.createOnNext(null);
33-
Assert.assertFalse(nullNotification.equals(integerNotification));
33+
Assert.assertNotEquals(nullNotification, integerNotification);
3434
}
3535

3636
@Test
3737
public void testOnNextIntegerNotificationsWhenEqual() {
3838
final Notification<Integer> integerNotification = Notification.createOnNext(1);
3939
final Notification<Integer> integerNotification2 = Notification.createOnNext(1);
40-
Assert.assertTrue(integerNotification.equals(integerNotification2));
40+
Assert.assertEquals(integerNotification, integerNotification2);
4141
}
4242

4343
@Test
4444
public void testOnNextIntegerNotificationsWhenNotEqual() {
4545
final Notification<Integer> integerNotification = Notification.createOnNext(1);
4646
final Notification<Integer> integerNotification2 = Notification.createOnNext(2);
47-
Assert.assertFalse(integerNotification.equals(integerNotification2));
47+
Assert.assertNotEquals(integerNotification, integerNotification2);
4848
}
4949

5050
@Test
5151
@Ignore("Nulls are not allowed")
5252
public void testOnErrorIntegerNotificationDoesNotEqualNullNotification() {
5353
final Notification<Integer> integerNotification = Notification.createOnError(new Exception());
5454
final Notification<Integer> nullNotification = Notification.createOnError(null);
55-
Assert.assertFalse(integerNotification.equals(nullNotification));
55+
Assert.assertNotEquals(integerNotification, nullNotification);
5656
}
5757

5858
@Test
5959
@Ignore("Nulls are not allowed")
6060
public void testOnErrorNullNotificationDoesNotEqualIntegerNotification() {
6161
final Notification<Integer> integerNotification = Notification.createOnError(new Exception());
6262
final Notification<Integer> nullNotification = Notification.createOnError(null);
63-
Assert.assertFalse(nullNotification.equals(integerNotification));
63+
Assert.assertNotEquals(nullNotification, integerNotification);
6464
}
6565

6666
@Test
6767
public void testOnErrorIntegerNotificationsWhenEqual() {
6868
final Exception exception = new Exception();
6969
final Notification<Integer> onErrorNotification = Notification.createOnError(exception);
7070
final Notification<Integer> onErrorNotification2 = Notification.createOnError(exception);
71-
Assert.assertTrue(onErrorNotification.equals(onErrorNotification2));
71+
Assert.assertEquals(onErrorNotification, onErrorNotification2);
7272
}
7373

7474
@Test
7575
public void testOnErrorIntegerNotificationWhenNotEqual() {
7676
final Notification<Integer> onErrorNotification = Notification.createOnError(new Exception());
7777
final Notification<Integer> onErrorNotification2 = Notification.createOnError(new Exception());
78-
Assert.assertFalse(onErrorNotification.equals(onErrorNotification2));
78+
Assert.assertNotEquals(onErrorNotification, onErrorNotification2);
7979
}
8080
}

src/test/java/io/reactivex/internal/operators/flowable/BlockingFlowableLatestTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public void testSimple() {
4343
for (int i = 0; i < 9; i++) {
4444
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
4545

46-
Assert.assertEquals(true, it.hasNext());
46+
Assert.assertTrue(it.hasNext());
4747

4848
Assert.assertEquals(Long.valueOf(i), it.next());
4949
}
5050

5151
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
52-
Assert.assertEquals(false, it.hasNext());
52+
Assert.assertFalse(it.hasNext());
5353
}
5454

5555
@Test(timeout = 1000)
@@ -68,13 +68,13 @@ public void testSameSourceMultipleIterators() {
6868
for (int i = 0; i < 9; i++) {
6969
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
7070

71-
Assert.assertEquals(true, it.hasNext());
71+
Assert.assertTrue(it.hasNext());
7272

7373
Assert.assertEquals(Long.valueOf(i), it.next());
7474
}
7575

7676
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
77-
Assert.assertEquals(false, it.hasNext());
77+
Assert.assertFalse(it.hasNext());
7878
}
7979
}
8080

@@ -86,7 +86,7 @@ public void testEmpty() {
8686

8787
Iterator<Long> it = iter.iterator();
8888

89-
Assert.assertEquals(false, it.hasNext());
89+
Assert.assertFalse(it.hasNext());
9090

9191
it.next();
9292
}
@@ -165,7 +165,7 @@ public void testFasterSource() {
165165
source.onNext(7);
166166
source.onComplete();
167167

168-
Assert.assertEquals(false, it.hasNext());
168+
Assert.assertFalse(it.hasNext());
169169
}
170170

171171
@Ignore("THe target is an enum")

src/test/java/io/reactivex/internal/operators/flowable/BlockingFlowableMostRecentTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
public class BlockingFlowableMostRecentTest {
2929
@Test
3030
public void testMostRecentNull() {
31-
assertEquals(null, Flowable.<Void>never().blockingMostRecent(null).iterator().next());
31+
assertNull(Flowable.<Void>never().blockingMostRecent(null).iterator().next());
3232
}
3333

3434
@Test
@@ -87,12 +87,12 @@ public void testSingleSourceManyIterators() {
8787
for (int i = 0; i < 9; i++) {
8888
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
8989

90-
Assert.assertEquals(true, it.hasNext());
90+
Assert.assertTrue(it.hasNext());
9191
Assert.assertEquals(Long.valueOf(i), it.next());
9292
}
9393
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
9494

95-
Assert.assertEquals(false, it.hasNext());
95+
Assert.assertFalse(it.hasNext());
9696
}
9797

9898
}

src/test/java/io/reactivex/internal/operators/flowable/BlockingFlowableNextTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public void testSingleSourceManyIterators() throws InterruptedException {
318318
BlockingFlowableNext.NextIterator<Long> it = (BlockingFlowableNext.NextIterator<Long>)iter.iterator();
319319

320320
for (long i = 0; i < 10; i++) {
321-
Assert.assertEquals(true, it.hasNext());
321+
Assert.assertTrue(it.hasNext());
322322
Assert.assertEquals(j + "th iteration next", Long.valueOf(i), it.next());
323323
}
324324
terminal.onNext(1);

src/test/java/io/reactivex/internal/operators/flowable/BlockingFlowableToFutureTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@ public void testGetWithEmptyFlowable() throws Throwable {
120120
public void testGetWithASingleNullItem() throws Exception {
121121
Flowable<String> obs = Flowable.just((String)null);
122122
Future<String> f = obs.toFuture();
123-
assertEquals(null, f.get());
123+
assertNull(f.get());
124124
}
125125
}

src/test/java/io/reactivex/internal/operators/flowable/BlockingFlowableToIteratorTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ public void testToIterator() {
3333

3434
Iterator<String> it = obs.blockingIterable().iterator();
3535

36-
assertEquals(true, it.hasNext());
36+
assertTrue(it.hasNext());
3737
assertEquals("one", it.next());
3838

39-
assertEquals(true, it.hasNext());
39+
assertTrue(it.hasNext());
4040
assertEquals("two", it.next());
4141

42-
assertEquals(true, it.hasNext());
42+
assertTrue(it.hasNext());
4343
assertEquals("three", it.next());
4444

45-
assertEquals(false, it.hasNext());
45+
assertFalse(it.hasNext());
4646

4747
}
4848

@@ -60,10 +60,10 @@ public void subscribe(Subscriber<? super String> subscriber) {
6060

6161
Iterator<String> it = obs.blockingIterable().iterator();
6262

63-
assertEquals(true, it.hasNext());
63+
assertTrue(it.hasNext());
6464
assertEquals("one", it.next());
6565

66-
assertEquals(true, it.hasNext());
66+
assertTrue(it.hasNext());
6767
it.next();
6868
}
6969

0 commit comments

Comments
 (0)