Search in sources :

Example 1 with ReadStreamPublisher

use of io.reactiverse.awssdk.reactivestreams.ReadStreamPublisher in project aws-sdk by reactiverse.

the class VertxS3ClientSpec method publishImageToBucket.

@Test
@Order(3)
void publishImageToBucket(Vertx vertx, VertxTestContext ctx) throws Exception {
    final Context originalContext = vertx.getOrCreateContext();
    final S3AsyncClient s3 = s3(originalContext);
    readFileFromDisk(vertx).flatMap(file -> {
        final AsyncRequestBody body = AsyncRequestBody.fromPublisher(new ReadStreamPublisher<>(file.getDelegate()));
        return single(s3.putObject(VertxS3ClientSpec::uploadImgReq, body));
    }).subscribe(putFileRes -> {
        assertContext(vertx, originalContext, ctx);
        ctx.verify(() -> {
            assertNotNull(putFileRes.eTag());
            ctx.completeNow();
        });
    }, ctx::failNow);
}
Also used : VertxTestContext(io.vertx.junit5.VertxTestContext) Context(io.vertx.core.Context) VertxTestContext(io.vertx.junit5.VertxTestContext) Bucket(software.amazon.awssdk.services.s3.model.Bucket) BeforeEach(org.junit.jupiter.api.BeforeEach) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) S3Object(software.amazon.awssdk.services.s3.model.S3Object) LocalStackBaseSpec(io.reactiverse.awssdk.integration.LocalStackBaseSpec) VertxAsyncResponseTransformer(io.reactiverse.awssdk.converters.VertxAsyncResponseTransformer) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Order(org.junit.jupiter.api.Order) Single(io.reactivex.Single) Context(io.vertx.core.Context) Timeout(io.vertx.junit5.Timeout) GetObjectResponse(software.amazon.awssdk.services.s3.model.GetObjectResponse) Mimetype(software.amazon.awssdk.core.internal.util.Mimetype) ArrayList(java.util.ArrayList) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) WriteStream(io.vertx.core.streams.WriteStream) CreateBucketRequest(software.amazon.awssdk.services.s3.model.CreateBucketRequest) GetObjectRequest(software.amazon.awssdk.services.s3.model.GetObjectRequest) Pump(io.vertx.core.streams.Pump) PutObjectRequest(software.amazon.awssdk.services.s3.model.PutObjectRequest) EnabledIfSystemProperty(org.junit.jupiter.api.condition.EnabledIfSystemProperty) AsyncResponseTransformer(software.amazon.awssdk.core.async.AsyncResponseTransformer) AsyncResult(io.vertx.core.AsyncResult) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) MessageProducer(io.vertx.core.eventbus.MessageProducer) ReadStreamPublisher(io.reactiverse.awssdk.reactivestreams.ReadStreamPublisher) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) ListObjectsRequest(software.amazon.awssdk.services.s3.model.ListObjectsRequest) OpenOptions(io.vertx.core.file.OpenOptions) S3AsyncClient(software.amazon.awssdk.services.s3.S3AsyncClient) Vertx(io.vertx.core.Vertx) LocalstackDockerExtension(cloud.localstack.docker.LocalstackDockerExtension) ListObjectsV2Request(software.amazon.awssdk.services.s3.model.ListObjectsV2Request) VertxExtension(io.vertx.junit5.VertxExtension) Future(io.vertx.core.Future) MethodOrderer(org.junit.jupiter.api.MethodOrderer) Nullable(io.vertx.codegen.annotations.Nullable) Test(org.junit.jupiter.api.Test) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Buffer(io.vertx.core.buffer.Buffer) AsyncFile(io.vertx.reactivex.core.file.AsyncFile) AsyncRequestBody(software.amazon.awssdk.core.async.AsyncRequestBody) LocalstackDockerProperties(cloud.localstack.docker.annotation.LocalstackDockerProperties) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Handler(io.vertx.core.Handler) AsyncRequestBody(software.amazon.awssdk.core.async.AsyncRequestBody) ReadStreamPublisher(io.reactiverse.awssdk.reactivestreams.ReadStreamPublisher) S3AsyncClient(software.amazon.awssdk.services.s3.S3AsyncClient) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Test(org.junit.jupiter.api.Test)

Aggregations

LocalstackDockerExtension (cloud.localstack.docker.LocalstackDockerExtension)1 LocalstackDockerProperties (cloud.localstack.docker.annotation.LocalstackDockerProperties)1 VertxAsyncResponseTransformer (io.reactiverse.awssdk.converters.VertxAsyncResponseTransformer)1 LocalStackBaseSpec (io.reactiverse.awssdk.integration.LocalStackBaseSpec)1 ReadStreamPublisher (io.reactiverse.awssdk.reactivestreams.ReadStreamPublisher)1 Single (io.reactivex.Single)1 Nullable (io.vertx.codegen.annotations.Nullable)1 AsyncResult (io.vertx.core.AsyncResult)1 Context (io.vertx.core.Context)1 Future (io.vertx.core.Future)1 Handler (io.vertx.core.Handler)1 Vertx (io.vertx.core.Vertx)1 Buffer (io.vertx.core.buffer.Buffer)1 MessageProducer (io.vertx.core.eventbus.MessageProducer)1 OpenOptions (io.vertx.core.file.OpenOptions)1 Pump (io.vertx.core.streams.Pump)1 WriteStream (io.vertx.core.streams.WriteStream)1 Timeout (io.vertx.junit5.Timeout)1 VertxExtension (io.vertx.junit5.VertxExtension)1 VertxTestContext (io.vertx.junit5.VertxTestContext)1