RankableObjectWithFields implements Rankable, Serializable { @Override public String toString() { StringBuffer buf = new StringBuffer(); buf.append("["); buf.append(obj); buf.append(toStringSeparator); buf.append(count); for (Object field : fields) { buf.append(toStringSeparator); buf.append(field); } buf.append("]"); return buf.toString(); } RankableObjectWithFields(Object obj, long count, Object... otherFields); static RankableObjectWithFields from(Tuple tuple); @Override Object getObject(); @Override long getCount(); List<Object> getFields(); @Override int compareTo(Rankable other); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override Rankable copy();  }
@Test(dataProvider = "toStringData") public void toStringShouldContainStringRepresentationsOfObjectAndCount(Object obj, long count) { RankableObjectWithFields r = new RankableObjectWithFields(obj, count); String strRepresentation = r.toString(); assertThat(strRepresentation).contains(obj.toString()).contains("" + count); }