public static FacetDisplayNameProvider getFacetDisplayNameProvider(
     final IndexedProperty property) {
   final String name = property.getFacetDisplayNameProvider();
   return name == null
       ? null
       : Registry.getGlobalApplicationContext().getBean(name, FacetDisplayNameProvider.class);
 }
  @BeforeClass
  public static void prepare() throws Exception // NOPMD
      {
    Registry.activateStandaloneMode();
    Utilities.setJUnitTenant();
    LOG.debug("Preparing...");

    final ApplicationContext appCtx = Registry.getGlobalApplicationContext();

    assertTrue(
        "Application context of type "
            + appCtx.getClass()
            + " is not a subclass of "
            + ConfigurableApplicationContext.class,
        appCtx instanceof ConfigurableApplicationContext);

    final ConfigurableApplicationContext applicationContext =
        (ConfigurableApplicationContext) appCtx;
    final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
    assertTrue(
        "Bean Factory of type "
            + beanFactory.getClass()
            + " is not of type "
            + BeanDefinitionRegistry.class,
        beanFactory instanceof BeanDefinitionRegistry);
    final XmlBeanDefinitionReader xmlReader =
        new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory);
    xmlReader.setDocumentReaderClass(ScopeTenantIgnoreDocReader.class);
    xmlReader.loadBeanDefinitions(
        new ClassPathResource(
            "/merchandisefulfilmentprocess/test/merchandisefulfilmentprocess-spring-test.xml"));
    xmlReader.loadBeanDefinitions(
        new ClassPathResource(
            "/merchandisefulfilmentprocess/test/merchandisefulfilmentprocess-spring-test-fraudcheck.xml"));
    xmlReader.loadBeanDefinitions(
        new ClassPathResource(
            "/merchandisefulfilmentprocess/test/process/order-process-spring.xml"));
    modelService = (ModelService) getBean("modelService");
    processService = (DefaultBusinessProcessService) getBean("businessProcessService");
    definitonFactory = processService.getProcessDefinitionFactory();

    LOG.warn("Prepare Process Definition factory...");
    definitonFactory.add(
        "classpath:/merchandisefulfilmentprocess/test/process/payment-process.xml");

    // setup command factory to mock
    final DefaultCommandFactoryRegistryImpl commandFactoryReg =
        appCtx.getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg.setCommandFactoryList(
        Arrays.asList((CommandFactory) appCtx.getBean("mockupCommandFactory")));

    taskServiceStub = appCtx.getBean(TaskServiceStub.class);
    productService = appCtx.getBean("defaultProductService", DefaultProductService.class);
    cartService = appCtx.getBean("defaultCartService", DefaultCartService.class);
    userService = appCtx.getBean("defaultUserService", DefaultUserService.class);
  }
  @AfterClass
  public static void removeProcessDefinitions() {
    LOG.debug("cleanup...");

    final ApplicationContext appCtx = Registry.getGlobalApplicationContext();

    assertTrue(
        "Application context of type "
            + appCtx.getClass()
            + " is not a subclass of "
            + ConfigurableApplicationContext.class,
        appCtx instanceof ConfigurableApplicationContext);

    final ConfigurableApplicationContext applicationContext =
        (ConfigurableApplicationContext) appCtx;
    final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
    assertTrue(
        "Bean Factory of type "
            + beanFactory.getClass()
            + " is not of type "
            + BeanDefinitionRegistry.class,
        beanFactory instanceof BeanDefinitionRegistry);
    final XmlBeanDefinitionReader xmlReader =
        new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory);
    xmlReader.loadBeanDefinitions(
        new ClassPathResource(
            "/merchandisefulfilmentprocess/test/merchandisefulfilmentprocess-spring-testcleanup.xml"));

    // cleanup command factory
    final Map<String, CommandFactory> commandFactoryList =
        applicationContext.getBeansOfType(CommandFactory.class);
    commandFactoryList.remove("mockupCommandFactory");
    final DefaultCommandFactoryRegistryImpl commandFactoryReg =
        appCtx.getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg.setCommandFactoryList(commandFactoryList.values());

    //		if (definitonFactory != null)
    //		{
    // TODO this test seems to let processes run after method completion - therefore we cannot
    // remove definitions !!!
    //			definitonFactory.remove("testPlaceorder");
    //			definitonFactory.remove("testConsignmentFulfilmentSubprocess");
    //		}
    processService.setTaskService(appCtx.getBean(DefaultTaskService.class));
    definitonFactory = null;
    processService = null;
  }