int t2 = ddl().getTableId(session(), new TableName(SCHEMA, "t2"));
Schema schema = SchemaCache.globalSchema(ddl().getAIS(session()));
RowType t1Type = schema.tableRowType(getTable(t1));
RowType t2Type = schema.tableRowType(getTable(t2));
StoreAdapter adapter = newStoreAdapter(schema);
txnService().beginTransaction(session());
Object[] r1 = { 1L, "MA", "Massachusetts" };
Object[] r101 = { 101L, 1L, "Boston" };
Object[] r102 = { 102L, 1L, "Cambridge" };
Object[] r2 = { 2L, "NY", "New York" };
Object[] r201 = { 201L, 2L, "New York" };
Object[] r202 = { 202L, 2L, "Albany" };
writeRow(t1, r1);
writeRow(t2, r101);
writeRow(t2, r102);
writeRow(t1, r2);
writeRow(t2, r201);
writeRow(t2, r202);
List<Object> raw = Arrays.<Object>asList(
Arrays.asList(Arrays.asList(1L, 1L, "abbrev"), Arrays.asList("MA")),
Arrays.asList(Arrays.asList(1L, 1L, "id"), Arrays.asList(1L)),
Arrays.asList(Arrays.asList(1L, 1L, "name"), Arrays.asList("Massachusetts")),
Arrays.asList(Arrays.asList(1L, 1L, 2L, 101L, "id"), Arrays.asList(101L)),
Arrays.asList(Arrays.asList(1L, 1L, 2L, 101L, "name"), Arrays.asList("Boston")),
Arrays.asList(Arrays.asList(1L, 1L, 2L, 101L, "sid"), Arrays.asList(1L)),
Arrays.asList(Arrays.asList(1L, 1L, 2L, 102L, "id"), Arrays.asList(102L)),
Arrays.asList(Arrays.asList(1L, 1L, 2L, 102L, "name"), Arrays.asList("Cambridge")),
Arrays.asList(Arrays.asList(1L, 1L, 2L, 102L, "sid"), Arrays.asList(1L)),
Arrays.asList(Arrays.asList(1L, 2L, "abbrev"), Arrays.asList("NY")),
Arrays.asList(Arrays.asList(1L, 2L, "id"), Arrays.asList(2L)),
Arrays.asList(Arrays.asList(1L, 2L, "name"), Arrays.asList("New York")),
Arrays.asList(Arrays.asList(1L, 2L, 2L, 201L, "id"), Arrays.asList(201L)),
Arrays.asList(Arrays.asList(1L, 2L, 2L, 201L, "name"), Arrays.asList("New York")),
Arrays.asList(Arrays.asList(1L, 2L, 2L, 201L, "sid"), Arrays.asList(2L)),
Arrays.asList(Arrays.asList(1L, 2L, 2L, 202L, "id"), Arrays.asList(202L)),
Arrays.asList(Arrays.asList(1L, 2L, 2L, 202L, "name"), Arrays.asList("Albany")),
Arrays.asList(Arrays.asList(1L, 2L, 2L, 202L, "sid"), Arrays.asList(2L))
);
assertEquals(raw, treeTuples(t1Type.table().getGroup()));
Row[] expected = {
new TestRow(t1Type, r1),
new TestRow(t2Type, r101),
new TestRow(t2Type, r102),
new TestRow(t1Type, r2),
new TestRow(t2Type, r201),
new TestRow(t2Type, r202)
};
compareRows(expected, adapter.newGroupCursor(t1Type.table().getGroup()));
txnService().commitTransaction(session());
}