All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.madhead.aws_junit5.s3.v1.S3 Maven / Gradle / Ivy

There is a newer version: 7.1.2
Show newest version
package me.madhead.aws_junit5.s3.v1;

import me.madhead.aws_junit5.common.impl.AWSClientExtension;
import me.madhead.aws_junit5.common.v1.AWSClientFactory;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * Use {@link S3} to extend tests with fields that are subjects for S3 injection.
 */
public class S3 extends AWSClientExtension {
    private final static Map factories;

    static {
        factories = new HashMap<>();
        factories.put(AmazonS3.class, new AWSClientFactory<>(AmazonS3ClientBuilder.standard()));
    }

    @Override
    protected boolean supports(final Field field) {
        return factories.containsKey(field.getType());
    }

    @Override
    protected Object client(final Field field) throws Exception {
        return factories.get(field.getType()).client(field);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy