@Test public void checkOkTenantConfigurationLoaded() throws PersistenceException, ConfigurationException { Collection<String> configurations = new LinkedList<>(); configurations.add("smartcity/team1"); when(persistence.listConfigurations()).thenReturn(configurations); when(applicationContext.getBean("eventMapper")).thenReturn(eventMapper); when(applicationContext.getBean("complexEventProcessor")).thenReturn(complexEventProcessor); when(applicationContext.getBean("subscriptionManager")).thenReturn(subscriptionManager); InOrder inOrder = inOrder( tenantFilter ); tenantInit.loadConfigurationOnStartup(); verify(tenantFilter, atLeastOnce()).forceTenantScope("smartcity/team1"); verify(tenantFilter, atLeastOnce()).forceTenantScope(null); inOrder.verify(tenantFilter).forceTenantScope("smartcity/team1"); inOrder.verify(tenantFilter).forceTenantScope(null); verify(persistence, atLeastOnce()).loadConfiguration("smartcity/team1"); verify(eventMapper, atLeastOnce()).setConfiguration(any()); verify(complexEventProcessor, atLeastOnce()).setConfiguration(any()); verify(subscriptionManager, atLeastOnce()).setConfiguration(any()); }
@PostConstruct protected void loadConfigurationOnStartup() { persistence.listConfigurations().forEach(id -> { logger.info("Loading configuration for tenant '{}'", id); tenantFilter.forceTenantScope(id); EventMapper eventMapper = (EventMapper) applicationContext.getBean("eventMapper"); ComplexEventProcessor complexEventProcessor = (ComplexEventProcessor) applicationContext.getBean("complexEventProcessor"); SubscriptionManager subscriptionManager = (SubscriptionManager) applicationContext.getBean("subscriptionManager"); try { Configuration configuration = persistence.loadConfiguration(id); eventMapper.setConfiguration(configuration); complexEventProcessor.setConfiguration(configuration); subscriptionManager.setConfiguration(configuration); } catch (PersistenceException | ConfigurationException e) { logger.error("Failed to load or apply persisted configuration {}", id, e); } tenantFilter.forceTenantScope(null); }); }
TenantInit { @PostConstruct protected void loadConfigurationOnStartup() { persistence.listConfigurations().forEach(id -> { logger.info("Loading configuration for tenant '{}'", id); tenantFilter.forceTenantScope(id); EventMapper eventMapper = (EventMapper) applicationContext.getBean("eventMapper"); ComplexEventProcessor complexEventProcessor = (ComplexEventProcessor) applicationContext.getBean("complexEventProcessor"); SubscriptionManager subscriptionManager = (SubscriptionManager) applicationContext.getBean("subscriptionManager"); try { Configuration configuration = persistence.loadConfiguration(id); eventMapper.setConfiguration(configuration); complexEventProcessor.setConfiguration(configuration); subscriptionManager.setConfiguration(configuration); } catch (PersistenceException | ConfigurationException e) { logger.error("Failed to load or apply persisted configuration {}", id, e); } tenantFilter.forceTenantScope(null); }); } }
TenantInit { @PostConstruct protected void loadConfigurationOnStartup() { persistence.listConfigurations().forEach(id -> { logger.info("Loading configuration for tenant '{}'", id); tenantFilter.forceTenantScope(id); EventMapper eventMapper = (EventMapper) applicationContext.getBean("eventMapper"); ComplexEventProcessor complexEventProcessor = (ComplexEventProcessor) applicationContext.getBean("complexEventProcessor"); SubscriptionManager subscriptionManager = (SubscriptionManager) applicationContext.getBean("subscriptionManager"); try { Configuration configuration = persistence.loadConfiguration(id); eventMapper.setConfiguration(configuration); complexEventProcessor.setConfiguration(configuration); subscriptionManager.setConfiguration(configuration); } catch (PersistenceException | ConfigurationException e) { logger.error("Failed to load or apply persisted configuration {}", id, e); } tenantFilter.forceTenantScope(null); }); }  }
TenantInit { @PostConstruct protected void loadConfigurationOnStartup() { persistence.listConfigurations().forEach(id -> { logger.info("Loading configuration for tenant '{}'", id); tenantFilter.forceTenantScope(id); EventMapper eventMapper = (EventMapper) applicationContext.getBean("eventMapper"); ComplexEventProcessor complexEventProcessor = (ComplexEventProcessor) applicationContext.getBean("complexEventProcessor"); SubscriptionManager subscriptionManager = (SubscriptionManager) applicationContext.getBean("subscriptionManager"); try { Configuration configuration = persistence.loadConfiguration(id); eventMapper.setConfiguration(configuration); complexEventProcessor.setConfiguration(configuration); subscriptionManager.setConfiguration(configuration); } catch (PersistenceException | ConfigurationException e) { logger.error("Failed to load or apply persisted configuration {}", id, e); } tenantFilter.forceTenantScope(null); }); }   }
TenantInit { @PostConstruct protected void loadConfigurationOnStartup() { persistence.listConfigurations().forEach(id -> { logger.info("Loading configuration for tenant '{}'", id); tenantFilter.forceTenantScope(id); EventMapper eventMapper = (EventMapper) applicationContext.getBean("eventMapper"); ComplexEventProcessor complexEventProcessor = (ComplexEventProcessor) applicationContext.getBean("complexEventProcessor"); SubscriptionManager subscriptionManager = (SubscriptionManager) applicationContext.getBean("subscriptionManager"); try { Configuration configuration = persistence.loadConfiguration(id); eventMapper.setConfiguration(configuration); complexEventProcessor.setConfiguration(configuration); subscriptionManager.setConfiguration(configuration); } catch (PersistenceException | ConfigurationException e) { logger.error("Failed to load or apply persisted configuration {}", id, e); } tenantFilter.forceTenantScope(null); }); }    }