@Test
public void dontRenameRecordTypeWhenClashingWithImported() {

    try (FDBRecordContext context = fdb.openContext()) {
        openMetaDataStore(context);
        RecordMetaData metaData = RecordMetaData.build(TestRecordsImportedAndNewProto.getDescriptor());
        metaDataStore.saveRecordMetaData(metaData);
        renameRecordType("MySimpleRecord", "MyLocalSimpleRecord"); // rename the nested record
        assertEquals(ImmutableSet.of("MySimpleRecord", "MyOtherRecord"), metaData.getRecordTypes().keySet());
        context.commit();
    }
    try (FDBRecordContext context = fdb.openContext()) {
        openMetaDataStore(context);
        MetaDataException e = assertThrows(MetaDataException.class, () -> renameRecordType("MyOtherRecord", "MySimpleRecord"));
        assertEquals("Cannot rename record type to MySimpleRecord as an imported record type of that name already exists", e.getMessage());
    }
}