BootstrapConfigPropertyMapper { public static Properties toProperties(BootstrapConfig bootstrapConfig) { Properties properties = new Properties(); properties.setProperty(BootstrapConfig.SQL_URL, bootstrapConfig.getSqlConfig().getUrl()); properties.setProperty(BootstrapConfig.SQL_DRIVER, bootstrapConfig.getSqlConfig().getDriver()); setIfNotBlank(properties, BootstrapConfig.SQL_USER, bootstrapConfig.getSqlConfig().getUsername()); setIfNotBlank(properties, BootstrapConfig.SQL_PASSWORD, bootstrapConfig.getSqlConfig().getPassword()); properties.setProperty(BootstrapConfig.CONFIG_SOURCE, bootstrapConfig.getConfigSource().getName()); setIfNotBlank(properties, BootstrapConfig.OSGI_FRAMEWORK_STORAGE, bootstrapConfig.getOsgiFrameworkStorage()); setIfNotBlank(properties, BootstrapConfig.MOTECH_DIR, bootstrapConfig.getMotechDir()); properties.putAll(bootstrapConfig.getActiveMqProperties()); return properties; } private  BootstrapConfigPropertyMapper(); static Properties toProperties(BootstrapConfig bootstrapConfig); static BootstrapConfig fromProperties(Properties bootstrapProperties);  }
@Test public void shouldMapToPropertiesFromBootstrapConfig() { Properties bootstrapProperties = BootstrapConfigPropertyMapper.toProperties(new BootstrapConfig(new SQLDBConfig(sqlUrl, sqlDriver, sqlUsername, sqlPassword), configSource, felixPath, motechDir, queueUrl)); Assert.assertThat(bootstrapProperties.getProperty(CONFIG_SOURCE), is(configSource.getName())); }
@Test public void shouldMapToPropertiesFromBootstrapConfig_WhenUsernameAndPasswordAreBlank() { Properties bootstrapProperties = BootstrapConfigPropertyMapper.toProperties(new BootstrapConfig(new SQLDBConfig(sqlUrl, sqlDriver, sqlUsername, sqlPassword), configSource, felixPath, motechDir, queueUrl)); Assert.assertThat(bootstrapProperties.getProperty(sqlUsername), nullValue()); Assert.assertThat(bootstrapProperties.getProperty(sqlPassword), nullValue()); Assert.assertThat(bootstrapProperties.getProperty(CONFIG_SOURCE), is(configSource.getName())); }