ConfigurationCommand extends Command { String generateConfiguration() throws JsonProcessingException { StrowgrConfiguration configuration = new StrowgrConfiguration(); configuration.setConsulRepositoryFactory(new ConsulRepositoryFactory()); configuration.setNsqLookupfactory(new NSQLookupFactory()); configuration.setNsqProducerFactory(new NSQProducerFactory()); configuration.setNsqProducerConfigFactory(new NSQConfigFactory()); PeriodicSchedulerFactory periodicScheduler = new PeriodicSchedulerFactory(); periodicScheduler.setPeriodicCommitCurrentSchedulerFactory(new PeriodicCommitCurrentSchedulerFactory()); periodicScheduler.setPeriodicCommitPendingSchedulerFactory(new PeriodicCommitPendingSchedulerFactory()); configuration.setPeriodicSchedulerFactory(periodicScheduler); configuration.setNsqConsumerConfigFactory(new NSQConfigFactory()); configuration.setNsqProducerConfigFactory(new NSQConfigFactory()); YAMLFactory yamlFactory = new YAMLFactory(); yamlFactory.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, false); ObjectMapper objectMapper = new ObjectMapper(yamlFactory); Map<String, Object> map = objectMapper.convertValue(configuration, Map.class); map.remove("metricsFactory"); map.remove("metrics"); map.remove("httpClient"); buildRoot(map); HashMap<String, Object> loggingValue = buildLoggingSnippet(); map.put("logging", loggingValue); HashMap<String, Object> server = buildServerSnippet(); HashMap<String, Object> ldapConfiguration = buildLdapConfiguration(); map.put("ldapConfiguration", ldapConfiguration); map.put("server", server); map.remove("nsqProducerConfigFactory"); map.remove("nsqConsumerConfigFactory"); return objectMapper.writeValueAsString(map); } ConfigurationCommand(); @Override void configure(Subparser subparser); @Override void run(Bootstrap bootstrap, Namespace namespace);  }
@Test public void should_generate_default_configuration_without_null() throws JsonProcessingException { ConfigurationCommand configurationCommand = new ConfigurationCommand(); String configuration = configurationCommand.generateConfiguration(); System.out.println(configuration); assertFalse(configuration.contains("null")); }