当前位置: 首页>>代码示例>>Java>>正文


Java TestObserver.assertNoErrors方法代码示例

本文整理汇总了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);
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:27,代码来源:RxFirebaseDatabaseTest.java

示例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();
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:19,代码来源:RetrofitAPICallsIntegrationTest.java

示例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());
    }
  });
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:25,代码来源:RxFirebaseStorageTest.java

示例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();
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:20,代码来源:NetworkManagerIntegrationTest.java

示例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();
}
 
开发者ID:FHannes,项目名称:RxJavaCollections,代码行数:12,代码来源:ObservableListTest.java

示例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);
}
 
开发者ID:graviton57,项目名称:TheNounProject,代码行数:16,代码来源:ApiHelperTest.java

示例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);
}
 
开发者ID:nikacotAndroid,项目名称:Weather-Guru-MVP,代码行数:15,代码来源:ApiHelperTest.java

示例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>());
}
 
开发者ID:nikacotAndroid,项目名称:Weather-Guru-MVP,代码行数:10,代码来源:DbHelperTest.java

示例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());
	}
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:12,代码来源:TestEmployeeRxJavaService.java

示例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));
}
 
开发者ID:sztomek,项目名称:cleanarchitecture-unidirectional,代码行数:15,代码来源:TimezoneGetUseCaseTest.java

示例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();
}
 
开发者ID:OrdnanceSurvey,项目名称:vt-support,代码行数:16,代码来源:StorageImplTest.java

示例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();
}
 
开发者ID:SimonScholz,项目名称:RxSWT,代码行数:12,代码来源:PaintObservableTest.java

示例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();
}
 
开发者ID:sergiiz,项目名称:RxBasicsKata,代码行数:9,代码来源:CountriesServiceSolvedTest.java

示例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));
}
 
开发者ID:dhinojosa,项目名称:rxjavatraining,代码行数:29,代码来源:ObservableTestingTest.java

示例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();
}
 
开发者ID:uber,项目名称:RIBs,代码行数:16,代码来源:StepTester.java


注:本文中的io.reactivex.observers.TestObserver.assertNoErrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。