@Test public void updateItemInTableTest() { AttributeValue hash = putItemInDb(); Map<String, AttributeValueUpdate> attrToUp = new HashMap<String, AttributeValueUpdate>(); AttributeValueUpdate update = new AttributeValueUpdate(); update.setAction("PUT"); update.setValue(hash); attrToUp.put("updated", update); Key key = new Key(hash); UpdateItemRequest request = new UpdateItemRequest(tableName, key, attrToUp); UpdateItemResult res = getClient().updateItem(request); Assert.assertNotNull(res); Assert.assertNotNull(res.getAttributes()); }
@Test public void updateItemWithoutKeyTest() { AttributeValue hash = putItemInDb(); Map<String, AttributeValueUpdate> attrToUp = new HashMap<String, AttributeValueUpdate>(); AttributeValueUpdate update = new AttributeValueUpdate(); update.setAction("PUT"); update.setValue(hash); attrToUp.put("updated", update); Key key = new Key(hash); UpdateItemRequest request = new UpdateItemRequest(); request.setTableName(tableName); request.setAttributeUpdates(attrToUp); try { getClient().updateItem(request); Assert.assertTrue(false); // Should have thrown an exception } catch (AmazonServiceException ase) { } }