NamePerson extends Name { public String getInitials() { StringBuilder stb = new StringBuilder(); if (!Strings.isNullOrEmpty(firstName)) { stb.append(firstName); stb.append(" "); } if (!Strings.isNullOrEmpty(middleName)) { stb.append(middleName); stb.append(" "); } stb.append(lastName); return WordUtils.initials(stb.toString()); } 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 initializeName() throws InvalidDataException { NamePerson name = new NamePerson("John", "Smith", "DOE"); String abbrev = name.getInitials(); String expect = "JSD"; assertEquals(expect, abbrev); }
@Test public void initializeName2() throws InvalidDataException { NamePerson name = new NamePerson("John Smith", "DOE"); String abbrev = name.getInitials(); String expect = "JSD"; assertEquals(expect, abbrev); }
@Test public void initializeMultiwordSurname() throws InvalidDataException { NamePerson name = new NamePerson("Bernardus", "van den Bosch"); String abbrev = name.getInitials(); String expect = "BvdB"; assertEquals(expect, abbrev); }
@Test public void initializeHyphenSurname() throws InvalidDataException { NamePerson name = new NamePerson("Karla", "BRAVO-ALTAMIRANO"); String abbrev = name.getInitials(); String expect = "KB"; assertEquals(expect, abbrev); }