### Question:
BatchJobLogger { public void logUpload( String uploadContents, URI uploadUri, @Nullable BatchJobUploadResponse batchJobUploadResponse, @Nullable Throwable throwable) { RequestInfo requestInfo = new RequestInfo.Builder() .withServiceName("batchjobupload") .withContext(CONTEXT_NAME, null) .withUrl(uploadUri.toString()) .withPayload(Strings.nullToEmpty(uploadContents).trim()) .build(); ResponseInfo.Builder responseInfoBuilder = new ResponseInfo.Builder(); if (batchJobUploadResponse != null) { responseInfoBuilder.withPayload( String.format( "%d %s%n", batchJobUploadResponse.getHttpStatus(), batchJobUploadResponse.getHttpResponseMessage())); } RemoteCallReturn remoteCallReturn = new RemoteCallReturn.Builder() .withRequestInfo(requestInfo) .withResponseInfo(responseInfoBuilder.build()) .withException(throwable) .build(); loggerDelegate.logRequestSummary(remoteCallReturn); loggerDelegate.logRequestDetails(remoteCallReturn); } @Inject  BatchJobLogger(@Named(AdWordsLoggingModule.BATCH_JOB_LOGGER_NAME) Logger batchJobLogger);   BatchJobLogger(RemoteCallLoggerDelegate loggerDelegate); void logUpload(
      String uploadContents,
      URI uploadUri,
      @Nullable BatchJobUploadResponse batchJobUploadResponse,
      @Nullable Throwable throwable); void logDownload(
      String downloadUrl,
      @Nullable BatchJobMutateResponseInterface<O, E, R> response,
      @Nullable Throwable throwable);  }### Answer:
@Test public void testLogUpload() throws IOException { String contentsString = "some contents"; InputStream responseContent = CharSource.wrap(contentsString).asByteSource(UTF_8).openStream(); BatchJobUploadResponse response = new BatchJobUploadResponse( responseContent, statusCode, statusMessage, contentsString.length(), URI.create(url)); ArgumentCaptor<RemoteCallReturn> returnCaptor = ArgumentCaptor.forClass(RemoteCallReturn.class); batchJobLogger.logUpload(contentsString, URI.create(url), response, exception); verify(loggerDelegate).logRequestSummary(returnCaptor.capture()); RemoteCallReturn capturedReturn = returnCaptor.getValue(); assertEquals(exception, capturedReturn.getException()); RequestInfo requestInfo = capturedReturn.getRequestInfo(); assertEquals(url, requestInfo.getUrl()); assertEquals("clientCustomerId", requestInfo.getContextName()); assertNull(requestInfo.getContextValue()); assertThat(requestInfo.getPayload(), containsString(contentsString)); assertThat(requestInfo.getServiceName(), containsString("upload")); ResponseInfo responseInfo = capturedReturn.getResponseInfo(); assertNull(responseInfo.getRequestId()); assertThat(responseInfo.getPayload(), startsWith(String.valueOf(response.getHttpStatus()))); assertThat(responseInfo.getPayload(), containsString(response.getHttpResponseMessage())); verify(loggerDelegate).logRequestDetails(returnCaptor.capture()); assertSame( "The same RemoteCallReturn object was not passed to request details and request summary", capturedReturn, returnCaptor.getValue()); }
@Test public void testLogUpload_nullablesNull() { String contentsString = "success contents"; ArgumentCaptor<RemoteCallReturn> returnCaptor = ArgumentCaptor.forClass(RemoteCallReturn.class); batchJobLogger.logUpload(contentsString, URI.create(url), null, null); verify(loggerDelegate).logRequestSummary(returnCaptor.capture()); RemoteCallReturn capturedReturn = returnCaptor.getValue(); assertNull(capturedReturn.getException()); verify(loggerDelegate).logRequestDetails(returnCaptor.capture()); assertSame( "The same RemoteCallReturn object was not passed to request details and request summary", capturedReturn, returnCaptor.getValue()); }