I'm working on a project where we need to customize the library a bit. This is quite hard to do because lots of methods are private or some fields are final.
Some examples:
Problem 1: Partition key
Requirement: Use a custom partition key to publish files to the manifest stream. This may be required when you need to run COPY commands in parallel to different tables.
//S3ManifestEmitter.java
// Use constant partition key to ensure file order
putRecordRequest.setPartitionKey(manifestStream);
Problem: To change that piece of code, we had to copy-paste the whole emit method.
Problem 2: Mock S3Client
Requirement: I want to unit test a module that extends S3Emitter. For that, I want to mock AmazonS3Client so it does not call the real service.
//S3Emitter.java
public S3Emitter(KinesisConnectorConfiguration configuration) {
s3Bucket = configuration.S3_BUCKET;
s3Endpoint = configuration.S3_ENDPOINT;
s3client = new AmazonS3Client(configuration.AWS_CREDENTIALS_PROVIDER);
if (s3Endpoint != null) {
s3client.setEndpoint(s3Endpoint);
}
}
Problem: There is no way to mock the S3Client because it is created inside the constructor. There is no constructor that receives the client. I ended up copy-pasting the whole class.
I'm working on a project where we need to customize the library a bit. This is quite hard to do because lots of methods are private or some fields are final.
Some examples:
Problem 1: Partition key
Problem 2: Mock S3Client