PersonRecord { public String getEmail() { return isEmailUnknown() ? getUnknownEmail(number) : email; } PersonRecord(long id, String name, String email, String number); boolean isUnknown(); Address getAddress(AddressStyle style); String getEmail(); String getId(); long getContactId(); String getNumber(); String getName(); String toString();  }
@Test public void shouldSanitizeInputDataEmail() throws Exception { PersonRecord r = new PersonRecord(1, "foo\n\r\n", "foo\n@gmail.com", "\r\r1234"); assertThat(r.getEmail()).isEqualTo("foo@gmail.com"); }
@Test public void shouldReturnUnknownEmail() throws Exception { PersonRecord record = new PersonRecord(0, null, null, "-1"); assertThat(record.getEmail()).isEqualTo("unknown.number@unknown.email"); }