UserDataSource { public Observable<SearchResult<UserEntity>> search(String keyWord, String language, SortType_User sort, int page) { if (keyWord == null) keyWord = ""; if (!TextUtils.isEmpty(language)) keyWord += language; return userApi.search(keyWord, sort.val(), page, Constant.PER_PAGE) .compose(RxJavaUtils.<SearchResult<UserEntity>>applySchedulers()); } UserDataSource(GithubAuthRetrofit authRetrofit, UserService userApi, Context ctx); Observable<UserInfo> getUserInfo(String user); Observable<Boolean> login(final String userName, String password); Observable<List<UserEntity>> listFollowers(String userName, int page); Observable<List<UserEntity>> listFollowing(String user, int page); Observable<List<RepositoryInfo>> listStarredRepo(String user, int page); Observable<List<RepositoryInfo>> listStarredRepo(String user, SortType_Repo sort, int page); Observable<List<RepositoryInfo>> listWatchingRepo(String user, int page); Observable<List<RepositoryInfo>> listOwnRepo(String user, int page); Observable<List<Event>> listNews(String user, int page); Observable<SearchResult<UserEntity>> search(String keyWord, String language, SortType_User sort, int page); Observable<Boolean> signOut(); String getLoginUserName(); Observable<Boolean> toFollow(String user); Observable<Boolean> toUnFollow(String user); Observable<Boolean> checkIfFollowing(String user);  }
@Test public void search() throws Exception { TestSubscriber<SearchResult<UserEntity>> subscriber = TestSubscriber.create(); userDataSource.search("", Constant.Language.ALL.val(), Constant.SortType.SortType_User.BEST_MATCH, 1) .subscribe(subscriber); List<SearchResult<UserEntity>> onNextEvents = subscriber.getOnNextEvents(); assertNotNull(onNextEvents); System.out.println(onNextEvents.get(0).toString()); }