DatabaseService implements LocalService { @Override public Observable<Void> removeUsers(List<String> ids) { return Observable.create(subscriber -> { try { SQLite.delete().from(CacheUser.class).where(CacheUser_Table.id.in(ids)).execute(); RxUtils.onNext(subscriber, null, true); } catch (Exception e) { RxUtils.onError(subscriber, e); } }); } DatabaseService(MVVMConverter<User, CacheUser> userConverter); @Override Observable<User> observeLocalChange(); @Override Observable<User> getUser(String id); @Override Observable<List<? extends User>> getUsers(); @Override Observable<Void> saveUser(User user); @Override Observable<Void> saveUsers(List<User> users); @Override Observable<Void> removeUser(String id); @Override Observable<Void> removeUsers(List<String> ids);  }
@Test public void testRemoveUsers() throws Exception { List<User> cacheUsers = new ArrayList<>(); cacheUsers.add(new CacheUser("1", "Lam", "lam@mysquar.com", "Lam", "123", "http: cacheUsers.add(new CacheUser("2", "Henry", "henry@mysquar.com", "Henry", "456", "http: cacheUsers.add(new CacheUser("3", "Long", "long@mysquar.com", "Long", "789", "http: mDatabaseService.saveUsers(cacheUsers) .subscribe(); TestSubscriber<Void> testSubscriber = new TestSubscriber<>(); Observable.from(cacheUsers) .map(user -> user.getId()) .toList() .flatMap(strings -> mDatabaseService.removeUsers(strings)) .subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertCompleted(); TestSubscriber<List<? extends User>> testGetSubscriber = new TestSubscriber<>(); mDatabaseService.getUsers() .subscribe(testGetSubscriber); List<? extends User> users = testGetSubscriber.getOnNextEvents().get(0); assertThat(users.size(), equalTo(0)); }