RequestKey { @Override public String toString() { return String.format("Request [%s %s: %s headers and %s]", method, url, headers == null ? "without" : "with " + headers, charset == null ? "no charset" : "charset " + charset); } private  RequestKey(Builder builder); private  RequestKey(Request request); static Builder builder(HttpMethod method, String url); static RequestKey create(Request request); HttpMethod getMethod(); String getUrl(); RequestHeaders getHeaders(); Charset getCharset(); byte[] getBody(); @Override int hashCode(); @Override boolean equals(Object obj); boolean equalsExtended(Object obj); @Override String toString();  }
@Test public void testToString() throws Exception { assertThat(requestKey.toString(), startsWith("Request [GET a: ")); assertThat(requestKey.toString(), both(containsString(" with my-header=[val] ")).and(containsString(" UTF-16]"))); }