### Question:
Cache { 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)); } private  Cache(CacheStorageFiles cacheStorageFiles); static Cache withDirectory(Path cacheDirectory); void writeMetadata(ImageReference imageReference, ImageMetadataTemplate metadata); void writeMetadata(
      ImageReference imageReference,
      BuildableManifestTemplate manifest,
      ContainerConfigurationTemplate containerConfiguration); void writeMetadata(ImageReference imageReference, V21ManifestTemplate manifestTemplate); CachedLayer writeCompressedLayer(Blob compressedLayerBlob); CachedLayer writeUncompressedLayer(
      Blob uncompressedLayerBlob, ImmutableList<FileEntry> layerEntries); CachedLayer writeTarLayer(DescriptorDigest diffId, Blob compressedBlob); void writeLocalConfig(
      DescriptorDigest imageId, ContainerConfigurationTemplate containerConfiguration); Optional<ImageMetadataTemplate> retrieveMetadata(ImageReference imageReference); Optional<CachedLayer> retrieve(ImmutableList<FileEntry> layerEntries); Optional<CachedLayer> retrieve(DescriptorDigest layerDigest); Optional<CachedLayer> retrieveTarLayer(DescriptorDigest diffId); Optional<ContainerConfigurationTemplate> retrieveLocalConfig(DescriptorDigest imageId);  }### Answer:
@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)); } }