### Question:
PersistenceOperations { @Nonnull public Single<Boolean> directoryContainsRecoverySchemeFiles(@Nonnull final File directory) { checkNotNull(directory, "\'directory\' must not be null."); return rxFiles .getFilesInDirectory(directory) .map(File::getName) .map(name -> name.matches("recovery-scheme")) .reduce(true, (noPreviousMatches, thisMatches) -> noPreviousMatches && !thisMatches) .map(noMatches -> !noMatches); } PersistenceOperations(
      @Nonnull final ShareSerialiser shareSerialiser,
      @Nonnull final RecoverySchemeSerialiser recoverySchemeSerialiser,
      @Nonnull final RxFiles rxFiles); @Nonnull Completable saveShareToFile(@Nonnull final Share share, @Nonnull final File file); @Nonnull Completable saveRecoverySchemeToFile(@Nonnull final RecoveryScheme recoveryScheme, @Nonnull final File file); @Nonnull Single<File> defineNewShareFile(@Nonnull final Share share, @Nonnull final File directory); @Nonnull Single<File> defineNewRecoverySchemeFile(@Nonnull final File directory); @Nonnull Single<Boolean> directoryContainsShareFiles(@Nonnull final File directory); @Nonnull Single<Boolean> directoryContainsRecoverySchemeFiles(@Nonnull final File directory);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testDirectoryContainsRecoveryScheme_nullDirectory() { persistenceOperations.directoryContainsRecoverySchemeFiles(null); }
@Test public void testDirectoryContainsRecoverySchemeFile_directoryDoesNotContainsRecoverySchemeFile() { final File directory = new File("test"); final List<File> files = ImmutableList.of( new File("recover-scheme"), new File("recovery-schme"), new File("recovery"), new File("scheme"), new File("-"), new File("recovery--scheme")); when(rxFiles.getFilesInDirectory(directory)).thenReturn(Observable.fromIterable(files)); persistenceOperations .directoryContainsRecoverySchemeFiles(directory) .test() .awaitDone(200, MILLISECONDS) .assertNoErrors() .assertValue(false); }
@Test public void testDirectoryContainsRecoverySchemeFile_directoryContainsRecoverySchemeFile() { final File directory = new File("test"); when(rxFiles.getFilesInDirectory(directory)).thenReturn(Observable.just(new File("recovery-scheme"))); persistenceOperations .directoryContainsRecoverySchemeFiles(directory) .test() .awaitDone(200, MILLISECONDS) .assertNoErrors() .assertValue(true); }