@Test
public void changeFormerIndexName() {

    RecordMetaDataBuilder metaData1Builder = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
    metaData1Builder.removeIndex("MySimpleRecord$str_value_indexed");
    RecordMetaData metaData1 = metaData1Builder.getRecordMetaData();
    RecordMetaDataProto.MetaData.Builder metaData2ProtoBuilder = metaData1.toProto()
            .toBuilder()
            .setVersion(metaData1.getVersion() + 1);
    metaData2ProtoBuilder.setFormerIndexes(0, metaData2ProtoBuilder.getFormerIndexesBuilder(0).setFormerName("some_other_name"));
    RecordMetaData metaData2 = RecordMetaData.build(metaData2ProtoBuilder.build());
    assertInvalid("name of former index differs from prior version", metaData1, metaData2);
    metaData2ProtoBuilder.setFormerIndexes(0, metaData2ProtoBuilder.getFormerIndexesBuilder(0).clearFormerName());
    metaData2 = RecordMetaData.build(metaData2ProtoBuilder.build());
    assertInvalid("name of former index differs from prior version", metaData1, metaData2);
    // For existing former indexes, changing the name is not allowed even with the laxer validation option
    MetaDataEvolutionValidator laxerValidator = MetaDataEvolutionValidator.newBuilder()
            .setAllowMissingFormerIndexNames(true)
            .build();
    assertInvalid("name of former index differs from prior version", laxerValidator, metaData1, metaData2);
}