本文整理汇总了Java中io.reactivex.observers.TestObserver.assertNoErrors方法的典型用法代码示例。如果您正苦于以下问题:Java TestObserver.assertNoErrors方法的具体用法?Java TestObserver.assertNoErrors怎么用?Java TestObserver.assertNoErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.observers.TestObserver
的用法示例。
在下文中一共展示了TestObserver.assertNoErrors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testChildEvents_remove
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testChildEvents_remove() {
TestObserver<ChildEvent> sub = TestObserver.create();
RxFirebaseDatabase.childEvents(mockDatabaseReference).subscribe(sub);
verifyAddChildEventListener();
callOnChildRemoved();
callOnChildRemoved();
sub.assertNotComplete();
sub.assertNoErrors();
sub.assertValueCount(2);
List events = sub.getEvents().get(0);
for (Object event : events) {
assertThat(event).isInstanceOf(ChildEvent.class);
assertThat(event).isInstanceOf(ChildRemoveEvent.class);
}
sub.dispose();
callOnChildRemoved();
// Ensure no more values are emitted after unsubscrube
sub.assertValueCount(2);
}
示例2: loginTest
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
/**
* Tests login API call
*/
@Test
public void loginTest() throws Exception {
LabService labService = retrofitBuilder.createService(
dummyApiUrl, LabService.class, dummyLogin, dummyPassword);
Gson gson = new Gson();
AccessToken accessToken = gson.fromJson(readFile(loginAccessTokenPath), AccessToken.class);
TestObserver<AccessToken> testObserver = new CustomTestObserver<>(accessToken);
labService.getAccessToken().subscribe(testObserver);
testObserver.assertSubscribed();
testObserver.assertValueCount(1);
testObserver.assertNoErrors();
testObserver.onComplete();
}
示例3: testGetDownloadUrl
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testGetDownloadUrl() {
mockSuccessfulResultForTask(mockUriTask, mockUri);
when(mockStorageReference.getDownloadUrl()).thenReturn(mockUriTask);
when(mockUri.toString()).thenReturn("file:///test");
TestObserver<Uri> obs = TestObserver.create();
RxFirebaseStorage.getDownloadUrl(mockStorageReference).subscribe(obs);
verifyAddOnCompleteListenerForTask(mockUriTask);
callOnComplete(mockUriTask);
obs.dispose();
callOnComplete(mockUriTask);
obs.assertNoErrors();
obs.assertComplete();
obs.assertValue(new Predicate<Uri>() {
@Override public boolean test(Uri uri) throws Exception {
return "file:///test".equals(uri.toString());
}
});
}
示例4: loginTest
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
/**
* {@link NetworkManager} integration test: login request to, local REST API server mock
*/
@Test
public void loginTest() throws Exception{
networkManager.configAuth(dummyApiUrl, dummyLogin, dummyPassword);
Gson gson = new Gson();
AccessToken expectedAccessToken
= gson.fromJson(readAssetFile(testContext, "api/login.json"), AccessToken.class);
TestObserver<AccessToken> testObserver = new CustomTestObserver<>(expectedAccessToken);
networkManager.getAccessToken().subscribe(testObserver);
testObserver.assertSubscribed();
testObserver.assertValueCount(1);
testObserver.assertNoErrors();
testObserver.onComplete();
}
示例5: concurrency
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void concurrency() throws Exception {
ObservableList<Integer> list = RxCollections.of(new ArrayList<>());
TestObserver<List<Integer>> o = list.observableChanges()
.observeOn(Schedulers.computation())
.map(l -> l.stream().filter(i -> i == 9).collect(Collectors.toList()))
.test();
IntStream.range(0, 10000).forEach(list::add);
o.assertNoErrors();
}
示例6: loadRecentUploadsIcons
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void loadRecentUploadsIcons() {
RecentUploadResponse responseModel = TestModels.getRecentUploadIconsResponse(5);
when(apiInterface.getRecentUploadsIcons(ArgumentMatchers.<String, String>anyMap()))
.thenReturn( Observable.just(responseModel));
TestObserver<RecentUploadResponse> testSubscriber = new TestObserver<>();
appApiHelper.getRecentUploadIcons(options).subscribe(testSubscriber);
testSubscriber.assertNoErrors();
testSubscriber.assertComplete();
testSubscriber.assertValueCount(1);
testSubscriber.assertValue(responseModel);
}
示例7: loadCities
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void loadCities() {
SearchApiResponseModel responseModel = TestModels.getSearchResponseModel(5);
when(apiInterface.getLocations(anyString(), anyString(), anyString())).thenReturn(
Observable.just(responseModel));
TestObserver<SearchApiResponseModel> testSubscriber = new TestObserver<>();
appApiHelper.locationsApiRequest("test").subscribe(testSubscriber);
testSubscriber.assertNoErrors();
testSubscriber.assertComplete();
testSubscriber.assertValueCount(1);
testSubscriber.assertValue(responseModel);
}
示例8: listCities
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void listCities() {
TestObserver<List<CityDetailsModel>> listTestSubscriber = new TestObserver<>();
dbHelper.getAllCities().subscribe(listTestSubscriber);
listTestSubscriber.assertNoErrors();
listTestSubscriber.assertComplete();
listTestSubscriber.assertValueCount(1);
listTestSubscriber.assertValue(new ArrayList<CityDetailsModel>());
}
示例9: testEmployeeDataRx
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void testEmployeeDataRx(){
TestObserver<Employee> testObserver = new TestObserver<>();
employeeRxJavaServiceImpl.getEmployeesRx().subscribe(testObserver);
testObserver.assertNoErrors();
List<Employee> emps = testObserver.values();
for(Employee emp: emps){
System.out.println(emp.getFirstName());
}
}
示例10: doActionTokenException
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void doActionTokenException() throws Exception {
Mockito.when(auth.getCurrentUser()).thenThrow(NOPE);
AuthService spyAuth = Mockito.spy(new AuthService(auth));
Mockito.when(restService.getTimezoneForUser(TEST_USER_ID, TEST_TIMEZONE_ID, TEST_TOKEN))
.thenReturn(Observable.just(TIMEZONE));
TimezoneEditUiActions.GetTimezoneAction action = TimezoneEditUiActions.get(TEST_USER_ID, TEST_TIMEZONE_ID);
TimezoneGetUseCase spyUseCase = Mockito.spy(new TimezoneGetUseCase(Schedulers.io(), Schedulers.io(), restService, spyAuth));
TestObserver<Result> test = spyUseCase.doAction(action).test();
test.awaitTerminalEvent();
test.assertNoErrors();
test.assertValue(Result.error(action, NOPE));
}
示例11: ensureStorageAppearsToBeGood
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void ensureStorageAppearsToBeGood() throws IOException {
final File file = provideNonExistentTestDirectoryOrBlow();
final StorageImpl storage = new StorageImpl.Builder(file).createIfNotExist().build();
final TestObserver<Entry> entrySubscriber = new TestObserver<>();
storage.getEntries().blockingSubscribe(entrySubscriber);
entrySubscriber.assertNoErrors();
entrySubscriber.assertComplete();
final TestObserver<Metadata> metadataSubscriber = new TestObserver<>();
storage.getMetadata().subscribe(metadataSubscriber);
metadataSubscriber.assertNoErrors();
metadataSubscriber.assertComplete();
}
示例12: testPaintControl
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void testPaintControl() {
TestObserver<PaintEvent> testObserver = new TestObserver<>();
Observable<PaintEvent> paintControl = SwtObservables.paintControl(shell);
paintControl.subscribe(testObserver);
testObserver.assertNoErrors();
testObserver.assertNotComplete();
}
示例13: 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();
}
示例14: testMakingObservablesTestableIntegrationTest
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void testMakingObservablesTestableIntegrationTest() throws IOException, InterruptedException {
String fakeData = "Date,Open,High,Low,Close,Volume\n" +
"10-Oct-17,1097.00,1123.00,1097.00,1110.00,11978\n" +
"9-Oct-17,1112.00,1120.00,1112.00,1120.00,5660\n" +
"6-Oct-17,1110.00,1110.00,1104.00,1104.00,1537\n" +
"5-Oct-17,1078.00,1105.00,1078.00,1105.00,8134\n";
Observable<Tuple2<String, Double>> tuple2Observable = processStock(Arrays.asList("M", "ATT"), s ->
{
String data = "";
try {
data = getInfoFromURL(s);
} catch (IOException e) {
e.printStackTrace();
}
return data;
});
TestObserver<Tuple2<String, Double>> testObserver = new TestObserver<>();
tuple2Observable.subscribe(testObserver);
Thread.sleep(10000);
testObserver.assertNoErrors();
testObserver.assertValues(new Tuple2<>("M", 20.66), new Tuple2<>("ATT", 1110.0));
}
示例15: assertStepEmitted
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
/**
* Asserts that exactly one {@link Step} has been emitted from the {@link TestObserver}
*
* @param testSubscriber the step subscriber to assert on.
* @param <T> type of return value for a step.
* @param <A> type of next actionable item for a step.
*/
public static <T, A extends ActionableItem> void assertStepEmitted(
TestObserver<Optional<Step.Data<T, A>>> testSubscriber) {
testSubscriber.assertValueCount(1);
Optional<Step.Data<T, A>> stepData = testSubscriber.values().get(0);
assertThat(stepData.isPresent()).isTrue();
testSubscriber.assertComplete();
testSubscriber.assertNoErrors();
}