DatabaseService implements LocalService { @Override public Observable<Void> removeUser(String id) { return Observable.create(subscriber -> { try { SQLite.delete().from(CacheUser.class).where(CacheUser_Table.id.eq(id)).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 testRemoveUser() throws Exception { TestSubscriber<Void> testSaveSubscriber = new TestSubscriber<>(); CacheUser cacheUser = new CacheUser("1", "Lam", "lam@mysquar.com", "Lam", "123", "http: mDatabaseService.saveUser(cacheUser) .flatMap(aVoid -> mDatabaseService.removeUser(cacheUser.getId())) .subscribe(testSaveSubscriber); testSaveSubscriber.assertNoErrors(); testSaveSubscriber.assertCompleted(); TestSubscriber<User> testGetSubscriber = new TestSubscriber<>(); mDatabaseService.getUser(cacheUser.getId()) .subscribe(testGetSubscriber); List<User> users = testGetSubscriber.getOnNextEvents(); assertThat(users.size(), equalTo(0)); }