NamePart { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("name", name) .append("friendlyCode", friendlyCode) .toString(); } NamePart(String name, String friendlyCode); String getName(); String getFriendlyCode(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void toStringShouldDisplayAllProperties() { Assert.assertEquals("NamePart[name=California,friendlyCode=CA]", new NamePart("California", "CA").toString()); }