Refactor RxJava (#2612)
This commit is contained in:
parent
7d0e9da6ce
commit
ba9d8324ee
|
@ -25,6 +25,12 @@
|
|||
<artifactId>rxjava</artifactId>
|
||||
<version>2.1.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.jayway.awaitility</groupId>
|
||||
<artifactId>awaitility</artifactId>
|
||||
<version>1.7.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -6,6 +6,7 @@ import rx.observables.ConnectableObservable;
|
|||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.jayway.awaitility.Awaitility.await;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
|
@ -15,12 +16,12 @@ public class ConnectableObservableTest {
|
|||
public void givenConnectableObservable_whenConnect_thenGetMessage() throws InterruptedException {
|
||||
String[] result = {""};
|
||||
ConnectableObservable<Long> connectable
|
||||
= Observable.interval(200, TimeUnit.MILLISECONDS).publish();
|
||||
= Observable.interval(500, TimeUnit.MILLISECONDS).publish();
|
||||
connectable.subscribe(i -> result[0] += i);
|
||||
assertFalse(result[0].equals("01"));
|
||||
|
||||
connectable.connect();
|
||||
Thread.sleep(500);
|
||||
assertTrue(result[0].equals("01"));
|
||||
await()
|
||||
.until(() -> assertTrue(result[0].equals("01")));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue