diff --git a/rxjava-2/pom.xml b/rxjava-2/pom.xml index f437a6005b..3038c20037 100644 --- a/rxjava-2/pom.xml +++ b/rxjava-2/pom.xml @@ -1,53 +1,53 @@ - - 4.0.0 + + 4.0.0 - rxjava-2 - 1.0-SNAPSHOT + rxjava-2 + 1.0-SNAPSHOT - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../parent-java - + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + - - - io.reactivex.rxjava2 - rxjava - ${rx.java2.version} - - - com.jayway.awaitility - awaitility - ${awaitility.version} - - - org.assertj - assertj-core - ${assertj.version} - - - com.jakewharton.rxrelay2 - rxrelay - ${rxrelay.version} - - - - com.github.akarnokd - rxjava2-extensions - ${rxjava2.ext.version} - - - + + + io.reactivex.rxjava2 + rxjava + ${rx.java2.version} + + + com.jayway.awaitility + awaitility + ${awaitility.version} + + + org.assertj + assertj-core + ${assertj.version} + + + com.jakewharton.rxrelay2 + rxrelay + ${rxrelay.version} + + + + com.github.akarnokd + rxjava2-extensions + ${rxjava2.ext.version} + + - - 3.8.0 - 2.2.2 - 1.7.0 - 2.0.0 - 0.20.4 - + + 3.8.0 + 2.2.2 + 1.7.0 + 2.0.0 + 0.20.4 + \ No newline at end of file diff --git a/rxjava-2/src/test/java/com/baeldung/rxjava/AsyncAndSyncToObservableIntegrationTest.java b/rxjava-2/src/test/java/com/baeldung/rxjava/AsyncAndSyncToObservableIntegrationTest.java index a646b453ff..90f4fe94ae 100644 --- a/rxjava-2/src/test/java/com/baeldung/rxjava/AsyncAndSyncToObservableIntegrationTest.java +++ b/rxjava-2/src/test/java/com/baeldung/rxjava/AsyncAndSyncToObservableIntegrationTest.java @@ -21,8 +21,9 @@ public class AsyncAndSyncToObservableIntegrationTest { AtomicInteger counter = new AtomicInteger(); Callable callable = () -> counter.incrementAndGet(); + /* Method will execute every time it gets subscribed*/ @Test - public void givenSyncMethod_whenConvertedWithFromCallable_thenReturnObservable() {// method will execute every time it gets subscribed + public void givenSyncMethod_whenConvertedWithFromCallable_thenReturnObservable() { Observable source = Observable.fromCallable(callable); @@ -35,8 +36,9 @@ public class AsyncAndSyncToObservableIntegrationTest { } } + /* Method will execute only once and cache its result.*/ @Test - public void givenSyncMethod_whenConvertedWithStart_thenReturnObservable() {// method will execute only once and cache its result. + public void givenSyncMethod_whenConvertedWithStart_thenReturnObservable() { Observable source = AsyncObservable.start(callable); @@ -49,8 +51,9 @@ public class AsyncAndSyncToObservableIntegrationTest { } } + /* Method will execute only once and cache its result.*/ @Test - public void givenAsyncMethod_whenConvertedWithFromFuture_thenRetrunObservble() { // method will execute only once and cache its result. + public void givenAsyncMethod_whenConvertedWithFromFuture_thenRetrunObservble() { ExecutorService executor = Executors.newSingleThreadExecutor(); Future future = executor.submit(callable); @@ -67,8 +70,9 @@ public class AsyncAndSyncToObservableIntegrationTest { executor.shutdown(); } + /* Method will execute every time it gets subscribed*/ @Test - public void givenAsyncMethod_whenConvertedWithStartFuture_thenRetrunObservble() {// method will execute every time it gets subscribed + public void givenAsyncMethod_whenConvertedWithStartFuture_thenRetrunObservble() { ExecutorService executor = Executors.newSingleThreadExecutor(); Observable source = AsyncObservable.startFuture(() -> executor.submit(callable)); @@ -84,9 +88,9 @@ public class AsyncAndSyncToObservableIntegrationTest { executor.shutdown(); } + /*Method will execute only once and cache its result.*/ @Test - public void givenAsyncMethod_whenConvertedWithDeferFuture_thenRetrunObservble() { // method will execute only once and cache its result. - + public void givenAsyncMethod_whenConvertedWithDeferFuture_thenRetrunObservble() { List list = Arrays.asList(new Integer[] { counter.incrementAndGet(), counter.incrementAndGet(), counter.incrementAndGet() }); ExecutorService exec = Executors.newSingleThreadExecutor(); Callable> callable = () -> Observable.fromIterable(list);