### Question:
UserRepository { public Single<UserEntity> getUser() { return userDao.select(); } @Inject  UserRepository(UserDao userDao); Single<UserEntity> getUser(); Completable putOrPostUser(String userName, String password); Completable deleteUser();  }### Answer:
@Test public void getUser() { repo.getUser(); verify(userDao).select(); }
@Test public void getUser_whenNoUserSaved() { EmptyResultSetException ex = new EmptyResultSetException("Test"); when(userDao.select()).thenReturn(Single.error(ex)); repo.getUser() .test() .assertError(ex); }
@Test public void getUser_whenUserSaved() { UserEntity user = new UserEntity("testUser", "testPassword"); when(userDao.select()).thenReturn(Single.just(user)); repo.getUser() .test() .assertValue(user); }