@Test
public void testMoveTreeToEmptyGroup()
{

    AISBuilder builder = new AISBuilder();
    // Source group tables: a(b(c, d))
    builder.table("s", "a");
    builder.column("s", "a", "aid", 0, type("MCOMPAT", "int", false), false, null, null);
    builder.pk("s", "a");
    builder.indexColumn("s", "a", Index.PRIMARY, "aid", 0, true, null);
    builder.table("s", "b");
    builder.column("s", "b", "bid", 0, type("MCOMPAT", "int", false), false, null, null);
    builder.column("s", "b", "aid", 1, type("MCOMPAT", "int", false), false, null, null);
    builder.pk("s", "b");
    builder.indexColumn("s", "b", Index.PRIMARY, "bid", 0, true, null);
    builder.table("s", "c");
    builder.column("s", "c", "cid", 0, type("MCOMPAT", "int", false), false, null, null);
    builder.column("s", "c", "bid", 1, type("MCOMPAT", "int", false), false, null, null);
    builder.table("s", "d");
    builder.column("s", "d", "did", 0, type("MCOMPAT", "int", false), false, null, null);
    builder.column("s", "d", "bid", 1, type("MCOMPAT", "int", false), false, null, null);
    builder.joinTables("ab", "s", "a", "s", "b");
    builder.joinColumns("ab", "s", "a", "aid", "s", "b", "aid");
    builder.joinTables("bc", "s", "b", "s", "c");
    builder.joinColumns("bc", "s", "b", "bid", "s", "c", "bid");
    builder.joinTables("bd", "s", "b", "s", "d");
    builder.joinColumns("bd", "s", "b", "bid", "s", "d", "bid");
    // Source and target groups
    builder.basicSchemaIsComplete();
    builder.createGroup("source", "g");
    builder.addJoinToGroup("source", "ab", 0);
    builder.addJoinToGroup("source", "bc", 0);
    builder.addJoinToGroup("source", "bd", 0);
    builder.createGroup("target", "g");
    AkibanInformationSchema ais = builder.akibanInformationSchema();
    Assert.assertEquals(4, ais.getTables().size());
    Assert.assertEquals(2, ais.getGroups().size());
    Assert.assertEquals(3, ais.getJoins().size());
    // Move b to target
    builder.moveTreeToEmptyGroup("s", "b", "target");
    builder.groupingIsComplete();
    Table a = ais.getTable("s", "a");
    List<Join> aChildren = a.getChildJoins();
    Assert.assertTrue(aChildren.isEmpty());
    Table b = ais.getTable("s", "b");
    for (Join join : b.getChildJoins()) {
        if (join.getChild() == ais.getTable("s", "c") ||
            join.getChild() == ais.getTable("s", "d")) {
        } else {
            Assert.fail();
        }
    }
    Assert.assertEquals(0, 
            builder.akibanInformationSchema().validate(AISValidations.BASIC_VALIDATIONS).failures().size());
}