本文整理匯總了Java中rx.observers.TestSubscriber.assertCompleted方法的典型用法代碼示例。如果您正苦於以下問題:Java TestSubscriber.assertCompleted方法的具體用法?Java TestSubscriber.assertCompleted怎麽用?Java TestSubscriber.assertCompleted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rx.observers.TestSubscriber
的用法示例。
在下文中一共展示了TestSubscriber.assertCompleted方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fetchAllOutdatedPackagesThatWereUninstalled
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void fetchAllOutdatedPackagesThatWereUninstalled() {
List<AppInfo> savedPackages = Arrays.asList(facebookInfo, instagramInfo);
when(appProvider.getInstalledPackages()).thenReturn(Observable.just(Collections.emptyList()));
when(appService.allInfos()).thenReturn(Observable.just(savedPackages));
TestSubscriber<List<String>> subscriber = new TestSubscriber<>();
fetchOutdatedPackages.get().toBlocking().subscribe(subscriber);
List<String> expectedPackages =
Arrays.asList(facebookInfo.packageName(), instagramInfo.packageName());
List<String> receivedPackages = subscriber.getOnNextEvents().get(0);
Assertions.assertThat(receivedPackages).containsAll(expectedPackages);
subscriber.assertCompleted();
}
示例2: saveAccount_retrievesAccount
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void saveAccount_retrievesAccount() {
Account account = new Account("Account1");
TestSubscriber<Account> saveAccountSubscriber = new TestSubscriber<>();
accountsDataSource.saveAccount(account).subscribe(saveAccountSubscriber);
saveAccountSubscriber.assertNoErrors();
List<Account> accounts = saveAccountSubscriber.getOnNextEvents();
assertThat(accounts.size(), is(1));
Account savedAccount = accounts.get(0);
assertThat(savedAccount.getName(), is(account.getName()));
saveAccountSubscriber.assertCompleted();
TestSubscriber<Account> getAccountSubscriber = new TestSubscriber<>();
accountsDataSource.getAccount(savedAccount.getId()).subscribe(getAccountSubscriber);
getAccountSubscriber.assertNoErrors();
accounts = getAccountSubscriber.getOnNextEvents();
assertThat(accounts.size(), is(1));
Account retrievedAccount = accounts.get(0);
assertThat(retrievedAccount.getId(), is(savedAccount.getId()));
assertThat(retrievedAccount.getName(), is(account.getName()));
}
示例3: fetchOnlyOnePackageIfMoreVersionsOfAnAppHaveBeenSaved
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void fetchOnlyOnePackageIfMoreVersionsOfAnAppHaveBeenSaved() {
List<AppInfo> savedPackages = Arrays.asList(facebookInfo, facebookInfoVersion2);
List<PackageInfo> installedPackages = Collections.emptyList();
when(appProvider.getInstalledPackages()).thenReturn(Observable.just(installedPackages));
when(appService.allInfos()).thenReturn(Observable.just(savedPackages));
TestSubscriber<List<String>> subscriber = new TestSubscriber<>();
fetchOutdatedPackages.get().toBlocking().subscribe(subscriber);
List<String> expectedPackages = Collections.singletonList(facebookInfo.packageName());
List<String> receivedPackages = subscriber.getOnNextEvents().get(0);
Assertions.assertThat(receivedPackages).containsAll(expectedPackages);
subscriber.assertCompleted();
}
示例4: fetchAllAppsFromDeviceIfNoneAreSavedInDB
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void fetchAllAppsFromDeviceIfNoneAreSavedInDB() {
List<PackageInfo> installedPackages =
Arrays.asList(MockPackageInfo.TEST, MockPackageInfo.TEST2);
when(appProvider.getInstalledPackages()).thenReturn(Observable.just(installedPackages));
when(appService.allInfos()).thenReturn(Observable.just(Collections.emptyList()));
TestSubscriber<List<PackageInfo>> testSubscriber = new TestSubscriber<>();
fetchUpdatedPackages.get().toBlocking().subscribe(testSubscriber);
List<PackageInfo> expectedPackages = Arrays.asList(MockPackageInfo.TEST, MockPackageInfo.TEST2);
List<PackageInfo> receivedPackages = testSubscriber.getOnNextEvents().get(0);
assertThat(receivedPackages).containsAll(expectedPackages);
testSubscriber.assertCompleted();
}
示例5: rxCompletableFallback
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void rxCompletableFallback() {
server.enqueue(new MockResponse().setResponseCode(500));
TestInterface api = target();
Completable completable = api.completable();
assertThat(completable).isNotNull();
assertThat(server.getRequestCount()).isEqualTo(0);
TestSubscriber<String> testSubscriber = new TestSubscriber<String>();
completable.subscribe(testSubscriber);
testSubscriber.awaitTerminalEvent();
testSubscriber.assertCompleted();
}
示例6: fetchOnlyNewAppsFromDevice
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void fetchOnlyNewAppsFromDevice() {
List<PackageInfo> installedPackages =
Arrays.asList(MockPackageInfo.TEST, MockPackageInfo.TEST2);
List<AppInfo> savedPackages = Collections.singletonList(MockApp.TEST_INFO);
when(appProvider.getInstalledPackages()).thenReturn(Observable.just(installedPackages));
when(appService.allInfos()).thenReturn(Observable.just(savedPackages));
TestSubscriber<List<PackageInfo>> testSubscriber = new TestSubscriber<>();
fetchUpdatedPackages.get().toBlocking().subscribe(testSubscriber);
List<PackageInfo> expectedPackages = Collections.singletonList(MockPackageInfo.TEST2);
List<PackageInfo> receivedPackages = testSubscriber.getOnNextEvents().get(0);
assertThat(receivedPackages).containsAll(expectedPackages);
testSubscriber.assertCompleted();
}
示例7: fetchSuggestionValueReceivedTest
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
public void fetchSuggestionValueReceivedTest() throws Exception {
final TestSubscriber<List<String>> testSubscriber = TestSubscriber.create();
RxSuggestions.fetch("a").subscribe(testSubscriber);
if (Util.isOnline()) {
testSubscriber.assertCompleted();
testSubscriber.assertNoErrors();
final List<List<String>> nextEvents = testSubscriber.getOnNextEvents();
for (String suggestion : nextEvents.get(0)) {
assertTrue(!suggestion.isEmpty());
}
} else {
assertNoValuesAndOneError(testSubscriber);
}
}
示例8: fetchAllApps
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void fetchAllApps() {
List<App> testApps = Arrays.asList(MockApp.TEST, MockApp.TEST2);
when(appRepository.all(any(BriteDatabase.class)))
.thenReturn(Observable.just(testApps));
TestSubscriber<List<App>> subscriber = new TestSubscriber<>();
appService.all()
.toBlocking()
.subscribe(subscriber);
verify(databaseManager).get();
subscriber.assertReceivedOnNext(Collections.singletonList(testApps));
subscriber.assertCompleted();
}
示例9: deleteOutdatedPackages
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void deleteOutdatedPackages() {
oldPackages.addAll(
Arrays.asList(MockPackageInfo.TEST.packageName, MockPackageInfo.TEST2.packageName));
TestSubscriber<Void> subscriber = new TestSubscriber<>();
dbSyncer.sync().toBlocking().subscribe(subscriber);
List<String> expectedPackages =
Arrays.asList(MockPackageInfo.TEST.packageName, MockPackageInfo.TEST2.packageName);
verify(appService).removeAllByPackageName(expectedPackages);
subscriber.assertCompleted();
}
示例10: updateAccount_retrievesAccount
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void updateAccount_retrievesAccount() {
Account account = new Account("Account1");
TestSubscriber<Account> saveAccountSubscriber = new TestSubscriber<>();
accountsDataSource.saveAccount(account).subscribe(saveAccountSubscriber);
List<Account> accounts = saveAccountSubscriber.getOnNextEvents();
account = accounts.get(0);
account.setName("Account2");
TestSubscriber<Account> updateAccountSubscriber = new TestSubscriber<>();
accountsDataSource.saveAccount(account).subscribe(updateAccountSubscriber);
updateAccountSubscriber.assertNoErrors();
accounts = updateAccountSubscriber.getOnNextEvents();
assertThat(accounts.size(), is(1));
account = accounts.get(0);
assertThat(account.getName(), is("Account2"));
updateAccountSubscriber.assertCompleted();
TestSubscriber<Account> getAccountSubscriber = new TestSubscriber<>();
accountsDataSource.getAccount(account.getId()).subscribe(getAccountSubscriber);
getAccountSubscriber.assertNoErrors();
accounts = getAccountSubscriber.getOnNextEvents();
assertThat(accounts.size(), is(1));
Account retrievedAccount = accounts.get(0);
assertThat(retrievedAccount.getId(), is(account.getId()));
assertThat(retrievedAccount.getName(), is("Account2"));
}
示例11: delete
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@SuppressLint("ApplySharedPref")
@Test
public void delete() throws Exception {
final Job test = createTestJob();
final String json = gson.toJson(test);
final String key = SimpleUploadDataStore.jobIdKey(test.id());
final Set<String> keys = new HashSet<>();
keys.add(key);
final SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putStringSet(SimpleUploadDataStore.KEY_JOB_IDS, keys);
editor.putString(key, json);
editor.commit();
final TestSubscriber<Job> ts = TestSubscriber.create();
dataStore.delete(test.id()).subscribe(ts);
ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
ts.assertNoErrors();
ts.assertValueCount(1);
ts.assertValue(test);
final TestSubscriber<Job> ts2 = TestSubscriber.create();
dataStore.getAll().subscribe(ts2);
ts2.awaitTerminalEvent(1, TimeUnit.SECONDS);
ts2.assertNoErrors();
ts2.assertCompleted();
ts2.assertNoValues();
}
示例12: insertUpdatedPackages
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void insertUpdatedPackages() {
newPackages.addAll(Arrays.asList(MockPackageInfo.TEST, MockPackageInfo.TEST2));
TestSubscriber<Void> subscriber = new TestSubscriber<>();
dbSyncer.sync().toBlocking().subscribe(subscriber);
List<PackageInfo> expectedPackages = Arrays.asList(MockPackageInfo.TEST, MockPackageInfo.TEST2);
verify(appService).addPackages(expectedPackages);
subscriber.assertCompleted();
}
示例13: alwaysCompleteAFetch
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void alwaysCompleteAFetch() {
when(appProvider.getInstalledPackages()).thenReturn(Observable.just(Collections.emptyList()));
when(appService.allInfos()).thenReturn(Observable.just(Collections.emptyList()));
TestSubscriber<List<PackageInfo>> testSubscriber = new TestSubscriber<>();
fetchUpdatedPackages.get().toBlocking().subscribe(testSubscriber);
testSubscriber.assertCompleted();
}
示例14: findNoMethodsInEmptySmaliFile
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void findNoMethodsInEmptySmaliFile() {
File locationActivityFolder = getFolder("de/philipphager/disclosure/smali/empty");
LibraryParser libraryParser = new LibraryParser(locationActivityFolder);
TestSubscriber<List<Method>> subscriber = new TestSubscriber<>();
libraryParser.findMethodInvocations()
.toBlocking()
.subscribe(subscriber);
subscriber.assertReceivedOnNext(Collections.singletonList(Collections.emptyList()));
subscriber.assertNoErrors();
subscriber.assertCompleted();
}
示例15: findAllMethodInvocationsInLocationActivity
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void findAllMethodInvocationsInLocationActivity() {
File locationActivityFolder = getFolder("de/philipphager/disclosure/smali/apk");
LibraryParser libraryParser = new LibraryParser(locationActivityFolder);
TestSubscriber<List<Method>> subscriber = new TestSubscriber<>();
libraryParser.findMethodInvocations()
.toBlocking()
.subscribe(subscriber);
subscriber.assertReceivedOnNext(Collections.singletonList(LocationActivity.INVOKED_METHODS));
subscriber.assertNoErrors();
subscriber.assertCompleted();
}