EnvironmentConfigRewriter implements ConfigRewriter { protected static String renameKey(String envName) { if (envName.length() <= SAMZA_KEY_PREFIX.length()) { throw new IllegalArgumentException(); } String configName = envName.substring(SAMZA_KEY_PREFIX.length()); return configName.toLowerCase().replace('_', '.'); }  @Override Config rewrite(String name, Config config); static final String SAMZA_KEY_PREFIX; static final Logger LOGGER; }
@Test public void testRewriteKeyValidKeys() { assertEquals("foo", EnvironmentConfigRewriter.renameKey("SAMZA_FOO")); assertEquals("foo.bar", EnvironmentConfigRewriter.renameKey("SAMZA_FOO_BAR")); }
@Test(expected = IllegalArgumentException.class) public void testRewriteKeyInvalidKeyPrefix() { EnvironmentConfigRewriter.renameKey("SAMZA"); }
@Test(expected = IllegalArgumentException.class) public void testRewriteKeyInvalidKeyNoSubkey() { EnvironmentConfigRewriter.renameKey("SAMZA"); }