### Question:
StringUtils { public String capitalizedAsConstant(String name) { if (name == null || name.length() == 0) { return name; } name = Util.specialCharsToJava(name); char charArray[] = name.toCharArray(); StringBuilder buffer = new StringBuilder(); for (int i = 0; i < charArray.length; i++) { if ((Character.isUpperCase(charArray[i])) && (i != 0)) { char prevChar = charArray[i - 1]; if ((Character.isLowerCase(prevChar))) { buffer.append("_"); } } buffer.append(Character.toUpperCase(charArray[i])); } return buffer.toString(); }  static StringUtils getInstance(); String formatVariableName(String variableName); String stripPackageName(String fullyQualifiedClassName); String stripClass(String aString); String capitalized(String name); String uncapitalized(String aString); String capitalizedAsConstant(String name); String pluralize(String str); String stripGeneric(String str); String replaceWildcardInStringWithString(String wildcard, String pattern, String replacement);  }### Answer:
@Test public void testCapitalizedAsConstant1() throws Exception { String expected = "LAST_NAME"; assertEquals(expected, stringUtils.capitalizedAsConstant("LastName")); }
@Test public void testCapitalizedAsConstant2() throws Exception { String expected = "A_CLASS"; assertEquals(expected, stringUtils.capitalizedAsConstant("aClass")); }
@Test public void testCapitalizedAsConstant3() throws Exception { String expected = "VAR_A"; assertEquals(expected, stringUtils.capitalizedAsConstant("varA")); }
@Test public void testCapitalizedAsConstant4() throws Exception { String expected = "LAST_NAME"; assertEquals(expected, stringUtils.capitalizedAsConstant("LAST_NAME")); }
@Test public void testCapitalizedAsConstant5() throws Exception { String expected = "ABC_A"; assertEquals(expected, stringUtils.capitalizedAsConstant("abc_A")); }
@Test public void testCapitalizedAsConstant6() throws Exception { String expected = "A123"; assertEquals(expected, stringUtils.capitalizedAsConstant("a123")); }
@Test public void testCapitalizedAsConstant7() throws Exception { String expected = "AB_CDEF"; assertEquals(expected, stringUtils.capitalizedAsConstant("abCDEF")); }
@Test public void testCapitalizedAsConstant8() throws Exception { String expected = "AB_CE"; assertEquals(expected, stringUtils.capitalizedAsConstant("abCe")); }