* and related orders. Modify an order and flush changes back
*/
public void testRead2() throws Exception {
// Create the group and set common connection
CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CustomersOrdersConfig.xml"));
commandGroup.setConnection(getConnection());
// Read all customers and remember the first one
Command read = commandGroup.getCommand("all customers");
DataObject root = read.executeQuery();
Integer id = (Integer) root.get("CUSTOMER[1]/ID");
// Read the specific Customer from above and its related orders
Command custOrders = commandGroup.getCommand("customer and orders");
custOrders.setParameterValue("ID", id);
root = custOrders.executeQuery();
// Modify the first order and flush this change back to the database
root.setString("CUSTOMER[1]/orders[1]/PRODUCT", "Defibrillator");
Integer orderId = (Integer) root.get("CUSTOMER[1]/orders[1]/ID");
ApplyChangesCommand flush = commandGroup.getApplyChangesCommand();
flush.execute(root);
// Verify
Command orderByID = commandGroup.getCommand("order by id");
orderByID.setParameterValue("ID", orderId);
assertEquals("Defibrillator", root.getString("ANORDER[1]/PRODUCT"));
}