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


Java TestSubscriber.assertNoErrors方法代碼示例

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


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

示例1: test_just_Flowable

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void test_just_Flowable() {

	Flowable<String> observable = Flowable.just("mango", "papaya", "guava");
	TestSubscriber<String> testSubscriber = new TestSubscriber<>();

	observable.subscribe(testSubscriber);

	List<String> items = testSubscriber.values();
	testSubscriber.assertComplete();
	testSubscriber.assertSubscribed();
	testSubscriber.assertNoErrors();
	testSubscriber.assertValueCount(3);
	testSubscriber.assertValues("mango", "papaya", "guava");

}
 
開發者ID:PacktPublishing,項目名稱:Reactive-Programming-With-Java-9,代碼行數:17,代碼來源:Modern_Testing.java

示例2: shouldSendNotificationForRemoves

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void shouldSendNotificationForRemoves() {
    // given:
    final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
    final TwoPSet<String> set = new TwoPSet<>("ID_1");
    set.subscribe(subscriber);

    set.add("1");
    set.add("1");

    // when:
    final Iterator<String> it = set.iterator();
    it.next();
    it.remove();

    // then:
    subscriber.assertNotComplete();
    subscriber.assertNoErrors();
    assertThat(subscriber.values(), contains(
            new AddCommandMatcher<>(set.getCrdtId(), "1"),
            new RemoveCommandMatcher<>(set.getCrdtId(), "1")
    ));
}
 
開發者ID:netopyr,項目名稱:wurmloch-crdt,代碼行數:25,代碼來源:TwoPSetTest.java

示例3: testDeleteAll

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testDeleteAll(){
    models.clear();
    List<TestModel> list = new ArrayList<>();
    list.add(new TestModel(1));
    list.add(new TestModel(2));
    list.add(new TestModel(3));
    memoryStore.insertOrUpdate(list);

    TestSubscriber<Integer> observer = new TestSubscriber<>();
    disposables.add(testStore.deleteAll()
            .subscribeOn(Schedulers.io())
            .subscribeWith(observer));

    observer.awaitTerminalEvent(5, SECONDS);
    observer.assertComplete();
    observer.assertNoErrors();

    Integer numberOfDeletions = observer.values().get(0);

    Assert.assertEquals(0, models.size());
    Assert.assertEquals(list.size(), (int) numberOfDeletions);
}
 
開發者ID:playmoweb,項目名稱:store2store,代碼行數:24,代碼來源:StoreServiceUnitTest.java

示例4: shouldHandleAddCommands

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldHandleAddCommands() {
    // given:
    final UUID uuid1 = UUID.randomUUID();
    final UUID uuid2 = UUID.randomUUID();
    final Processor<USet.USetCommand<UUID>, USet.USetCommand<UUID>> inputStream = ReplayProcessor.create();
    final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
    final USet<UUID> set = new USet<>("ID_1");
    set.subscribeTo(inputStream);
    set.subscribe(subscriber);

    final USet.AddCommand<UUID> command1 = new USet.AddCommand<>(set.getCrdtId(), uuid1);
    final USet.AddCommand<UUID> command2 = new USet.AddCommand<>(set.getCrdtId(), uuid2);

    // when:
    inputStream.onNext(command1);
    inputStream.onNext(command2);

    // then:
    assertThat(set, hasSize(2));
    assertThat(subscriber.valueCount(), is(2));
    subscriber.assertNotComplete();
    subscriber.assertNoErrors();
}
 
開發者ID:netopyr,項目名稱:wurmloch-crdt,代碼行數:25,代碼來源:USetTest.java

示例5: shouldHandleRemoveCommands

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldHandleRemoveCommands() {
    // given:
    final UUID uuid1 = UUID.randomUUID();
    final Processor<USet.USetCommand<UUID>, USet.USetCommand<UUID>> inputStream = ReplayProcessor.create();
    final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
    final USet<UUID> set = new USet<>("ID_1");
    set.subscribeTo(inputStream);
    set.subscribe(subscriber);

    final USet.AddCommand<UUID> command1 = new USet.AddCommand<>(set.getCrdtId(), uuid1);
    final USet.RemoveCommand<UUID> command2 = new USet.RemoveCommand<>(set.getCrdtId(), uuid1);

    // when:
    inputStream.onNext(command1);
    inputStream.onNext(command2);

    // then:
    assertThat(set, empty());
    assertThat(subscriber.valueCount(), is(2));
    subscriber.assertNotComplete();
    subscriber.assertNoErrors();
}
 
開發者ID:netopyr,項目名稱:wurmloch-crdt,代碼行數:24,代碼來源:USetTest.java

示例6: testGetOneAscending

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testGetOneAscending(){
    models.clear();
    List<TestModel> list = new ArrayList<>();
    list.add(new TestModel(10));
    list.add(new TestModel(30));
    memoryStore.insertOrUpdate(list);

    TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
    disposables.add(testStore.getOne()
            .subscribeOn(Schedulers.io())
            .subscribeWith(observer));

    observer.awaitTerminalEvent(5, SECONDS);
    observer.assertComplete();
    observer.assertNoErrors();

    Assert.assertEquals(2, models.size());

    TestModel tm = observer.values().get(0).get();
    Assert.assertEquals(10, tm.getId());
}
 
開發者ID:playmoweb,項目名稱:store2store,代碼行數:23,代碼來源:StoreServiceUnitTest.java

示例7: testBufferingWithNoUpdates

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testBufferingWithNoUpdates() throws InterruptedException
{
    TestScheduler testScheduler = new TestScheduler();
    SimpleFlowableList<Integer> list = new SimpleFlowableList<>();
    FlowableList<Integer> bufferedList = list.buffer(50, TimeUnit.MILLISECONDS, testScheduler);

    TestSubscriber testSubscriber = new TestSubscriber();

    bufferedList.updates().subscribe(testSubscriber);

    testScheduler.advanceTimeBy(50, TimeUnit.MILLISECONDS);
    testScheduler.triggerActions();
    testSubscriber.awaitCount(1);

    testSubscriber.assertNoErrors();
    testSubscriber.assertValueCount(1);

    testScheduler.advanceTimeBy(50, TimeUnit.MILLISECONDS);
    testScheduler.triggerActions();
    testSubscriber.awaitCount(1);

    testSubscriber.dispose();
}
 
開發者ID:mproberts,項目名稱:rxtools,代碼行數:25,代碼來源:BackpressureFlowableListTest.java

示例8: shouldHandleAddCommands

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldHandleAddCommands() {
    // given:
    final Processor<ORSet.ORSetCommand<String>, ORSet.ORSetCommand<String>> inputStream = ReplayProcessor.create();
    final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
    final ORSet<String> set = new ORSet<>("ID_1");
    set.subscribeTo(inputStream);
    set.subscribe(subscriber);

    final ORSet.AddCommand<String> command1 = new ORSet.AddCommand<>(set.getCrdtId(), new ORSet.Element<>("1", UUID.randomUUID()));
    final ORSet.AddCommand<String> command2 = new ORSet.AddCommand<>(set.getCrdtId(), new ORSet.Element<>("2", UUID.randomUUID()));
    final ORSet.AddCommand<String> command3 = new ORSet.AddCommand<>(set.getCrdtId(), new ORSet.Element<>("1", UUID.randomUUID()));

    // when:
    inputStream.onNext(command1);
    inputStream.onNext(command2);
    inputStream.onNext(command3);

    // then:
    assertThat(set, hasSize(2));
    assertThat(subscriber.valueCount(), is(3));
    subscriber.assertNotComplete();
    subscriber.assertNoErrors();
}
 
開發者ID:netopyr,項目名稱:wurmloch-crdt,代碼行數:25,代碼來源:ORSetTest.java

示例9: shouldSendNotificationForAdds

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void shouldSendNotificationForAdds() {
    // given:
    final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
    final GSet<String> set = new GSet<>("ID_1");
    set.subscribe(subscriber);

    // when:
    set.add("1");
    set.add("2");
    set.add("1");

    // then:
    subscriber.assertNotComplete();
    subscriber.assertNoErrors();
    assertThat(subscriber.values(), contains(
            new AddCommandMatcher<>(set.getCrdtId(), "1"),
            new AddCommandMatcher<>(set.getCrdtId(), "2"),
            new AddCommandMatcher<>(set.getCrdtId(), "1")
    ));
}
 
開發者ID:netopyr,項目名稱:wurmloch-crdt,代碼行數:23,代碼來源:GSetTest.java

示例10: shouldSendNotificationForAdds

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void shouldSendNotificationForAdds() {
    // given:
    final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
    final TwoPSet<String> set = new TwoPSet<>("ID_1");
    set.subscribe(subscriber);

    // when:
    set.add("1");
    set.add("2");
    set.add("1");

    // then:
    subscriber.assertNotComplete();
    subscriber.assertNoErrors();
    assertThat(subscriber.values(), contains(
            new AddCommandMatcher<>(set.getCrdtId(), "1"),
            new AddCommandMatcher<>(set.getCrdtId(), "2")
    ));
}
 
開發者ID:netopyr,項目名稱:wurmloch-crdt,代碼行數:22,代碼來源:TwoPSetTest.java

示例11: testInsertOrUpdateMany

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertOrUpdateMany(){
    models.clear();
    List<TestModel> list = new ArrayList<>();
    list.add(new TestModel(10));
    list.add(new TestModel(20));
    list.add(new TestModel(30));
    memoryStore.insertOrUpdate(list);

    List<TestModel> listToInsertOrUpdate = new ArrayList<>();
    final TestModel first = new TestModel(20);
    first.setAvailable(true);
    final TestModel second = new TestModel(99);
    second.setAvailable(true);

    listToInsertOrUpdate.add(first);
    listToInsertOrUpdate.add(second);

    TestSubscriber<Optional<List<TestModel>>> observer = new TestSubscriber<>();
    disposables.add(testStore.insertOrUpdate(listToInsertOrUpdate)
            .subscribeOn(Schedulers.io())
            .subscribeWith(observer));

    observer.awaitTerminalEvent(5, SECONDS);
    observer.assertComplete();
    observer.assertNoErrors();

    final List<TestModel> output = observer.values().get(0).get();
    Assert.assertNotNull(output);
    Assert.assertEquals(4, models.size());

    for(TestModel tm : output){
        if(tm.getId() == 99 || tm.getId() == 20){
            Assert.assertTrue(tm.isAvailable());
        } else {
            Assert.assertFalse(tm.isAvailable());
        }
    }
}
 
開發者ID:playmoweb,項目名稱:store2store,代碼行數:40,代碼來源:StoreServiceUnitTest.java

示例12: testGetAll

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testGetAll(){
    models.clear();
    List<TestModel> list = new ArrayList<>();
    list.add(new TestModel(1));
    list.add(new TestModel(2));
    list.add(new TestModel(3));
    memoryStore.insertOrUpdate(list);

    TestSubscriber<Optional<List<TestModel>>> observer = new TestSubscriber<>();
    disposables.add(testStore.getAll(null, null)
            .subscribeOn(Schedulers.io())
            .subscribeWith(observer));

    observer.awaitTerminalEvent(5, SECONDS);
    observer.assertComplete();
    observer.assertNoErrors();

    Assert.assertEquals(models.size(), 3);

    int sum = 0;
    for(TestModel tm : models){
        sum += tm.getId();
    }

    Assert.assertEquals(60, sum);
}
 
開發者ID:playmoweb,項目名稱:store2store,代碼行數:28,代碼來源:StoreServiceUnitTest.java

示例13: shouldHandleRemoveCommands

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldHandleRemoveCommands() {
    // given:
    final Processor<ORSet.ORSetCommand<String>, ORSet.ORSetCommand<String>> inputStream = ReplayProcessor.create();
    final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
    final ORSet<String> set = new ORSet<>("ID_1");
    set.subscribeTo(inputStream);
    set.subscribe(subscriber);

    final ORSet.Element<String> elem1 = new ORSet.Element<>("1", UUID.randomUUID());
    final ORSet.Element<String> elem2 = new ORSet.Element<>("1", UUID.randomUUID());
    final Set<ORSet.Element<String>> elements = new HashSet<>(Arrays.asList(elem1, elem2));
    final ORSet.AddCommand<String> command1 = new ORSet.AddCommand<>(set.getCrdtId(), elem1);
    final ORSet.AddCommand<String> command2 = new ORSet.AddCommand<>(set.getCrdtId(), elem2);
    final ORSet.RemoveCommand<String> command3 = new ORSet.RemoveCommand<>(set.getCrdtId(), elements);

    // when:
    inputStream.onNext(command1);
    inputStream.onNext(command2);
    inputStream.onNext(command3);

    // then:
    assertThat(set, empty());
    assertThat(subscriber.valueCount(), is(3));
    subscriber.assertNotComplete();
    subscriber.assertNoErrors();
}
 
開發者ID:netopyr,項目名稱:wurmloch-crdt,代碼行數:28,代碼來源:ORSetTest.java

示例14: shouldReturnEmptyWhenUserIsNotFound

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldReturnEmptyWhenUserIsNotFound() throws Exception {

    when(userRepository.getUser(anyString())).thenReturn(Flowable.empty());

    final TestSubscriber<User> userTestSubscriber = new TestSubscriber<>();
    final Flowable<User> userByNick = profileViewModel.getUserByNick("non existing user");
    userByNick.subscribe(userTestSubscriber);

    userTestSubscriber.assertNoErrors();
    userTestSubscriber.assertNoValues();
}
 
開發者ID:charafau,項目名稱:TurboChat,代碼行數:13,代碼來源:ProfileViewModelTest.java

示例15: shouldSendAllCommandsAfterConnect

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void shouldSendAllCommandsAfterConnect() {
    // given:
    final CrdtStore store1 = new CrdtStore(NODE_ID_1);
    store1.registerFactory(SimpleCrdt.class, SimpleCrdt::new);
    final TestSubscriber<CrdtDefinition> store1Subscriber = TestSubscriber.create();
    store1.subscribe(store1Subscriber);

    final CrdtStore store2 = new CrdtStore(NODE_ID_2);
    store2.registerFactory(SimpleCrdt.class, SimpleCrdt::new);
    final TestSubscriber<CrdtDefinition> store2Subscriber = TestSubscriber.create();
    store2.subscribe(store2Subscriber);


    final SimpleCrdt crdt1 = store1.createCrdt(SimpleCrdt.class, CRDT_ID);
    final TestSubscriber<CrdtCommand> crdt1Subscriber = TestSubscriber.create();
    crdt1.subscribe(crdt1Subscriber);
    final SimpleCrdt crdt2 = store2.createCrdt(SimpleCrdt.class, CRDT_ID);
    final TestSubscriber<CrdtCommand> crdt2Subscriber = TestSubscriber.create();
    crdt2.subscribe(crdt2Subscriber);

    final SimpleCommand command1_1 = new SimpleCommand(NODE_ID_1, CRDT_ID);
    crdt1.sendCommands(command1_1);

    final SimpleCommand command2_1 = new SimpleCommand(NODE_ID_2, CRDT_ID);
    crdt2.sendCommands(command2_1);

    final SimpleCommand command3_1 = new SimpleCommand(NODE_ID_1, CRDT_ID);
    final SimpleCommand command3_2 = new SimpleCommand(NODE_ID_1, CRDT_ID);
    final SimpleCommand command3_3 = new SimpleCommand(NODE_ID_1, CRDT_ID);
    crdt1.sendCommands(command3_1, command3_2, command3_3);

    final SimpleCommand command4_1 = new SimpleCommand(NODE_ID_2, CRDT_ID);
    final SimpleCommand command4_2 = new SimpleCommand(NODE_ID_2, CRDT_ID);
    final SimpleCommand command4_3 = new SimpleCommand(NODE_ID_2, CRDT_ID);
    crdt2.sendCommands(command4_1, command4_2, command4_3);

    // when:
    store1.connect(store2);

    // then:
    assertThat(store1Subscriber.valueCount(), is(1));
    store1Subscriber.assertNotComplete();
    store1Subscriber.assertNoErrors();

    crdt1Subscriber.assertValues(
            command1_1,
            command3_1,
            command3_2,
            command3_3,
            command2_1,
            command4_1,
            command4_2,
            command4_3
    );
    crdt1Subscriber.assertNotComplete();
    crdt1Subscriber.assertNoErrors();

    assertThat(store2Subscriber.valueCount(), is(1));
    store2Subscriber.assertNotComplete();
    store2Subscriber.assertNoErrors();

    crdt2Subscriber.assertValues(
            command2_1,
            command4_1,
            command4_2,
            command4_3,
            command1_1,
            command3_1,
            command3_2,
            command3_3
    );
    crdt2Subscriber.assertNotComplete();
    crdt2Subscriber.assertNoErrors();
}
 
開發者ID:netopyr,項目名稱:wurmloch-crdt,代碼行數:77,代碼來源:CrdtStoreTest.java


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