@@ -0,0 +1,3551 @@
+package com.guavabot.marshpermissions.domain.interactor;%0A%0Aimport com.guavabot.marshpermissions.domain.entity.App;%0Aimport com.guavabot.marshpermissions.domain.gateway.AppRepository;%0Aimport com.guavabot.marshpermissions.domain.gateway.AppSettings;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Mock;%0Aimport org.mockito.runners.MockitoJUnitRunner;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.concurrent.TimeUnit;%0A%0Aimport rx.Observable;%0Aimport rx.functions.Func1;%0Aimport rx.observers.TestSubscriber;%0Aimport rx.schedulers.TestScheduler;%0A%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0A/**%0A * %3Cp%3ECreated by Ivan on 12/31/15.%0A */%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class GetAppListUseCaseTest %7B%0A%0A    private GetAppListUseCase mTested;%0A%0A    @Mock%0A    private AppRepository mAppRepository;%0A    @Mock%0A    private AppSettings mAppSettings;%0A%0A    @Before%0A    public void setup() %7B%0A        mTested = new GetAppListUseCase(mAppRepository, mAppSettings);%0A    %7D%0A%0A    @Test%0A    public void shouldReturnEmptyListAndNotComplete() throws Exception %7B%0A        when(mAppSettings.isDisplayHidden()).thenReturn(Observable.just(true));%0A        when(mAppSettings.isDisplayAndroid()).thenReturn(Observable.just(true));%0A        when(mAppSettings.isDisplayGoogle()).thenReturn(Observable.just(true));%0A        when(mAppRepository.hiddenAppsUpdate()).thenReturn(Observable.%3CVoid%3Enever());%0A        List%3CApp%3E list = new ArrayList%3C%3E();%0A        when(mAppRepository.findAppsMarshmallow()).thenReturn(Observable.just(list));%0A        TestSubscriber%3CList%3CApp%3E%3E subscriber = new TestSubscriber%3C%3E();%0A%0A        mTested.execute()%0A                .subscribe(subscriber);%0A%0A        subscriber.assertValue(list);%0A        subscriber.assertNotCompleted();%0A    %7D%0A%0A    @Test%0A    public void shouldUpdateListWhenChangesPushed() %7B%0A        when(mAppSettings.isDisplayHidden()).thenReturn(Observable.just(true));%0A        when(mAppSettings.isDisplayAndroid()).thenReturn(Observable.just(true));%0A        when(mAppSettings.isDisplayGoogle()).thenReturn(Observable.just(true));%0A        List%3CApp%3E list = new ArrayList%3C%3E();%0A        when(mAppRepository.findAppsMarshmallow()).thenReturn(Observable.just(list));%0A        TestSubscriber%3CList%3CApp%3E%3E subscriber = new TestSubscriber%3C%3E();%0A%0A        final List%3CApp%3E list2 = new ArrayList%3C%3E();%0A        App app = mock(App.class);%0A        when(app.getPackage()).thenReturn(%22com%22);%0A        when(app.isHidden()).thenReturn(false);%0A        list2.add(app);%0A        TestScheduler scheduler = new TestScheduler();%0A        when(mAppRepository.hiddenAppsUpdate()).thenReturn(%0A                Observable.interval(1, TimeUnit.SECONDS, scheduler)%0A                        .flatMap(new Func1%3CLong, Observable%3CVoid%3E%3E() %7B%0A                            @Override%0A                            public Observable%3CVoid%3E call(Long aLong) %7B%0A                                //change list of apps to return from repository%0A                                when(mAppRepository.findAppsMarshmallow()).thenReturn(Observable.just(list2));%0A                                return Observable.just(null);%0A                            %7D%0A                        %7D));%0A%0A        mTested.execute()%0A                .subscribe(subscriber);%0A%0A        subscriber.assertValue(list);%0A        subscriber.assertNotCompleted();%0A%0A        scheduler.advanceTimeBy(1, TimeUnit.SECONDS);%0A        //noinspection unchecked%0A        subscriber.assertValues(list, list2);%0A        subscriber.assertNotCompleted();%0A    %7D%0A%7D

add tests for GetAppListUseCase