當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。