### Question:
RxFiles { @Nonnull public Completable createNewFile(@Nonnull final File file) { checkNotNull(file, "\'file\' must not be null."); final Completable createFile = Single .fromCallable(file::createNewFile) .flatMapCompletable(createdSuccessfully -> createdSuccessfully ? Completable.complete() : Completable.error(makeError("Failed to create file", file, "Reason unknown"))); return exists(file) .flatMapCompletable(exists -> exists ? Completable.error(makeError( "Failed to create file", file, "A file or directory already exists at the location")) : exists(file.getParentFile()) .flatMapCompletable(parentExists -> parentExists ? createFile : Completable.error(makeError("Failed to create file", file, "The parent 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 testCreateNewFile_nullFile() { rxFiles.createNewFile(null); }
@Test public void testCreateNewFile_fileAlreadyExistsAsAFile() throws IOException { final File file = new File(testDirectory, "test.txt"); file.createNewFile(); rxFiles .createNewFile(file) .test() .awaitDone(200, MILLISECONDS) .assertError(IOException.class) .assertNotComplete(); }
@Test public void testCreateNewFile_fileAlreadyExistsAsADirectory() throws IOException { final File directory = new File(testDirectory, "test"); FileUtils.forceMkdir(directory); rxFiles .createNewFile(directory) .test() .awaitDone(200, MILLISECONDS) .assertError(IOException.class) .assertNotComplete(); }