ParseUserDataSource implements UserDataSource<ExampleUser> { @NonNull @Override public Observable<ExampleUser> getSingleUser(UserQueries.GetUserQuery query) { ParseQuery<ParseUser> parseQuery = new ParseQuery<>("_User"); parseQuery.whereEqualTo("objectId", query.getUserId()); parseQuery.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ONLY); return mParseHelper.find(parseQuery) .flatMap(Observable::from) .map(ParseUtils::fromParseUser) .subscribeOn(Schedulers.io()); } ParseUserDataSource(@NonNull ParseHelper parseHelper); @NonNull @Override Observable<List<ExampleUser>> getAllUsers(UserQueries.GetAllUsersQuery query); @NonNull @Override Observable<ExampleUser> getSingleUser(UserQueries.GetUserQuery query);  }
@Test public void getSingleUser() { List<ParseUser> users = Collections.singletonList(ModelTestHelper.createParseUser(OTHER_USER)); when(mMockParseHelper.find(Mockito.<ParseQuery<ParseUser>>any())).thenReturn(Observable.just(users)); TestSubscriber<ExampleUser> testSubscriber = executeTarget(mTarget.getSingleUser(new UserQueries.GetUserQuery(OTHER_USER))); assertThat(testSubscriber.getOnNextEvents().size(), is(1)); BaseUser user = testSubscriber.getOnNextEvents().get(0); assertEquals(OTHER_USER, user.getUserId()); testSubscriber.assertCompleted(); }