// Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
//     protected final static int WAIT = 50;
//     @Mock protected UI UIMock;
//     @Mock protected ObserveOn observeOnMock;
//     @Mock protected SubscribeOn subscribeOnMock;
// 
//     @Before public void setUp() {
//         MockitoAnnotations.initMocks(this);
//         when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
//         when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
//     }
// }
// 
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
//     Observable<UserDemoEntity> searchByUserName(String nameUser);
//     Observable<List<UserDemoEntity>> askForUsers();
//     Observable<UserDemoEntity> getSelectedUserDemoList();
//     Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
// 
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
//     private final int id;
//     private final String login;
//     private String avatar_url = "";
// 
//     public String getAvatarUrl() {
//         if (avatar_url.isEmpty()) return avatar_url;
//         return avatar_url.split("\\?")[0];
//     }
// }


import org.junit.Test;
import org.mockito.Mock;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
/*
 * Copyright 2015 RefineriaWeb
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package domain.sections.user_demo.detail;




public class GetSelectedDemoUserListUseCaseTest extends BaseTest {
    private GetSelectedDemoUserListUseCase getSelectedDemoUserListUseCaseUT;
    @Mock protected UserDemoRepository userDemoRepositoryMock;
    @Mock protected UserDemoEntity userDemoEntityMock;

    @Override public void setUp() {
        super.setUp();
        getSelectedDemoUserListUseCaseUT = new GetSelectedDemoUserListUseCase(UIMock, userDemoRepositoryMock);
    }

    @Test public void When_Execute_Get_User() {
        when(userDemoRepositoryMock.getSelectedUserDemoList()).thenReturn(Observable.just(userDemoEntityMock));

        TestSubscriber<UserDemoEntity> subscriberMock = new TestSubscriber<>();
        getSelectedDemoUserListUseCaseUT.react().subscribe(subscriberMock);
        subscriberMock.awaitTerminalEvent();

// Path: domain/src/test/java/domain/common/BaseTest.java
// public abstract class BaseTest {
//     protected final static int WAIT = 50;
//     @Mock protected UI UIMock;
//     @Mock protected ObserveOn observeOnMock;
//     @Mock protected SubscribeOn subscribeOnMock;
// 
//     @Before public void setUp() {
//         MockitoAnnotations.initMocks(this);
//         when(observeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
//         when(subscribeOnMock.getScheduler()).thenReturn(Schedulers.newThread());
//     }
// }
// 
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
//     Observable<UserDemoEntity> searchByUserName(String nameUser);
//     Observable<List<UserDemoEntity>> askForUsers();
//     Observable<UserDemoEntity> getSelectedUserDemoList();
//     Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }
// 
// Path: domain/src/main/java/domain/sections/user_demo/entities/UserDemoEntity.java
// @AllArgsConstructor(access = AccessLevel.PROTECTED)
// @Data
// public class UserDemoEntity {
//     private final int id;
//     private final String login;
//     private String avatar_url = "";
// 
//     public String getAvatarUrl() {
//         if (avatar_url.isEmpty()) return avatar_url;
//         return avatar_url.split("\\?")[0];
//     }
// }


// Path: domain/src/test/java/domain/sections/user_demo/detail/GetSelectedDemoUserListUseCaseTest.java
import org.junit.Test;
import org.mockito.Mock;
import domain.common.BaseTest;
import domain.sections.user_demo.UserDemoRepository;
import domain.sections.user_demo.entities.UserDemoEntity;
import rx.Observable;
import rx.observers.TestSubscriber;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;

/*
 * Copyright 2015 RefineriaWeb
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package domain.sections.user_demo.detail;




public class GetSelectedDemoUserListUseCaseTest extends BaseTest {
    private GetSelectedDemoUserListUseCase getSelectedDemoUserListUseCaseUT;
    @Mock protected UserDemoRepository userDemoRepositoryMock;
    @Mock protected UserDemoEntity userDemoEntityMock;

    @Override public void setUp() {
        super.setUp();
        getSelectedDemoUserListUseCaseUT = new GetSelectedDemoUserListUseCase(UIMock, userDemoRepositoryMock);
    }

    @Test public void When_Execute_Get_User() {
        when(userDemoRepositoryMock.getSelectedUserDemoList()).thenReturn(Observable.just(userDemoEntityMock));

        TestSubscriber<UserDemoEntity> subscriberMock = new TestSubscriber<>();
        getSelectedDemoUserListUseCaseUT.react().subscribe(subscriberMock);
        subscriberMock.awaitTerminalEvent();

        assertThat(subscriberMock.getOnCompletedEvents().size(), is(1));