Report { @Override public String toString() { if (map == null) { return buf.toString(); } StringBuilder buf = new StringBuilder("X-Trace Report ver 1.0\n"); final Iterator<Map.Entry<String, List<String>>> iter = map.entrySet() .iterator(); while (iter.hasNext()) { final Map.Entry<String, List<String>> entry = iter.next(); final Iterator<String> values = entry.getValue().iterator(); while (values.hasNext()) { final String v = values.next(); buf.append(entry.getKey() + ": " + v + "\n"); } } return buf.toString(); } Report(); private  Report(String s); void put(final String key, final String value, boolean append); void put(final String key, final String value); void remove(final String key); XTraceMetadata getMetadata(); List<String> get(String key); @Override String toString(); static Report createFromString(final String s); @Override boolean equals(Object o);  }
@Test public void testToString() { Report r = new Report(); XTraceMetadata xtr = new XTraceMetadata(); r.put("X-Trace", xtr.toString()); r.put("Key1", "Value1"); r.put("Key2", "Value2"); r.put("Key4", "Value4.1"); r.put("Key4", "Value4.2"); r.put("Key4", "Value4.3"); String s = r.toString(); assertNotNull(s); assertTrue(s.startsWith("X-Trace Report ver 1.0")); assertTrue(s.contains("Key1: Value1")); assertTrue(s.contains("Key2: Value2")); assertTrue(s.contains("Key4: Value4.1")); assertTrue(s.contains("Key4: Value4.2")); assertTrue(s.contains("Key4: Value4.3")); assertTrue(s.contains("X-Trace: 100000000000000000")); }