### Question:
SystemNamingService { public static String generateSystemName(String name) { String systemName = StringUtils.trimToEmpty(name); if (StringUtils.isBlank(systemName)) { return systemName; } systemName = systemName.replaceAll(" +", "_"); systemName = systemName.replaceAll("[^\\w_]", ""); int i = 0; StringBuilder s = new StringBuilder(); CharacterIterator itr = new StringCharacterIterator(systemName); for (char c = itr.first(); c != CharacterIterator.DONE; c = itr.next()) { if (Character.isUpperCase(c)) { if (i > 0 && i != systemName.length() - 1) { char prevChar = systemName.charAt(i - 1); char nextChar = systemName.charAt(i + 1); if (Character.isUpperCase(prevChar) && (Character.isUpperCase(nextChar) || CharUtils.isAsciiNumeric(nextChar) || '_' == nextChar || '-' == nextChar)) { char lowerChar = Character.toLowerCase(systemName.charAt(i)); s.append(lowerChar); } else { s.append(c); } } else if (i > 0 && i == systemName.length() - 1) { char prevChar = systemName.charAt(i - 1); if (Character.isUpperCase(prevChar) && !CharUtils.isAsciiNumeric(systemName.charAt(i))) { char lowerChar = Character.toLowerCase(systemName.charAt(i)); s.append(lowerChar); } else { s.append(c); } } else { s.append(c); } } else { s.append(c); } i++; } systemName = s.toString(); systemName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, systemName); systemName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_UNDERSCORE, systemName); systemName = StringUtils.replace(systemName, "__", "_"); systemName = (systemName.length() > 128 ? systemName.substring(0, 127) : systemName); return systemName; }  static String generateSystemName(String name);  }### Answer:
@Test public void testSystemName() { String name = "MYFeedName"; String systemName = SystemNamingService.generateSystemName(name); Assert.assertEquals("my_feed_name", systemName); name = "myFeedNameTEST"; systemName = SystemNamingService.generateSystemName(name); Assert.assertEquals("my_feed_name_test", systemName); name = "My-TestFeedName"; systemName = SystemNamingService.generateSystemName(name); Assert.assertEquals("my_test_feed_name", systemName); name = "MY_TESTFeedName"; systemName = SystemNamingService.generateSystemName(name); Assert.assertEquals("my_test_feed_name", systemName); name = "ALPHA1"; systemName = SystemNamingService.generateSystemName(name); Assert.assertEquals("alpha1", systemName); name = "myALPHA13242"; systemName = SystemNamingService.generateSystemName(name); Assert.assertEquals("my_alpha13242", systemName); name = "ALPHA13242"; systemName = SystemNamingService.generateSystemName(name); Assert.assertEquals("alpha13242", systemName); name = "ALPHA13242TEST"; systemName = SystemNamingService.generateSystemName(name); Assert.assertEquals("alpha13242_test", systemName); name = "m;,y_feed_name"; systemName = SystemNamingService.generateSystemName(name); Assert.assertEquals("my_feed_name", systemName); name = ";,my feed name"; systemName = SystemNamingService.generateSystemName(name); Assert.assertEquals("my_feed_name", systemName); }