Search in sources :

Example 1 with SystemMessage

use of com.tevinjeffrey.rutgersct.rutgersapi.model.SystemMessage in project Rutgers-Course-Tracker by tevjef.

the class ChooserPresenterImpl method loadSystemMessage.

@Override
public void loadSystemMessage() {
    cancePreviousSubscription();
    Subscriber<SystemMessage> mSubscriber = new Subscriber<SystemMessage>() {

        @Override
        public void onCompleted() {
        //Noop
        }

        @Override
        public void onError(Throwable e) {
        //Noop
        }

        @Override
        public void onNext(SystemMessage systemMessage) {
            if (getView() != null) {
                getView().showMessage(systemMessage);
            }
        }
    };
    mSubsciption = mRetroRutgers.getSystemMessage().doOnSubscribe(new Action0() {

        @Override
        public void call() {
            isLoading = true;
        }
    }).doOnTerminate(new Action0() {

        @Override
        public void call() {
            isLoading = false;
        }
    }).subscribeOn(mBackgroundThread).observeOn(mMainThread).subscribe(mSubscriber);
}
Also used : SystemMessage(com.tevinjeffrey.rutgersct.rutgersapi.model.SystemMessage) Action0(rx.functions.Action0) Subscriber(rx.Subscriber)

Example 2 with SystemMessage

use of com.tevinjeffrey.rutgersct.rutgersapi.model.SystemMessage in project Rutgers-Course-Tracker by tevjef.

the class ChooserPresenterImplTest method LoadChooser_CompletesWithData.

@Test
public void LoadChooser_CompletesWithData() throws Exception {
    SystemMessage systemMessage = mock(SystemMessage.class);
    chooserPresenterImpl.attachView(chooserView);
    databaseHandler.addSectionToDb(TestConts.getPrimarySemesterRequest());
    when(retroRutgers.getSystemMessage()).thenReturn(Observable.just(systemMessage));
    chooserPresenterImpl.loadSystemMessage();
    verify(chooserView).showMessage(any(SystemMessage.class));
}
Also used : SystemMessage(com.tevinjeffrey.rutgersct.rutgersapi.model.SystemMessage) Test(org.junit.Test)

Aggregations

SystemMessage (com.tevinjeffrey.rutgersct.rutgersapi.model.SystemMessage)2 Test (org.junit.Test)1 Subscriber (rx.Subscriber)1 Action0 (rx.functions.Action0)1