PhoneNumber implements Serializable { @Override public String toString() { return getAsString(this); } PhoneNumber(final int countryCode, final int areaCode, final long number);  PhoneNumber(@Size(min = 11, max = 11) String pPhoneNumber); final int getCountryCode(); final void setCountryCode(final int pCountryCode); final int getAreaCode(); final void setAreaCode(final int pAreaCode); final long getNumber(); final void setNumber(final long pNumber); static PhoneNumber getAsObject(final String value); static String getAsString(final PhoneNumber phoneNumber); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void shouldToStringHaveTheRightform() throws Exception { PhoneNumber p1 = new PhoneNumber(33, 123, 456); Assert.assertEquals("a.toString()", "+33-0123-0456", p1.toString()); PhoneNumber p4 = new PhoneNumber("+33-0123-0456"); Assert.assertEquals("a.toString()", "+33-0123-0456", p4.toString()); }