Search in sources :

Example 1 with ProductInfoRepository

use of com.baeldung.dynamodb.repository.ProductInfoRepository in project tutorials by eugenp.

the class ProductInfoRepositoryIntegrationTest method setup.

@Before
public void setup() {
    try {
        repository = new ProductInfoRepository();
        repository.setMapper(dynamoDBMapper);
        CreateTableRequest tableRequest = dynamoDBMapper.generateCreateTableRequest(ProductInfo.class);
        tableRequest.setProvisionedThroughput(new ProvisionedThroughput(1L, 1L));
        amazonDynamoDB.createTable(tableRequest);
    } catch (ResourceInUseException e) {
    // Do nothing, table already created
    }
    // TODO How to handle different environments. i.e. AVOID deleting all entries in ProductInfo on table
    dynamoDBMapper.batchDelete((List<ProductInfo>) repository.findAll());
}
Also used : ProductInfoRepository(com.baeldung.dynamodb.repository.ProductInfoRepository) ProductInfo(com.baeldung.dynamodb.entity.ProductInfo) ResourceInUseException(com.amazonaws.services.dynamodbv2.model.ResourceInUseException) ProvisionedThroughput(com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput) CreateTableRequest(com.amazonaws.services.dynamodbv2.model.CreateTableRequest) Before(org.junit.Before)

Aggregations

CreateTableRequest (com.amazonaws.services.dynamodbv2.model.CreateTableRequest)1 ProvisionedThroughput (com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput)1 ResourceInUseException (com.amazonaws.services.dynamodbv2.model.ResourceInUseException)1 ProductInfo (com.baeldung.dynamodb.entity.ProductInfo)1 ProductInfoRepository (com.baeldung.dynamodb.repository.ProductInfoRepository)1 Before (org.junit.Before)1