@@ -0,0 +1,3128 @@
+/*%0A* Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.%0A*%0A* Licensed under the Apache License, Version 2.0 (the %22License%22).%0A* You may not use this file except in compliance with the License.%0A* A copy of the License is located at%0A*%0A*  http://aws.amazon.com/apache2.0%0A*%0A* or in the %22license%22 file accompanying this file. This file is distributed%0A* on an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either%0A* express or implied. See the License for the specific language governing%0A* permissions and limitations under the License.%0A*/%0Apackage com.microexample.geolocation.factories;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport org.junit.Test;%0A%0Aimport com.amazonaws.services.dynamodbv2.AmazonDynamoDB;%0Aimport com.amazonaws.services.dynamodbv2.local.embedded.DynamoDBEmbedded;%0Aimport com.amazonaws.services.dynamodbv2.model.*;%0A%0Apublic class InMemoryDynamoDbFactoryTests %7B%0A%0A    @Test%0A    public void createTableTest() %7B%0A        AmazonDynamoDB ddb = DynamoDBEmbedded.create().amazonDynamoDB();%0A        // AmazonDynamoDB ddb = new AmazonDynamoDbFactory().create();%0A        try %7B%0A            String tableName = %22Movies%22;%0A            String hashKeyName = %22film_id%22;%0A            CreateTableResult res = createTable(ddb, tableName, hashKeyName);%0A%0A            TableDescription tableDesc = res.getTableDescription();%0A            assertEquals(tableName, tableDesc.getTableName());%0A            assertEquals(%22%5B%7BAttributeName: %22 + hashKeyName + %22,KeyType: HASH%7D%5D%22, tableDesc.getKeySchema().toString());%0A            assertEquals(%22%5B%7BAttributeName: %22 + hashKeyName + %22,AttributeType: S%7D%5D%22,%0A                    tableDesc.getAttributeDefinitions().toString());%0A            assertEquals(Long.valueOf(1000L), tableDesc.getProvisionedThroughput().getReadCapacityUnits());%0A            assertEquals(Long.valueOf(1000L), tableDesc.getProvisionedThroughput().getWriteCapacityUnits());%0A            assertEquals(%22ACTIVE%22, tableDesc.getTableStatus());%0A            assertEquals(%22arn:aws:dynamodb:ddblocal:000000000000:table/Movies%22, tableDesc.getTableArn());%0A%0A            ListTablesResult tables = ddb.listTables();%0A            assertEquals(1, tables.getTableNames().size());%0A        %7D finally %7B%0A            ddb.shutdown();%0A        %7D%0A    %7D%0A%0A    private static CreateTableResult createTable(AmazonDynamoDB ddb, String tableName, String hashKeyName) %7B%0A        List%3CAttributeDefinition%3E attributeDefinitions = new ArrayList%3CAttributeDefinition%3E();%0A        attributeDefinitions.add(new AttributeDefinition(hashKeyName, ScalarAttributeType.S));%0A%0A        List%3CKeySchemaElement%3E ks = new ArrayList%3CKeySchemaElement%3E();%0A        ks.add(new KeySchemaElement(hashKeyName, KeyType.HASH));%0A%0A        ProvisionedThroughput provisionedthroughput = new ProvisionedThroughput(1000L, 1000L);%0A%0A        CreateTableRequest request = new CreateTableRequest().withTableName(tableName)%0A                .withAttributeDefinitions(attributeDefinitions).withKeySchema(ks)%0A                .withProvisionedThroughput(provisionedthroughput);%0A%0A        return ddb.createTable(request);%0A    %7D%0A%7D%0A

add in memory dynamodb test