Source:
<code><START> void createStubItemWithGlobalSecondaryIndexTable() throws Exception { <END> final String tableName = unitTestSchemaName + "." + stubItemWithGsiTableName; boolean tableCreated = false; try { final DescribeTableResult result = amazonDynamoDbClient.describeTable(tableName); if (isTableCreated(tableName, result)) { tableCreated = true; } } catch (final ResourceNotFoundException e) { tableCreated = false; } if (!tableCreated) { final Collection<AttributeDefinition> attributeDefinitions = new ArrayList<>(); attributeDefinitions.add(new AttributeDefinition("id", ScalarAttributeType.S)); attributeDefinitions.add(new AttributeDefinition("gsi", ScalarAttributeType.S)); attributeDefinitions.add(new AttributeDefinition("gsiSupportingValue", ScalarAttributeType.N)); final Collection<KeySchemaElement> keySchema = new ArrayList<>(); keySchema.add(new KeySchemaElement("id", "S").withKeyType(KeyType.HASH)); final GlobalSecondaryIndex globalSecondaryIndex = new GlobalSecondaryIndex(); final Collection<KeySchemaElement> globalSecondaryIndexKeySchema = new ArrayList<>(); globalSecondaryIndexKeySchema.add(new KeySchemaElement("gsi", "S").withKeyType(KeyType.HASH)); globalSecondaryIndexKeySchema .add(new KeySchemaElement("gsiSupportingValue", "N").withKeyType(KeyType.RANGE)); globalSecondaryIndex.setIndexName("gsi_idx"); globalSecondaryIndex.setKeySchema(globalSecondaryIndexKeySchema); globalSecondaryIndex.setProvisionedThroughput(new ProvisionedThroughput(10L, 10L)); final Projection projection = new Projection(); projection.setProjectionType(ProjectionType.ALL); globalSecondaryIndex.setProjection(projection); final CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName) .withAttributeDefinitions(attributeDefinitions).withKeySchema(keySchema) .withGlobalSecondaryIndexes(globalSecondaryIndex) .withProvisionedThroughput(new ProvisionedThroughput(10L, 10L)); amazonDynamoDbClient.createTable(createTableRequest); final long startTime = System.currentTimeMillis(); do { Thread.sleep(1000); final DescribeTableResult describeTableResult = amazonDynamoDbClient.describeTable(tableName); tableCreated = isTableCreated(tableName, describeTableResult); } while (!tableCreated && System.currentTimeMillis() - startTime < 60000); } }</code><technical_language>default/package level visibility</technical_language>

Target:
public void createStubItemWithGlobalSecondaryIndexTable() throws Exception { final String tableName = unitTestSchemaName + "." + stubItemWithGsiTableName; boolean tableCreated = false; try { final DescribeTableResult result = amazonDynamoDbClient.describeTable(tableName); if (isTableCreated(tableName, result)) { tableCreated = true; } } catch (final ResourceNotFoundException e) { tableCreated = false; } if (!tableCreated) { final Collection<AttributeDefinition> attributeDefinitions = new ArrayList<>(); attributeDefinitions.add(new AttributeDefinition("id", ScalarAttributeType.S)); attributeDefinitions.add(new AttributeDefinition("gsi", ScalarAttributeType.S)); attributeDefinitions.add(new AttributeDefinition("gsiSupportingValue", ScalarAttributeType.N)); final Collection<KeySchemaElement> keySchema = new ArrayList<>(); keySchema.add(new KeySchemaElement("id", "S").withKeyType(KeyType.HASH)); final GlobalSecondaryIndex globalSecondaryIndex = new GlobalSecondaryIndex(); final Collection<KeySchemaElement> globalSecondaryIndexKeySchema = new ArrayList<>(); globalSecondaryIndexKeySchema.add(new KeySchemaElement("gsi", "S").withKeyType(KeyType.HASH)); globalSecondaryIndexKeySchema .add(new KeySchemaElement("gsiSupportingValue", "N").withKeyType(KeyType.RANGE)); globalSecondaryIndex.setIndexName("gsi_idx"); globalSecondaryIndex.setKeySchema(globalSecondaryIndexKeySchema); globalSecondaryIndex.setProvisionedThroughput(new ProvisionedThroughput(10L, 10L)); final Projection projection = new Projection(); projection.setProjectionType(ProjectionType.ALL); globalSecondaryIndex.setProjection(projection); final CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName) .withAttributeDefinitions(attributeDefinitions).withKeySchema(keySchema) .withGlobalSecondaryIndexes(globalSecondaryIndex) .withProvisionedThroughput(new ProvisionedThroughput(10L, 10L)); amazonDynamoDbClient.createTable(createTableRequest); final long startTime = System.currentTimeMillis(); do { Thread.sleep(1000); final DescribeTableResult describeTableResult = amazonDynamoDbClient.describeTable(tableName); tableCreated = isTableCreated(tableName, describeTableResult); } while (!tableCreated && System.currentTimeMillis() - startTime < 60000); } }