/**
* Test ability to handle multiple changes to the graph including Creates/Updates/Deletes Employs generated CUD
*/
public void testReadModifyDeleteInsertApply() throws Exception {
DAS das = DAS.FACTORY.createDAS(getConfig("basicCustomerMapping.xml"), getConnection());
// Read some customers
Command select = das.createCommand("Select * from CUSTOMER where LASTNAME = 'Williams'");
DataObject root = select.executeQuery();
DataObject cust1 = (DataObject) root.getList("CUSTOMER").get(0);
DataObject cust2 = (DataObject) root.getList("CUSTOMER").get(1);
DataObject cust3 = (DataObject) root.getList("CUSTOMER").get(2);
// Modify a customer
cust1.set("LASTNAME", "Pavick");
int cust1ID = cust1.getInt("ID");
// Save IDs before delete
int cust2ID = cust2.getInt("ID");
int cust3ID = cust3.getInt("ID");
// Delete a couple
cust2.delete();
cust3.delete();
// Create a new customer
DataObject cust4 = root.createDataObject("CUSTOMER");
cust4.set("ID", Integer.valueOf(100));
cust4.set("ADDRESS", "5528 Wells Fargo Drive");
cust4.set("LASTNAME", "Gerkin");
// Build apply changes command
das.applyChanges(root);
// Verify deletes
select = das.createCommand("Select * from CUSTOMER where ID = ?");
select.setParameter(1, Integer.valueOf(cust2ID));
root = select.executeQuery();
assertTrue(root.getList("CUSTOMER").isEmpty());
// reparameterize same command
select.setParameter(1, Integer.valueOf(cust3ID));