@Test public void testQueryDryRun() throws Exception { // https://github.com/googleapis/google-cloud-java/issues/2479 EasyMock.replay(bigqueryRpcMock); thrown.expect(UnsupportedOperationException.class); options .toBuilder() .setRetrySettings(ServiceOptions.getDefaultRetrySettings()) .build() .getService() .query(QueryJobConfiguration.newBuilder("foo").setDryRun(true).build()); } }
@Test public void testQueryJobWithDryRun() throws InterruptedException, TimeoutException { String tableName = "test_query_job_table"; String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable(); TableId destinationTable = TableId.of(DATASET, tableName); QueryJobConfiguration configuration = QueryJobConfiguration.newBuilder(query) .setDefaultDataset(DatasetId.of(DATASET)) .setDestinationTable(destinationTable) .setDryRun(true) .build(); Job remoteJob = bigquery.create(JobInfo.of(configuration)); assertNull(remoteJob.getJobId().getJob()); assertEquals(DONE, remoteJob.getStatus().getState()); assertNotNull(remoteJob.getConfiguration()); }