me.madhead.aws_junit5.sqs.v2.SQS Maven / Gradle / Ivy
package me.madhead.aws_junit5.sqs.v2;
import me.madhead.aws_junit5.common.impl.AWSClientExtension;
import me.madhead.aws_junit5.common.v2.AWSClientFactory;
import software.amazon.awssdk.services.sqs.SqsAsyncClient;
import software.amazon.awssdk.services.sqs.SqsClient;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
/**
* Use {@link SQS} to extend tests with fields that are subjects for SQS injection.
*/
public class SQS extends AWSClientExtension {
private final static Map factories;
static {
factories = new HashMap<>();
factories.put(SqsClient.class, new AWSClientFactory<>(SqsClient.builder()));
factories.put(SqsAsyncClient.class, new AWSClientFactory<>(SqsAsyncClient.builder()));
}
@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);
}
}