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 public class BasicTempTable extends DynamoDBTableResource { 29 30 public static final String TEMP_TABLE_NAME = "java-sdk-" + System.currentTimeMillis(); 31 public static final String HASH_KEY_NAME = "hash"; 32 public static final Long READ_CAPACITY = 10L; 33 public static final Long WRITE_CAPACITY = 5L; 34 public static final ProvisionedThroughput DEFAULT_PROVISIONED_THROUGHPUT = 35 ProvisionedThroughput.builder().readCapacityUnits(READ_CAPACITY).writeCapacityUnits(WRITE_CAPACITY).build(); 36 37 @Override getClient()38 protected DynamoDbClient getClient() { 39 return DynamoDBTestBase.getClient(); 40 } 41 42 @Override getCreateTableRequest()43 protected CreateTableRequest getCreateTableRequest() { 44 CreateTableRequest request = CreateTableRequest.builder() 45 .tableName(TEMP_TABLE_NAME) 46 .keySchema( 47 KeySchemaElement.builder().attributeName(HASH_KEY_NAME) 48 .keyType(KeyType.HASH).build()) 49 .attributeDefinitions( 50 AttributeDefinition.builder().attributeName( 51 HASH_KEY_NAME).attributeType( 52 ScalarAttributeType.S).build()) 53 .provisionedThroughput(DEFAULT_PROVISIONED_THROUGHPUT).build(); 54 return request; 55 } 56 57 } 58