NamePerson extends Name { public boolean validate() throws InvalidDataException { String fullName = getName(); if (Strings.isNullOrEmpty(lastName)) { throw new InvalidDataException("Invalid NamePerson, lastname can not be blank"); } if (Strings.isNullOrEmpty(fullName) || fullName.length() < 2) { throw new InvalidDataException("Invalid NamePerson, fullName can not be blank or smaller than 2."); } return true; } 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(expected = InvalidDataException.class) public void invalidNameNullLastName() throws InvalidDataException { NamePerson name = new NamePerson("John", null); name.validate(); }
@Test(expected = InvalidDataException.class) public void invalidNameEmptyLastName() throws InvalidDataException { NamePerson name = new NamePerson("John", ""); name.validate(); }