### Question:
RxFiles { @Nonnull public Observable<File> getFilesInDirectory(@Nonnull final File directory) { checkNotNull(directory, "\'directory\' must not be null."); final Observable<File> listFiles = Observable .fromCallable(() -> Optional.ofNullable(directory.listFiles())) .flatMap(optionalFiles -> optionalFiles.isPresent() ? Observable.fromIterable(Arrays.asList(optionalFiles.get())) : Observable.error(makeError("Failed to get files in", directory, "Reason unknown"))); return exists(directory).flatMapObservable(exists -> exists ? isFile(directory) .flatMapObservable(isFile -> isFile ? Observable.error(makeError( "Failed to get files in", directory, "Expected a directory but found a file")) : listFiles) : Observable.error(makeError("Failed to get files in", directory, "The directory does not exist"))); }  @Nonnull Completable createDirectory(@Nonnull final File directory); @Nonnull Completable createNewFile(@Nonnull final File file); @Nonnull Completable delete(@Nonnull final File file); @Nonnull Observable<File> getFilesInDirectory(@Nonnull final File directory); @Nonnull Single<String> readStringFromFile(@Nonnull final File file, @Nonnull final Charset charset); @Nonnull Completable writeStringToFile(
      @Nonnull final String data,
      @Nonnull final File file,
      @Nonnull final Charset charset); @Nonnull Single<byte[]> readBytesFromFile(@Nonnull final File file); @Nonnull Completable writeBytesToFile(@Nonnull final byte[] data, @Nonnull final File file); @Nonnull Single<Boolean> exists(@Nonnull final File file); @Nonnull Single<Long> sizeInBytes(@Nonnull final File file); @Nonnull Single<Boolean> isFile(@Nonnull final File file); @Nonnull Single<Boolean> isDirectory(@Nonnull final File directory);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testGetFilesInDirectory_nullDirectory() { rxFiles.getFilesInDirectory(null); }
@Test public void testGetFilesInDirectory_directoryIsActuallyAFile() { final File file = new File(testDirectory, "test"); rxFiles .getFilesInDirectory(file) .test() .awaitDone(200, MILLISECONDS) .assertError(IOException.class) .assertNoValues(); }
@Test public void testGetFilesInDirectory_directoryDoesNotExist() throws IOException { final File directory = new File(testDirectory, "test"); rxFiles .getFilesInDirectory(directory) .test() .awaitDone(200, MILLISECONDS) .assertError(IOException.class) .assertNoValues(); }
@Test public void testGetFilesInDirectory_directoryContainsNoFiles() throws IOException { final File directory = new File(testDirectory, "test"); FileUtils.forceMkdir(directory); rxFiles .getFilesInDirectory(directory) .test() .awaitDone(200, MILLISECONDS) .assertNoErrors() .assertNoValues(); }