MarsDynamoDBManager { public static void createImageTable(final AmazonDynamoDB dynamoDB, final String tableName, final ProvisionedThroughput tableProvisionedThroughput, final ProvisionedThroughput timeGSIProvisionedThroughput, final ProvisionedThroughput voteGSIProvisionedThroughput) { final GlobalSecondaryIndex timeGSI = new GlobalSecondaryIndex(); timeGSI.setIndexName(IMAGE_TABLE_TIME_GSI_NAME); timeGSI.setKeySchema(Arrays.asList(IMAGE_TABLE_TIME_GSI_HASH_KSE, IMAGE_TABLE_TIME_GSI_RANGE_KSE)); timeGSI.setProjection(IMAGE_TABLE_TIME_GSI_PROJECTION); timeGSI.setProvisionedThroughput(timeGSIProvisionedThroughput); final GlobalSecondaryIndex voteGSI = new GlobalSecondaryIndex(); voteGSI.setIndexName(IMAGE_TABLE_VOTE_GSI_NAME); voteGSI.setKeySchema(Arrays.asList(IMAGE_TABLE_VOTE_GSI_HASH_KSE, IMAGE_TABLE_VOTE_GSI_RANGE_KSE)); voteGSI.setProjection(IMAGE_TABLE_VOTE_GSI_PROJECTION); voteGSI.setProvisionedThroughput(voteGSIProvisionedThroughput); final CreateTableRequest request = new CreateTableRequest(); request.setAttributeDefinitions(IMAGE_TABLE_ATTRIBUTE_DEFINITIONS); request.setKeySchema(IMAGE_TABLE_KEY_SCHEMA); request.setGlobalSecondaryIndexes(Arrays.asList(timeGSI, voteGSI)); request.setProvisionedThroughput(tableProvisionedThroughput); request.setTableName(tableName); LOGGER.info("Creating image table: " + request); final TableDescription result = DynamoDBManager.createTable(dynamoDB, request); LOGGER.info("Image table successfully created: " + result); } private  MarsDynamoDBManager(); static void createImageTable(final AmazonDynamoDB dynamoDB, final String tableName,
        final ProvisionedThroughput tableProvisionedThroughput,
        final ProvisionedThroughput timeGSIProvisionedThroughput,
        final ProvisionedThroughput voteGSIProvisionedThroughput); static void createResourceTable(final AmazonDynamoDB dynamoDB, final String tableName,
        final ProvisionedThroughput provisionedThroughput); static final Collection<AttributeDefinition> RESOURCE_TABLE_ATTRIBUTE_DEFINITIONS; static final String RESOURCE_TABLE_HASH_KEY; static final String IMAGE_TABLE_HASH_KEY; static final String IMAGE_TABLE_GSI_HASH_KEY; static final String IMAGE_TABLE_TIME_GSI_RANGE_KEY; static final String IMAGE_TABLE_VOTE_GSI_RANGE_KEY; static final String IMAGE_TABLE_URL_ATTRIBUTE; static final String IMAGE_TABLE_THUMBNAIL_ATTRIBUTE; static final String IMAGE_TABLE_TIME_ATTRIBUTE; static final String IMAGE_TABLE_MISSION_ATTRIBUTE; static final String IMAGE_TABLE_INSTRUMENT_ATTRIBUTE; static final Collection<AttributeDefinition> IMAGE_TABLE_ATTRIBUTE_DEFINITIONS; static final Collection<KeySchemaElement> IMAGE_TABLE_KEY_SCHEMA; static final String IMAGE_TABLE_TIME_GSI_NAME; static final Collection<String> IMAGE_TABLE_TIME_GSI_NON_KEY_PROJECTED_ATTRIBUTES; static final Projection IMAGE_TABLE_TIME_GSI_PROJECTION; static final KeySchemaElement IMAGE_TABLE_TIME_GSI_HASH_KSE; static final KeySchemaElement IMAGE_TABLE_TIME_GSI_RANGE_KSE; static final String IMAGE_TABLE_VOTE_GSI_NAME; static final Collection<String> IMAGE_TABLE_VOTE_GSI_NON_KEY_PROJECTED_ATTRIBUTES; static final Projection IMAGE_TABLE_VOTE_GSI_PROJECTION; static final KeySchemaElement IMAGE_TABLE_VOTE_GSI_HASH_KSE; static final KeySchemaElement IMAGE_TABLE_VOTE_GSI_RANGE_KSE; }
@Test public void testCreateImageTable() { final AmazonDynamoDB dynamoDB = PowerMock.createMock(AmazonDynamoDB.class); PowerMock.mockStatic(DynamoDBManager.class); final CreateTableRequest request = new CreateTableRequest(); request.setAttributeDefinitions(MarsDynamoDBManager.IMAGE_TABLE_ATTRIBUTE_DEFINITIONS); request.setKeySchema(MarsDynamoDBManager.IMAGE_TABLE_KEY_SCHEMA); final GlobalSecondaryIndex timeGSI = new GlobalSecondaryIndex(); timeGSI.setIndexName(MarsDynamoDBManager.IMAGE_TABLE_TIME_GSI_NAME); timeGSI.setKeySchema(Arrays.asList(MarsDynamoDBManager.IMAGE_TABLE_TIME_GSI_HASH_KSE, MarsDynamoDBManager.IMAGE_TABLE_TIME_GSI_RANGE_KSE)); timeGSI.setProjection(MarsDynamoDBManager.IMAGE_TABLE_TIME_GSI_PROJECTION); timeGSI.setProvisionedThroughput(PROVISIONED_THROUGHPUT); final GlobalSecondaryIndex voteGSI = new GlobalSecondaryIndex(); voteGSI.setIndexName(MarsDynamoDBManager.IMAGE_TABLE_VOTE_GSI_NAME); voteGSI.setKeySchema(Arrays.asList(MarsDynamoDBManager.IMAGE_TABLE_VOTE_GSI_HASH_KSE, MarsDynamoDBManager.IMAGE_TABLE_VOTE_GSI_RANGE_KSE)); voteGSI.setProjection(MarsDynamoDBManager.IMAGE_TABLE_VOTE_GSI_PROJECTION); voteGSI.setProvisionedThroughput(PROVISIONED_THROUGHPUT); request.setGlobalSecondaryIndexes(Arrays.asList(timeGSI, voteGSI)); request.setProvisionedThroughput(PROVISIONED_THROUGHPUT); request.setTableName(TABLE_NAME); DynamoDBManager.createTable(dynamoDB, request); PowerMock.expectLastCall().andReturn(null); PowerMock.replayAll(); MarsDynamoDBManager.createImageTable(dynamoDB, TABLE_NAME, PROVISIONED_THROUGHPUT, PROVISIONED_THROUGHPUT, PROVISIONED_THROUGHPUT); PowerMock.verifyAll(); }