本文整理汇总了Java中io.reactivex.observers.TestObserver.assertResult方法的典型用法代码示例。如果您正苦于以下问题:Java TestObserver.assertResult方法的具体用法?Java TestObserver.assertResult怎么用?Java TestObserver.assertResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.observers.TestObserver
的用法示例。
在下文中一共展示了TestObserver.assertResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_just_new
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void test_just_new() {
Observable<Integer> observable = Observable.just(12, 34, 6);
TestObserver<Integer> testObserver = new TestObserver<>();
observable.subscribe(testObserver);
List<Integer> list = new ArrayList();
testObserver.assertComplete();
testObserver.assertResult(12, 34, 6);
testObserver.assertValueCount(3);
testObserver.assertNoErrors();
testObserver.assertValueAt(2, (value) -> {
// TODO Auto-generated method stub
return value == 34;
});
}
示例2: testForecast
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void testForecast() throws Exception {
server.enqueue(new MockResponse().setBody(responseExample));
DarkSkyApi darkSkyApi = Utils.buildDarkSkyInstance(server.url("/"));
Observable<JsonObject> forecast = darkSkyApi.forecast("", -1, -1);
TestObserver<JsonObject> test = forecast.test();
test.assertNoErrors();
JsonObject expected = new Gson().fromJson(responseExample, JsonObject.class);
test.assertResult(expected);
}
示例3: rx_IsAllCountriesPopulationMoreThanOneMillion_Positive
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void rx_IsAllCountriesPopulationMoreThanOneMillion_Positive() {
TestObserver<Boolean> testObserver = countriesService
.isAllCountriesPopulationMoreThanOneMillion(CountriesTestProvider.countriesPopulationMoreThanOneMillion())
.test();
testObserver.assertResult(true);
testObserver.assertNoErrors();
}
示例4: rx_IsAllCountriesPopulationMoreThanOneMillion_Negative
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void rx_IsAllCountriesPopulationMoreThanOneMillion_Negative() {
TestObserver<Boolean> testObserver = countriesService
.isAllCountriesPopulationMoreThanOneMillion(allCountries)
.test();
testObserver.assertResult(false);
testObserver.assertNoErrors();
}
示例5: rx_GetCurrencyUsdIfNotFound_When_CountryFound
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void rx_GetCurrencyUsdIfNotFound_When_CountryFound() {
String countryRequested = "Austria";
String expectedCurrencyValue = "EUR";
TestObserver<String> testObserver = countriesService
.getCurrencyUsdIfNotFound(countryRequested, allCountries)
.test();
testObserver.assertResult(expectedCurrencyValue);
testObserver.assertNoErrors();
}
示例6: rx_GetCurrencyUsdIfNotFound_When_CountryNotFound
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void rx_GetCurrencyUsdIfNotFound_When_CountryNotFound() {
String countryRequested = "Senegal";
String expectedCurrencyValue = "USD";
TestObserver<String> testObserver = countriesService
.getCurrencyUsdIfNotFound(countryRequested, allCountries)
.test();
testObserver.assertResult(expectedCurrencyValue);
testObserver.assertNoErrors();
}
示例7: rx_SumPopulationOfCountries
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void rx_SumPopulationOfCountries() {
// hint: use "reduce" operator
TestObserver<Long> testObserver = countriesService
.sumPopulationOfCountries(allCountries)
.test();
testObserver.assertResult(CountriesTestProvider.sumPopulationOfAllCountries());
testObserver.assertNoErrors();
}
示例8: requestEachSeveralPermissionsOneDenied
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test @TargetApi(M) public void requestEachSeveralPermissionsOneDenied() {
final String[] permissions = { READ_PHONE_STATE, CAMERA };
doReturn(false).when(rxPermission).isGranted(anyString());
final int[] result = { PERMISSION_GRANTED, PERMISSION_DENIED };
final TestObserver<Permission> o = rxPermission.requestEach(permissions)
.test();
rxPermission.onRequestPermissionsResult(result, FALSE_ARRAY_2, FALSE_ARRAY_2, permissions);
o.assertResult(Permission.granted(READ_PHONE_STATE), Permission.deniedNotShown(CAMERA));
}
示例9: rx_sumPopulationOfCountries
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void rx_sumPopulationOfCountries() {
// hint: use "map" operator
TestObserver<Long> testObserver = countriesService
.sumPopulationOfCountries(Observable.fromIterable(allCountries), Observable.fromIterable(allCountries))
.test();
testObserver.assertResult(CountriesTestProvider.sumPopulationOfAllCountries()
+ CountriesTestProvider.sumPopulationOfAllCountries());
testObserver.assertNoErrors();
}
示例10: rx_areEmittingSameSequences_Positive
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void rx_areEmittingSameSequences_Positive() {
// hint: use "sequenceEqual" operator
TestObserver<Boolean> testObserver = countriesService
.areEmittingSameSequences(Observable.fromIterable(allCountries), Observable.fromIterable(allCountries))
.test();
testObserver.assertResult(true);
testObserver.assertNoErrors();
}
示例11: rx_areEmittingSameSequences_Negative
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void rx_areEmittingSameSequences_Negative() {
List<Country> allCountriesDifferentSequence = new ArrayList<>(allCountries);
Collections.swap(allCountriesDifferentSequence, 0, 1);
TestObserver<Boolean> testObserver = countriesService
.areEmittingSameSequences(
Observable.fromIterable(allCountries),
Observable.fromIterable(allCountriesDifferentSequence))
.test();
testObserver.assertResult(false);
testObserver.assertNoErrors();
}
示例12: requestGranted
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test @TargetApi(M) public void requestGranted() {
doReturn(false).when(rxPermission).isGranted(READ_PHONE_STATE);
final TestObserver<Permission> o = rxPermission.request(READ_PHONE_STATE)
.test();
rxPermission.onRequestPermissionsResult(permissionGranted(), FALSE_ARRAY, FALSE_ARRAY, READ_PHONE_STATE);
o.assertResult(Permission.granted(READ_PHONE_STATE));
}
示例13: requestDeniedFirstTime
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test @TargetApi(M) public void requestDeniedFirstTime() {
doReturn(false).when(rxPermission).isGranted(READ_PHONE_STATE);
final TestObserver<Permission> o = rxPermission.request(READ_PHONE_STATE)
.test();
rxPermission.onRequestPermissionsResult(permissionDenied(), FALSE_ARRAY, TRUE_ARRAY, READ_PHONE_STATE);
o.assertResult(Permission.denied(READ_PHONE_STATE));
}
示例14: requestDeniedAnyOtherTime
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test @TargetApi(M) public void requestDeniedAnyOtherTime() {
doReturn(false).when(rxPermission).isGranted(READ_PHONE_STATE);
final TestObserver<Permission> o = rxPermission.request(READ_PHONE_STATE)
.test();
rxPermission.onRequestPermissionsResult(permissionDenied(), TRUE_ARRAY, TRUE_ARRAY, READ_PHONE_STATE);
o.assertResult(Permission.denied(READ_PHONE_STATE));
}
示例15: requestDeniedNotShown
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test @TargetApi(M) public void requestDeniedNotShown() {
doReturn(false).when(rxPermission).isGranted(READ_PHONE_STATE);
final TestObserver<Permission> o = rxPermission.request(READ_PHONE_STATE)
.test();
rxPermission.onRequestPermissionsResult(permissionDenied(), FALSE_ARRAY, FALSE_ARRAY, READ_PHONE_STATE);
o.assertResult(Permission.deniedNotShown(READ_PHONE_STATE));
}