本文整理汇总了Java中io.reactivex.observers.TestObserver.assertValue方法的典型用法代码示例。如果您正苦于以下问题:Java TestObserver.assertValue方法的具体用法?Java TestObserver.assertValue怎么用?Java TestObserver.assertValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.observers.TestObserver
的用法示例。
在下文中一共展示了TestObserver.assertValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void test() {
MaybeSubject<String> subject = MaybeSubject.create();
Maybe<String> maybeSource = subject.hide();
TestObserver testObserver = new TestObserver();
CompositeDisposable composite = new CompositeDisposable();
Disposable disposable = maybeSource
.compose(DisposableAttach.<String>to(composite))
.subscribeWith(testObserver);
subject.onSuccess("Foo");
testObserver.assertValue("Foo");
assertTrue(composite.size() == 1);
composite.dispose();
assertTrue(composite.size() == 0);
assertTrue(composite.isDisposed());
assertTrue(disposable.isDisposed());
assertTrue(testObserver.isDisposed());
}
示例2: testUpdateMetadata
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testUpdateMetadata() {
when(mockStorageMetadata.getName()).thenReturn("metadata");
mockSuccessfulResultForTask(mockStorageMetadataTask, mockStorageMetadata);
TestObserver<StorageMetadata> obs = TestObserver.create();
when(mockStorageReference.updateMetadata(mockStorageMetadata)).thenReturn(
mockStorageMetadataTask);
RxFirebaseStorage.updateMetadata(mockStorageReference, mockStorageMetadata).subscribe(obs);
verifyAddOnCompleteListenerForTask(mockStorageMetadataTask);
callOnComplete(mockStorageMetadataTask);
obs.dispose();
callOnComplete(mockStorageMetadataTask);
obs.assertNoErrors();
obs.assertComplete();
obs.assertValue(new Predicate<StorageMetadata>() {
@Override public boolean test(StorageMetadata metadata) throws Exception {
return "metadata".equals(metadata.getName());
}
});
}
示例3: testPutFileWithMetadata
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testPutFileWithMetadata() {
mockSuccessfulResultForTask(mockUploadTask, mockUploadTaskSnapshot);
when(mockStorageReference.putFile(mockUri, mockStorageMetadata)).thenReturn(mockUploadTask);
when(mockUploadTaskSnapshot.getBytesTransferred()).thenReturn(1000L);
when(mockUploadTaskSnapshot.getTotalByteCount()).thenReturn(1000L);
TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create();
RxFirebaseStorage.putFile(mockStorageReference, mockUri, mockStorageMetadata).subscribe(obs);
verifyAddOnCompleteListenerForTask(mockUploadTask);
callOnComplete(mockUploadTask);
obs.dispose();
callOnComplete(mockUploadTask);
obs.assertNoErrors();
obs.assertComplete();
obs.assertValue(new Predicate<UploadTask.TaskSnapshot>() {
@Override public boolean test(UploadTask.TaskSnapshot taskSnapshot) throws Exception {
return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount()
&& taskSnapshot.getTotalByteCount() == 1000L;
}
});
}
示例4: testGetFileUri
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@SuppressWarnings("Duplicates") @Test public void testGetFileUri() {
mockSuccessfulResultForTask(mockFileDownloadTask, mockFileDownloadTaskSnapshot);
when(mockStorageReference.getFile(mockUri)).thenReturn(mockFileDownloadTask);
when(mockFileDownloadTaskSnapshot.getBytesTransferred()).thenReturn(1000L);
when(mockFileDownloadTaskSnapshot.getTotalByteCount()).thenReturn(1000L);
TestObserver<FileDownloadTask.TaskSnapshot> obs = TestObserver.create();
RxFirebaseStorage.getFile(mockStorageReference, mockUri).subscribe(obs);
verifyAddOnCompleteListenerForTask(mockFileDownloadTask);
callOnComplete(mockFileDownloadTask);
obs.dispose();
callOnComplete(mockFileDownloadTask);
obs.assertNoErrors();
obs.assertComplete();
obs.assertValue(new Predicate<FileDownloadTask.TaskSnapshot>() {
@Override public boolean test(FileDownloadTask.TaskSnapshot taskSnapshot) throws Exception {
return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount()
&& taskSnapshot.getTotalByteCount() == 1000;
}
});
}
示例5: rxActivity_shouldCallback_onLowMemory
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void rxActivity_shouldCallback_onLowMemory() {
ActivityController<EmptyActivity> activityController = buildActivity(EmptyActivity.class);
RibActivity activity = activityController.setup().get();
TestObserver<ActivityCallbackEvent> testSub = new TestObserver<>();
activity
.callbacks()
.filter(
new Predicate<ActivityCallbackEvent>() {
@Override
public boolean test(ActivityCallbackEvent activityEvent) throws Exception {
return activityEvent.getType() == ActivityCallbackEvent.Type.LOW_MEMORY;
}
})
.subscribe(testSub);
activity.onLowMemory();
testSub.assertValue(ActivityCallbackEvent.create(ActivityCallbackEvent.Type.LOW_MEMORY));
}
示例6: test
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void test() {
SingleSubject<String> subject = SingleSubject.create();
Single<String> singleSource = subject.hide();
TestObserver testObserver = new TestObserver();
CompositeDisposable composite = new CompositeDisposable();
Disposable disposable = singleSource
.compose(DisposableAttach.<String>to(composite))
.subscribeWith(testObserver);
subject.onSuccess("Foo");
testObserver.assertValue("Foo");
assertTrue(composite.size() == 1);
composite.dispose();
assertTrue(composite.size() == 0);
assertTrue(composite.isDisposed());
assertTrue(disposable.isDisposed());
assertTrue(testObserver.isDisposed());
}
示例7: should_process_the_json_payload_from_provider
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
@PactVerification("our_provider")
public void should_process_the_json_payload_from_provider() {
TestObserver<ServiceResponse> observer = service.fetchResponse(DATE_TIME).test();
observer.assertNoErrors();
observer.assertValue(ServiceResponse.create(DATE_TIME, Arrays.asList(
Animal.create("Doggy", "dog"),
Animal.create("Doggy", "dog"),
Animal.create("Doggy", "dog")
)));
}
示例8: testPutBytesWithMetadata
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testPutBytesWithMetadata() {
mockSuccessfulResultForTask(mockUploadTask, mockUploadTaskSnapshot);
when(mockStorageReference.putBytes(new byte[] { 1, 2, 3 }, mockStorageMetadata)).thenReturn(
mockUploadTask);
when(mockUploadTaskSnapshot.getBytesTransferred()).thenReturn(1000L);
when(mockUploadTaskSnapshot.getTotalByteCount()).thenReturn(1000L);
TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create();
RxFirebaseStorage.putBytes(mockStorageReference, new byte[] { 1, 2, 3 }, mockStorageMetadata)
.subscribe(obs);
verifyAddOnCompleteListenerForTask(mockUploadTask);
callOnComplete(mockUploadTask);
obs.dispose();
callOnComplete(mockUploadTask);
obs.assertNoErrors();
obs.assertComplete();
obs.assertValue(new Predicate<UploadTask.TaskSnapshot>() {
@Override public boolean test(UploadTask.TaskSnapshot taskSnapshot) throws Exception {
return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount()
&& taskSnapshot.getTotalByteCount() == 1000L;
}
});
}
示例9: loadCollectionIcons
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void loadCollectionIcons() {
IconsResponse responseModel = TestModels.getIconsResponseModel(5);
when(apiInterface.getCollectionIcons(anyInt(), ArgumentMatchers.<String, String>anyMap()))
.thenReturn(Observable.just(responseModel));
TestObserver<IconsResponse> testSubscriber = new TestObserver<>();
appApiHelper.getCollectionIcons(29508, options).subscribe(testSubscriber);
testSubscriber.assertNoErrors();
testSubscriber.assertComplete();
testSubscriber.assertValueCount(1);
testSubscriber.assertValue(responseModel);
}
示例10: diffResults_WhenNoSubscribers_CachesResult
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void diffResults_WhenNoSubscribers_CachesResult() {
// Given
mDiffRequestManager.receive(mRxDiffResult);
// When
final TestObserver<RxDiffResult> testObserver = new TestObserver<>();
mDiffRequestManager.diffResults()
.subscribe(testObserver);
// Then
testObserver.assertValue(mRxDiffResult);
}
示例11: rx_CountryNameInCapitals
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void rx_CountryNameInCapitals() {
Country testCountry = CountriesTestProvider.countries().get(0);
String expected = testCountry.name.toUpperCase(Locale.US);
TestObserver<String> testObserver = countriesService
.countryNameInCapitals(testCountry)
.test();
testObserver.assertNoErrors();
testObserver.assertValue(expected);
}
示例12: oneWrongEvent
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void oneWrongEvent() {
TestObserver<String> testObserver = Single.just("1")
.delay(1, TimeUnit.MILLISECONDS, testScheduler)
.compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, "stop"))
.test();
testObserver.assertNoValues();
lifecycle.onNext("keep going");
testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);
testObserver.assertValue("1");
testObserver.assertComplete();
}
示例13: 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);
}
示例14: oneWrongEvent
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void oneWrongEvent() {
TestObserver<String> testObserver = maybe
.compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, "stop"))
.test();
lifecycle.onNext("keep going");
subject.onNext("1");
testObserver.assertValue("1");
testObserver.assertComplete();
}
示例15: oneStartEvent
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void oneStartEvent() {
TestObserver<String> testObserver = maybe
.compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))
.test();
lifecycle.onNext("create");
subject.onNext("1");
testObserver.assertValue("1");
testObserver.assertComplete();
}