use of com.google.api.ads.common.lib.client.ResponseInfo in project googleads-java-lib by googleads.
the class RemoteCallLoggerDelegateTest method testLogRequestSummary_failure.
@Test
public void testLogRequestSummary_failure() {
Throwable returnedException = new Throwable();
remoteCallReturn = new RemoteCallReturn.Builder().withRequestInfo(remoteCallReturn.getRequestInfo()).withResponseInfo(remoteCallReturn.getResponseInfo()).withException(returnedException).build();
when(requestInfoLogger.isWarnEnabled()).thenReturn(true);
loggerDelegate.logRequestSummary(remoteCallReturn);
RequestInfo requestInfo = remoteCallReturn.getRequestInfo();
ResponseInfo responseInfo = remoteCallReturn.getResponseInfo();
verify(requestInfoLogger).warn(RemoteCallLoggerDelegate.SUMMARY_TEMPLATE, requestInfo.getServiceName(), requestInfo.getMethodName(), requestInfo.getContextName(), requestInfo.getContextValue(), requestInfo.getUrl(), responseInfo.getRequestId(), responseInfo.getResponseTime(), responseInfo.getOperationsCount(), true, returnedException.toString());
}
use of com.google.api.ads.common.lib.client.ResponseInfo in project googleads-java-lib by googleads.
the class RemoteCallLoggerDelegateTest method testLogRequestSummary_success.
@Test
public void testLogRequestSummary_success() {
// Set up the request info mock.
when(requestInfoLogger.isInfoEnabled()).thenReturn(true);
loggerDelegate.logRequestSummary(remoteCallReturn);
RequestInfo requestInfo = remoteCallReturn.getRequestInfo();
ResponseInfo responseInfo = remoteCallReturn.getResponseInfo();
verify(requestInfoLogger).info(RemoteCallLoggerDelegate.SUMMARY_TEMPLATE, requestInfo.getServiceName(), requestInfo.getMethodName(), requestInfo.getContextName(), requestInfo.getContextValue(), requestInfo.getUrl(), responseInfo.getRequestId(), responseInfo.getResponseTime(), responseInfo.getOperationsCount(), false, null);
}
use of com.google.api.ads.common.lib.client.ResponseInfo 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.ResponseInfo 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.ResponseInfo in project googleads-java-lib by googleads.
the class ResponseInfoXPathSetTest method testParseActualMessage.
@Test
public void testParseActualMessage() throws SOAPException, IOException {
Builder builder = new Builder();
SOAPMessage message = Mockito.mock(SOAPMessage.class);
SOAPHeader header = Mockito.mock(SOAPHeader.class);
when(message.getSOAPHeader()).thenReturn(header);
final String payload = "<foo><bar>MyBar</bar></foo>";
doAnswer(invocation -> {
OutputStream outputStream = (OutputStream) invocation.getArguments()[0];
outputStream.write(payload.getBytes(StandardCharsets.UTF_8));
return null;
}).when(message).writeTo(org.mockito.ArgumentMatchers.any(OutputStream.class));
assertSame("parseMessage should return the same builder passed in", builder, xPathSet.parseMessage(builder, message));
ResponseInfo responseInfo = builder.build();
assertEquals("Payload doesn't match", payload, responseInfo.getPayload());
}
Aggregations