@Test void testStore() throws IOException, XmlPullParserException, NoSuchAlgorithmException, InvalidKeyException, InvalidArgumentException, InternalException, NoResponseException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException { ReadableByteChannel fromChannel = mock(ReadableByteChannel.class); String blobId = "MyBlobId"; when(idGenerator.generateId()).thenReturn(blobId); long size = 3L; ObjectStat objectStat = when(mock(ObjectStat.class).length()).thenReturn(size).getMock(); when(minioClientFacade.statObject(blobId)).thenReturn(objectStat); assertEquals(create(blobId, size), minioBlobStore.store(fromChannel)); verify(minioClientFacade) .putObject(eq(blobId), any(InputStream.class), eq("application/octet-stream")); }
@Override public BlobMetadata store(ReadableByteChannel fromChannel) { String blobId = generateBlobId(); String contentType = "application/octet-stream"; InputStream inputStream = Channels.newInputStream(fromChannel); try { minioClientFacade.putObject(blobId, inputStream, contentType); } catch (IOException e) { throw new UncheckedIOException(e); } catch (InvalidBucketNameException | NoSuchAlgorithmException | InvalidKeyException | NoResponseException | XmlPullParserException | ErrorResponseException | InternalException | InvalidArgumentException | InsufficientDataException e) { throw new UncheckedIOException(new IOException(e)); } ObjectStat objectStat; try { objectStat = minioClientFacade.statObject(blobId); } catch (IOException e) { throw new UncheckedIOException(e); } catch (InvalidBucketNameException | NoSuchAlgorithmException | InsufficientDataException | InvalidKeyException | NoResponseException | XmlPullParserException | ErrorResponseException | InternalException e) { throw new UncheckedIOException(new IOException(e)); } long size = objectStat.length(); return BlobMetadata.builder().setId(blobId).setSize(size).build(); }
MinioBlobStore implements BlobStore { @Override public BlobMetadata store(ReadableByteChannel fromChannel) { String blobId = generateBlobId(); String contentType = "application/octet-stream"; InputStream inputStream = Channels.newInputStream(fromChannel); try { minioClientFacade.putObject(blobId, inputStream, contentType); } catch (IOException e) { throw new UncheckedIOException(e); } catch (InvalidBucketNameException | NoSuchAlgorithmException | InvalidKeyException | NoResponseException | XmlPullParserException | ErrorResponseException | InternalException | InvalidArgumentException | InsufficientDataException e) { throw new UncheckedIOException(new IOException(e)); } ObjectStat objectStat; try { objectStat = minioClientFacade.statObject(blobId); } catch (IOException e) { throw new UncheckedIOException(e); } catch (InvalidBucketNameException | NoSuchAlgorithmException | InsufficientDataException | InvalidKeyException | NoResponseException | XmlPullParserException | ErrorResponseException | InternalException e) { throw new UncheckedIOException(new IOException(e)); } long size = objectStat.length(); return BlobMetadata.builder().setId(blobId).setSize(size).build(); } }
MinioBlobStore implements BlobStore { @Override public BlobMetadata store(ReadableByteChannel fromChannel) { String blobId = generateBlobId(); String contentType = "application/octet-stream"; InputStream inputStream = Channels.newInputStream(fromChannel); try { minioClientFacade.putObject(blobId, inputStream, contentType); } catch (IOException e) { throw new UncheckedIOException(e); } catch (InvalidBucketNameException | NoSuchAlgorithmException | InvalidKeyException | NoResponseException | XmlPullParserException | ErrorResponseException | InternalException | InvalidArgumentException | InsufficientDataException e) { throw new UncheckedIOException(new IOException(e)); } ObjectStat objectStat; try { objectStat = minioClientFacade.statObject(blobId); } catch (IOException e) { throw new UncheckedIOException(e); } catch (InvalidBucketNameException | NoSuchAlgorithmException | InsufficientDataException | InvalidKeyException | NoResponseException | XmlPullParserException | ErrorResponseException | InternalException e) { throw new UncheckedIOException(new IOException(e)); } long size = objectStat.length(); return BlobMetadata.builder().setId(blobId).setSize(size).build(); } MinioBlobStore(MinioClientFacade minioClientFacade, IdGenerator idGenerator); }
MinioBlobStore implements BlobStore { @Override public BlobMetadata store(ReadableByteChannel fromChannel) { String blobId = generateBlobId(); String contentType = "application/octet-stream"; InputStream inputStream = Channels.newInputStream(fromChannel); try { minioClientFacade.putObject(blobId, inputStream, contentType); } catch (IOException e) { throw new UncheckedIOException(e); } catch (InvalidBucketNameException | NoSuchAlgorithmException | InvalidKeyException | NoResponseException | XmlPullParserException | ErrorResponseException | InternalException | InvalidArgumentException | InsufficientDataException e) { throw new UncheckedIOException(new IOException(e)); } ObjectStat objectStat; try { objectStat = minioClientFacade.statObject(blobId); } catch (IOException e) { throw new UncheckedIOException(e); } catch (InvalidBucketNameException | NoSuchAlgorithmException | InsufficientDataException | InvalidKeyException | NoResponseException | XmlPullParserException | ErrorResponseException | InternalException e) { throw new UncheckedIOException(new IOException(e)); } long size = objectStat.length(); return BlobMetadata.builder().setId(blobId).setSize(size).build(); } MinioBlobStore(MinioClientFacade minioClientFacade, IdGenerator idGenerator); @Override BlobMetadata store(ReadableByteChannel fromChannel); @Override void delete(String blobId); @Override ReadableByteChannel newChannel(String blobId); }
MinioBlobStore implements BlobStore { @Override public BlobMetadata store(ReadableByteChannel fromChannel) { String blobId = generateBlobId(); String contentType = "application/octet-stream"; InputStream inputStream = Channels.newInputStream(fromChannel); try { minioClientFacade.putObject(blobId, inputStream, contentType); } catch (IOException e) { throw new UncheckedIOException(e); } catch (InvalidBucketNameException | NoSuchAlgorithmException | InvalidKeyException | NoResponseException | XmlPullParserException | ErrorResponseException | InternalException | InvalidArgumentException | InsufficientDataException e) { throw new UncheckedIOException(new IOException(e)); } ObjectStat objectStat; try { objectStat = minioClientFacade.statObject(blobId); } catch (IOException e) { throw new UncheckedIOException(e); } catch (InvalidBucketNameException | NoSuchAlgorithmException | InsufficientDataException | InvalidKeyException | NoResponseException | XmlPullParserException | ErrorResponseException | InternalException e) { throw new UncheckedIOException(new IOException(e)); } long size = objectStat.length(); return BlobMetadata.builder().setId(blobId).setSize(size).build(); } MinioBlobStore(MinioClientFacade minioClientFacade, IdGenerator idGenerator); @Override BlobMetadata store(ReadableByteChannel fromChannel); @Override void delete(String blobId); @Override ReadableByteChannel newChannel(String blobId);  }