本文整理匯總了Java中io.reactivex.subscribers.TestSubscriber.values方法的典型用法代碼示例。如果您正苦於以下問題:Java TestSubscriber.values方法的具體用法?Java TestSubscriber.values怎麽用?Java TestSubscriber.values使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.reactivex.subscribers.TestSubscriber
的用法示例。
在下文中一共展示了TestSubscriber.values方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testWeakTransform
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testWeakTransform()
{
TestSubscriber<Update<Integer>> testSubscriber = new TestSubscriber<>();
SimpleFlowableList<Integer> list = new SimpleFlowableList<>(Arrays.asList(1, 2, 3));
FlowableList<Integer> transformedList = list.cachedMap(new Function<Integer, Integer>() {
@Override
public Integer apply(Integer integer) {
return integer + 12;
}
});
transformedList.updates().subscribe(testSubscriber);
testSubscriber.assertValueCount(1);
List<Update<Integer>> onNextEvents = testSubscriber.values();
assertEquals(Arrays.asList(Change.reloaded()), onNextEvents.get(0).changes);
assertEquals(Arrays.asList(13, 14, 15), onNextEvents.get(0).list);
}
示例2: test
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void test() throws InterruptedException {
// The stream id specify which stream we want to obtain
IntegerRangeId streamId = new IntegerRangeId(0, 10);
// Using the RxJava 2 test subscriber
TestSubscriber<Integer> subscriber = TestSubscriber.create();
// The stream id will be discovered (and created by the factory)
discovery.discover(streamId).subscribe(subscriber);
// Wait for the end of the stream
subscriber.await();
List<Integer> values = subscriber.values();
List<Integer> expectedValues = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
assertThat(values).containsExactlyElementsOf(expectedValues);
}
示例3: 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");
}
示例4: testOneGist
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testOneGist() {
ServiceLocator.put(OkHttpClient.class, OkHttpClientUtil.getOkHttpClient(null, MockBehavior.MOCK));
Flowable<Gist> flowable = ServiceInjector.resolve(RxEndpoints.class).getGist("3d7cbc2f66cf5d61b8014d957a270c7c");
TestSubscriber<Gist> testSubscriber = new TestSubscriber<>();
flowable.subscribe(testSubscriber);
testSubscriber.assertComplete();
List<Gist> gistList = testSubscriber.values();
Gist gist = gistList.get(0);
assertEquals("Bootstrap Customizer Config", gist.getDescription());
GistFile file = gist.getFile(gist.getFilenames().iterator().next());
assertEquals(file.getContent().length(), file.getSize());
assertEquals("config.json", file.getFilename());
flowable = ServiceInjector.resolve(RxEndpoints.class).getGist("not actually an ID");
testSubscriber = new TestSubscriber<>();
flowable.subscribe(testSubscriber);
testSubscriber.assertNotComplete();
testSubscriber.assertNoValues();
List<Throwable> errorList = testSubscriber.errors();
assertEquals(errorList.size(), 1);
assertEquals("Not Found", errorList.get(0).getMessage());
}
示例5: createGist
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void createGist() throws IOException {
ServiceLocator.put(OkHttpClient.class, OkHttpClientUtil.getOkHttpClient(null, MockBehavior.MOCK_ONLY));
Gist gist = new GistImpl();
gist.setDescription(CREATE_DESCRIPTION);
gist.addFile(CREATE_FILE_NAME, readFromAsset("mocks/javaclass"));
Flowable<Gist> flowable = ServiceInjector.resolve(RxEndpoints.class).createGist(gist);
TestSubscriber<Gist> testSubscriber = new TestSubscriber<>();
flowable.subscribe(testSubscriber);
testSubscriber.assertComplete();
List<Gist> gistList = testSubscriber.values();
Gist resultGist = gistList.get(0);
Flowable<Gist> gistFlowable = ServiceInjector.resolve(RxEndpoints.class).getGist(resultGist.getId());
TestSubscriber<Gist> gistTestSubscriber = new TestSubscriber<>();
gistFlowable.subscribe(gistTestSubscriber);
Gist detailGist = gistTestSubscriber.values().get(0);
assertEquals(detailGist.getDescription(), CREATE_DESCRIPTION);
}
示例6: testBasicTransform
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testBasicTransform()
{
TestSubscriber<Update<Integer>> testSubscriber = new TestSubscriber<>();
SimpleFlowableList<Integer> list = new SimpleFlowableList<>(Arrays.asList(1, 2, 3));
FlowableList<Integer> transformedList = list.map(new Function<Integer, Integer>() {
@Override
public Integer apply(Integer integer) {
return integer + 12;
}
});
transformedList.updates().subscribe(testSubscriber);
testSubscriber.assertValueCount(1);
List<Update<Integer>> onNextEvents = testSubscriber.values();
assertEquals(Arrays.asList(Change.reloaded()), onNextEvents.get(0).changes);
assertEquals(Arrays.asList(13, 14, 15), onNextEvents.get(0).list);
}
示例7: testOrganization
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testOrganization() {
ServiceLocator.put(OkHttpClient.class, OkHttpClientUtil.getOkHttpClient(null, MockBehavior.MOCK));
Flowable<Organization> flowable = ServiceInjector.resolve(RxEndpoints.class).getOrg("bottlerocketstudios");
TestSubscriber<Organization> testSubscriber = new TestSubscriber<>();
flowable.subscribe(testSubscriber);
testSubscriber.assertComplete();
List<Organization> orgList = testSubscriber.values();
assertEquals(orgList.size(), 1);
assertEquals(orgList.get(0).getName(), "Bottle Rocket Studios");
}
示例8: testItemAddition
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testItemAddition()
{
VisibleItem<Integer> item1 = new VisibleItem<>(1, true);
VisibleItem<Integer> item2 = new VisibleItem<>(2, true);
VisibleItem<Integer> item3 = new VisibleItem<>(3, true);
VisibleItem<Integer> hidden1 = new VisibleItem<>(4, false);
SimpleFlowableList<VisibleItem<Integer>> simpleList = new SimpleFlowableList<>();
FlowableList<Integer> list = FlowableList.collapseVisibility(simpleList);
TestSubscriber testSubscriber = new TestSubscriber();
simpleList.add(item3);
list.updates().subscribe(testSubscriber);
simpleList.add(0, item1);
simpleList.add(1, item2);
simpleList.add(1, hidden1);
List<Update> onNextEvents = testSubscriber.values();
testSubscriber.assertValueCount(3);
Update update1 = onNextEvents.get(0);
Update update2 = onNextEvents.get(1);
Update update3 = onNextEvents.get(2);
assertEquals(Arrays.asList(Change.reloaded()), update1.changes);
assertEquals(Arrays.asList(3), update1.list);
assertEquals(Arrays.asList(Change.inserted(0)), update2.changes);
assertEquals(Arrays.asList(1, 3), update2.list);
assertEquals(Arrays.asList(Change.inserted(1)), update3.changes);
assertEquals(Arrays.asList(1, 2, 3), update3.list);
}
示例9: testRemovePropagation
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testRemovePropagation()
{
SimpleFlowableList<Integer> a = new SimpleFlowableList<>();
SimpleFlowableList<Integer> b = new SimpleFlowableList<>();
SimpleFlowableList<Integer> c = new SimpleFlowableList<>();
a.add(1);
a.add(2);
b.add(3);
c.add(4);
FlowableList<?> list = FlowableList.concat(Arrays.<FlowableList<Integer>>asList(a, b, c));
TestSubscriber testSubscriber = new TestSubscriber();
list.updates().subscribe(testSubscriber);
b.remove(0);
a.remove(1);
testSubscriber.assertValueCount(3);
List<Update> onNextEvents = testSubscriber.values();
Update reload = onNextEvents.get(0);
Update remove3 = onNextEvents.get(1);
Update remove2 = onNextEvents.get(2);
assertEquals(Arrays.asList(Change.reloaded()), reload.changes);
assertEquals(Arrays.asList(1, 2, 3, 4), reload.list);
assertEquals(Arrays.asList(Change.removed(2)), remove3.changes);
assertEquals(Arrays.asList(1, 2, 4), remove3.list);
assertEquals(Arrays.asList(Change.removed(1)), remove2.changes);
assertEquals(Arrays.asList(1, 4), remove2.list);
}
示例10: testRemoveTransform
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testRemoveTransform()
{
SimpleFlowableList<Integer> list = new SimpleFlowableList<>(Arrays.asList(1, 2, 3, 4));
TestSubscriber<Update<Flowable<String>>> testSubscriber = createIndexedList(list);
testSubscriber.assertValueCount(1);
List<Update<Flowable<String>>> onNextEvents = testSubscriber.values();
assertEquals(Arrays.asList(Change.reloaded()), onNextEvents.get(0).changes);
List<Flowable<String>> list1 = onNextEvents.get(0).list;
Flowable<String> item1 = list1.get(0);
Flowable<String> item2 = list1.get(1);
Flowable<String> item3 = list1.get(2);
Flowable<String> item4 = list1.get(3);
TestSubscriber<String> test1 = item1.test();
TestSubscriber<String> test2 = item2.test();
TestSubscriber<String> test3 = item3.test();
TestSubscriber<String> test4 = item4.test();
test1.assertValue("? < 1 > 2");
test2.assertValue("1 < 2 > 3");
test3.assertValue("2 < 3 > 4");
test4.assertValue("3 < 4 > ?");
list.remove(3);
test3.assertValues("2 < 3 > 4", "2 < 3 > ?");
list.remove(1);
test1.assertValues("? < 1 > 2", "? < 1 > 3");
test3.assertValues("2 < 3 > 4", "2 < 3 > ?", "1 < 3 > ?");
}
示例11: testConcatListEquals
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testConcatListEquals()
{
SimpleFlowableList<Integer> a = new SimpleFlowableList<>();
SimpleFlowableList<Integer> b = new SimpleFlowableList<>();
SimpleFlowableList<Integer> c = new SimpleFlowableList<>();
a.add(1);
a.add(2);
a.add(3);
b.add(4);
b.add(5);
c.add(6);
c.add(7);
c.add(8);
FlowableList<?> list = FlowableList.concat(Arrays.<FlowableList<Integer>>asList(a, b, c));
TestSubscriber testSubscriber = new TestSubscriber();
list.updates().subscribe(testSubscriber);
testSubscriber.assertValueCount(1);
List<Update> onNextEvents = testSubscriber.values();
Update reload = onNextEvents.get(0);
assertEquals(reload.list, Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8));
assertNotEquals(reload.list, Arrays.asList(1, 2, 3, 4, 5, 6, 7));
assertNotEquals(reload.list, Arrays.asList(1, 2, 3, 4, 5, 8, 7, 6));
}
示例12: testLopSidedPrefetch
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testLopSidedPrefetch()
{
final List<Integer> fetches = new ArrayList<>();
final List<Integer> prefetches = new ArrayList<>();
TestSubscriber<Update<Integer>> testSubscriber = new TestSubscriber<>();
SimpleFlowableList<Integer> list = new SimpleFlowableList<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
FlowableList<Integer> transformedList = list.map(new Function<Integer, Integer>() {
@Override
public Integer apply(Integer value) {
fetches.add(value);
return value;
}
});
FlowableList<Integer> prefetchList = transformedList.prefetch(0, 4,
new Consumer<Collection<Integer>>() {
@Override
public void accept(Collection<Integer> integer) throws Exception {
prefetches.addAll(integer);
}
});
prefetchList.updates().subscribe(testSubscriber);
testSubscriber.assertValueCount(1);
List<Update<Integer>> onNextEvents = testSubscriber.values();
assertEquals(Arrays.asList(Change.reloaded()), onNextEvents.get(0).changes);
List<Integer> list1 = onNextEvents.get(0).list;
assertEquals(Integer.valueOf(4), list1.get(3));
assertEquals(Arrays.asList(4, 5, 6, 7, 8), fetches);
assertEquals(Arrays.asList(5, 6, 7, 8), prefetches);
assertEquals(Integer.valueOf(9), list1.get(8));
assertEquals(Arrays.asList(4, 5, 6, 7, 8, 9, 10), fetches);
assertEquals(Arrays.asList(5, 6, 7, 8, 10), prefetches);
}
示例13: testMoveTransform
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testMoveTransform()
{
SimpleFlowableList<Integer> list = new SimpleFlowableList<>(Arrays.asList(1, 2, 3, 4));
TestSubscriber<Update<Flowable<String>>> testSubscriber = createIndexedList(list);
testSubscriber.assertValueCount(1);
List<Update<Flowable<String>>> onNextEvents = testSubscriber.values();
assertEquals(Arrays.asList(Change.reloaded()), onNextEvents.get(0).changes);
List<Flowable<String>> list1 = onNextEvents.get(0).list;
Flowable<String> item1 = list1.get(0);
Flowable<String> item2 = list1.get(1);
Flowable<String> item3 = list1.get(2);
Flowable<String> item4 = list1.get(3);
TestSubscriber<String> test1 = item1.test();
TestSubscriber<String> test2 = item2.test();
TestSubscriber<String> test3 = item3.test();
TestSubscriber<String> test4 = item4.test();
test1.assertValue("? < 1 > 2");
test2.assertValue("1 < 2 > 3");
test3.assertValue("2 < 3 > 4");
test4.assertValue("3 < 4 > ?");
list.move(3, 1);
test1.assertValues("? < 1 > 2", "? < 1 > 4");
test2.assertValues("1 < 2 > 3", "4 < 2 > 3");
test3.assertValues("2 < 3 > 4", "2 < 3 > ?");
list.move(1, 3);
test1.assertValues("? < 1 > 2", "? < 1 > 4", "? < 1 > 2");
test2.assertValues("1 < 2 > 3", "4 < 2 > 3", "1 < 2 > 3");
test3.assertValues("2 < 3 > 4", "2 < 3 > ?", "2 < 3 > 4");
}
示例14: testSingleConcatListInsertions
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testSingleConcatListInsertions()
{
SimpleFlowableList<Integer> a = new SimpleFlowableList<>();
SimpleFlowableList<Integer> b = new SimpleFlowableList<>();
SimpleFlowableList<Integer> c = new SimpleFlowableList<>();
a.add(1);
a.add(2);
a.add(3);
b.add(4);
b.add(5);
c.add(6);
c.add(7);
c.add(8);
FlowableList<?> list = FlowableList.concat(Arrays.<FlowableList<Integer>>asList(a, b, c));
TestSubscriber testSubscriber = new TestSubscriber();
list.updates().subscribe(testSubscriber);
b.add(9);
c.add(1, 10);
testSubscriber.assertValueCount(3);
List<Update> onNextEvents = testSubscriber.values();
Update reload = onNextEvents.get(0);
Update insert9 = onNextEvents.get(1);
Update insert10 = onNextEvents.get(2);
assertEquals(Arrays.asList(Change.reloaded()), reload.changes);
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8), reload.list);
assertEquals(Arrays.asList(Change.inserted(5)), insert9.changes);
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 9, 6, 7, 8), insert9.list);
assertEquals(Arrays.asList(Change.inserted(7)), insert10.changes);
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 9, 6, 10, 7, 8), insert10.list);
}
示例15: testInsertAndRemoveListPropagation
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertAndRemoveListPropagation()
{
SimpleFlowableList<Integer> a = new SimpleFlowableList<>();
SimpleFlowableList<Integer> b = new SimpleFlowableList<>();
SimpleFlowableList<Integer> c = new SimpleFlowableList<>();
SimpleFlowableList<Integer> d = new SimpleFlowableList<>();
a.add(1);
a.add(2);
b.add(3);
b.add(4);
c.add(5);
d.add(6);
SimpleFlowableList<FlowableList<Integer>> combinedList = new SimpleFlowableList<>();
combinedList.add(a);
combinedList.add(b);
combinedList.add(c);
FlowableList<?> list = FlowableList.concat(combinedList);
TestSubscriber testSubscriber = new TestSubscriber();
list.updates().subscribe(testSubscriber);
combinedList.add(1, d);
combinedList.remove(b);
List<Update> onNextEvents = testSubscriber.values();
testSubscriber.assertValueCount(3);
Update reload = onNextEvents.get(0);
Update insertd = onNextEvents.get(1);
Update removeb = onNextEvents.get(2);
assertEquals(Arrays.asList(Change.reloaded()), reload.changes);
assertEquals(Arrays.asList(1, 2, 3, 4, 5), reload.list);
assertEquals(Arrays.asList(Change.inserted(2)), insertd.changes);
assertEquals(Arrays.asList(1, 2, 6, 3, 4, 5), insertd.list);
assertEquals(
Arrays.asList(
Change.removed(3),
Change.removed(4)),
removeb.changes);
assertEquals(Arrays.asList(1, 2, 6, 5), removeb.list);
}