Refactor RxJava (#2612)

This commit is contained in:
Grzegorz Piwowarek 2017-09-12 20:30:01 +02:00 committed by GitHub
parent 7d0e9da6ce
commit ba9d8324ee
2 changed files with 10 additions and 3 deletions

View File

@ -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>

View File

@ -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")));
}
}