DefaultXMLConfiguration implements XMLConfiguration { public String nameFor(String name) { if(name.length()==1) { return name.toLowerCase(); } StringBuilder content = new StringBuilder(); content.append(Character.toLowerCase(name.charAt(0))); for(int i=1;i<name.length();i++) { char c = name.charAt(i); if(Character.isUpperCase(c)) { content.append('_'); content.append(Character.toLowerCase(c)); } else { content.append(c); } } return content.toString(); }  String nameFor(String name);  }
@Test public void shouldUndernalizeAllCamelcase() { String base = "CamelCaseValue"; assertThat(config.nameFor(base), is(equalTo("camel_case_value"))); }
@Test public void shouldUndernalizeAllCamelcaseCharacters() { String base = "C"; assertThat(config.nameFor(base), is(equalTo("c"))); }