private void registerMock(ConfigurableListableBeanFactory beanFactory,
                            BeanDefinitionRegistry registry, MockDefinition definition) {
    BeanDefinition beanDefinition = createBeanDefinition(definition);
    String beanName = getBeanName(beanFactory, registry, definition, beanDefinition);
    String transformedBeanName = BeanFactoryUtils.transformedBeanName(beanName);
    beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(1, beanName);
    if (registry.containsBeanDefinition(transformedBeanName)) {
      BeanDefinition existing = registry.getBeanDefinition(transformedBeanName);
      copyBeanDefinitionDetails(existing, beanDefinition);
      registry.removeBeanDefinition(transformedBeanName);
    }
    registry.registerBeanDefinition(transformedBeanName, beanDefinition);
    Object mock = createMock(definition, beanName);
    beanFactory.registerSingleton(transformedBeanName, mock);
    registerAliases(beanFactory, definition, transformedBeanName);
  }
Create a new {@link SpockMockPostprocessor} instance with the given initial
definitions.

@param definitions the initial definitions
spock-spring/src/main/java/org/spockframework/spring/mock/SpockMockPostprocessor.java