NameUtil { public static String[] lastnameSuffix(String surname) { String[] parts = surname.split(","); if (parts.length == 2 && isPersonSuffix(parts[1])) { String suffixCheck = parts[1].trim().replaceFirst("\\.$", "").toUpperCase(); return new String[] { parts[0], suffixCheck }; } return new String[] { surname }; }  static String normalizeCase(String text); static String capitalizeFirstLetter(String word); static String[] lastnameSuffix(String surname); static boolean isPersonSuffix(String word); static String normalizeOrgNameCase(String companyName);  }
@Test public void lastnameSuffix() { String name = "John Doe, Esq."; String[] actual = NameUtil.lastnameSuffix(name); assertEquals("John Doe", actual[0]); assertEquals("ESQ", actual[1]); String name2 = "John Doe, VI"; String[] actual2 = NameUtil.lastnameSuffix(name2); assertEquals("John Doe", actual2[0]); assertEquals("VI", actual2[1]); }