當前位置: 首頁>>代碼示例>>Java>>正文


Java TestSubscriber.getOnNextEvents方法代碼示例

本文整理匯總了Java中rx.observers.TestSubscriber.getOnNextEvents方法的典型用法代碼示例。如果您正苦於以下問題:Java TestSubscriber.getOnNextEvents方法的具體用法?Java TestSubscriber.getOnNextEvents怎麽用?Java TestSubscriber.getOnNextEvents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rx.observers.TestSubscriber的用法示例。


在下文中一共展示了TestSubscriber.getOnNextEvents方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testAddData

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void testAddData() {
      /* 1. Add CSValue to the db and assert that cachedValues() returns this new inserted CSValue */
  TestSubscriber<CSValue> subscriber1 = new TestSubscriber<>();

  sqlite.addData(CSValue1);
  sqlite.cachedValues(csKey, Long.MAX_VALUE).subscribe(subscriber1);

  List<CSValue> CSValueFromDB = subscriber1.getOnNextEvents();
  assertEquals(1, CSValueFromDB.size());
  assertDataEquals(CSValueFromDB.get(0), CSValue1);

      /* 2. Try to overwrite inserted CSValue from step 1 and assert that the overwrite is ignored */
  TestSubscriber<CSValue> subscriber2 = new TestSubscriber<>();

  sqlite.addData(CSValue2);
  sqlite.cachedValues(csKey, Long.MAX_VALUE).subscribe(subscriber2);

  CSValueFromDB = subscriber2.getOnNextEvents();
  assertEquals(1, CSValueFromDB.size());
  assertTrue(!CSValueFromDB.get(0).data().equals(CSValue2));
  assertDataEquals(CSValueFromDB.get(0), CSValue1);
}
 
開發者ID:csync,項目名稱:csync-android,代碼行數:23,代碼來源:SqliteDBManagerTest.java

示例2: searchUsers_200OKResponse_InvokesCorrectApiCalls

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void searchUsers_200OKResponse_InvokesCorrectApiCalls() {
    // Given
    when(githubUserRestService.searchGithubUsers(anyString())).thenReturn(Observable.just
            (githubUserList()));
    when(githubUserRestService.getUser(anyString())).thenReturn(Observable.just
            (user1FullDetails()), Observable.just(user2FullDetails()));

    // When
    TestSubscriber<List<User>> subscriber = new TestSubscriber<>();
    userRepository.searchUsers(USER_LOGIN_MOYHEEN).subscribe(subscriber);

    // Then
    subscriber.awaitTerminalEvent();
    subscriber.assertNoErrors();

    List<List<User>> onNextEvents = subscriber.getOnNextEvents();
    List<User> users = onNextEvents.get(0);
    Assert.assertEquals(USER_LOGIN_MOYHEEN, users.get(0).getLogin());
    Assert.assertEquals(USER_LOGIN_2_MOYHEEN, users.get(1).getLogin());
    verify(githubUserRestService).searchGithubUsers(USER_LOGIN_MOYHEEN);
    verify(githubUserRestService).getUser(USER_LOGIN_MOYHEEN);
    verify(githubUserRestService).getUser(USER_LOGIN_2_MOYHEEN);
}
 
開發者ID:moyheen,項目名稱:github-user-search,代碼行數:25,代碼來源:UserRepositoryImplTest.java

示例3: 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()));

}
 
開發者ID:przemyslaw-holownia,項目名稱:financial-manager,代碼行數:24,代碼來源:LocalAccountsDataSourceTest.java

示例4: saveAccounts_retrievesAccounts

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void saveAccounts_retrievesAccounts() {
    Account account1 = new Account("Account1");
    Account account2 = new Account("Account2");

    TestSubscriber<Account> saveFirstAccountSubscriber = new TestSubscriber<>();
    accountsDataSource.saveAccount(account1).subscribe(saveFirstAccountSubscriber);
    account1 = saveFirstAccountSubscriber.getOnNextEvents().get(0);
    TestSubscriber<Account> saveSecondAccountSubscriber = new TestSubscriber<>();
    accountsDataSource.saveAccount(account2).subscribe(saveSecondAccountSubscriber);
    account2 = saveSecondAccountSubscriber.getOnNextEvents().get(0);

    TestSubscriber<List<Account>> getAccountsSubscriber = new TestSubscriber<>();
    accountsDataSource.getAccounts().subscribe(getAccountsSubscriber);
    List<List<Account>> onNextEvents = getAccountsSubscriber.getOnNextEvents();
    List<Account> accounts = onNextEvents.get(0);
    getAccountsSubscriber.assertNoErrors();
    assertThat(accounts.isEmpty(), is(false));
    assertThat(accounts.size(), is(2));
    assertTrue(accounts.contains(account1));
    assertTrue(accounts.contains(account2));

}
 
開發者ID:przemyslaw-holownia,項目名稱:financial-manager,代碼行數:24,代碼來源:LocalAccountsDataSourceTest.java

示例5: saveAccounts_retrievesAccounts

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void saveAccounts_retrievesAccounts() {
    Account account1 = new Account(1L, "Account1");
    Account account2 = new Account(2L, "Account2");


    accountsDataSource.saveAccount(account1).subscribe(new TestSubscriber<>());
    accountsDataSource.saveAccount(account2).subscribe(new TestSubscriber<>());

    TestSubscriber<List<Account>> getAccountsSubscriber = new TestSubscriber<>();
    accountsDataSource.getAccounts().subscribe(getAccountsSubscriber);
    List<List<Account>> onNextEvents = getAccountsSubscriber.getOnNextEvents();
    assertThat(onNextEvents.isEmpty(), is(false));

    List<Account> accounts = onNextEvents.get(0);
    assertThat(accounts.isEmpty(), is(false));
    assertThat(accounts.size(), is(2));
    assertTrue(accounts.contains(account1));
    assertTrue(accounts.contains(account2));

}
 
開發者ID:przemyslaw-holownia,項目名稱:financial-manager,代碼行數:22,代碼來源:MemoryAccountsDataSourceTest.java

示例6: searchMakeUp_200OkResponse_InvokesCorrectApiCalls

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void searchMakeUp_200OkResponse_InvokesCorrectApiCalls() {
    // Given
    when(makeUpProductRestService.searchMakeUpProducts(anyString(), anyString())).thenReturn
            (Observable.just(makeUpList()).toList());

    // When
    TestSubscriber<List<MakeUp>> subscriber = new TestSubscriber<>();
    makeUpRepository.searchMakeUp(BRAND_COVERGIRL, PRODUCT_TYPE_LIPSTICK).subscribe(subscriber);

    // Then
    subscriber.awaitTerminalEvent();
    subscriber.assertNoErrors();

    List<List<MakeUp>> onNextEvents = subscriber.getOnNextEvents();
    List<MakeUp> makeup = onNextEvents.get(0);
    Assert.assertEquals(BRAND_COVERGIRL, makeup.get(0).getBrand());
    Assert.assertEquals(PRODUCT_TYPE_LIPSTICK, makeup.get(0).getProductType());
    verify(makeUpProductRestService).searchMakeUpProducts(BRAND_COVERGIRL,
            PRODUCT_TYPE_LIPSTICK);
}
 
開發者ID:moyheen,項目名稱:MakeUpSearch,代碼行數:22,代碼來源:MakeUpRepositoryImplTest.java

示例7: fetchSuggestionsTransformerTest

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void fetchSuggestionsTransformerTest() throws Exception {
    final Observable<List<String>> listObservable = Observable
            .just("1", "2", "3")
            .concatMap(each -> Observable.just(each).delay(5, TimeUnit.SECONDS))
            .compose(RxSuggestions.suggestionsTransformer());

    final TestSubscriber<List<String>> testSubscriber = TestSubscriber.create();
    listObservable.subscribe(testSubscriber);

    testSubscriber.awaitTerminalEvent();

    if (Util.isOnline()) {
        testSubscriber.assertNoErrors();
        assertTrue(testSubscriber.getOnNextEvents().size() == 3);
        assertAllListContentsNotEmpty(testSubscriber);
    } else {
        testSubscriber.assertValueCount(3);
        assertTrue(testSubscriber.getOnNextEvents().size() == 3);
        testSubscriber.assertNoErrors();
        // Transformer swallows error to continue stream.
        for (List<String> suggestions : testSubscriber.getOnNextEvents()) {
            assertTrue(suggestions.isEmpty());
        }
    }
}
 
開發者ID:arunkumar9t2,項目名稱:rxSuggestions,代碼行數:27,代碼來源:RxSuggestionsTransformerTest.java

示例8: thatValidInputIndentsProperly

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void thatValidInputIndentsProperly() {
    TestSubscriber<String> testSubscriber = new TestSubscriber<String>();

     MigrationManager.migrate(OLD_INDENTATION_MARKS, new FileUtils()
            .getFileLines("input1.txt"))
            .subscribe(testSubscriber);

    List<String> expectedLines = getExpectedLines("input1_out.txt");
    List<String> actualLines = testSubscriber.getOnNextEvents();
    assertEquals(expectedLines, actualLines);
}
 
開發者ID:VigoTech,項目名稱:reto,代碼行數:12,代碼來源:MigrationManagerTest.java

示例9: verifySubscribers

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
private void verifySubscribers(List<TestSubscriber<Integer>> subscribers, List<StartWith> startWiths, int schedulerI) {
    for (int s = 0; s < subscribers.size(); s++) {
        TestSubscriber<Integer> subscriber1 = subscribers.get(s);
        List<Integer> values = subscriber1.getOnNextEvents();
        if (values.size() > 0) {
            ArrayList<Integer> expected = new ArrayList<>(values.size());
            for (int i = 0, v = values.get(0); i < values.size(); i++, v++) {
                expected.add(v);
            }
            assertEquals("startWith: " + startWiths.get(s) + ", scheduler: " + schedulerI, expected, values);
        }
    }
}
 
開發者ID:konmik,項目名稱:rxstate,代碼行數:14,代碼來源:RxStateTest.java

示例10: testWriteApostrophe

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void testWriteApostrophe() {
  TestSubscriber<CSValue> listenSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> writeSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> deleteSubscriber = new TestSubscriber<>();

  CSKey key = CSKey.fromString("tests.android").uuidChild();
  app.listen(key).first().subscribe(listenSubscriber);

  String apostrophe = "\'";
  app.write(key, apostrophe, ACL).subscribe(writeSubscriber);

  app.delete(key).subscribe(deleteSubscriber);

  writeSubscriber.awaitTerminalEvent();

  listenSubscriber.awaitTerminalEvent();
  listenSubscriber.assertNoErrors();

  deleteSubscriber.awaitTerminalEvent();

  List<CSValue> receivedValues = listenSubscriber.getOnNextEvents();
  assertEquals(1, receivedValues.size());

  CSValue receivedValue = receivedValues.get(0);
  assertTrue(receivedValue.key().matches(key));
  assertTrue(receivedValue.acl().rawAcl().equals(ACL.rawAcl()));
  assertTrue(receivedValue.data().equals(apostrophe));
}
 
開發者ID:csync,項目名稱:csync-android,代碼行數:29,代碼來源:CSAppTest.java

示例11: testDelete

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void testDelete() {
  TestSubscriber<CSValue> listenSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> writeSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> deleteSubscriber = new TestSubscriber<>();

  CSKey key = CSKey.fromString("tests.android").uuidChild();
  app.listen(key).take(2).subscribe(listenSubscriber);

  String apostrophe = "\'";
  app.write(key, apostrophe, ACL).subscribe(writeSubscriber);
  writeSubscriber.awaitTerminalEvent();

  app.delete(key).subscribe(deleteSubscriber);

  deleteSubscriber.awaitTerminalEvent();

  listenSubscriber.awaitTerminalEvent();
  listenSubscriber.assertNoErrors();

  assertEquals(true, deleteSubscriber.getOnNextEvents().get(0).booleanValue());

  List<CSValue> receivedValues = listenSubscriber.getOnNextEvents();
  assertEquals(2, receivedValues.size());

  CSValue deleted = receivedValues.get(1);

  assertTrue(deleted.key().matches(key));
  assertEquals(true, receivedValues.get(1).isKeyDeleted());
}
 
開發者ID:csync,項目名稱:csync-android,代碼行數:30,代碼來源:CSAppTest.java

示例12: testListenWithAdvance

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void testListenWithAdvance() {
  TestSubscriber<CSValue> listenSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> writeSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> deleteSubscriber = new TestSubscriber<>();

  CSKey key = CSKey.fromString("tests.android").uuidChild();

  String data = "testing1234";
  app.write(key, data, ACL).subscribe(writeSubscriber);

  writeSubscriber.awaitTerminalEvent();

  app.listen(key).first().subscribe(listenSubscriber);
  listenSubscriber.awaitTerminalEvent();
  listenSubscriber.assertNoErrors();

  List<CSValue> receivedValues = listenSubscriber.getOnNextEvents();
  assertEquals(1, receivedValues.size());

  CSValue receivedValue = receivedValues.get(0);
  assertTrue(receivedValue.key().matches(key));
  assertTrue(receivedValue.acl().rawAcl().equals(ACL.rawAcl()));
  assertTrue(receivedValue.data().equals(data));

  app.delete(key).subscribe(deleteSubscriber);
  deleteSubscriber.awaitTerminalEvent();
}
 
開發者ID:csync,項目名稱:csync-android,代碼行數:28,代碼來源:CSAppTest.java

示例13: testDeleteWildcard

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void testDeleteWildcard() {
  TestSubscriber<CSValue> listenSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> writeSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> deleteSubscriber = new TestSubscriber<>();
  String uuid = UUID.randomUUID().toString();
  CSKey key = CSKey.fromString("tests.android." + uuid + ".*");
  app.listen(key).take(2).subscribe(listenSubscriber);
  CSKey writeKey = CSKey.fromString("tests.android." + uuid + ".a");
  String data = "helllo";
  app.write(writeKey, data, ACL).subscribe(writeSubscriber);
  writeSubscriber.awaitTerminalEvent();

  app.delete(key).subscribe(deleteSubscriber);
  deleteSubscriber.awaitTerminalEvent();
  listenSubscriber.awaitTerminalEvent();
  listenSubscriber.assertNoErrors();

  assertEquals(true, deleteSubscriber.getOnNextEvents().get(0).booleanValue());

  List<CSValue> receivedValues = listenSubscriber.getOnNextEvents();
  assertEquals(2, receivedValues.size());

  CSValue created = receivedValues.get(0);
  CSValue deleted = receivedValues.get(1);

  //Checked
  assertTrue(created.key().matches(key));
  assertTrue(!created.isKeyDeleted());

  //Check deleted key
  assertTrue(deleted.key().matches(key));
  assertTrue(deleted.isKeyDeleted());
}
 
開發者ID:csync,項目名稱:csync-android,代碼行數:34,代碼來源:CSAppTest.java

示例14: 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"));

}
 
開發者ID:przemyslaw-holownia,項目名稱:financial-manager,代碼行數:30,代碼來源:LocalAccountsDataSourceTest.java

示例15: checkEmptyStream

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void checkEmptyStream() throws Exception {
    TestSubscriber<Map<String, Stock>> testSubscriber = new TestSubscriber<>();
    stockService.getStockSamplesObservable()
            .subscribe(testSubscriber);

    testSubscriber.assertNoErrors();
    final List<Map<String, Stock>> result = testSubscriber.getOnNextEvents();
    assertEquals(0, result.size());
}
 
開發者ID:mumukiller,項目名稱:stock-patterns-recognition,代碼行數:11,代碼來源:StockServiceIT.java


注:本文中的rx.observers.TestSubscriber.getOnNextEvents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。