Skip to content

Commit

Permalink
Migrated to awaitTerminalEvent for FutureTask test case reported in #1
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiiz committed Feb 5, 2017
1 parent 13c2277 commit a08266c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.concurrent.FutureTask;

import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.Single;

interface CountriesService {
Expand All @@ -24,7 +23,7 @@ interface CountriesService {

Observable<Country> listPopulationMoreThanOneMillion(List<Country> countries);

Observable<Country> listPopulationMoreThanOneMillion(FutureTask<List<Country>> countriesFromNetwork, Scheduler scheduler);
Observable<Country> listPopulationMoreThanOneMillion(FutureTask<List<Country>> countriesFromNetwork);

Observable<String> getCurrencyUsdIfNotFound(String countryName, List<Country> countries);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.concurrent.FutureTask;

import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.Single;

class CountriesServiceSolved implements CountriesService {
Expand Down Expand Up @@ -45,7 +44,7 @@ public Observable<Country> listPopulationMoreThanOneMillion(List<Country> countr
}

@Override
public Observable<Country> listPopulationMoreThanOneMillion(FutureTask<List<Country>> countriesFromNetwork, Scheduler scheduler) {
public Observable<Country> listPopulationMoreThanOneMillion(FutureTask<List<Country>> countriesFromNetwork) {
return null; // put your solution here
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.util.concurrent.FutureTask;

import io.reactivex.observers.TestObserver;
import io.reactivex.schedulers.TestScheduler;

public class CountriesServiceSolvedTest {

Expand Down Expand Up @@ -113,11 +112,11 @@ public void rx_ListPopulationMoreThanOneMillion_FutureTask() {
return allCountries;
});
new Thread(futureTask).start();
TestScheduler testScheduler = new TestScheduler();
TestObserver<Country> testObserver = countriesService
.listPopulationMoreThanOneMillion(futureTask, testScheduler)
.listPopulationMoreThanOneMillion(futureTask)
.test();
List<Country> expectedResult = CountriesTestProvider.countriesPopulationMoreThanOneMillion();
testObserver.awaitTerminalEvent();
testObserver.assertValueSet(expectedResult);
testObserver.assertNoErrors();
}
Expand Down

0 comments on commit a08266c

Please sign in to comment.