Source:
@Test public void logSuccessfulRequestResponseHeadersAndArgsWhenResponseBodyPresent() throws Exception { final List<String> logMessages = new ArrayList<String>(); RestAdapter.Log log = new RestAdapter.Log() { public void log(String message) { logMessages.add(message); } }; Example example = new RestAdapter.Builder() .setClient(mockClient) .setExecutors(mockRequestExecutor, mockCallbackExecutor) .setEndpoint("<LINK_1>") .setProfiler(mockProfiler) .setLog(log) .setLogLevel(HEADERS_AND_ARGS) .build() .create(Example.class); when(mockClient.execute(any(Request.class))) .thenReturn(new Response("<LINK_0>", 200, "OK", TWO_HEADERS, new TypedString("{}"))); example.something(new TypedString("Hi")); assertThat(logMessages).hasSize(13); assertThat(logMessages.get(0)).isEqualTo("---> HTTP POST <LINK_0>"); assertThat(logMessages.get(1)).isEqualTo("Foo: Bar"); assertThat(logMessages.get(2)).isEqualTo("Content-Type: text/plain; charset=UTF-8"); assertThat(logMessages.get(3)).isEqualTo("Content-Length: 2"); assertThat(logMessages.get(4)).isEqualTo("---> REQUEST:"); assertThat(logMessages.get(5)).isEqualTo("#0: TypedString[Hi]"); assertThat(logMessages.get(6)).isEqualTo("---> END HTTP (2-byte body)"); assertThat(logMessages.get(7)).matches("<--- HTTP 200 <LINK_0> \\([0-9]+ms\\)"); assertThat(logMessages.get(8)).isEqualTo("Content-Type: application/json"); assertThat(logMessages.get(9)).isEqualTo("Content-Length: 42"); assertThat(logMessages.get(10)).isEqualTo("<--- END HTTP (2-byte body)"); assertThat(logMessages.get(11)).isEqualTo("<--- BODY:"); assertThat(logMessages.get(12)).isEqualTo("{}"); }

Target:
@Test public void logSuccessfulRequestResponseHeadersAndArgsWhenResponseBodyPresent() throws Exception { final List<String> logMessages = new ArrayList<String>(); RestAdapter.Log log = new RestAdapter.Log() { @Override public void log(String message) { logMessages.add(message); } }; Example example = new RestAdapter.Builder() .setClient(mockClient) .setExecutors(mockRequestExecutor, mockCallbackExecutor) .setEndpoint("<LINK_1>") .setProfiler(mockProfiler) .setLog(log) .setLogLevel(HEADERS_AND_ARGS) .build() .create(Example.class); when(mockClient.execute(any(Request.class))) .thenReturn(new Response("<LINK_0>", 200, "OK", TWO_HEADERS, new TypedString("{}"))); example.something(new TypedString("Hi")); assertThat(logMessages).hasSize(13); assertThat(logMessages.get(0)).isEqualTo("---> HTTP POST <LINK_0>"); assertThat(logMessages.get(1)).isEqualTo("Foo: Bar"); assertThat(logMessages.get(2)).isEqualTo("Content-Type: text/plain; charset=UTF-8"); assertThat(logMessages.get(3)).isEqualTo("Content-Length: 2"); assertThat(logMessages.get(4)).isEqualTo("---> REQUEST:"); assertThat(logMessages.get(5)).isEqualTo("#0: TypedString[Hi]"); assertThat(logMessages.get(6)).isEqualTo("---> END HTTP (2-byte body)"); assertThat(logMessages.get(7)).matches("<--- HTTP 200 <LINK_0> \\([0-9]+ms\\)"); assertThat(logMessages.get(8)).isEqualTo("Content-Type: application/json"); assertThat(logMessages.get(9)).isEqualTo("Content-Length: 42"); assertThat(logMessages.get(10)).isEqualTo("<--- END HTTP (2-byte body)"); assertThat(logMessages.get(11)).isEqualTo("<--- BODY:"); assertThat(logMessages.get(12)).isEqualTo("{}"); }