io.github.carousell.cucumber2junit.aws.AWSDynamoService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cucumber2junit-maven-plugin Show documentation
Show all versions of cucumber2junit-maven-plugin Show documentation
Generates plain JUnit tests from Gherkin feature files. This is useful when you want to execute Cucumber tests in an environment which does not allow custom JUnit runners, e.g. the AWS Device Farm.
The newest version!
package io.github.carousell.cucumber2junit.aws;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Service class to interact with AWS Dynamo DB, basically a wrapper around {@link AmazonDynamoDB}.
*/
public class AWSDynamoService {
private static final Logger LOG = LoggerFactory.getLogger(AWSDynamoService.class);
private AmazonDynamoDB awsDynamoDB;
/**
* Constructor
*
* @param awsAccessKey the AWS access key
* @param awsSecretKey the AWS secret key
* @param awsRegion the AWS region
*/
public AWSDynamoService(String awsAccessKey, String awsSecretKey, String awsRegion) {
awsDynamoDB = buildDynamoClient(awsAccessKey, awsSecretKey, awsRegion);
}
/** @return {@link AmazonDynamoDB} */
public AmazonDynamoDB getAwsDynamo() {
return awsDynamoDB;
}
private AmazonDynamoDB buildDynamoClient(
String awsAccessKey, String awsSecretKey, String awsRegion) {
LOG.debug("Building AWS Dynamo DB client");
LOG.debug("awsAccessKey={}", awsAccessKey);
LOG.debug("awsSecretKey={}", awsSecretKey);
LOG.debug("awsRegion={}", awsRegion);
AWSCredentials awsCredentials = new BasicAWSCredentials(awsAccessKey, awsSecretKey);
AWSCredentialsProvider awsCredentialsProvider =
new AWSStaticCredentialsProvider(awsCredentials);
AmazonDynamoDBClientBuilder awsDynamoBuilder =
AmazonDynamoDBClientBuilder.standard().withRegion(awsRegion);
awsDynamoBuilder.setCredentials(awsCredentialsProvider);
return awsDynamoBuilder.build();
}
}