@Test public void testBoolean() throws Exception { String key = "myKey"; assertTrue(settings.getBoolean(key, true)); assertFalse(settings.getBoolean(key, false)); map.put(key, Boolean.TRUE); assertTrue(settings.getBoolean(key, false)); map.put(key, "true"); assertTrue(settings.getBoolean(key, false)); map.put(key, new Object()); try { settings.getBoolean(key, false); fail(); } catch (ClassCastException e) { ; // to be expected } }
public LoadSolr(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); Config solrLocatorConfig = getConfigs().getConfig(config, SOLR_LOCATOR_PARAM); SolrLocator locator = new SolrLocator(solrLocatorConfig, context); LOG.debug("solrLocator: {}", locator); this.loader = locator.getLoader(); Config boostsConfig = getConfigs().getConfig(config, "boosts", ConfigFactory.empty()); for (Map.Entry<String, Object> entry : new Configs().getEntrySet(boostsConfig)) { String fieldName = entry.getKey(); float boost = Float.parseFloat(entry.getValue().toString().trim()); boosts.put(fieldName, boost); } this.isDryRun = context.getTypedSettings().getBoolean(TypedSettings.DRY_RUN_SETTING_NAME, false); validateArguments(); this.elapsedTime = getTimer(Metrics.ELAPSED_TIME); }
public LoadSolr(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); Config solrLocatorConfig = getConfigs().getConfig(config, SOLR_LOCATOR_PARAM); SolrLocator locator = new SolrLocator(solrLocatorConfig, context); LOG.debug("solrLocator: {}", locator); RetryPolicyFactory retryPolicyFactory = parseRetryPolicyFactory( getConfigs().getConfig(config, "retryPolicy", null)); this.loader = locator.getLoader(retryPolicyFactory, new CodahaleMetricsFacade(context.getMetricRegistry())); Config boostsConfig = getConfigs().getConfig(config, "boosts", ConfigFactory.empty()); for (Map.Entry<String, Object> entry : new Configs().getEntrySet(boostsConfig)) { String fieldName = entry.getKey(); float boost = Float.parseFloat(entry.getValue().toString().trim()); boosts.put(fieldName, boost); } this.rateLimiter = RateLimiter.create(getConfigs().getDouble(config, "maxRecordsPerSecond", Double.MAX_VALUE)); this.isDryRun = context.getTypedSettings().getBoolean(TypedSettings.DRY_RUN_SETTING_NAME, false); validateArguments(); this.elapsedTime = getTimer(Metrics.ELAPSED_TIME); }