Jahir
Jahir

Reputation: 778

Creating a mock S3Response object

I have a piece of code that calls S3 API and it returns an object of [S3Response][1Ω type. But I want to create this S3Response object manually without calling the S3 API. How can I do that?

As far as I tested, the S3Response class does not expose any methods that you can use to instantiate an object and populate the values. But at the end of the day, this is just another Java object so I'm guessing there is some way of creating an S3Response object from scratch without dealing with the S3 API.

Upvotes: 2

Views: 473

Answers (1)

Youcef LAIDANI
Youcef LAIDANI

Reputation: 59950

I'm not sure why you want to do this, but there are many implementations using the builder pattern you can use for example:

S3Response response = CreateBucketResponse.builder(). /*...*/ .build();
S3Response response = CopyObjectResponse.builder(). /*...*/ .build();
S3Response response = AbortMultipartUploadResponse.builder(). /*...*/ .build();
...
...

You can find the full list of implementations in the documentation Package software.amazon.awssdk.services.s3.model

Upvotes: 2

Related Questions