use of com.google.api.ads.adwords.lib.utils.BatchJobMutateResultInterface in project googleads-java-lib by googleads.
the class BatchJobLoggerTest method testLogDownload.
/**
* Confirms a download is logged as expected.
*/
@SuppressWarnings("unchecked")
@Test
public void testLogDownload() {
BatchJobMutateResponseInterface<String, IllegalArgumentException, BatchJobMutateResultInterface<String, IllegalArgumentException>> response = Mockito.mock(BatchJobMutateResponseInterface.class);
// Cannot specify generic args for mocks
@SuppressWarnings("rawtypes") BatchJobMutateResultInterface[] mutateResults = new BatchJobMutateResultInterface[] { Mockito.mock(BatchJobMutateResultInterface.class), Mockito.mock(BatchJobMutateResultInterface.class) };
when(response.getMutateResults()).thenReturn(mutateResults);
batchJobLogger.logDownload(url, response, exception);
ArgumentCaptor<RemoteCallReturn> returnCaptor = ArgumentCaptor.forClass(RemoteCallReturn.class);
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());
assertNull(requestInfo.getPayload());
assertThat(requestInfo.getServiceName(), containsString("download"));
ResponseInfo responseInfo = capturedReturn.getResponseInfo();
assertNull(responseInfo.getRequestId());
assertEquals("Results count: 2", responseInfo.getPayload());
verify(loggerDelegate).logRequestDetails(returnCaptor.capture());
assertSame("The same RemoteCallReturn object was not passed to request details and request summary", capturedReturn, returnCaptor.getValue());
}
Aggregations