NamePerson extends Name { public String getAbbreviatedName() { if (!Strings.isNullOrEmpty(firstName)) { StringBuilder stb = new StringBuilder(); stb.append(normalizeCase(lastName)); stb.append(", "); stb.append(firstName.substring(0, 1).toUpperCase()); stb.append("."); return NameUtil.normalizeCase(stb.toString()); } else { return normalizeCase(lastName); } } NamePerson(String firstName, String lastName);  NamePerson(String firstName, String middleName, String lastName); @Override String getName(); @Override String getNameNormalizeCase(); String getFirstName(); String getMiddleName(); String getLastName(); boolean validate(); String getAbbreviatedName(); String getInitials(); @Override String toString();  }
@Test public void abbreviatedName() throws InvalidDataException { NamePerson name = new NamePerson("John", "DOE"); String abbrev = name.getAbbreviatedName(); String expect = "Doe, J."; assertEquals(expect, abbrev); }
@Test public void abbreviatedName2() throws InvalidDataException { NamePerson name = new NamePerson("John", "McMillian"); String abbrev = name.getAbbreviatedName(); String expect = "McMillian, J."; assertEquals(expect, abbrev); }