AISBBasedBuilder { public static NewAISBuilder create(TypesTranslator typesTranslator) { return new ActualBuilder(typesTranslator); }  static NewAISBuilder create(TypesTranslator typesTranslator); static NewAISBuilder create(String defaultSchema,
                                       TypesTranslator typesTranslator);  }
@Test public void example() { NewAISBuilder builder = AISBBasedBuilder.create(typesTranslator()); AkibanInformationSchema ais = builder.defaultSchema("sch") .table("customer").colInt("cid").colString("name", 32).pk("cid") .table("order").colInt("oid").colInt("c2").colInt("c_id").pk("oid", "c2").key("c_id", "c_id").joinTo("customer").on("c_id", "cid") .table("item").colInt("iid").colInt("o_id").colInt("o_c2").key("o_id", "o_id", "o_c2").joinTo("order").on("o_id", "oid").and("o_c2", "c2") .table("address").colInt("aid").colInt("c_id").key("c_id", "c_id").joinTo("customer").on("c_id", "cid") .ais(); Group cGroup = ais.getGroup(new TableName("sch", "customer")); Table cTable = ais.getTable("sch", "customer"); Table aTable = ais.getTable("sch", "address"); Table oTable = ais.getTable("sch", "order"); Table iTable = ais.getTable("sch", "item"); assertNotNull("customer group", cGroup); assertEquals("customer group root", cGroup.getRoot(), cTable); assertEquals("address parent", cTable, aTable.getParentJoin().getParent()); assertEquals("address join", "[JoinColumn(c_id -> cid)]", aTable.getParentJoin().getJoinColumns().toString()); assertEquals("order parent", cTable, oTable.getParentJoin().getParent()); assertEquals("order join", "[JoinColumn(c_id -> cid)]", oTable.getParentJoin().getJoinColumns().toString()); assertEquals("item parent", oTable, iTable.getParentJoin().getParent()); assertEquals("item join", "[JoinColumn(o_id -> oid), JoinColumn(o_c2 -> c2)]", iTable.getParentJoin().getJoinColumns().toString()); }
@Test public void exampleWithGroupIndexes() { NewAISBuilder builder = AISBBasedBuilder.create(typesTranslator()); AkibanInformationSchema ais = builder.defaultSchema("sch") .table("customer").colInt("cid").colString("name", 32).pk("cid") .table("order").colInt("oid").colInt("c2").colInt("c_id").pk("oid", "c2").key("c_id", "c_id").joinTo("customer").on("c_id", "cid") .table("item").colInt("iid").colInt("o_id").colInt("o_c2").key("o_id", "o_id", "o_c2").joinTo("order").on("o_id", "oid").and("o_c2", "c2") .table("address").colInt("aid").colInt("c_id").key("c_id", "c_id").joinTo("customer").on("c_id", "cid") .groupIndex("name_c2", Index.JoinType.LEFT).on("customer", "name").and("order", "c2") .groupIndex("iid_name_c2", Index.JoinType.LEFT).on("item", "iid").and("customer", "name").and("order", "c2") .ais(); Group cGroup = ais.getGroup(new TableName("sch", "customer")); Table cTable = ais.getTable("sch", "customer"); Table aTable = ais.getTable("sch", "address"); Table oTable = ais.getTable("sch", "order"); Table iTable = ais.getTable("sch", "item"); assertNotNull("customer group", cGroup); assertEquals("customer group root", cGroup.getRoot(), cTable); assertEquals("address parent", cTable, aTable.getParentJoin().getParent()); assertEquals("address join", "[JoinColumn(c_id -> cid)]", aTable.getParentJoin().getJoinColumns().toString()); assertEquals("order parent", cTable, oTable.getParentJoin().getParent()); assertEquals("order join", "[JoinColumn(c_id -> cid)]", oTable.getParentJoin().getJoinColumns().toString()); assertEquals("item parent", oTable, iTable.getParentJoin().getParent()); assertEquals("item join", "[JoinColumn(o_id -> oid), JoinColumn(o_c2 -> c2)]", iTable.getParentJoin().getJoinColumns().toString()); }