Search in sources :

Example 1 with DynamoDbHelper

use of com.formkiq.stacks.dynamodb.DynamoDbHelper in project formkiq-core by formkiq.

the class DynamoDbExtension method beforeAll.

@Override
public void beforeAll(final ExtensionContext context) throws Exception {
    this.dynamoDbLocal = DynamoDbTestServices.getDynamoDbLocal();
    this.dynamoDbLocal.start();
    this.dbConnection = DynamoDbTestServices.getDynamoDbConnection(this.dynamoDbLocal);
    this.dbhelper = new DynamoDbHelper(DynamoDbTestServices.getDynamoDbConnection(this.dynamoDbLocal));
    DynamoDbHelper dbHelper = new DynamoDbHelper(this.dbConnection);
    if (!dbHelper.isDocumentsTableExists()) {
        dbHelper.createDocumentsTable();
    }
    if (!dbHelper.isCacheTableExists()) {
        dbHelper.createCacheTable();
    }
}
Also used : DynamoDbHelper(com.formkiq.stacks.dynamodb.DynamoDbHelper)

Example 2 with DynamoDbHelper

use of com.formkiq.stacks.dynamodb.DynamoDbHelper in project formkiq-core by formkiq.

the class DocumentsRestrictionsMaxContentLengthTest method before.

/**
 * Before Tests.
 * @throws URISyntaxException URISyntaxException
 * @throws IOException IOException
 */
@BeforeEach
public void before() throws URISyntaxException, IOException {
    DynamoDbConnectionBuilder adb = DynamoDbTestServices.getDynamoDbConnection(null);
    DynamoDbHelper dbhelper = new DynamoDbHelper(adb);
    this.awsservice = new AwsServiceCache().dbConnection(adb, dbhelper.getDocumentTable(), "").appEnvironment("unittest");
}
Also used : DynamoDbHelper(com.formkiq.stacks.dynamodb.DynamoDbHelper) AwsServiceCache(com.formkiq.lambda.apigateway.AwsServiceCache) DynamoDbConnectionBuilder(com.formkiq.stacks.dynamodb.DynamoDbConnectionBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with DynamoDbHelper

use of com.formkiq.stacks.dynamodb.DynamoDbHelper in project formkiq-core by formkiq.

the class DocumentsS3UpdateTest method beforeClass.

/**
 * Before Class.
 *
 * @throws URISyntaxException URISyntaxException
 * @throws InterruptedException InterruptedException
 * @throws IOException IOException
 */
@BeforeAll
public static void beforeClass() throws URISyntaxException, InterruptedException, IOException {
    Region region = Region.US_EAST_1;
    AwsCredentialsProvider cred = StaticCredentialsProvider.create(AwsSessionCredentials.create("ACCESSKEY", "SECRETKEY", "TOKENKEY"));
    localstack.start();
    snsBuilder = new SnsConnectionBuilder().setEndpointOverride(localstack.getEndpointOverride(Service.SNS).toString()).setRegion(region).setCredentials(cred);
    sqsBuilder = new SqsConnectionBuilder().setEndpointOverride(localstack.getEndpointOverride(Service.SQS).toString()).setRegion(region).setCredentials(cred);
    sqsService = new SqsService(sqsBuilder);
    s3Builder = new S3ConnectionBuilder().setEndpointOverride(localstack.getEndpointOverride(Service.S3).toString()).setRegion(region).setCredentials(cred);
    dbBuilder = DynamoDbTestServices.getDynamoDbConnection(null);
    service = new DocumentServiceImpl(dbBuilder, "Documents");
    if (!sqsService.exists(ERROR_SQS_QUEUE)) {
        sqsService.createQueue(ERROR_SQS_QUEUE);
    }
    if (!sqsService.exists(SNS_SQS_CREATE_QUEUE)) {
        sqsDocumentEventUrl = sqsService.createQueue(SNS_SQS_CREATE_QUEUE).queueUrl();
    }
    s3service = new S3Service(s3Builder);
    try (S3Client s3 = s3service.buildClient()) {
        s3service.createBucket(s3, "example-bucket");
    }
    snsService = new SnsService(snsBuilder);
    snsDocumentEvent = snsService.createTopic("createDocument1").topicArn();
    snsService.subscribe(snsDocumentEvent, "sqs", sqsDocumentEventUrl);
    dbHelper = new DynamoDbHelper(dbBuilder);
    if (!dbHelper.isDocumentsTableExists()) {
        dbHelper.createDocumentsTable();
        dbHelper.createCacheTable();
    }
}
Also used : DocumentServiceImpl(com.formkiq.stacks.dynamodb.DocumentServiceImpl) DynamoDbHelper(com.formkiq.stacks.dynamodb.DynamoDbHelper) SqsConnectionBuilder(com.formkiq.aws.sqs.SqsConnectionBuilder) SnsService(com.formkiq.aws.sns.SnsService) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) SqsService(com.formkiq.aws.sqs.SqsService) S3ConnectionBuilder(com.formkiq.aws.s3.S3ConnectionBuilder) Region(software.amazon.awssdk.regions.Region) SnsConnectionBuilder(com.formkiq.aws.sns.SnsConnectionBuilder) S3Client(software.amazon.awssdk.services.s3.S3Client) S3Service(com.formkiq.aws.s3.S3Service) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 4 with DynamoDbHelper

use of com.formkiq.stacks.dynamodb.DynamoDbHelper in project formkiq-core by formkiq.

the class DynamoDbExtension method beforeAll.

@Override
public void beforeAll(final ExtensionContext context) throws Exception {
    this.dynamoDbLocal = DynamoDbTestServices.getDynamoDbLocal();
    this.dynamoDbLocal.start();
    this.dbConnection = DynamoDbTestServices.getDynamoDbConnection(this.dynamoDbLocal);
    this.dbhelper = new DynamoDbHelper(DynamoDbTestServices.getDynamoDbConnection(this.dynamoDbLocal));
    DynamoDbHelper dbHelper = new DynamoDbHelper(this.dbConnection);
    if (!dbHelper.isDocumentsTableExists()) {
        dbHelper.createDocumentsTable();
    }
    if (!dbHelper.isCacheTableExists()) {
        dbHelper.createCacheTable();
    }
}
Also used : DynamoDbHelper(com.formkiq.stacks.dynamodb.DynamoDbHelper)

Aggregations

DynamoDbHelper (com.formkiq.stacks.dynamodb.DynamoDbHelper)4 S3ConnectionBuilder (com.formkiq.aws.s3.S3ConnectionBuilder)1 S3Service (com.formkiq.aws.s3.S3Service)1 SnsConnectionBuilder (com.formkiq.aws.sns.SnsConnectionBuilder)1 SnsService (com.formkiq.aws.sns.SnsService)1 SqsConnectionBuilder (com.formkiq.aws.sqs.SqsConnectionBuilder)1 SqsService (com.formkiq.aws.sqs.SqsService)1 AwsServiceCache (com.formkiq.lambda.apigateway.AwsServiceCache)1 DocumentServiceImpl (com.formkiq.stacks.dynamodb.DocumentServiceImpl)1 DynamoDbConnectionBuilder (com.formkiq.stacks.dynamodb.DynamoDbConnectionBuilder)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 AwsCredentialsProvider (software.amazon.awssdk.auth.credentials.AwsCredentialsProvider)1 Region (software.amazon.awssdk.regions.Region)1 S3Client (software.amazon.awssdk.services.s3.S3Client)1