Code formatted
This commit is contained in:
parent
a32cb1a489
commit
127c3eca04
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -40,7 +41,6 @@
|
|||
<artifactId>rxjava2-extensions</artifactId>
|
||||
<version>${rxjava2.ext.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -21,8 +21,9 @@ public class AsyncAndSyncToObservableIntegrationTest {
|
|||
AtomicInteger counter = new AtomicInteger();
|
||||
Callable<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Integer> list = Arrays.asList(new Integer[] { counter.incrementAndGet(), counter.incrementAndGet(), counter.incrementAndGet() });
|
||||
ExecutorService exec = Executors.newSingleThreadExecutor();
|
||||
Callable<Observable<Integer>> callable = () -> Observable.fromIterable(list);
|
||||
|
|
Loading…
Reference in New Issue