本文整理匯總了Java中rx.observers.TestSubscriber.assertValue方法的典型用法代碼示例。如果您正苦於以下問題:Java TestSubscriber.assertValue方法的具體用法?Java TestSubscriber.assertValue怎麽用?Java TestSubscriber.assertValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rx.observers.TestSubscriber
的用法示例。
在下文中一共展示了TestSubscriber.assertValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGetInvalidJobId
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@SuppressLint("ApplySharedPref")
@Test
public void testGetInvalidJobId() 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.get("bad_id").subscribe(ts);
ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
ts.assertNoErrors();
ts.assertValueCount(1);
ts.assertValue(Job.INVALID_JOB);
}
示例2: shouldNotSaveDuplicateLocation
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldNotSaveDuplicateLocation() throws Exception {
PointOfInterest pointOfInterest = MockModelsUtil.createMockPointOfInterest();
pointOfInterest.id = POI_DUPLICATE_ID;
TestSubscriber<PointOfInterest> result = new TestSubscriber<>();
mDatabaseHelper.saveLocation(pointOfInterest).subscribe(result);
result.assertNoErrors();
result.assertValue(pointOfInterest);
Cursor cursor = mDatabaseHelper.getBriteDb()
.query("SELECT * FROM " + Db.PointOfInterestTable.TABLE_NAME);
assertEquals(1, cursor.getCount());
cursor.moveToNext();
assertEquals(pointOfInterest, Db.PointOfInterestTable.parseCursor(cursor));
TestSubscriber<PointOfInterest> secondResult = new TestSubscriber<>();
mDatabaseHelper.saveLocation(pointOfInterest).subscribe(secondResult);
result.assertNoErrors();
result.assertValue(pointOfInterest);
Cursor duplicateCursor = mDatabaseHelper.getBriteDb()
.query("SELECT * FROM " + Db.PointOfInterestTable.TABLE_NAME);
assertEquals(1, duplicateCursor.getCount());
duplicateCursor.moveToNext();
assertEquals(pointOfInterest, Db.PointOfInterestTable.parseCursor(duplicateCursor));
}
示例3: shouldGetLocation
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldGetLocation() throws Exception {
PointOfInterest pointOfInterest = MockModelsUtil.createMockPointOfInterest();
mDatabaseHelper.saveLocation(pointOfInterest).subscribe();
TestSubscriber<PointOfInterest> result = new TestSubscriber<>();
mDatabaseHelper.getLocation(pointOfInterest.id).subscribe(result);
result.assertNoErrors();
result.assertValue(pointOfInterest);
Cursor cursor = mDatabaseHelper.getBriteDb()
.query("SELECT * FROM " + Db.PointOfInterestTable.TABLE_NAME);
assertEquals(1, cursor.getCount());
cursor.moveToNext();
assertEquals(pointOfInterest, Db.PointOfInterestTable.parseCursor(cursor));
}
示例4: shouldDeleteLocation
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldDeleteLocation() throws Exception {
PointOfInterest pointOfInterest = MockModelsUtil.createMockPointOfInterest();
TestSubscriber<PointOfInterest> result = new TestSubscriber<>();
mDatabaseHelper.saveLocation(pointOfInterest).subscribe(result);
result.assertNoErrors();
result.assertValue(pointOfInterest);
Cursor saveCursor = mDatabaseHelper.getBriteDb()
.query("SELECT * FROM " + Db.PointOfInterestTable.TABLE_NAME);
assertEquals(1, saveCursor.getCount());
saveCursor.moveToNext();
assertEquals(pointOfInterest, Db.PointOfInterestTable.parseCursor(saveCursor));
mDatabaseHelper.deleteLocation(pointOfInterest).subscribe(result);
result.assertNoErrors();
Cursor deleteCursor = mDatabaseHelper.getBriteDb()
.query("SELECT * FROM " + Db.PointOfInterestTable.TABLE_NAME);
assertEquals(0, deleteCursor.getCount());
}
示例5: getAccounts_callsLocalStorageWhenNoCacheInMemory
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void getAccounts_callsLocalStorageWhenNoCacheInMemory() {
// And memory is empty
setAccountsNotAvailable(memoryAccountsDataSource);
// And local has accounts
setAccountsAvailable(localAccountsDataSource, ACCOUNTS);
// Ask for accounts list
TestSubscriber<List<Account>> testSubscriber = new TestSubscriber<>();
accountsRepository.getAccounts()
.subscribe(testSubscriber);
testSubscriber.assertNoErrors();
// Then the local and memory data source should be called only once
verify(localAccountsDataSource).getAccounts();
verify(memoryAccountsDataSource).getAccounts();
testSubscriber.assertValue(ACCOUNTS);
}
示例6: states_should_stopObservingStateChanges
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void states_should_stopObservingStateChanges() {
//GIVEN
Store<Integer> store = new Store<>(0);
TestSubscriber<Integer> testSubscriber = new TestSubscriber<>();
final Subscription subscription = states(store).subscribe(testSubscriber);
//WHEN
subscription.unsubscribe();
store.dispatch(integer -> integer + 1);
final Integer state = store.getState();
//THEN
testSubscriber.assertNoTerminalEvent();
testSubscriber.assertValue(0);
testSubscriber.assertUnsubscribed();
assertThat(state, is(1));
}
示例7: testUploadJobNotFound
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testUploadJobNotFound() throws Exception {
final String jobId = "job-id";
when(dataStore.get(jobId)).thenReturn(Observable.just(Job.INVALID_JOB));
final TestSubscriber<Status> ts = TestSubscriber.create();
uploadInteractor.upload(jobId).subscribe(ts);
testScheduler.triggerActions();
ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
ts.assertNoErrors();
ts.assertValueCount(1);
ts.assertValue(Status.createInvalid(jobId));
verify(uploader, times(0)).upload(any(Job.class), any(File.class));
}
示例8: testGet
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@SuppressLint("ApplySharedPref")
@Test
public void testGet() 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.get(test.id()).subscribe(ts);
ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
ts.assertNoErrors();
ts.assertValueCount(1);
ts.assertValue(test);
}
示例9: update
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void update() 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.apply();
final TestSubscriber<Job> ts = TestSubscriber.create();
dataStore.update(Status.createCompleted(test.id(), null)).subscribe(ts);
ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
ts.assertNoErrors();
ts.assertValueCount(1);
ts.assertValue(test.withStatus(Status.createCompleted(test.id(), null)));
}
示例10: test_use_case_execution
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void test_use_case_execution() {
TestSubscriber<Boolean> subscriber = new TestSubscriber<>();
IsNumberOdd isNumberOdd = new IsNumberOdd(useCaseExecutor, postExecutionThread);
isNumberOdd.execute(10).subscribe(subscriber);
subscriber.assertValue(false);
subscriber.assertCompleted();
}
示例11: shouldSaveLocation
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldSaveLocation() throws Exception {
PointOfInterest pointOfInterest = MockModelsUtil.createMockPointOfInterest();
pointOfInterest.id = POI_DUPLICATE_ID;
TestSubscriber<PointOfInterest> result = new TestSubscriber<>();
mDatabaseHelper.saveLocation(pointOfInterest).subscribe(result);
result.assertNoErrors();
result.assertValue(pointOfInterest);
Cursor cursor = mDatabaseHelper.getBriteDb()
.query("SELECT * FROM " + Db.PointOfInterestTable.TABLE_NAME);
assertEquals(1, cursor.getCount());
cursor.moveToNext();
assertEquals(pointOfInterest, Db.PointOfInterestTable.parseCursor(cursor));
}
示例12: saveAccount_retrievesAccount
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void saveAccount_retrievesAccount() {
int accountId = 1;
Account account = new Account(accountId);
account.setName("Account1");
TestSubscriber<Account> saveAccountSubscriber = new TestSubscriber<>();
accountsDataSource.saveAccount(account).subscribe(saveAccountSubscriber);
saveAccountSubscriber.assertValue(account);
TestSubscriber<Account> getAccountSubscriber = new TestSubscriber<>();
accountsDataSource.getAccount(accountId).subscribe(getAccountSubscriber);
getAccountSubscriber.assertValue(account);
}
示例13: filteredObservableOnlyReceivesSomeObjects
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void filteredObservableOnlyReceivesSomeObjects() {
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
mEventBus.filteredObservable(String.class).subscribe(testSubscriber);
String stringEvent = "Event";
Integer intEvent = 20;
mEventBus.post(stringEvent);
mEventBus.post(intEvent);
testSubscriber.assertValueCount(1);
testSubscriber.assertValue(stringEvent);
}
示例14: getRibots
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void getRibots() {
Ribot ribot1 = TestDataFactory.makeRibot("r1");
Ribot ribot2 = TestDataFactory.makeRibot("r2");
List<Ribot> ribots = Arrays.asList(ribot1, ribot2);
mDatabaseHelper.setRibots(ribots).subscribe();
TestSubscriber<List<Ribot>> result = new TestSubscriber<>();
mDatabaseHelper.getRibots().subscribe(result);
result.assertNoErrors();
result.assertValue(ribots);
}
示例15: states_should_observeInitialState
import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void states_should_observeInitialState() {
//GIVEN
Store<Integer> store = new Store<>(0);
TestSubscriber<Integer> testSubscriber = new TestSubscriber<>();
//WHEN
states(store).subscribe(testSubscriber);
//THEN
testSubscriber.assertNoTerminalEvent();
testSubscriber.assertValue(0);
}