當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。