// Test: put item with HashKey @Test public void putItemWithHashKey() { KeySchema schema = new KeySchema( new KeySchemaElement() .withAttributeName("id") .withAttributeType(ScalarAttributeType.S)); createTable(tableName, schema); PutItemRequest request = new PutItemRequest().withTableName(tableName).withItem(createGenericItem()); PutItemResult res = getClient().putItem(request); Assert.assertNotNull(res); Assert.assertNotNull(res.getConsumedCapacityUnits()); }
@Test public void putItemWithHashKeyAndRangeKeyOverwriteItem() { KeySchema schema = new KeySchema( new KeySchemaElement() .withAttributeName("id") .withAttributeType(ScalarAttributeType.S)); schema.setRangeKeyElement( new KeySchemaElement().withAttributeName("range").withAttributeType(ScalarAttributeType.S)); createTable(tableName, schema); PutItemRequest request = new PutItemRequest().withTableName(tableName).withItem(createGenericItem()); getClient().putItem(request); // put item beforehand PutItemResult res = getClient().putItem(request); // Add another Assert.assertNotNull(res); Assert.assertNotNull(res.getConsumedCapacityUnits()); }