Java Code Examples for rx.observers.TestSubscriber#assertNoErrors()
The following examples show how to use
rx.observers.TestSubscriber#assertNoErrors() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RxStringOperatorsUnitTest.java From tutorials with MIT License | 6 votes |
@Test public void givenStringObservable_whenJoiningStrings_ThenSuccessfullObtainingSingleString() { //given Observable<String> sourceObservable = Observable.just("Lorem ipsum loream","Lorem ipsum lore"); TestSubscriber<String> subscriber = TestSubscriber.create(); // when StringObservable.join(sourceObservable,",") .subscribe(subscriber); // then subscriber.assertCompleted(); subscriber.assertNoErrors(); subscriber.assertValueCount(1); subscriber.assertValues("Lorem ipsum loream,Lorem ipsum lore"); }
Example 2
Source File: RxAggregateOperatorsUnitTest.java From tutorials with MIT License | 6 votes |
@Test public void givenObservable_whenUsingToList_thenObtainedAList() { // given Observable<Integer> sourceObservable = Observable.range(1, 5); TestSubscriber<List> subscriber = TestSubscriber.create(); // when Observable<List<Integer>> listObservable = sourceObservable.toList(); listObservable.subscribe(subscriber); // then subscriber.assertCompleted(); subscriber.assertNoErrors(); subscriber.assertValueCount(1); subscriber.assertValue(Arrays.asList(1, 2, 3, 4, 5)); }
Example 3
Source File: EnvironmentRepositoryTest.java From openwebnet-android with MIT License | 6 votes |
@Test public void environmentRepository_findById() { Integer ENVIRONMENT_ID = 100; EnvironmentModel environment = newEnvironmentModel(ENVIRONMENT_ID, "myName"); List<EnvironmentModel> environments = Arrays.asList(environment); when(databaseRealm.findCopyWhere(EnvironmentModel.class, EnvironmentModel.FIELD_ID, ENVIRONMENT_ID, null)) .thenReturn(environments); TestSubscriber<EnvironmentModel> tester = new TestSubscriber<>(); environmentRepository.findById(ENVIRONMENT_ID).subscribe(tester); verify(databaseRealm).findCopyWhere(EnvironmentModel.class, EnvironmentModel.FIELD_ID, ENVIRONMENT_ID, null); tester.assertValue(environment); tester.assertCompleted(); tester.assertNoErrors(); }
Example 4
Source File: RxFirebaseDatabaseTests.java From RxFirebase with Apache License 2.0 | 6 votes |
@Test public void testObserveChildEvent_Moved() { TestSubscriber<RxFirebaseChildEvent<TestData>> testSubscriber = new TestSubscriber<>(); RxFirebaseDatabase.observeChildEvent(mockDatabase, TestData.class) .subscribeOn(Schedulers.immediate()) .subscribe(testSubscriber); ArgumentCaptor<ChildEventListener> argument = ArgumentCaptor.forClass(ChildEventListener.class); verify(mockDatabase).addChildEventListener(argument.capture()); argument.getValue().onChildMoved(mockFirebaseDataSnapshot, "root"); testSubscriber.assertNoErrors(); testSubscriber.assertValueCount(1); testSubscriber.assertReceivedOnNext(Collections.singletonList(testChildEventMoved)); testSubscriber.assertNotCompleted(); testSubscriber.unsubscribe(); }
Example 5
Source File: LightServiceTest.java From openwebnet-android with MIT License | 6 votes |
@Test public void lightService_findById() { String LIGHT_UUID = "myUuid"; LightModel lightModel = new LightModel(); lightModel.setUuid(LIGHT_UUID); when(lightRepository.findById(LIGHT_UUID)).thenReturn(Observable.just(lightModel)); TestSubscriber<LightModel> tester = new TestSubscriber<>(); lightService.findById(LIGHT_UUID).subscribe(tester); verify(lightRepository).findById(LIGHT_UUID); tester.assertValue(lightModel); tester.assertCompleted(); tester.assertNoErrors(); }
Example 6
Source File: RxFirebaseDatabaseTests.java From RxFirebase with Apache License 2.0 | 6 votes |
@Test public void testObserveChildEvent_Added() { TestSubscriber<RxFirebaseChildEvent<TestData>> testSubscriber = new TestSubscriber<>(); RxFirebaseDatabase.observeChildEvent(mockDatabase, TestData.class) .subscribeOn(Schedulers.immediate()) .subscribe(testSubscriber); ArgumentCaptor<ChildEventListener> argument = ArgumentCaptor.forClass(ChildEventListener.class); verify(mockDatabase).addChildEventListener(argument.capture()); argument.getValue().onChildAdded(mockFirebaseDataSnapshot, "root"); testSubscriber.assertNoErrors(); testSubscriber.assertValueCount(1); testSubscriber.assertReceivedOnNext(Collections.singletonList(testChildEventAdded)); testSubscriber.assertNotCompleted(); testSubscriber.unsubscribe(); }
Example 7
Source File: EnergyServiceTest.java From openwebnet-android with MIT License | 6 votes |
@Test public void energyService_add() { String ENERGY_UUID = "myUuid"; EnergyModel energyModel = new EnergyModel(); when(energyRepository.add(energyModel)).thenReturn(Observable.just(ENERGY_UUID)); TestSubscriber<String> tester = new TestSubscriber<>(); energyService.add(energyModel).subscribe(tester); verify(energyRepository).add(energyModel); tester.assertValue(ENERGY_UUID); tester.assertCompleted(); tester.assertNoErrors(); }
Example 8
Source File: DeviceServiceTest.java From openwebnet-android with MIT License | 6 votes |
@Test public void deviceService_findById() { String DEVICE_UUID = "myUuid"; DeviceModel deviceModel = new DeviceModel(); deviceModel.setUuid(DEVICE_UUID); when(deviceRepository.findById(DEVICE_UUID)).thenReturn(Observable.just(deviceModel)); TestSubscriber<DeviceModel> tester = new TestSubscriber<>(); deviceService.findById(DEVICE_UUID).subscribe(tester); verify(deviceRepository).findById(DEVICE_UUID); tester.assertValue(deviceModel); tester.assertCompleted(); tester.assertNoErrors(); }
Example 9
Source File: CompressionTest.java From hawkular-metrics with Apache License 2.0 | 5 votes |
private void compressData(long start) { Completable completable = metricsService.compressBlock(start, 2000, 2); TestSubscriber<Row> tsr = new TestSubscriber<>(); completable.subscribe(tsr); tsr.awaitTerminalEvent(100, TimeUnit.SECONDS); // Travis again for (Throwable throwable : tsr.getOnErrorEvents()) { throwable.printStackTrace(); } tsr.assertCompleted(); tsr.assertNoErrors(); }
Example 10
Source File: RxJavaSkipOperatorsIntegrationTest.java From tutorials with MIT License | 5 votes |
@Test public void givenRangeObservable_whenSkipping_thenFirstFourItemsAreSkipped() { Observable<Integer> sourceObservable = Observable.range(1, 10); TestSubscriber<Integer> subscriber = new TestSubscriber(); Observable<Integer> filteredObservable = sourceObservable.skip(4); filteredObservable.subscribe(subscriber); subscriber.assertCompleted(); subscriber.assertNoErrors(); subscriber.assertValueCount(6); subscriber.assertValues(5, 6, 7, 8, 9, 10); }
Example 11
Source File: LightServiceTest.java From openwebnet-android with MIT License | 5 votes |
@Test public void lightService_turnOff() { LightModel light = mockLightModel(); mockClient(); TestSubscriber<LightModel> tester = new TestSubscriber<>(); lightService.turnOff(light).subscribe(tester); verify(commonService).findClient(GATEWAY_UUID); tester.assertValue(light); tester.assertCompleted(); tester.assertNoErrors(); }
Example 12
Source File: InfoWindowCloseFuncTest.java From RxGoogleMaps with Apache License 2.0 | 5 votes |
@Test public void shouldEmmitMarker() throws Exception { TestSubscriber<Marker> testSubscriber = new TestSubscriber<>(); new InfoWindowCloseFunc().call(googleMap) .subscribe(testSubscriber); verify(googleMap).setOnInfoWindowCloseListener(argumentCaptor.capture()); argumentCaptor.getValue().onInfoWindowClose(null); testSubscriber.assertNoErrors(); testSubscriber.assertValueCount(1); argumentCaptor.getValue().onInfoWindowClose(null); testSubscriber.assertValueCount(2); }
Example 13
Source File: SoundServiceTest.java From openwebnet-android with MIT License | 5 votes |
@Test public void soundService_findFavourites() { List<SoundModel> sounds = new ArrayList<>(); when(soundRepository.findFavourites()).thenReturn(Observable.just(sounds)); TestSubscriber<List<SoundModel>> tester = new TestSubscriber<>(); soundService.findFavourites().subscribe(tester); verify(soundRepository).findFavourites(); tester.assertValue(sounds); tester.assertCompleted(); tester.assertNoErrors(); }
Example 14
Source File: IpcamServiceTest.java From openwebnet-android with MIT License | 5 votes |
@Test public void ipcamService_update() { IpcamModel ipcamModel = new IpcamModel(); when(ipcamRepository.update(ipcamModel)).thenReturn(Observable.just(null)); TestSubscriber<Void> tester = new TestSubscriber<>(); ipcamService.update(ipcamModel).subscribe(tester); verify(ipcamRepository).update(ipcamModel); tester.assertCompleted(); tester.assertNoErrors(); }
Example 15
Source File: SnapshotFuncTest.java From RxGoogleMaps with Apache License 2.0 | 5 votes |
@Test public void shouldProvideBitmap() throws Exception { TestSubscriber<Bitmap> testSubscriber = new TestSubscriber<>(); new SnapshotFunc().call(googleMap) .subscribe(testSubscriber); verify(googleMap).snapshot(argumentCaptor.capture()); argumentCaptor.getValue().onSnapshotReady(null); testSubscriber.assertNoErrors(); testSubscriber.assertValueCount(1); testSubscriber.assertValue(null); }
Example 16
Source File: MapObservableProviderTest.java From RxGoogleMaps with Apache License 2.0 | 5 votes |
@Test public void shouldReturnMapFromSupportFragment() { TestSubscriber<GoogleMap> subscriber = new TestSubscriber<>(); new MapObservableProvider(supportMapFragment) .getMapReadyObservable() .subscribe(subscriber); verify(supportMapFragment).getMapAsync(argumentCaptor.capture()); argumentCaptor.getValue().onMapReady(googleMap); subscriber.assertNoErrors(); subscriber.assertValue(googleMap); }
Example 17
Source File: AutomationServiceTest.java From openwebnet-android with MIT License | 5 votes |
@Test public void automationService_requestFavourites() { List<AutomationModel> automations = new ArrayList<>(); when(automationRepository.findFavourites()).thenReturn(Observable.just(automations)); mockClient(); TestSubscriber<List<AutomationModel>> tester = new TestSubscriber<>(); automationService.requestFavourites().subscribe(tester); tester.assertValue(automations); tester.assertCompleted(); tester.assertNoErrors(); }
Example 18
Source File: FontDownloaderTest.java From fontster with Apache License 2.0 | 5 votes |
@Test public void testDownloadAllFonts_filesExist() throws Exception { TestSubscriber<File> testSubscriber = new TestSubscriber<>(); FontDownloader fontDownloader = new FontDownloader(new MockFontPackage(MOCK_FONT_PACK_NAME)); fontDownloader.downloadAllFonts().subscribe(testSubscriber); testSubscriber.assertNoErrors(); File downloadedFontPack = new File(MockFontPackage.TEST_FOLDER, MOCK_FONT_PACK_NAME + "FontPack"); assertTrue(downloadedFontPack.exists()); assertTrue(downloadedFontPack.isDirectory()); assertEquals(Style.values().length, downloadedFontPack.listFiles().length); }
Example 19
Source File: TemperatureServiceTest.java From openwebnet-android with MIT License | 5 votes |
@Test public void temperatureService_requestFavourites() { List<TemperatureModel> temperatures = new ArrayList<>(); mockClient(); when(temperatureRepository.findFavourites()).thenReturn(Observable.just(temperatures)); TestSubscriber<List<TemperatureModel>> tester = new TestSubscriber<>(); temperatureService.requestFavourites().subscribe(tester); tester.assertValue(temperatures); tester.assertCompleted(); tester.assertNoErrors(); }
Example 20
Source File: PrayerDownloaderTest.java From android with Apache License 2.0 | 4 votes |
@Test public void getPrayerContextSameYear() { PrayerDownloader d = new PrayerDownloader( mDateHelper, mPrayerClient, mPrayerCache, mInterfacePreferences ); when(mLocation.getLatitude()) .thenReturn(3.28011); when(mLocation.getLongitude()) .thenReturn(101.556); when(mLocation.distanceTo(any(Location.class))) .thenReturn(0f); when(mDateHelper.getCurrentMonth()) .thenReturn(3); when(mDateHelper.getCurrentYear()) .thenReturn(2016); when(mDateHelper.getNextMonth()) .thenReturn(4); when(mDateHelper.isNextMonthNewYear()) .thenReturn(false); when(mPrayerCache.get(anyInt(), anyInt(), eq(mLocation))) .thenReturn(Observable.<PrayerData>empty()); when(mPrayerClient.getPrayerTimesByCoordinates(anyDouble(), anyDouble(), anyInt(), eq(4))) .thenReturn(Observable.just(mPrayerData1)); when(mPrayerClient.getPrayerTimesByCoordinates(anyDouble(), anyDouble(), anyInt(), eq(5))) .thenReturn(Observable.just(mPrayerData2)); TestSubscriber<PrayerContext> testSubscriber = new TestSubscriber<>(); d.getPrayerTimes(mLocation).subscribe(testSubscriber); testSubscriber.assertNoErrors(); List<PrayerContext> prayers = testSubscriber.getOnNextEvents(); assertThat(prayers).hasSize(1); verify(mPrayerCache, times(1)).get(eq(2016), eq(4), eq(mLocation)); verify(mPrayerCache, times(1)).get(eq(2016), eq(5), eq(mLocation)); verify(mPrayerClient, times(1)).getPrayerTimesByCoordinates(eq(3.28011), eq(101.556), eq(2016), eq(4)); verify(mPrayerClient, times(1)).getPrayerTimesByCoordinates(eq(3.28011), eq(101.556), eq(2016), eq(5)); verify(mPrayerCache, times(1)).save(eq(mPrayerData1), eq(mLocation)); verify(mPrayerCache, times(1)).save(eq(mPrayerData2), eq(mLocation)); }