IndexIDValidation implements AISValidation { @Override public void validate(AkibanInformationSchema ais, AISValidationOutput output) { ais.visit(new IndexIDVisitor(output)); }  @Override void validate(AkibanInformationSchema ais, AISValidationOutput output);  }
@Test(expected=DuplicateIndexIdException.class) public void dupSameTable() { AkibanInformationSchema ais = AISBBasedBuilder .create("test", typesTranslator) .table("p").colInt("id").key("k1", "id").key("k2", "id") .unvalidatedAIS(); ais.getTable("test", "p").getIndex("k1").setIndexId(10); ais.getTable("test", "p").getIndex("k2").setIndexId(10); validate(ais); }
@Test(expected=DuplicateIndexIdException.class) public void dupDifferentTable() { AkibanInformationSchema ais = AISBBasedBuilder .create("test", typesTranslator) .table("p").colInt("id").pk("id").key("k1", "id") .table("c").colInt("id").colInt("pid").key("k2", "id").joinTo("p").on("pid", "id") .unvalidatedAIS(); ais.getTable("test", "p").getIndex("k1").setIndexId(10); ais.getTable("test", "c").getIndex("k2").setIndexId(10); validate(ais); }
@Test(expected=DuplicateIndexIdException.class) public void dupTableAndFullText() { AkibanInformationSchema ais = AISBBasedBuilder .create("test", typesTranslator) .table("p").colInt("id").colString("s", 255).key("k1") .unvalidatedAIS(); Table t = ais.getTable("test", "p"); t.getIndex("k1").setIndexId(10); Index idx = FullTextIndex.create(ais, t, "k2", 10); IndexColumn.create(idx, t.getColumn("s"), 0, true, null); validate(ais); }
@Test(expected=DuplicateIndexIdException.class) public void dupTableAndGroup() { AkibanInformationSchema ais = AISBBasedBuilder .create("test", typesTranslator) .table("p").colInt("id").pk("id").key("k1", "id") .table("c").colInt("id").colInt("pid").joinTo("p").on("pid", "id") .groupIndex("k2", JoinType.LEFT).on("c", "id").and("p", "id") .unvalidatedAIS(); ais.getTable("test", "p").getIndex("k1").setIndexId(10); ais.getTable("test", "p").getGroup().getIndex("k2").setIndexId(10); validate(ais); }
@Test(expected=InvalidIndexIDException.class) public void nullID() { AkibanInformationSchema ais = AISBBasedBuilder .create("test", typesTranslator) .table("p").colInt("id").key("k", "id") .unvalidatedAIS(); ais.getTable("test", "p").getIndex("k").setIndexId(null); validate(ais); }
@Test(expected=InvalidIndexIDException.class) public void negativeID() { AkibanInformationSchema ais = AISBBasedBuilder .create("test", typesTranslator) .table("p").colInt("id").key("k", "id") .unvalidatedAIS(); ais.getTable("test", "p").getIndex("k").setIndexId(-1); validate(ais); }
@Test(expected=InvalidIndexIDException.class) public void zeroID() { AkibanInformationSchema ais = AISBBasedBuilder .create("test", typesTranslator) .table("p").colInt("id").key("k", "id") .unvalidatedAIS(); ais.getTable("test", "p").getIndex("k").setIndexId(0); validate(ais); }