@Test public void testGetBytes() 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); byte[] actualData = storage.getBytes(key); assertThat(actualData, is(data)); }
@Override public byte[] getBytes(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)); } return Files.readAllBytes(fileName); }
FileBasedBlobStorage implements BlobStorage { @Override public byte[] getBytes(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)); } return Files.readAllBytes(fileName); } }
FileBasedBlobStorage implements BlobStorage { @Override public byte[] getBytes(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)); } return Files.readAllBytes(fileName); }  }
FileBasedBlobStorage implements BlobStorage { @Override public byte[] getBytes(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)); } return Files.readAllBytes(fileName); }  @Override String put(byte[] data); @Override byte[] getBytes(String key); @Override void delete(String key); }
FileBasedBlobStorage implements BlobStorage { @Override public byte[] getBytes(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)); } return Files.readAllBytes(fileName); }  @Override String put(byte[] data); @Override byte[] getBytes(String key); @Override void delete(String key);  }