@AfterMethod public void cleanUp(Method method) throws InterruptedException { // A previous test didn't call onComplete on the processor, manual clean up if (driverManager.getCounter() > 0) { Thread.sleep(1000); if (driverManager.getCounter() > 0) { System.err.println( "Possibly method " + method.getName() + " didn't call onComplete on processor"); for (AeronProcessor processor : processors) { processor.shutdown(); TestSubscriber.await(5L, "processor didn't terminate", processor::isTerminated); } TestSubscriber.await( 5L, "Embedded Media driver wasn't shutdown properly", () -> driverManager.getCounter() == 0); } } processors.clear(); }
@Test public void singleConversion() { Mono<User> mono = repository.findFirst(); Single<User> single = fromMonoToSingle(mono); TestSubscriber<User> testSubscriber = new TestSubscriber<>(); testSubscriber .bindTo(fromSingleToMono(single)) .await() .assertValues(User.SKYLER) .assertComplete(); }
@Test public void completableFutureConversion() { Mono<User> mono = repository.findFirst(); CompletableFuture<User> future = fromMonoToCompletableFuture(mono); TestSubscriber<User> testSubscriber = new TestSubscriber<>(); testSubscriber .bindTo(fromCompletableFutureToMono(future)) .await() .assertValues(User.SKYLER) .assertComplete(); }
@Test public void observableConversion() { Flux<User> flux = repository.findAll(); Observable<User> observable = fromFluxToObservable(flux); TestSubscriber<User> testSubscriber = new TestSubscriber<>(); testSubscriber .bindTo(fromObservableToFlux(observable)) .await() .assertValues(User.SKYLER, User.JESSE, User.WALTER, User.SAUL) .assertComplete(); }