本文整理匯總了Java中io.reactivex.subscribers.TestSubscriber.assertComplete方法的典型用法代碼示例。如果您正苦於以下問題:Java TestSubscriber.assertComplete方法的具體用法?Java TestSubscriber.assertComplete怎麽用?Java TestSubscriber.assertComplete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.reactivex.subscribers.TestSubscriber
的用法示例。
在下文中一共展示了TestSubscriber.assertComplete方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: manyToMany
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void manyToMany() throws Exception {
RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
Flowable<HelloRequest> req = Flowable.just(
HelloRequest.newBuilder().setName("a").build(),
HelloRequest.newBuilder().setName("b").build(),
HelloRequest.newBuilder().setName("c").build(),
HelloRequest.newBuilder().setName("d").build(),
HelloRequest.newBuilder().setName("e").build());
Flowable<HelloResponse> resp = stub.sayHelloBothStream(req);
TestSubscriber<String> testSubscriber = resp.map(HelloResponse::getMessage).test();
testSubscriber.awaitTerminalEvent(3, TimeUnit.SECONDS);
testSubscriber.assertValues("Hello a and b", "Hello c and d", "Hello e");
testSubscriber.assertComplete();
}
示例2: 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");
}
示例3: 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());
}
示例4: 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);
}
示例5: 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());
}
示例6: testGetOneObject
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testGetOneObject(){
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);
TestModel toFind = new TestModel(20);
TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
disposables.add(testStore.getOne(toFind)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(5, SECONDS);
observer.assertComplete();
observer.assertNoErrors();
Assert.assertEquals(3, models.size());
TestModel tm = observer.values().get(0).get();
Assert.assertEquals(20, tm.getId());
}
示例7: testInsertList
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertList(){
models.clear();
List<TestModel> list = new ArrayList<>();
list.add(new TestModel(1));
list.add(new TestModel(2));
list.add(new TestModel(3));
TestSubscriber<Optional<List<TestModel>>> observer = new TestSubscriber<>();
disposables.add(testStore.insert(list)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(2, SECONDS);
observer.assertComplete();
observer.assertNoErrors();
Assert.assertEquals(3, models.size());
}
示例8: testInsert
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsert(){
models.clear();
TestModel model = new TestModel(99);
TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
disposables.add(testStore.insert(model)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(2, SECONDS);
observer.assertComplete();
observer.assertNoErrors();
int sum = 0;
for(TestModel tm : models){
sum += tm.getId();
}
Assert.assertEquals(1, models.size());
Assert.assertEquals(99, sum);
}
示例9: 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);
}
示例10: testInsertOrUpdate
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertOrUpdate(){
models.clear();
final TestModel model = new TestModel(99);
model.setAvailable(true);
TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
disposables.add(testStore.insertOrUpdate(model)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(4, SECONDS);
observer.assertComplete();
observer.assertNoErrors();
final TestModel output = observer.values().get(0).get();
Assert.assertNotNull(output);
Assert.assertTrue(output.isAvailable());
Assert.assertEquals(1, models.size());
}
示例11: openAndCloseEvent
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void openAndCloseEvent() {
TestSubscriber<String> testSubscriber = stream
.compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))
.test();
lifecycle.onNext("create");
stream.onNext("1");
lifecycle.onNext("destroy");
stream.onNext("2");
testSubscriber.assertValues("1");
testSubscriber.assertComplete();
}
示例12: oneEvent
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void oneEvent() {
TestSubscriber<String> testSubscriber = stream
.compose(RxLifecycle.<String, String>bind(lifecycle))
.test();
stream.onNext("1");
lifecycle.onNext("stop");
stream.onNext("2");
testSubscriber.assertValues("1");
testSubscriber.assertComplete();
}
示例13: testUpdate
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testUpdate(){
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);
TestModel testModel = new TestModel(1);
testModel.setAvailable(true);
TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
disposables.add(testStore.update(testModel)
.subscribeOn(Schedulers.io())
.subscribeWith(observer));
observer.awaitTerminalEvent(4, SECONDS);
observer.assertComplete();
observer.assertNoErrors();
Optional<TestModel> results = observer.values().get(0);
Optional<TestModel> resultsAfter = observer.values().get(1);
Assert.assertNotNull(results.get());
Assert.assertNotNull(resultsAfter.get());
Assert.assertTrue(results.get().isAvailable());
Assert.assertTrue(resultsAfter.get().isAvailable());
Assert.assertEquals(3, models.size());
for(TestModel tm : models){
if(tm.getId() == 1){
Assert.assertTrue(tm.isAvailable());
}
}
}
示例14: testAllGists
import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testAllGists() {
ServiceLocator.put(OkHttpClient.class, OkHttpClientUtil.getOkHttpClient(null, MockBehavior.MOCK));
Flowable<Gist[]> flowable = ServiceInjector.resolve(RxEndpoints.class).getGists();
TestSubscriber<Gist[]> testSubscriber = new TestSubscriber<>();
flowable.subscribe(testSubscriber);
testSubscriber.assertComplete();
List<Gist[]> gists = testSubscriber.values();
Gist gist = gists.get(0)[0];
Flowable<Gist> gistFlowable = ServiceInjector.resolve(RxEndpoints.class).getGist(gist.getId());
TestSubscriber<Gist> gistTestSubscriber = new TestSubscriber<>();
gistFlowable.subscribe(gistTestSubscriber);
Gist detailGist = (Gist) gistTestSubscriber.values().get(0);
assertEquals(detailGist.getDescription(), gist.getDescription());
}
示例15: 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");
}