Report { public XTraceMetadata getMetadata() { convertToMap(); List<String> xtrlist = map.get("X-Trace"); if (xtrlist == null || xtrlist.size() < 1) return null; String xtrstr = xtrlist.iterator().next(); XTraceMetadata xtr = null; try { xtr = XTraceMetadata.createFromString(xtrstr); } catch (Exception e) { return null; } return xtr; } 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 testGetMetadata() { TaskID task = new TaskID(8); XTraceMetadata md = new XTraceMetadata(task, 0); Report r = new Report(); r.put("X-Trace", md.toString()); r.put("Key1", "Value1"); r.put("Key2", "Value2"); assertEquals(md, r.getMetadata()); r = new Report(); r.put("Key1", "Value1"); r.put("X-Trace", md.toString()); r.put("Key2", "Value2"); assertEquals(md, r.getMetadata()); }