@Test public void testNoConfig() { new Expectations() { { ApplicationContextUtil.getEnvironment(); result = environment; } { Binder.get(environment); result = binder; } { @SuppressWarnings("unchecked") Bindable<ZebraShardingConfiguration> bindable = (Bindable<ZebraShardingConfiguration>) any; binder.bind("zebra.database", bindable); result = bindResult; } { bindResult.isBound(); result = false; } }; ZebraShardingConfiguration cfg = ZebraShardingConfigurationUtil.getZebraShardingConfiguration(); assertThat(cfg, is(nullValue())); }
public static ZebraShardingConfiguration getZebraShardingConfiguration() { Environment environment = ApplicationContextUtil.getEnvironment(); BindResult<ZebraShardingConfiguration> bindResult = Binder.get(environment) .bind(ZEBRA_SHARDING_CONF_PREFIX, Bindable.of(ZebraShardingConfiguration.class)); ZebraShardingConfiguration cfg = bindResult.isBound() ? bindResult.get() : null; if (cfg != null) { setType(cfg); setNameIfMasterSlave(cfg); fillDefaultCfgOfShardingIfNotCfg(cfg); } return cfg; }
ZebraShardingConfigurationUtil { public static ZebraShardingConfiguration getZebraShardingConfiguration() { Environment environment = ApplicationContextUtil.getEnvironment(); BindResult<ZebraShardingConfiguration> bindResult = Binder.get(environment) .bind(ZEBRA_SHARDING_CONF_PREFIX, Bindable.of(ZebraShardingConfiguration.class)); ZebraShardingConfiguration cfg = bindResult.isBound() ? bindResult.get() : null; if (cfg != null) { setType(cfg); setNameIfMasterSlave(cfg); fillDefaultCfgOfShardingIfNotCfg(cfg); } return cfg; } }
ZebraShardingConfigurationUtil { public static ZebraShardingConfiguration getZebraShardingConfiguration() { Environment environment = ApplicationContextUtil.getEnvironment(); BindResult<ZebraShardingConfiguration> bindResult = Binder.get(environment) .bind(ZEBRA_SHARDING_CONF_PREFIX, Bindable.of(ZebraShardingConfiguration.class)); ZebraShardingConfiguration cfg = bindResult.isBound() ? bindResult.get() : null; if (cfg != null) { setType(cfg); setNameIfMasterSlave(cfg); fillDefaultCfgOfShardingIfNotCfg(cfg); } return cfg; } private  ZebraShardingConfigurationUtil(); }
ZebraShardingConfigurationUtil { public static ZebraShardingConfiguration getZebraShardingConfiguration() { Environment environment = ApplicationContextUtil.getEnvironment(); BindResult<ZebraShardingConfiguration> bindResult = Binder.get(environment) .bind(ZEBRA_SHARDING_CONF_PREFIX, Bindable.of(ZebraShardingConfiguration.class)); ZebraShardingConfiguration cfg = bindResult.isBound() ? bindResult.get() : null; if (cfg != null) { setType(cfg); setNameIfMasterSlave(cfg); fillDefaultCfgOfShardingIfNotCfg(cfg); } return cfg; } private  ZebraShardingConfigurationUtil(); static ZebraShardingConfiguration getZebraShardingConfiguration(); }
ZebraShardingConfigurationUtil { public static ZebraShardingConfiguration getZebraShardingConfiguration() { Environment environment = ApplicationContextUtil.getEnvironment(); BindResult<ZebraShardingConfiguration> bindResult = Binder.get(environment) .bind(ZEBRA_SHARDING_CONF_PREFIX, Bindable.of(ZebraShardingConfiguration.class)); ZebraShardingConfiguration cfg = bindResult.isBound() ? bindResult.get() : null; if (cfg != null) { setType(cfg); setNameIfMasterSlave(cfg); fillDefaultCfgOfShardingIfNotCfg(cfg); } return cfg; } private  ZebraShardingConfigurationUtil(); static ZebraShardingConfiguration getZebraShardingConfiguration();  }