@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()); }
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); }
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); } }
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); }
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); }
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);  }