| 1 |
/* |
| 2 |
* Copyright (c) 2016-present, RxJava Contributors. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 5 |
* compliance with the License. You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 10 |
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See |
| 11 |
* the License for the specific language governing permissions and limitations under the License. |
| 12 |
*/ |
| 13 |
|
| 14 |
package io.reactivex.rxjava3.flowable; |
| 15 |
|
| 16 |
import static org.junit.Assert.*; |
| 17 |
|
| 18 |
import java.lang.reflect.*; |
| 19 |
import java.util.*; |
| 20 |
import java.util.concurrent.*; |
| 21 |
|
| 22 |
import org.junit.*; |
| 23 |
import org.reactivestreams.*; |
| 24 |
|
| 25 |
import io.reactivex.rxjava3.core.*; |
| 26 |
import io.reactivex.rxjava3.exceptions.*; |
| 27 |
import io.reactivex.rxjava3.functions.*; |
| 28 |
import io.reactivex.rxjava3.internal.functions.Functions; |
| 29 |
import io.reactivex.rxjava3.processors.*; |
| 30 |
import io.reactivex.rxjava3.schedulers.Schedulers; |
| 31 |
import io.reactivex.rxjava3.subscribers.TestSubscriber; |
| 32 |
import io.reactivex.rxjava3.testsupport.TestHelper; |
| 33 |
|
| 34 |
/** |
| 35 |
* Verifies the operators handle null values properly by emitting/throwing NullPointerExceptions. |
| 36 |
*/ |
| 37 |
public class FlowableNullTests extends RxJavaTest { |
| 38 |
|
| 39 |
Flowable<Integer> just1 = Flowable.just(1); |
| 40 |
|
| 41 |
//*********************************************************** |
| 42 |
// Static methods |
| 43 |
//*********************************************************** |
| 44 |
|
| 45 |
@Test(expected = NullPointerException.class) |
| 46 |
public void ambVarargsOneIsNull() { |
| 47 |
Flowable.ambArray(Flowable.never(), null).blockingLast(); |
| 48 |
} |
| 49 |
|
| 50 |
@Test |
| 51 |
public void ambIterableIteratorNull() { |
| 52 |
Flowable.amb(new Iterable<Publisher<Object>>() { |
| 53 |
@Override |
| 54 |
public Iterator<Publisher<Object>> iterator() { |
| 55 |
return null; |
| 56 |
} |
| 57 |
}).test().assertError(NullPointerException.class); |
| 58 |
} |
| 59 |
|
| 60 |
@Test |
| 61 |
public void ambIterableOneIsNull() { |
| 62 |
Flowable.amb(Arrays.asList(Flowable.never(), null)) |
| 63 |
.test() |
| 64 |
.assertError(NullPointerException.class); |
| 65 |
} |
| 66 |
|
| 67 |
@Test(expected = NullPointerException.class) |
| 68 |
public void combineLatestIterableIteratorNull() { |
| 69 |
Flowable.combineLatestDelayError(new Iterable<Publisher<Object>>() { |
| 70 |
@Override |
| 71 |
public Iterator<Publisher<Object>> iterator() { |
| 72 |
return null; |
| 73 |
} |
| 74 |
}, new Function<Object[], Object>() { |
| 75 |
@Override |
| 76 |
public Object apply(Object[] v) { |
| 77 |
return 1; |
| 78 |
} |
| 79 |
}).blockingLast(); |
| 80 |
} |
| 81 |
|
| 82 |
@Test(expected = NullPointerException.class) |
| 83 |
public void combineLatestIterableOneIsNull() { |
| 84 |
Flowable.combineLatestDelayError(Arrays.asList(Flowable.never(), null), new Function<Object[], Object>() { |
| 85 |
@Override |
| 86 |
public Object apply(Object[] v) { |
| 87 |
return 1; |
| 88 |
} |
| 89 |
}).blockingLast(); |
| 90 |
} |
| 91 |
|
| 92 |
@Test(expected = NullPointerException.class) |
| 93 |
public void combineLatestIterableFunctionReturnsNull() { |
| 94 |
Flowable.combineLatestDelayError(Arrays.asList(just1), new Function<Object[], Object>() { |
| 95 |
@Override |
| 96 |
public Object apply(Object[] v) { |
| 97 |
return null; |
| 98 |
} |
| 99 |
}).blockingLast(); |
| 100 |
} |
| 101 |
|
| 102 |
@Test(expected = NullPointerException.class) |
| 103 |
public void concatIterableIteratorNull() { |
| 104 |
Flowable.concat(new Iterable<Publisher<Object>>() { |
| 105 |
@Override |
| 106 |
public Iterator<Publisher<Object>> iterator() { |
| 107 |
return null; |
| 108 |
} |
| 109 |
}).blockingLast(); |
| 110 |
} |
| 111 |
|
| 112 |
@Test(expected = NullPointerException.class) |
| 113 |
public void concatIterableOneIsNull() { |
| 114 |
Flowable.concat(Arrays.asList(just1, null)).blockingLast(); |
| 115 |
} |
| 116 |
|
| 117 |
@Test(expected = NullPointerException.class) |
| 118 |
public void concatArrayOneIsNull() { |
| 119 |
Flowable.concatArray(just1, null).blockingLast(); |
| 120 |
} |
| 121 |
|
| 122 |
@Test(expected = NullPointerException.class) |
| 123 |
public void deferFunctionReturnsNull() { |
| 124 |
Flowable.defer(new Supplier<Publisher<Object>>() { |
| 125 |
@Override |
| 126 |
public Publisher<Object> get() { |
| 127 |
return null; |
| 128 |
} |
| 129 |
}).blockingLast(); |
| 130 |
} |
| 131 |
|
| 132 |
@Test(expected = NullPointerException.class) |
| 133 |
public void errorFunctionReturnsNull() { |
| 134 |
Flowable.error(new Supplier<Throwable>() { |
| 135 |
@Override |
| 136 |
public Throwable get() { |
| 137 |
return null; |
| 138 |
} |
| 139 |
}).blockingSubscribe(); |
| 140 |
} |
| 141 |
|
| 142 |
@Test(expected = NullPointerException.class) |
| 143 |
public void fromArrayOneIsNull() { |
| 144 |
Flowable.fromArray(1, null).blockingLast(); |
| 145 |
} |
| 146 |
|
| 147 |
@Test(expected = NullPointerException.class) |
| 148 |
public void fromCallableReturnsNull() { |
| 149 |
Flowable.fromCallable(new Callable<Object>() { |
| 150 |
@Override |
| 151 |
public Object call() throws Exception { |
| 152 |
return null; |
| 153 |
} |
| 154 |
}).blockingLast(); |
| 155 |
} |
| 156 |
|
| 157 |
@Test |
| 158 |
public void fromFutureReturnsNull() { |
| 159 |
FutureTask<Object> f = new FutureTask<>(Functions.EMPTY_RUNNABLE, null); |
| 160 |
f.run(); |
| 161 |
|
| 162 |
TestSubscriber<Object> ts = new TestSubscriber<>(); |
| 163 |
Flowable.fromFuture(f).subscribe(ts); |
| 164 |
ts.assertNoValues(); |
| 165 |
ts.assertNotComplete(); |
| 166 |
ts.assertError(NullPointerException.class); |
| 167 |
} |
| 168 |
|
| 169 |
@Test(expected = NullPointerException.class) |
| 170 |
public void fromFutureTimedReturnsNull() { |
| 171 |
FutureTask<Object> f = new FutureTask<>(Functions.EMPTY_RUNNABLE, null); |
| 172 |
f.run(); |
| 173 |
Flowable.fromFuture(f, 1, TimeUnit.SECONDS).blockingLast(); |
| 174 |
} |
| 175 |
|
| 176 |
@Test(expected = NullPointerException.class) |
| 177 |
public void fromIterableIteratorNull() { |
| 178 |
Flowable.fromIterable(new Iterable<Object>() { |
| 179 |
@Override |
| 180 |
public Iterator<Object> iterator() { |
| 181 |
return null; |
| 182 |
} |
| 183 |
}).blockingLast(); |
| 184 |
} |
| 185 |
|
| 186 |
@Test(expected = NullPointerException.class) |
| 187 |
public void fromIterableValueNull() { |
| 188 |
Flowable.fromIterable(Arrays.asList(1, null)).blockingLast(); |
| 189 |
} |
| 190 |
|
| 191 |
@Test(expected = NullPointerException.class) |
| 192 |
public void generateConsumerEmitsNull() { |
| 193 |
Flowable.generate(new Consumer<Emitter<Object>>() { |
| 194 |
@Override |
| 195 |
public void accept(Emitter<Object> s) { |
| 196 |
s.onNext(null); |
| 197 |
} |
| 198 |
}).blockingLast(); |
| 199 |
} |
| 200 |
|
| 201 |
@Test(expected = NullPointerException.class) |
| 202 |
public void generateStateConsumerInitialStateNull() { |
| 203 |
BiConsumer<Integer, Emitter<Integer>> generator = new BiConsumer<Integer, Emitter<Integer>>() { |
| 204 |
@Override |
| 205 |
public void accept(Integer s, Emitter<Integer> o) { |
| 206 |
o.onNext(1); |
| 207 |
} |
| 208 |
}; |
| 209 |
Flowable.generate(null, generator); |
| 210 |
} |
| 211 |
|
| 212 |
@Test(expected = NullPointerException.class) |
| 213 |
public void generateStateFunctionInitialStateNull() { |
| 214 |
Flowable.generate(null, new BiFunction<Object, Emitter<Object>, Object>() { |
| 215 |
@Override |
| 216 |
public Object apply(Object s, Emitter<Object> o) { |
| 217 |
o.onNext(1); return s; |
| 218 |
} |
| 219 |
}); |
| 220 |
} |
| 221 |
|
| 222 |
@Test(expected = NullPointerException.class) |
| 223 |
public void generateStateConsumerNull() { |
| 224 |
Flowable.generate(new Supplier<Integer>() { |
| 225 |
@Override |
| 226 |
public Integer get() { |
| 227 |
return 1; |
| 228 |
} |
| 229 |
}, (BiConsumer<Integer, Emitter<Object>>)null); |
| 230 |
} |
| 231 |
|
| 232 |
@Test |
| 233 |
public void generateConsumerStateNullAllowed() { |
| 234 |
BiConsumer<Integer, Emitter<Integer>> generator = new BiConsumer<Integer, Emitter<Integer>>() { |
| 235 |
@Override |
| 236 |
public void accept(Integer s, Emitter<Integer> o) { |
| 237 |
o.onComplete(); |
| 238 |
} |
| 239 |
}; |
| 240 |
Flowable.generate(new Supplier<Integer>() { |
| 241 |
@Override |
| 242 |
public Integer get() { |
| 243 |
return null; |
| 244 |
} |
| 245 |
}, generator).blockingSubscribe(); |
| 246 |
} |
| 247 |
|
| 248 |
@Test |
| 249 |
public void generateFunctionStateNullAllowed() { |
| 250 |
Flowable.generate(new Supplier<Object>() { |
| 251 |
@Override |
| 252 |
public Object get() { |
| 253 |
return null; |
| 254 |
} |
| 255 |
}, new BiFunction<Object, Emitter<Object>, Object>() { |
| 256 |
@Override |
| 257 |
public Object apply(Object s, Emitter<Object> o) { |
| 258 |
o.onComplete(); return s; |
| 259 |
} |
| 260 |
}).blockingSubscribe(); |
| 261 |
} |
| 262 |
|
| 263 |
@Test |
| 264 |
public void justNull() throws Exception { |
| 265 |
@SuppressWarnings("rawtypes") |
| 266 |
Class<Flowable> clazz = Flowable.class; |
| 267 |
for (int argCount = 1; argCount < 10; argCount++) { |
| 268 |
for (int argNull = 1; argNull <= argCount; argNull++) { |
| 269 |
Class<?>[] params = new Class[argCount]; |
| 270 |
Arrays.fill(params, Object.class); |
| 271 |
|
| 272 |
Object[] values = new Object[argCount]; |
| 273 |
Arrays.fill(values, 1); |
| 274 |
values[argNull - 1] = null; |
| 275 |
|
| 276 |
Method m = clazz.getMethod("just", params); |
| 277 |
|
| 278 |
try { |
| 279 |
m.invoke(null, values); |
| 280 |
Assert.fail("No exception for argCount " + argCount + " / argNull " + argNull); |
| 281 |
} catch (InvocationTargetException ex) { |
| 282 |
if (!(ex.getCause() instanceof NullPointerException)) { |
| 283 |
Assert.fail("Unexpected exception for argCount " + argCount + " / argNull " + argNull + ": " + ex); |
| 284 |
} |
| 285 |
} |
| 286 |
} |
| 287 |
} |
| 288 |
} |
| 289 |
|
| 290 |
@Test(expected = NullPointerException.class) |
| 291 |
public void mergeIterableIteratorNull() { |
| 292 |
Flowable.merge(new Iterable<Publisher<Object>>() { |
| 293 |
@Override |
| 294 |
public Iterator<Publisher<Object>> iterator() { |
| 295 |
return null; |
| 296 |
} |
| 297 |
}, 128, 128).blockingLast(); |
| 298 |
} |
| 299 |
|
| 300 |
@Test(expected = NullPointerException.class) |
| 301 |
public void mergeIterableOneIsNull() { |
| 302 |
Flowable.merge(Arrays.asList(just1, null), 128, 128).blockingLast(); |
| 303 |
} |
| 304 |
|
| 305 |
@Test(expected = NullPointerException.class) |
| 306 |
public void mergeArrayOneIsNull() { |
| 307 |
Flowable.mergeArray(128, 128, just1, null).blockingLast(); |
| 308 |
} |
| 309 |
|
| 310 |
@Test(expected = NullPointerException.class) |
| 311 |
public void mergeDelayErrorIterableIteratorNull() { |
| 312 |
Flowable.mergeDelayError(new Iterable<Publisher<Object>>() { |
| 313 |
@Override |
| 314 |
public Iterator<Publisher<Object>> iterator() { |
| 315 |
return null; |
| 316 |
} |
| 317 |
}, 128, 128).blockingLast(); |
| 318 |
} |
| 319 |
|
| 320 |
@Test(expected = NullPointerException.class) |
| 321 |
public void mergeDelayErrorIterableOneIsNull() { |
| 322 |
Flowable.mergeDelayError(Arrays.asList(just1, null), 128, 128).blockingLast(); |
| 323 |
} |
| 324 |
|
| 325 |
@Test(expected = NullPointerException.class) |
| 326 |
public void mergeDelayErrorArrayOneIsNull() { |
| 327 |
Flowable.mergeArrayDelayError(128, 128, just1, null).blockingLast(); |
| 328 |
} |
| 329 |
|
| 330 |
@Test(expected = NullPointerException.class) |
| 331 |
public void usingFlowableSupplierReturnsNull() { |
| 332 |
Flowable.using(new Supplier<Object>() { |
| 333 |
@Override |
| 334 |
public Object get() { |
| 335 |
return 1; |
| 336 |
} |
| 337 |
}, new Function<Object, Publisher<Object>>() { |
| 338 |
@Override |
| 339 |
public Publisher<Object> apply(Object d) { |
| 340 |
return null; |
| 341 |
} |
| 342 |
}, Functions.emptyConsumer()).blockingLast(); |
| 343 |
} |
| 344 |
|
| 345 |
@Test(expected = NullPointerException.class) |
| 346 |
public void zipIterableIteratorNull() { |
| 347 |
Flowable.zip(new Iterable<Publisher<Object>>() { |
| 348 |
@Override |
| 349 |
public Iterator<Publisher<Object>> iterator() { |
| 350 |
return null; |
| 351 |
} |
| 352 |
}, new Function<Object[], Object>() { |
| 353 |
@Override |
| 354 |
public Object apply(Object[] v) { |
| 355 |
return 1; |
| 356 |
} |
| 357 |
}).blockingLast(); |
| 358 |
} |
| 359 |
|
| 360 |
@Test(expected = NullPointerException.class) |
| 361 |
public void zipIterableFunctionReturnsNull() { |
| 362 |
Flowable.zip(Arrays.asList(just1, just1), new Function<Object[], Object>() { |
| 363 |
@Override |
| 364 |
public Object apply(Object[] a) { |
| 365 |
return null; |
| 366 |
} |
| 367 |
}).blockingLast(); |
| 368 |
} |
| 369 |
|
| 370 |
@Test(expected = NullPointerException.class) |
| 371 |
public void zipIterable2Null() { |
| 372 |
Flowable.zip((Iterable<Publisher<Object>>)null, new Function<Object[], Object>() { |
| 373 |
@Override |
| 374 |
public Object apply(Object[] a) { |
| 375 |
return 1; |
| 376 |
} |
| 377 |
}, true, 128); |
| 378 |
} |
| 379 |
|
| 380 |
@Test(expected = NullPointerException.class) |
| 381 |
public void zipIterable2IteratorNull() { |
| 382 |
Flowable.zip(new Iterable<Publisher<Object>>() { |
| 383 |
@Override |
| 384 |
public Iterator<Publisher<Object>> iterator() { |
| 385 |
return null; |
| 386 |
} |
| 387 |
}, new Function<Object[], Object>() { |
| 388 |
@Override |
| 389 |
public Object apply(Object[] a) { |
| 390 |
return 1; |
| 391 |
} |
| 392 |
}, true, 128).blockingLast(); |
| 393 |
} |
| 394 |
|
| 395 |
@Test(expected = NullPointerException.class) |
| 396 |
public void zipIterable2FunctionReturnsNull() { |
| 397 |
Flowable.zip(Arrays.asList(just1, just1), new Function<Object[], Object>() { |
| 398 |
@Override |
| 399 |
public Object apply(Object[] a) { |
| 400 |
return null; |
| 401 |
} |
| 402 |
}, true, 128).blockingLast(); |
| 403 |
} |
| 404 |
|
| 405 |
//************************************************************* |
| 406 |
// Instance methods |
| 407 |
//************************************************************* |
| 408 |
|
| 409 |
@Test(expected = NullPointerException.class) |
| 410 |
public void bufferSupplierReturnsNull() { |
| 411 |
just1.buffer(1, 1, new Supplier<Collection<Integer>>() { |
| 412 |
@Override |
| 413 |
public Collection<Integer> get() { |
| 414 |
return null; |
| 415 |
} |
| 416 |
}).blockingSubscribe(); |
| 417 |
} |
| 418 |
|
| 419 |
@Test(expected = NullPointerException.class) |
| 420 |
public void bufferTimedSupplierReturnsNull() { |
| 421 |
just1.buffer(1L, 1L, TimeUnit.SECONDS, Schedulers.single(), new Supplier<Collection<Integer>>() { |
| 422 |
@Override |
| 423 |
public Collection<Integer> get() { |
| 424 |
return null; |
| 425 |
} |
| 426 |
}).blockingSubscribe(); |
| 427 |
} |
| 428 |
|
| 429 |
@Test(expected = NullPointerException.class) |
| 430 |
public void bufferOpenCloseCloseReturnsNull() { |
| 431 |
just1.buffer(just1, new Function<Integer, Publisher<Object>>() { |
| 432 |
@Override |
| 433 |
public Publisher<Object> apply(Integer v) { |
| 434 |
return null; |
| 435 |
} |
| 436 |
}).blockingSubscribe(); |
| 437 |
} |
| 438 |
|
| 439 |
@Test(expected = NullPointerException.class) |
| 440 |
public void bufferBoundarySupplierReturnsNull() { |
| 441 |
just1.buffer(just1, new Supplier<Collection<Integer>>() { |
| 442 |
@Override |
| 443 |
public Collection<Integer> get() { |
| 444 |
return null; |
| 445 |
} |
| 446 |
}).blockingSubscribe(); |
| 447 |
} |
| 448 |
|
| 449 |
@Test(expected = NullPointerException.class) |
| 450 |
public void collectInitialSupplierReturnsNull() { |
| 451 |
just1.collect(new Supplier<Object>() { |
| 452 |
@Override |
| 453 |
public Object get() { |
| 454 |
return null; |
| 455 |
} |
| 456 |
}, new BiConsumer<Object, Integer>() { |
| 457 |
@Override |
| 458 |
public void accept(Object a, Integer b) { } |
| 459 |
}).blockingGet(); |
| 460 |
} |
| 461 |
|
| 462 |
@Test(expected = NullPointerException.class) |
| 463 |
public void concatMapReturnsNull() { |
| 464 |
just1.concatMap(new Function<Integer, Publisher<Object>>() { |
| 465 |
@Override |
| 466 |
public Publisher<Object> apply(Integer v) { |
| 467 |
return null; |
| 468 |
} |
| 469 |
}).blockingSubscribe(); |
| 470 |
} |
| 471 |
|
| 472 |
@Test(expected = NullPointerException.class) |
| 473 |
public void concatMapIterableReturnNull() { |
| 474 |
just1.concatMapIterable(new Function<Integer, Iterable<Object>>() { |
| 475 |
@Override |
| 476 |
public Iterable<Object> apply(Integer v) { |
| 477 |
return null; |
| 478 |
} |
| 479 |
}).blockingSubscribe(); |
| 480 |
} |
| 481 |
|
| 482 |
@Test(expected = NullPointerException.class) |
| 483 |
public void concatMapIterableIteratorNull() { |
| 484 |
just1.concatMapIterable(new Function<Integer, Iterable<Object>>() { |
| 485 |
@Override |
| 486 |
public Iterable<Object> apply(Integer v) { |
| 487 |
return new Iterable<Object>() { |
| 488 |
@Override |
| 489 |
public Iterator<Object> iterator() { |
| 490 |
return null; |
| 491 |
} |
| 492 |
}; |
| 493 |
} |
| 494 |
}).blockingSubscribe(); |
| 495 |
} |
| 496 |
|
| 497 |
@Test(expected = NullPointerException.class) |
| 498 |
public void debounceFunctionReturnsNull() { |
| 499 |
just1.debounce(new Function<Integer, Publisher<Object>>() { |
| 500 |
@Override |
| 501 |
public Publisher<Object> apply(Integer v) { |
| 502 |
return null; |
| 503 |
} |
| 504 |
}).blockingSubscribe(); |
| 505 |
} |
| 506 |
|
| 507 |
@Test(expected = NullPointerException.class) |
| 508 |
public void delayWithFunctionReturnsNull() { |
| 509 |
just1.delay(new Function<Integer, Publisher<Object>>() { |
| 510 |
@Override |
| 511 |
public Publisher<Object> apply(Integer v) { |
| 512 |
return null; |
| 513 |
} |
| 514 |
}).blockingSubscribe(); |
| 515 |
} |
| 516 |
|
| 517 |
@Test(expected = NullPointerException.class) |
| 518 |
public void delayBothItemSupplierReturnsNull() { |
| 519 |
just1.delay(just1, new Function<Integer, Publisher<Object>>() { |
| 520 |
@Override |
| 521 |
public Publisher<Object> apply(Integer v) { |
| 522 |
return null; |
| 523 |
} |
| 524 |
}).blockingSubscribe(); |
| 525 |
} |
| 526 |
|
| 527 |
@Test(expected = NullPointerException.class) |
| 528 |
public void distinctSupplierReturnsNull() { |
| 529 |
just1.distinct(new Function<Integer, Object>() { |
| 530 |
@Override |
| 531 |
public Object apply(Integer v) { |
| 532 |
return v; |
| 533 |
} |
| 534 |
}, new Supplier<Collection<Object>>() { |
| 535 |
@Override |
| 536 |
public Collection<Object> get() { |
| 537 |
return null; |
| 538 |
} |
| 539 |
}).blockingSubscribe(); |
| 540 |
} |
| 541 |
|
| 542 |
@Test(expected = NullPointerException.class) |
| 543 |
public void distinctFunctionReturnsNull() { |
| 544 |
just1.distinct(new Function<Integer, Object>() { |
| 545 |
@Override |
| 546 |
public Object apply(Integer v) { |
| 547 |
return null; |
| 548 |
} |
| 549 |
}).blockingSubscribe(); |
| 550 |
} |
| 551 |
|
| 552 |
@Test |
| 553 |
public void distinctUntilChangedFunctionReturnsNull() { |
| 554 |
Flowable.range(1, 2).distinctUntilChanged(new Function<Integer, Object>() { |
| 555 |
@Override |
| 556 |
public Object apply(Integer v) { |
| 557 |
return null; |
| 558 |
} |
| 559 |
}).test().assertResult(1); |
| 560 |
} |
| 561 |
|
| 562 |
@Test(expected = NullPointerException.class) |
| 563 |
public void flatMapFunctionReturnsNull() { |
| 564 |
just1.flatMap(new Function<Integer, Publisher<Object>>() { |
| 565 |
@Override |
| 566 |
public Publisher<Object> apply(Integer v) { |
| 567 |
return null; |
| 568 |
} |
| 569 |
}).blockingSubscribe(); |
| 570 |
} |
| 571 |
|
| 572 |
@Test(expected = NullPointerException.class) |
| 573 |
public void flatMapNotificationOnNextReturnsNull() { |
| 574 |
just1.flatMap(new Function<Integer, Publisher<Integer>>() { |
| 575 |
@Override |
| 576 |
public Publisher<Integer> apply(Integer v) { |
| 577 |
return null; |
| 578 |
} |
| 579 |
}, new Function<Throwable, Publisher<Integer>>() { |
| 580 |
@Override |
| 581 |
public Publisher<Integer> apply(Throwable e) { |
| 582 |
return just1; |
| 583 |
} |
| 584 |
}, new Supplier<Publisher<Integer>>() { |
| 585 |
@Override |
| 586 |
public Publisher<Integer> get() { |
| 587 |
return just1; |
| 588 |
} |
| 589 |
}).blockingSubscribe(); |
| 590 |
} |
| 591 |
|
| 592 |
@Test(expected = NullPointerException.class) |
| 593 |
public void flatMapNotificationOnCompleteReturnsNull() { |
| 594 |
just1.flatMap(new Function<Integer, Publisher<Integer>>() { |
| 595 |
@Override |
| 596 |
public Publisher<Integer> apply(Integer v) { |
| 597 |
return just1; |
| 598 |
} |
| 599 |
}, new Function<Throwable, Publisher<Integer>>() { |
| 600 |
@Override |
| 601 |
public Publisher<Integer> apply(Throwable e) { |
| 602 |
return just1; |
| 603 |
} |
| 604 |
}, new Supplier<Publisher<Integer>>() { |
| 605 |
@Override |
| 606 |
public Publisher<Integer> get() { |
| 607 |
return null; |
| 608 |
} |
| 609 |
}).blockingSubscribe(); |
| 610 |
} |
| 611 |
|
| 612 |
@Test(expected = NullPointerException.class) |
| 613 |
public void flatMapCombinerMapperReturnsNull() { |
| 614 |
just1.flatMap(new Function<Integer, Publisher<Object>>() { |
| 615 |
@Override |
| 616 |
public Publisher<Object> apply(Integer v) { |
| 617 |
return null; |
| 618 |
} |
| 619 |
}, new BiFunction<Integer, Object, Object>() { |
| 620 |
@Override |
| 621 |
public Object apply(Integer a, Object b) { |
| 622 |
return 1; |
| 623 |
} |
| 624 |
}).blockingSubscribe(); |
| 625 |
} |
| 626 |
|
| 627 |
@Test(expected = NullPointerException.class) |
| 628 |
public void flatMapCombinerCombinerReturnsNull() { |
| 629 |
just1.flatMap(new Function<Integer, Publisher<Integer>>() { |
| 630 |
@Override |
| 631 |
public Publisher<Integer> apply(Integer v) { |
| 632 |
return just1; |
| 633 |
} |
| 634 |
}, new BiFunction<Integer, Integer, Object>() { |
| 635 |
@Override |
| 636 |
public Object apply(Integer a, Integer b) { |
| 637 |
return null; |
| 638 |
} |
| 639 |
}).blockingSubscribe(); |
| 640 |
} |
| 641 |
|
| 642 |
@Test(expected = NullPointerException.class) |
| 643 |
public void flatMapIterableMapperReturnsNull() { |
| 644 |
just1.flatMapIterable(new Function<Integer, Iterable<Object>>() { |
| 645 |
@Override |
| 646 |
public Iterable<Object> apply(Integer v) { |
| 647 |
return null; |
| 648 |
} |
| 649 |
}).blockingSubscribe(); |
| 650 |
} |
| 651 |
|
| 652 |
@Test(expected = NullPointerException.class) |
| 653 |
public void flatMapIterableMapperIteratorNull() { |
| 654 |
just1.flatMapIterable(new Function<Integer, Iterable<Object>>() { |
| 655 |
@Override |
| 656 |
public Iterable<Object> apply(Integer v) { |
| 657 |
return new Iterable<Object>() { |
| 658 |
@Override |
| 659 |
public Iterator<Object> iterator() { |
| 660 |
return null; |
| 661 |
} |
| 662 |
}; |
| 663 |
} |
| 664 |
}).blockingSubscribe(); |
| 665 |
} |
| 666 |
|
| 667 |
@Test(expected = NullPointerException.class) |
| 668 |
public void flatMapIterableMapperIterableOneNull() { |
| 669 |
just1.flatMapIterable(new Function<Integer, Iterable<Integer>>() { |
| 670 |
@Override |
| 671 |
public Iterable<Integer> apply(Integer v) { |
| 672 |
return Arrays.asList(1, null); |
| 673 |
} |
| 674 |
}).blockingSubscribe(); |
| 675 |
} |
| 676 |
|
| 677 |
@Test(expected = NullPointerException.class) |
| 678 |
public void flatMapIterableCombinerReturnsNull() { |
| 679 |
just1.flatMapIterable(new Function<Integer, Iterable<Integer>>() { |
| 680 |
@Override |
| 681 |
public Iterable<Integer> apply(Integer v) { |
| 682 |
return Arrays.asList(1); |
| 683 |
} |
| 684 |
}, new BiFunction<Integer, Integer, Object>() { |
| 685 |
@Override |
| 686 |
public Object apply(Integer a, Integer b) { |
| 687 |
return null; |
| 688 |
} |
| 689 |
}).blockingSubscribe(); |
| 690 |
} |
| 691 |
|
| 692 |
public void groupByKeyNull() { |
| 693 |
just1.groupBy(new Function<Integer, Object>() { |
| 694 |
@Override |
| 695 |
public Object apply(Integer v) { |
| 696 |
return null; |
| 697 |
} |
| 698 |
}).blockingSubscribe(); |
| 699 |
} |
| 700 |
|
| 701 |
@Test(expected = NullPointerException.class) |
| 702 |
public void groupByValueReturnsNull() { |
| 703 |
just1.groupBy(new Function<Integer, Object>() { |
| 704 |
@Override |
| 705 |
public Object apply(Integer v) { |
| 706 |
return v; |
| 707 |
} |
| 708 |
}, new Function<Integer, Object>() { |
| 709 |
@Override |
| 710 |
public Object apply(Integer v) { |
| 711 |
return null; |
| 712 |
} |
| 713 |
}).blockingSubscribe(); |
| 714 |
} |
| 715 |
|
| 716 |
@Test(expected = NullPointerException.class) |
| 717 |
public void liftReturnsNull() { |
| 718 |
just1.lift(new FlowableOperator<Object, Integer>() { |
| 719 |
@Override |
| 720 |
public Subscriber<? super Integer> apply(Subscriber<? super Object> s) { |
| 721 |
return null; |
| 722 |
} |
| 723 |
}).blockingSubscribe(); |
| 724 |
} |
| 725 |
|
| 726 |
@Test(expected = NullPointerException.class) |
| 727 |
public void mapReturnsNull() { |
| 728 |
just1.map(new Function<Integer, Object>() { |
| 729 |
@Override |
| 730 |
public Object apply(Integer v) { |
| 731 |
return null; |
| 732 |
} |
| 733 |
}).blockingSubscribe(); |
| 734 |
} |
| 735 |
|
| 736 |
@Test |
| 737 |
public void onErrorResumeNextFunctionReturnsNull() { |
| 738 |
try { |
| 739 |
Flowable.error(new TestException()).onErrorResumeNext(new Function<Throwable, Publisher<Object>>() { |
| 740 |
@Override |
| 741 |
public Publisher<Object> apply(Throwable e) { |
| 742 |
return null; |
| 743 |
} |
| 744 |
}).blockingSubscribe(); |
| 745 |
fail("Should have thrown"); |
| 746 |
} catch (CompositeException ex) { |
| 747 |
List<Throwable> errors = ex.getExceptions(); |
| 748 |
TestHelper.assertError(errors, 0, TestException.class); |
| 749 |
TestHelper.assertError(errors, 1, NullPointerException.class); |
| 750 |
assertEquals(2, errors.size()); |
| 751 |
} |
| 752 |
} |
| 753 |
|
| 754 |
@Test |
| 755 |
public void onErrorReturnFunctionReturnsNull() { |
| 756 |
try { |
| 757 |
Flowable.error(new TestException()).onErrorReturn(new Function<Throwable, Object>() { |
| 758 |
@Override |
| 759 |
public Object apply(Throwable e) { |
| 760 |
return null; |
| 761 |
} |
| 762 |
}).blockingSubscribe(); |
| 763 |
fail("Should have thrown"); |
| 764 |
} catch (CompositeException ex) { |
| 765 |
List<Throwable> errors = TestHelper.compositeList(ex); |
| 766 |
|
| 767 |
TestHelper.assertError(errors, 0, TestException.class); |
| 768 |
TestHelper.assertError(errors, 1, NullPointerException.class, "The valueSupplier returned a null value"); |
| 769 |
} |
| 770 |
} |
| 771 |
|
| 772 |
@Test(expected = NullPointerException.class) |
| 773 |
public void publishFunctionReturnsNull() { |
| 774 |
just1.publish(new Function<Flowable<Integer>, Publisher<Object>>() { |
| 775 |
@Override |
| 776 |
public Publisher<Object> apply(Flowable<Integer> v) { |
| 777 |
return null; |
| 778 |
} |
| 779 |
}).blockingSubscribe(); |
| 780 |
} |
| 781 |
|
| 782 |
@Test(expected = NullPointerException.class) |
| 783 |
public void reduceFunctionReturnsNull() { |
| 784 |
Flowable.just(1, 1).reduce(new BiFunction<Integer, Integer, Integer>() { |
| 785 |
@Override |
| 786 |
public Integer apply(Integer a, Integer b) { |
| 787 |
return null; |
| 788 |
} |
| 789 |
}).toFlowable().blockingSubscribe(); |
| 790 |
} |
| 791 |
|
| 792 |
@Test(expected = NullPointerException.class) |
| 793 |
public void reduceSeedFunctionReturnsNull() { |
| 794 |
just1.reduce(1, new BiFunction<Integer, Integer, Integer>() { |
| 795 |
@Override |
| 796 |
public Integer apply(Integer a, Integer b) { |
| 797 |
return null; |
| 798 |
} |
| 799 |
}).blockingGet(); |
| 800 |
} |
| 801 |
|
| 802 |
@Test(expected = NullPointerException.class) |
| 803 |
public void reduceWithSeedNull() { |
| 804 |
just1.reduceWith(null, new BiFunction<Object, Integer, Object>() { |
| 805 |
@Override |
| 806 |
public Object apply(Object a, Integer b) { |
| 807 |
return 1; |
| 808 |
} |
| 809 |
}); |
| 810 |
} |
| 811 |
|
| 812 |
@Test(expected = NullPointerException.class) |
| 813 |
public void reduceWithSeedReturnsNull() { |
| 814 |
just1.reduceWith(new Supplier<Object>() { |
| 815 |
@Override |
| 816 |
public Object get() { |
| 817 |
return null; |
| 818 |
} |
| 819 |
}, new BiFunction<Object, Integer, Object>() { |
| 820 |
@Override |
| 821 |
public Object apply(Object a, Integer b) { |
| 822 |
return 1; |
| 823 |
} |
| 824 |
}).blockingGet(); |
| 825 |
} |
| 826 |
|
| 827 |
@Test(expected = NullPointerException.class) |
| 828 |
public void repeatWhenFunctionReturnsNull() { |
| 829 |
just1.repeatWhen(new Function<Flowable<Object>, Publisher<Object>>() { |
| 830 |
@Override |
| 831 |
public Publisher<Object> apply(Flowable<Object> v) { |
| 832 |
return null; |
| 833 |
} |
| 834 |
}).blockingSubscribe(); |
| 835 |
} |
| 836 |
|
| 837 |
@Test(expected = NullPointerException.class) |
| 838 |
public void replaySelectorNull() { |
| 839 |
just1.replay((Function<Flowable<Integer>, Flowable<Integer>>)null); |
| 840 |
} |
| 841 |
|
| 842 |
@Test(expected = NullPointerException.class) |
| 843 |
public void replaySelectorReturnsNull() { |
| 844 |
just1.replay(new Function<Flowable<Integer>, Publisher<Object>>() { |
| 845 |
@Override |
| 846 |
public Publisher<Object> apply(Flowable<Integer> f) { |
| 847 |
return null; |
| 848 |
} |
| 849 |
}).blockingSubscribe(); |
| 850 |
} |
| 851 |
|
| 852 |
@Test(expected = NullPointerException.class) |
| 853 |
public void replayBoundedSelectorReturnsNull() { |
| 854 |
just1.replay(new Function<Flowable<Integer>, Publisher<Object>>() { |
| 855 |
@Override |
| 856 |
public Publisher<Object> apply(Flowable<Integer> v) { |
| 857 |
return null; |
| 858 |
} |
| 859 |
}, 1, 1, TimeUnit.SECONDS).blockingSubscribe(); |
| 860 |
} |
| 861 |
|
| 862 |
@Test(expected = NullPointerException.class) |
| 863 |
public void replayTimeBoundedSelectorReturnsNull() { |
| 864 |
just1.replay(new Function<Flowable<Integer>, Publisher<Object>>() { |
| 865 |
@Override |
| 866 |
public Publisher<Object> apply(Flowable<Integer> v) { |
| 867 |
return null; |
| 868 |
} |
| 869 |
}, 1, TimeUnit.SECONDS, Schedulers.single()).blockingSubscribe(); |
| 870 |
} |
| 871 |
|
| 872 |
@Test(expected = NullPointerException.class) |
| 873 |
public void retryWhenFunctionReturnsNull() { |
| 874 |
Flowable.error(new TestException()).retryWhen(new Function<Flowable<? extends Throwable>, Publisher<Object>>() { |
| 875 |
@Override |
| 876 |
public Publisher<Object> apply(Flowable<? extends Throwable> f) { |
| 877 |
return null; |
| 878 |
} |
| 879 |
}).blockingSubscribe(); |
| 880 |
} |
| 881 |
|
| 882 |
@Test(expected = NullPointerException.class) |
| 883 |
public void scanFunctionReturnsNull() { |
| 884 |
Flowable.just(1, 1).scan(new BiFunction<Integer, Integer, Integer>() { |
| 885 |
@Override |
| 886 |
public Integer apply(Integer a, Integer b) { |
| 887 |
return null; |
| 888 |
} |
| 889 |
}).blockingSubscribe(); |
| 890 |
} |
| 891 |
|
| 892 |
@Test(expected = NullPointerException.class) |
| 893 |
public void scanSeedNull() { |
| 894 |
just1.scan(null, new BiFunction<Object, Integer, Object>() { |
| 895 |
@Override |
| 896 |
public Object apply(Object a, Integer b) { |
| 897 |
return 1; |
| 898 |
} |
| 899 |
}); |
| 900 |
} |
| 901 |
|
| 902 |
@Test(expected = NullPointerException.class) |
| 903 |
public void scanSeedFunctionReturnsNull() { |
| 904 |
just1.scan(1, new BiFunction<Integer, Integer, Integer>() { |
| 905 |
@Override |
| 906 |
public Integer apply(Integer a, Integer b) { |
| 907 |
return null; |
| 908 |
} |
| 909 |
}).blockingSubscribe(); |
| 910 |
} |
| 911 |
|
| 912 |
@Test(expected = NullPointerException.class) |
| 913 |
public void scanSeedSupplierReturnsNull() { |
| 914 |
just1.scanWith(new Supplier<Object>() { |
| 915 |
@Override |
| 916 |
public Object get() { |
| 917 |
return null; |
| 918 |
} |
| 919 |
}, new BiFunction<Object, Integer, Object>() { |
| 920 |
@Override |
| 921 |
public Object apply(Object a, Integer b) { |
| 922 |
return 1; |
| 923 |
} |
| 924 |
}).blockingSubscribe(); |
| 925 |
} |
| 926 |
|
| 927 |
@Test(expected = NullPointerException.class) |
| 928 |
public void scanSeedSupplierFunctionReturnsNull() { |
| 929 |
just1.scanWith(new Supplier<Object>() { |
| 930 |
@Override |
| 931 |
public Object get() { |
| 932 |
return 1; |
| 933 |
} |
| 934 |
}, new BiFunction<Object, Integer, Object>() { |
| 935 |
@Override |
| 936 |
public Object apply(Object a, Integer b) { |
| 937 |
return null; |
| 938 |
} |
| 939 |
}).blockingSubscribe(); |
| 940 |
} |
| 941 |
|
| 942 |
@Test(expected = NullPointerException.class) |
| 943 |
public void startWithIterableIteratorNull() { |
| 944 |
just1.startWithIterable(new Iterable<Integer>() { |
| 945 |
@Override |
| 946 |
public Iterator<Integer> iterator() { |
| 947 |
return null; |
| 948 |
} |
| 949 |
}).blockingSubscribe(); |
| 950 |
} |
| 951 |
|
| 952 |
@Test(expected = NullPointerException.class) |
| 953 |
public void startWithIterableOneNull() { |
| 954 |
just1.startWithIterable(Arrays.asList(1, null)).blockingSubscribe(); |
| 955 |
} |
| 956 |
|
| 957 |
@Test(expected = NullPointerException.class) |
| 958 |
public void startWithArrayOneNull() { |
| 959 |
just1.startWithArray(1, null).blockingSubscribe(); |
| 960 |
} |
| 961 |
|
| 962 |
@Test(expected = NullPointerException.class) |
| 963 |
public void switchMapFunctionReturnsNull() { |
| 964 |
just1.switchMap(new Function<Integer, Publisher<Object>>() { |
| 965 |
@Override |
| 966 |
public Publisher<Object> apply(Integer v) { |
| 967 |
return null; |
| 968 |
} |
| 969 |
}).blockingSubscribe(); |
| 970 |
} |
| 971 |
|
| 972 |
@Test(expected = NullPointerException.class) |
| 973 |
public void timeoutSelectorReturnsNull() { |
| 974 |
just1.timeout(new Function<Integer, Publisher<Object>>() { |
| 975 |
@Override |
| 976 |
public Publisher<Object> apply(Integer v) { |
| 977 |
return null; |
| 978 |
} |
| 979 |
}).blockingSubscribe(); |
| 980 |
} |
| 981 |
|
| 982 |
@Test(expected = NullPointerException.class) |
| 983 |
public void timeoutSelectorOtherNull() { |
| 984 |
just1.timeout(new Function<Integer, Publisher<Integer>>() { |
| 985 |
@Override |
| 986 |
public Publisher<Integer> apply(Integer v) { |
| 987 |
return just1; |
| 988 |
} |
| 989 |
}, null); |
| 990 |
} |
| 991 |
|
| 992 |
@Test(expected = NullPointerException.class) |
| 993 |
public void timeoutFirstItemReturnsNull() { |
| 994 |
just1.timeout(Flowable.never(), new Function<Integer, Publisher<Object>>() { |
| 995 |
@Override |
| 996 |
public Publisher<Object> apply(Integer v) { |
| 997 |
return null; |
| 998 |
} |
| 999 |
}).blockingSubscribe(); |
| 1000 |
} |
| 1001 |
|
| 1002 |
@Test(expected = NullPointerException.class) |
| 1003 |
public void timestampUnitNull() { |
| 1004 |
just1.timestamp(null, Schedulers.single()); |
| 1005 |
} |
| 1006 |
|
| 1007 |
@Test(expected = NullPointerException.class) |
| 1008 |
public void timestampSchedulerNull() { |
| 1009 |
just1.timestamp(TimeUnit.SECONDS, null); |
| 1010 |
} |
| 1011 |
|
| 1012 |
@Test(expected = NullPointerException.class) |
| 1013 |
public void toListSupplierReturnsNull() { |
| 1014 |
just1.toList(new Supplier<Collection<Integer>>() { |
| 1015 |
@Override |
| 1016 |
public Collection<Integer> get() { |
| 1017 |
return null; |
| 1018 |
} |
| 1019 |
}).toFlowable().blockingSubscribe(); |
| 1020 |
} |
| 1021 |
|
| 1022 |
@Test(expected = NullPointerException.class) |
| 1023 |
public void toListSupplierReturnsNullSingle() { |
| 1024 |
just1.toList(new Supplier<Collection<Integer>>() { |
| 1025 |
@Override |
| 1026 |
public Collection<Integer> get() { |
| 1027 |
return null; |
| 1028 |
} |
| 1029 |
}).blockingGet(); |
| 1030 |
} |
| 1031 |
|
| 1032 |
@Test |
| 1033 |
public void toMapValueSelectorReturnsNull() { |
| 1034 |
just1.toMap(new Function<Integer, Object>() { |
| 1035 |
@Override |
| 1036 |
public Object apply(Integer v) { |
| 1037 |
return v; |
| 1038 |
} |
| 1039 |
}, new Function<Integer, Object>() { |
| 1040 |
@Override |
| 1041 |
public Object apply(Integer v) { |
| 1042 |
return null; |
| 1043 |
} |
| 1044 |
}).blockingGet(); |
| 1045 |
} |
| 1046 |
|
| 1047 |
@Test(expected = NullPointerException.class) |
| 1048 |
public void toMapMapSupplierReturnsNull() { |
| 1049 |
just1.toMap(new Function<Integer, Object>() { |
| 1050 |
@Override |
| 1051 |
public Object apply(Integer v) { |
| 1052 |
return v; |
| 1053 |
} |
| 1054 |
}, new Function<Integer, Object>() { |
| 1055 |
@Override |
| 1056 |
public Object apply(Integer v) { |
| 1057 |
return v; |
| 1058 |
} |
| 1059 |
}, new Supplier<Map<Object, Object>>() { |
| 1060 |
@Override |
| 1061 |
public Map<Object, Object> get() { |
| 1062 |
return null; |
| 1063 |
} |
| 1064 |
}).blockingGet(); |
| 1065 |
} |
| 1066 |
|
| 1067 |
@Test |
| 1068 |
public void toMultiMapValueSelectorReturnsNullAllowed() { |
| 1069 |
just1.toMap(new Function<Integer, Object>() { |
| 1070 |
@Override |
| 1071 |
public Object apply(Integer v) { |
| 1072 |
return v; |
| 1073 |
} |
| 1074 |
}, new Function<Integer, Object>() { |
| 1075 |
@Override |
| 1076 |
public Object apply(Integer v) { |
| 1077 |
return null; |
| 1078 |
} |
| 1079 |
}).blockingGet(); |
| 1080 |
} |
| 1081 |
|
| 1082 |
@Test(expected = NullPointerException.class) |
| 1083 |
public void toMultimapMapSupplierReturnsNull() { |
| 1084 |
just1.toMultimap(new Function<Integer, Object>() { |
| 1085 |
@Override |
| 1086 |
public Object apply(Integer v) { |
| 1087 |
return v; |
| 1088 |
} |
| 1089 |
}, new Function<Integer, Object>() { |
| 1090 |
@Override |
| 1091 |
public Object apply(Integer v) { |
| 1092 |
return v; |
| 1093 |
} |
| 1094 |
}, new Supplier<Map<Object, Collection<Object>>>() { |
| 1095 |
@Override |
| 1096 |
public Map<Object, Collection<Object>> get() { |
| 1097 |
return null; |
| 1098 |
} |
| 1099 |
}).blockingGet(); |
| 1100 |
} |
| 1101 |
|
| 1102 |
@Test(expected = NullPointerException.class) |
| 1103 |
public void toMultimapMapCollectionSupplierReturnsNull() { |
| 1104 |
just1.toMultimap(new Function<Integer, Integer>() { |
| 1105 |
@Override |
| 1106 |
public Integer apply(Integer v) { |
| 1107 |
return v; |
| 1108 |
} |
| 1109 |
}, new Function<Integer, Integer>() { |
| 1110 |
@Override |
| 1111 |
public Integer apply(Integer v) { |
| 1112 |
return v; |
| 1113 |
} |
| 1114 |
}, new Supplier<Map<Integer, Collection<Integer>>>() { |
| 1115 |
@Override |
| 1116 |
public Map<Integer, Collection<Integer>> get() { |
| 1117 |
return new HashMap<>(); |
| 1118 |
} |
| 1119 |
}, new Function<Integer, Collection<Integer>>() { |
| 1120 |
@Override |
| 1121 |
public Collection<Integer> apply(Integer v) { |
| 1122 |
return null; |
| 1123 |
} |
| 1124 |
}).blockingGet(); |
| 1125 |
} |
| 1126 |
|
| 1127 |
@Test(expected = NullPointerException.class) |
| 1128 |
public void windowOpenCloseOpenNull() { |
| 1129 |
just1.window(null, new Function<Object, Publisher<Integer>>() { |
| 1130 |
@Override |
| 1131 |
public Publisher<Integer> apply(Object v) { |
| 1132 |
return just1; |
| 1133 |
} |
| 1134 |
}); |
| 1135 |
} |
| 1136 |
|
| 1137 |
@Test(expected = NullPointerException.class) |
| 1138 |
public void windowOpenCloseCloseReturnsNull() { |
| 1139 |
Flowable.never().window(just1, new Function<Integer, Publisher<Object>>() { |
| 1140 |
@Override |
| 1141 |
public Publisher<Object> apply(Integer v) { |
| 1142 |
return null; |
| 1143 |
} |
| 1144 |
}).blockingSubscribe(); |
| 1145 |
} |
| 1146 |
|
| 1147 |
@Test(expected = NullPointerException.class) |
| 1148 |
public void withLatestFromOtherNull() { |
| 1149 |
just1.withLatestFrom(null, new BiFunction<Integer, Object, Object>() { |
| 1150 |
@Override |
| 1151 |
public Object apply(Integer a, Object b) { |
| 1152 |
return 1; |
| 1153 |
} |
| 1154 |
}); |
| 1155 |
} |
| 1156 |
|
| 1157 |
@Test(expected = NullPointerException.class) |
| 1158 |
public void withLatestFromCombinerReturnsNull() { |
| 1159 |
just1.withLatestFrom(just1, new BiFunction<Integer, Integer, Object>() { |
| 1160 |
@Override |
| 1161 |
public Object apply(Integer a, Integer b) { |
| 1162 |
return null; |
| 1163 |
} |
| 1164 |
}).blockingSubscribe(); |
| 1165 |
} |
| 1166 |
|
| 1167 |
@Test(expected = NullPointerException.class) |
| 1168 |
public void zipWithIterableNull() { |
| 1169 |
just1.zipWith((Iterable<Integer>)null, new BiFunction<Integer, Integer, Object>() { |
| 1170 |
@Override |
| 1171 |
public Object apply(Integer a, Integer b) { |
| 1172 |
return 1; |
| 1173 |
} |
| 1174 |
}); |
| 1175 |
} |
| 1176 |
|
| 1177 |
@Test(expected = NullPointerException.class) |
| 1178 |
public void zipWithIterableCombinerReturnsNull() { |
| 1179 |
just1.zipWith(Arrays.asList(1), new BiFunction<Integer, Integer, Object>() { |
| 1180 |
@Override |
| 1181 |
public Object apply(Integer a, Integer b) { |
| 1182 |
return null; |
| 1183 |
} |
| 1184 |
}).blockingSubscribe(); |
| 1185 |
} |
| 1186 |
|
| 1187 |
@Test(expected = NullPointerException.class) |
| 1188 |
public void zipWithIterableIteratorNull() { |
| 1189 |
just1.zipWith(new Iterable<Object>() { |
| 1190 |
@Override |
| 1191 |
public Iterator<Object> iterator() { |
| 1192 |
return null; |
| 1193 |
} |
| 1194 |
}, new BiFunction<Integer, Object, Object>() { |
| 1195 |
@Override |
| 1196 |
public Object apply(Integer a, Object b) { |
| 1197 |
return 1; |
| 1198 |
} |
| 1199 |
}).blockingSubscribe(); |
| 1200 |
} |
| 1201 |
|
| 1202 |
@Test(expected = NullPointerException.class) |
| 1203 |
public void zipWithIterableOneIsNull() { |
| 1204 |
Flowable.just(1, 2).zipWith(Arrays.asList(1, null), new BiFunction<Integer, Integer, Object>() { |
| 1205 |
@Override |
| 1206 |
public Object apply(Integer a, Integer b) { |
| 1207 |
return 1; |
| 1208 |
} |
| 1209 |
}).blockingSubscribe(); |
| 1210 |
} |
| 1211 |
|
| 1212 |
@Test(expected = NullPointerException.class) |
| 1213 |
public void zipWithPublisherNull() { |
| 1214 |
just1.zipWith((Publisher<Integer>)null, new BiFunction<Integer, Integer, Object>() { |
| 1215 |
@Override |
| 1216 |
public Object apply(Integer a, Integer b) { |
| 1217 |
return 1; |
| 1218 |
} |
| 1219 |
}); |
| 1220 |
} |
| 1221 |
|
| 1222 |
@Test(expected = NullPointerException.class) |
| 1223 |
public void zipWithCombinerReturnsNull() { |
| 1224 |
just1.zipWith(just1, new BiFunction<Integer, Integer, Object>() { |
| 1225 |
@Override |
| 1226 |
public Object apply(Integer a, Integer b) { |
| 1227 |
return null; |
| 1228 |
} |
| 1229 |
}).blockingSubscribe(); |
| 1230 |
} |
| 1231 |
|
| 1232 |
//********************************************* |
| 1233 |
// Subject null tests |
| 1234 |
//********************************************* |
| 1235 |
|
| 1236 |
@Test(expected = NullPointerException.class) |
| 1237 |
public void asyncSubjectOnNextNull() { |
| 1238 |
FlowableProcessor<Integer> processor = AsyncProcessor.create(); |
| 1239 |
processor.onNext(null); |
| 1240 |
processor.blockingSubscribe(); |
| 1241 |
} |
| 1242 |
|
| 1243 |
@Test(expected = NullPointerException.class) |
| 1244 |
public void asyncSubjectOnErrorNull() { |
| 1245 |
FlowableProcessor<Integer> processor = AsyncProcessor.create(); |
| 1246 |
processor.onError(null); |
| 1247 |
processor.blockingSubscribe(); |
| 1248 |
} |
| 1249 |
|
| 1250 |
@Test(expected = NullPointerException.class) |
| 1251 |
public void behaviorSubjectOnNextNull() { |
| 1252 |
FlowableProcessor<Integer> processor = BehaviorProcessor.create(); |
| 1253 |
processor.onNext(null); |
| 1254 |
processor.blockingSubscribe(); |
| 1255 |
} |
| 1256 |
|
| 1257 |
@Test(expected = NullPointerException.class) |
| 1258 |
public void behaviorSubjectOnErrorNull() { |
| 1259 |
FlowableProcessor<Integer> processor = BehaviorProcessor.create(); |
| 1260 |
processor.onError(null); |
| 1261 |
processor.blockingSubscribe(); |
| 1262 |
} |
| 1263 |
|
| 1264 |
@Test(expected = NullPointerException.class) |
| 1265 |
public void publishSubjectOnNextNull() { |
| 1266 |
FlowableProcessor<Integer> processor = PublishProcessor.create(); |
| 1267 |
processor.onNext(null); |
| 1268 |
processor.blockingSubscribe(); |
| 1269 |
} |
| 1270 |
|
| 1271 |
@Test(expected = NullPointerException.class) |
| 1272 |
public void publishSubjectOnErrorNull() { |
| 1273 |
FlowableProcessor<Integer> processor = PublishProcessor.create(); |
| 1274 |
processor.onError(null); |
| 1275 |
processor.blockingSubscribe(); |
| 1276 |
} |
| 1277 |
|
| 1278 |
@Test(expected = NullPointerException.class) |
| 1279 |
public void replaycSubjectOnNextNull() { |
| 1280 |
FlowableProcessor<Integer> processor = ReplayProcessor.create(); |
| 1281 |
processor.onNext(null); |
| 1282 |
processor.blockingSubscribe(); |
| 1283 |
} |
| 1284 |
|
| 1285 |
@Test(expected = NullPointerException.class) |
| 1286 |
public void replaySubjectOnErrorNull() { |
| 1287 |
FlowableProcessor<Integer> processor = ReplayProcessor.create(); |
| 1288 |
processor.onError(null); |
| 1289 |
processor.blockingSubscribe(); |
| 1290 |
} |
| 1291 |
|
| 1292 |
@Test(expected = NullPointerException.class) |
| 1293 |
public void serializedcSubjectOnNextNull() { |
| 1294 |
FlowableProcessor<Integer> processor = PublishProcessor.<Integer>create().toSerialized(); |
| 1295 |
processor.onNext(null); |
| 1296 |
processor.blockingSubscribe(); |
| 1297 |
} |
| 1298 |
|
| 1299 |
@Test(expected = NullPointerException.class) |
| 1300 |
public void serializedSubjectOnErrorNull() { |
| 1301 |
FlowableProcessor<Integer> processor = PublishProcessor.<Integer>create().toSerialized(); |
| 1302 |
processor.onError(null); |
| 1303 |
processor.blockingSubscribe(); |
| 1304 |
} |
| 1305 |
|
| 1306 |
@Test(expected = NullPointerException.class) |
| 1307 |
public void combineLatestDelayErrorIterableFunctionReturnsNull() { |
| 1308 |
Flowable.combineLatestDelayError(Arrays.asList(just1), new Function<Object[], Object>() { |
| 1309 |
@Override |
| 1310 |
public Object apply(Object[] v) { |
| 1311 |
return null; |
| 1312 |
} |
| 1313 |
}, 128).blockingLast(); |
| 1314 |
} |
| 1315 |
|
| 1316 |
@Test(expected = NullPointerException.class) |
| 1317 |
public void combineLatestDelayErrorIterableIteratorNull() { |
| 1318 |
Flowable.combineLatestDelayError(new Iterable<Flowable<Object>>() { |
| 1319 |
@Override |
| 1320 |
public Iterator<Flowable<Object>> iterator() { |
| 1321 |
return null; |
| 1322 |
} |
| 1323 |
}, new Function<Object[], Object>() { |
| 1324 |
@Override |
| 1325 |
public Object apply(Object[] v) { |
| 1326 |
return 1; |
| 1327 |
} |
| 1328 |
}, 128).blockingLast(); |
| 1329 |
} |
| 1330 |
|
| 1331 |
@Test(expected = NullPointerException.class) |
| 1332 |
public void combineLatestDelayErrorIterableOneIsNull() { |
| 1333 |
Flowable.combineLatestDelayError(Arrays.asList(Flowable.never(), null), new Function<Object[], Object>() { |
| 1334 |
@Override |
| 1335 |
public Object apply(Object[] v) { |
| 1336 |
return 1; |
| 1337 |
} |
| 1338 |
}, 128).blockingLast(); |
| 1339 |
} |
| 1340 |
} |