protected static BeanDefinitionRegistry getBeanDefinitionRegistry(ApplicationContext context) {
        if (context instanceof BeanDefinitionRegistry) {
            return (BeanDefinitionRegistry) context;
        }
        if (context instanceof AbstractApplicationContext) {
            return (BeanDefinitionRegistry) ((AbstractApplicationContext) context).getBeanFactory();
        }
        throw new IllegalStateException("Could not locate BeanDefinitionRegistry");
    }
Implementation of the {@link org.springframework.test.context.ContextCustomizerFactory} interface,
which is responsible for initialization of the embedded database and its registration to the application context.
The applied initialization strategy is driven by the {@link AutoConfigureEmbeddedDatabase} annotation.

@see AutoConfigureEmbeddedDatabase
embedded-database-spring-test/src/main/java/io/zonky/test/db/EmbeddedDatabaseContextCustomizerFactory.java