use of com.google.api.ads.common.lib.client.RequestInfo in project googleads-java-lib by googleads.
the class ReportServiceLoggerTest method testBuildInfos_failure.
@Test
public void testBuildInfos_failure() {
RequestInfo requestInfo = reportServiceLogger.buildRequestInfo(httpRequest);
checkRequestInfoAttributes(requestInfo, true);
ResponseInfo responseInfo = reportServiceLogger.buildResponseInfo(httpRequest, HttpStatusCodes.STATUS_CODE_BAD_GATEWAY, "Bad gateway");
checkResponseInfoAttributes(responseInfo, HttpStatusCodes.STATUS_CODE_BAD_GATEWAY, "Bad gateway");
}
use of com.google.api.ads.common.lib.client.RequestInfo in project googleads-java-lib by googleads.
the class ReportServiceLoggerTest method testBuildInfos_success.
@Test
public void testBuildInfos_success() {
RequestInfo requestInfo = reportServiceLogger.buildRequestInfo(httpRequest);
checkRequestInfoAttributes(requestInfo, true);
ResponseInfo responseInfo = reportServiceLogger.buildResponseInfo(httpRequest, HttpStatusCodes.STATUS_CODE_OK, null);
checkResponseInfoAttributes(responseInfo, HttpStatusCodes.STATUS_CODE_OK, null);
}
use of com.google.api.ads.common.lib.client.RequestInfo in project googleads-java-lib by googleads.
the class RequestInfoXPathSetTest method testParseActualMessage.
@Test
public void testParseActualMessage() throws SOAPException, IOException, TransformerException {
Builder builder = new Builder();
SOAPMessage message = Mockito.mock(SOAPMessage.class);
SOAPHeader header = Mockito.mock(SOAPHeader.class);
SOAPPart soapPart = Mockito.mock(SOAPPart.class);
when(message.getSOAPHeader()).thenReturn(header);
when(message.getSOAPPart()).thenReturn(soapPart);
final String payload = "<foo><bar>MyBar</bar></foo>";
when(transformerSupplier.get()).thenReturn(transformer);
doAnswer(invocation -> {
StreamResult streamResult = (StreamResult) invocation.getArguments()[1];
streamResult.getOutputStream().write(payload.getBytes(StandardCharsets.UTF_8));
return null;
}).when(transformer).transform(any(), any());
assertSame("parseMessage should return the same builder passed in", builder, xPathSet.parseMessage(builder, message));
RequestInfo requestInfo = builder.build();
assertEquals("Payload doesn't match", payload, requestInfo.getPayload());
assertEquals("Context name doesn't match", "bar", requestInfo.getContextName());
}
use of com.google.api.ads.common.lib.client.RequestInfo in project googleads-java-lib by googleads.
the class RemoteCallLoggerDelegate method logRequestSummary.
public void logRequestSummary(RemoteCallReturn remoteCallReturn) {
if (remoteCallReturn == null) {
return;
}
boolean isSuccess = remoteCallReturn.getException() == null;
if (!isSummaryLoggable(isSuccess)) {
return;
}
RequestInfo request = remoteCallReturn.getRequestInfo();
ResponseInfo response = remoteCallReturn.getResponseInfo();
Object[] logArgs = new Object[10];
if (request != null) {
logArgs[0] = request.getServiceName();
logArgs[1] = request.getMethodName();
logArgs[2] = request.getContextName();
logArgs[3] = request.getContextValue();
logArgs[4] = request.getUrl();
}
if (response != null) {
logArgs[5] = response.getRequestId();
logArgs[6] = response.getResponseTime();
logArgs[7] = response.getOperationsCount();
Throwable throwable = remoteCallReturn.getException();
logArgs[8] = throwable != null;
logArgs[9] = truncateThrowable(throwable, MAX_SUMMARY_ERROR_LENGTH);
}
if (isSuccess) {
summaryLogger.info(SUMMARY_TEMPLATE, logArgs);
} else {
summaryLogger.warn(SUMMARY_TEMPLATE, logArgs);
}
}
use of com.google.api.ads.common.lib.client.RequestInfo in project googleads-java-lib by googleads.
the class JaxWsSoapContextHandlerTest method testCaptureServiceAndOperationNames.
@Test
public void testCaptureServiceAndOperationNames() throws Exception {
when(mockSoapMessageContext.get(MessageContext.WSDL_SERVICE)).thenReturn(wsdlService);
when(mockSoapMessageContext.getMessage()).thenReturn(mockMessage);
when(mockMessage.getSOAPBody()).thenReturn(mockSoapBody);
when(mockSoapBody.getFirstChild()).thenReturn(firstChild);
when(firstChild.getLocalName()).thenReturn(OPERATION_LOCAL_NAME);
jaxWsSoapContextHandler.captureServiceAndOperationNames(mockSoapMessageContext);
RequestInfo requestInfo = jaxWsSoapContextHandler.getLastRequestInfoBuilder().build();
assertEquals(wsdlService.getLocalPart(), requestInfo.getServiceName());
assertEquals(OPERATION_LOCAL_NAME, requestInfo.getMethodName());
}
Aggregations