public static Cache withDirectory(Path cacheDirectory) throws CacheDirectoryCreationException {
    try {
      Files.createDirectories(cacheDirectory);
    } catch (IOException ex) {
      throw new CacheDirectoryCreationException(ex);
    }
    return new Cache(new CacheStorageFiles(cacheDirectory));
  }
@Test
  public void testWithDirectory_existsButNotDirectory() throws IOException {
    Path file = temporaryFolder.newFile().toPath();

    try {
      Cache.withDirectory(file);
      Assert.fail();

    } catch (CacheDirectoryCreationException ex) {
      MatcherAssert.assertThat(
          ex.getCause(), CoreMatchers.instanceOf(FileAlreadyExistsException.class));
    }
  }