• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  *  http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 package utils.resources.tables;
17 
18 import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
19 import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition;
20 import software.amazon.awssdk.services.dynamodb.model.CreateTableRequest;
21 import software.amazon.awssdk.services.dynamodb.model.KeySchemaElement;
22 import software.amazon.awssdk.services.dynamodb.model.KeyType;
23 import software.amazon.awssdk.services.dynamodb.model.ProvisionedThroughput;
24 import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType;
25 import utils.test.resources.DynamoDBTableResource;
26 import utils.test.util.DynamoDBTestBase;
27 
28 /**
29  * DynamoDB table used by {@link ProvisionedThroughputThrottlingIntegrationTest}
30  */
31 public class BasicTempTableWithLowThroughput extends DynamoDBTableResource {
32 
33     public static final String TEMP_TABLE_NAME = "java-sdk-low-throughput-" + System.currentTimeMillis();
34     public static final String HASH_KEY_NAME = "hash";
35     public static final Long READ_CAPACITY = 1L;
36     public static final Long WRITE_CAPACITY = 1L;
37     public static final ProvisionedThroughput DEFAULT_PROVISIONED_THROUGHPUT =
38             ProvisionedThroughput.builder().readCapacityUnits(READ_CAPACITY).writeCapacityUnits(WRITE_CAPACITY).build();
39 
40     @Override
getClient()41     protected DynamoDbClient getClient() {
42         return DynamoDBTestBase.getClient();
43     }
44 
45     @Override
getCreateTableRequest()46     protected CreateTableRequest getCreateTableRequest() {
47         CreateTableRequest request = CreateTableRequest.builder()
48                 .tableName(TEMP_TABLE_NAME)
49                 .keySchema(
50                         KeySchemaElement.builder().attributeName(HASH_KEY_NAME)
51                                               .keyType(KeyType.HASH).build())
52                 .attributeDefinitions(
53                         AttributeDefinition.builder().attributeName(
54                                 HASH_KEY_NAME).attributeType(
55                                 ScalarAttributeType.S).build())
56                 .provisionedThroughput(DEFAULT_PROVISIONED_THROUGHPUT)
57                 .build();
58         return request;
59     }
60 }
61