@Test
public void indexUsedWhereFormerIndexWas() {

    RecordMetaDataBuilder metaDataBuilder = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
    metaDataBuilder.removeIndex("MySimpleRecord$str_value_indexed");
    RecordMetaData metaData1 = metaDataBuilder.getRecordMetaData();
    RecordMetaDataBuilder metaData2Builder = RecordMetaData.newBuilder().setRecords(
            metaData1.toProto().toBuilder().clearFormerIndexes().build()
    );
    Index newIndex = new Index("newIndex", "str_value_indexed");
    newIndex.setSubspaceKey("MySimpleRecord$str_value_indexed");
    metaData2Builder.addIndex("MySimpleRecord", newIndex);
    RecordMetaData metaData2 = metaData2Builder.getRecordMetaData();
    assertInvalid("former index key used for new index in meta-data", metaData1, metaData2);
}