use of com.google.api.services.bigquery.model.TableDataList in project beam by apache.
the class BigQueryUtilTest method testTableGet.
@Test
public void testTableGet() throws InterruptedException, IOException {
onTableGet(basicTableSchema());
TableDataList dataList = new TableDataList().setTotalRows(0L);
onTableList(dataList);
BigQueryServicesImpl.DatasetServiceImpl services = new BigQueryServicesImpl.DatasetServiceImpl(mockClient, options);
services.getTable(new TableReference().setProjectId("project").setDatasetId("dataset").setTableId("table"));
verifyTableGet();
}
use of com.google.api.services.bigquery.model.TableDataList in project beam by apache.
the class BigQueryServicesImplTest method testIsTableEmptySucceeds.
@Test
public void testIsTableEmptySucceeds() throws Exception {
TableReference tableRef = new TableReference().setProjectId("projectId").setDatasetId("datasetId").setTableId("tableId");
TableDataList testDataList = new TableDataList().setRows(ImmutableList.of(new TableRow()));
// First response is 403 rate limited, second response has valid payload.
when(response.getContentType()).thenReturn(Json.MEDIA_TYPE);
when(response.getStatusCode()).thenReturn(403).thenReturn(200);
when(response.getContent()).thenReturn(toStream(errorWithReasonAndStatus("rateLimitExceeded", 403))).thenReturn(toStream(testDataList));
BigQueryServicesImpl.DatasetServiceImpl datasetService = new BigQueryServicesImpl.DatasetServiceImpl(bigquery, PipelineOptionsFactory.create());
assertFalse(datasetService.isTableEmpty(tableRef, BackOff.ZERO_BACKOFF, Sleeper.DEFAULT));
verify(response, times(2)).getStatusCode();
verify(response, times(2)).getContent();
verify(response, times(2)).getContentType();
}
Aggregations