FileBasedBlobStorage implements BlobStorage { @Override public void delete(String key) throws BlobNotFoundException, IOException { Path fileName = getFileName(key); if (!Files.exists(fileName)) { throw new BlobNotFoundException(String.format( "There is no blob with the key %s", key)); } Files.delete(fileName); }  @Override String put(byte[] data); @Override byte[] getBytes(String key); @Override void delete(String key);  }
@Test public void testDelete() throws Exception { byte[] data = new byte[] { 4, 5, 6, 7 }; String key = "the-key"; Path blobPath = dataDirectory.resolve("blobs").resolve(key); Files.createDirectories(blobPath.getParent()); Files.write(blobPath, data); storage.delete(key); assertFalse("Blob file " + blobPath + " has not been deleted", Files.exists(blobPath)); }