当前位置: 首页>>代码示例>>Java>>正文


Java TestObserver.onComplete方法代码示例

本文整理汇总了Java中io.reactivex.observers.TestObserver.onComplete方法的典型用法代码示例。如果您正苦于以下问题:Java TestObserver.onComplete方法的具体用法?Java TestObserver.onComplete怎么用?Java TestObserver.onComplete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.reactivex.observers.TestObserver的用法示例。


在下文中一共展示了TestObserver.onComplete方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldBeAbleToDisplayMovies

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
    public void shouldBeAbleToDisplayMovies() {
//        System.out.println(MainThread);


        TestScheduler testScheduler = new TestScheduler();
        TestObserver<List<Movie>> testObserver = new TestObserver<>();
        Observable<List<Movie>> responseObservable = Observable.just(movies)
                .subscribeOn(testScheduler)
                .observeOn(testScheduler);

        responseObservable.subscribe(testObserver);
        when(interactor.fetchMovies()).thenReturn(responseObservable);

        presenter.setView(view);
        testScheduler.triggerActions();

        testObserver.assertNoErrors();
        testObserver.onComplete();
        verify(view).showMovies(movies);
    }
 
开发者ID:boyangyuu,项目名称:ILoveMovie,代码行数:22,代码来源:MoviesListingPresenterImplTest.java

示例2: loginTest

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
/**
 * {@link NetworkManager} integration test: login request to, local REST API server mock
 */
@Test
public void loginTest() throws Exception{
    networkManager.configAuth(dummyApiUrl, dummyLogin, dummyPassword);

    Gson gson = new Gson();
    AccessToken expectedAccessToken
            = gson.fromJson(readAssetFile(testContext, "api/login.json"), AccessToken.class);

    TestObserver<AccessToken> testObserver = new CustomTestObserver<>(expectedAccessToken);
    networkManager.getAccessToken().subscribe(testObserver);

    testObserver.assertSubscribed();
    testObserver.assertValueCount(1);
    testObserver.assertNoErrors();
    testObserver.onComplete();
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:20,代码来源:NetworkManagerIntegrationTest.java

示例3: getLastUpdate

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
/**
 * {@link NetworkManager} integration test: get last_update id from local REST API mock server
 */
@Test
public void getLastUpdate() throws Exception {
    networkManager.configAuth(dummyApiUrl);

    String expectedLastUpdate
            = new String(readAssetFile(testContext, "api/last_update.json").getBytes());

    TestObserver<String> testObserver = new CustomTestObserver<>(expectedLastUpdate);
    networkManager.getLastUpdate().subscribe(testObserver);

    testObserver.assertSubscribed();
    testObserver.assertValueCount(1);
    testObserver.assertNoErrors();
    testObserver.onComplete();
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:19,代码来源:NetworkManagerIntegrationTest.java

示例4: getAppDataTest

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
/**
 * {@link NetworkManager} integration test: get AppData from local REST API mock server,
 * compere parsed response to AppData parsed directly from .json file
 */
@Test
public void getAppDataTest() throws Exception {
    networkManager.configAuth(dummyApiUrl);

    Gson gson = new Gson();
    AppData appData = gson.fromJson(
            readAssetFile(testContext, "api/app_data.json"), AppData.class);

    TestObserver<AppData> testObserver = new CustomTestObserver<>(appData);
    networkManager.getAppData().subscribe(testObserver);

    testObserver.assertSubscribed();
    testObserver.assertValueCount(1);
    testObserver.assertNoErrors();
    testObserver.onComplete();
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:21,代码来源:NetworkManagerIntegrationTest.java

示例5: getAppDataTokenTest

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
/**
 * {@link NetworkManager} integration test: same as getAppDataTest() but with token Authorization
 */
@Test
public void getAppDataTokenTest() throws Exception {
    networkManager.configAuth(dummyApiUrl, dummyToken);

    Gson gson = new Gson();
    AppData appData = gson.fromJson(
            readAssetFile(testContext, "api/app_data.json"), AppData.class);

    TestObserver<AppData> testObserver = new CustomTestObserver<>(appData);
    networkManager.getAppData().subscribe(testObserver);

    testObserver.assertSubscribed();
    testObserver.assertValueCount(1);
    testObserver.assertNoErrors();
    testObserver.onComplete();
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:20,代码来源:NetworkManagerIntegrationTest.java

示例6: loginTest

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
/**
 * Tests login API call
 */
@Test
public void loginTest() throws Exception {
    LabService labService = retrofitBuilder.createService(
            dummyApiUrl, LabService.class, dummyLogin, dummyPassword);

    Gson gson = new Gson();
    AccessToken accessToken = gson.fromJson(readFile(loginAccessTokenPath), AccessToken.class);
    TestObserver<AccessToken> testObserver = new CustomTestObserver<>(accessToken);
    labService.getAccessToken().subscribe(testObserver);

    testObserver.assertSubscribed();
    testObserver.assertValueCount(1);
    testObserver.assertNoErrors();
    testObserver.onComplete();
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:19,代码来源:RetrofitAPICallsIntegrationTest.java

示例7: appDataLoginTest

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
/**
 * Tests response from AppData API call with login&password authorization
 */
@Test
public void appDataLoginTest() throws Exception {
    Gson gson = new Gson();
    AppData appData = gson.fromJson(readFile(appDataJsonPath), AppData.class);

    LabService labService = retrofitBuilder.createService(
            dummyApiUrl, LabService.class, dummyLogin, dummyPassword);
    TestObserver<AppData> testObserver = new CustomTestObserver<>(appData);
    labService.getAppData().subscribe(testObserver);

    testObserver.assertSubscribed();
    testObserver.assertValueCount(1);
    testObserver.assertNoErrors();
    testObserver.onComplete();
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:19,代码来源:RetrofitAPICallsIntegrationTest.java

示例8: createServiceWithInterceptor

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
/**
 * test RetrofitBuilder in isolation from AuthenticationInterceptor
 */
@Test
public void createServiceWithInterceptor() throws Exception {
    Request request = new Request.Builder().header("Authorization", dummyToken)
            .get().url(dummyApiUrl).build();

    ResponseBody dummyResponse = new ResponseBody() {
        @Nullable
        @Override
        public MediaType contentType() {
            return null;
        }

        @Override
        public long contentLength() {
            return 0;
        }

        @Override
        public BufferedSource source() {
            return null;
        }
    };

    when(authenticationInterceptor.intercept(any())).thenReturn(
            new Response.Builder().request(request).protocol(Protocol.HTTP_2).code(200)
            .body(dummyResponse).message(message).build());

    LabService labService = retrofitBuilder.createService(dummyApiUrl, LabService.class, dummyToken);

    TestObserver<AppData> testObserver = new TestObserver<>();
    labService.getAppData().subscribe(testObserver);

    testObserver.assertSubscribed();
    testObserver.onComplete();

    InOrder order = inOrder(authenticationInterceptor);
    order.verify(authenticationInterceptor, calls(1)).setAuthToken(dummyToken);
    order.verify(authenticationInterceptor, calls(1)).intercept(any());
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:43,代码来源:RetrofitBuilderTest.java

示例9: lastUpdateTest

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
/**
 * Tests API response to last_update call
 */
@Test
public void lastUpdateTest() throws Exception {
    LabService labService = retrofitBuilder.createService(dummyApiUrl, LabService.class);
    String expectedLastUpdate = readFile(lastUpdateJsonPath);
    TestObserver<String> testObserver = new CustomTestObserver<>(expectedLastUpdate);
    labService.getLastUpdate().subscribe(testObserver);

    testObserver.assertSubscribed();
    testObserver.assertValueCount(1);
    testObserver.assertNoErrors();
    testObserver.onComplete();
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:16,代码来源:RetrofitAPICallsIntegrationTest.java

示例10: appDataTokenTest

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
/**
 * Tests response from AppData API call with token authorization
 */
@Test
public void appDataTokenTest() throws Exception {
    Gson gson = new Gson();
    AppData appData = gson.fromJson(readFile(appDataJsonPath), AppData.class);

    LabService labService = retrofitBuilder.createService(dummyApiUrl, LabService.class, dummyToken);
    TestObserver<AppData> testObserver = new CustomTestObserver<>(appData);
    labService.getAppData().subscribe(testObserver);

    testObserver.assertSubscribed();
    testObserver.assertValueCount(1);
    testObserver.assertNoErrors();
    testObserver.onComplete();
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:18,代码来源:RetrofitAPICallsIntegrationTest.java


注:本文中的io.reactivex.observers.TestObserver.onComplete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。