String.format( "%d %s%n", batchJobUploadResponse.getHttpStatus(), batchJobUploadResponse.getHttpResponseMessage()));
/** Confirms an upload is logged as expected. */ @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()); }
uploadRequestBody, mockHttpServer.getLastResponse().getRequestBody()); assertEquals("Last request should have succeeded", 200, response.getHttpStatus()); new BatchJobUploadStatus( uploadRequestBody.getBytes(UTF_8).length, URI.create(mockHttpServer.getServerUrl())); BatchJobUploadStatus actualStatus = response.getBatchJobUploadStatus(); assertEquals( "Status total content length is incorrect",
batchJobUploadResponse = new BatchJobUploadResponse( response, effectiveStatus.getTotalContentLength() + httpRequest.getContent().getLength(), new BatchJobUploadResponse(new ByteArrayInputStream(new byte[0]), e.getStatusCode(), e.getStatusMessage(), effectiveStatus.getTotalContentLength() + contentLength, effectiveStatus.getResumableUploadUri());
assertEquals("Request should have succeeded", 200, response.getHttpStatus()); status.getTotalContentLength() + expectedBody.getBytes(UTF_8).length, URI.create(mockHttpServer.getServerUrl())); BatchJobUploadStatus actualStatus = response.getBatchJobUploadStatus(); assertEquals( "Status total content length is incorrect",
batchJobUploadResponse = new BatchJobUploadResponse( response, effectiveStatus.getTotalContentLength() + httpRequest.getContent().getLength(), new BatchJobUploadResponse(new ByteArrayInputStream(new byte[0]), e.getStatusCode(), e.getStatusMessage(), effectiveStatus.getTotalContentLength() + contentLength, effectiveStatus.getResumableUploadUri());
String.format( "%d %s%n", batchJobUploadResponse.getHttpStatus(), batchJobUploadResponse.getHttpResponseMessage()));
assertEquals("Request should have succeeded", 200, response.getHttpStatus()); status.getTotalContentLength() + expectedBody.getBytes(UTF_8).length, URI.create(mockHttpServer.getServerUrl())); BatchJobUploadStatus actualStatus = response.getBatchJobUploadStatus(); assertEquals( "Status total content length is incorrect",