/** * {@inheritDoc} */ @Override public StrategyConfig getDisruptorStrategyConfig() throws StorageException { ensureConfigurationExists(); StrategyConfig disruptorStrategy = agentConfiguration.getDisruptorStrategyConfig(); if (null == disruptorStrategy) { throw new StorageException("Disruptor strategy not defined in the agent configuration."); } return disruptorStrategy; } /**
@Test public void strategyCheck() throws StorageException { StrategyConfig strategyConfig = mock(StrategyConfig.class); when(agentConfiguration.getDisruptorStrategyConfig()).thenReturn(strategyConfig); StrategyConfig config = configurationStorage.getDisruptorStrategyConfig(); assertThat(config, is(strategyConfig)); }
@Test(expectedExceptions = { StorageException.class }) public void strategyNotDefined() throws StorageException { when(agentConfiguration.getDisruptorStrategyConfig()).thenReturn(null); configurationStorage.getDisruptorStrategyConfig(); } }
@Test public void disruptorStrategy() throws Exception { String className = "className"; Map<String, String> settings = Collections.singletonMap("key", "value"); IStrategyConfig config = mock(IStrategyConfig.class); when(config.getClassName()).thenReturn(className); when(config.getSettings()).thenReturn(settings); when(environment.getDisruptorStrategyConfig()).thenReturn(config); AgentConfig agentConfiguration = creator.environmentToConfiguration(environment, 0); StrategyConfig strategyConfig = agentConfiguration.getDisruptorStrategyConfig(); assertThat(strategyConfig.getClassName(), is(className)); assertThat(strategyConfig.getSettings(), is(settings)); }