ColumnMaxAndPrefixSizesMatch implements AISValidation { @Override public void validate(AkibanInformationSchema ais, AISValidationOutput output) { for(Table table : ais.getTables().values()) { for(Column column : table.getColumnsIncludingInternal()) { Long maxStorage = column.getMaxStorageSize(); Long computedMaxStorage = column.computeStorageSize(false); Integer prefix = column.getPrefixSize(); Integer computedPrefix = column.computePrefixSize(); if((maxStorage != null) && !maxStorage.equals(computedMaxStorage)) { output.reportFailure(new AISValidationFailure( new ColumnSizeMismatchException(table.getName(), column.getName(), "maxStorageSize", maxStorage, computedMaxStorage) )); } if((prefix != null) && !prefix.equals(computedPrefix)) { output.reportFailure(new AISValidationFailure( new ColumnSizeMismatchException(table.getName(), column.getName(), "prefixSize", prefix, computedPrefix) )); } } } }  @Override void validate(AkibanInformationSchema ais, AISValidationOutput output);  }
@Test public void nulls() { validate(createAIS(null, null)); }
@Test public void correct() { validate(createAIS(8L, 0)); }
@Test(expected=ColumnSizeMismatchException.class) public void wroteMaxIsError() { validate(createAIS(50L, 0)); }
@Test(expected=ColumnSizeMismatchException.class) public void wrongPrefixIsError() { validate(createAIS(8L, 50)); }
@Test public void wrongStorageAndPrefixIsError() { JUnitUtils.expectMultipleCause( new Runnable() { @Override public void run() { validate(createAIS(50L, 50)); } }, ColumnSizeMismatchException.class, ColumnSizeMismatchException.class ); }