use of com.google.cloud.bigquery.testing.RemoteBigQueryHelper in project google-cloud-java by GoogleCloudPlatform.
the class ITBigQueryTest method beforeClass.
@BeforeClass
public static void beforeClass() throws InterruptedException, TimeoutException {
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
RemoteStorageHelper storageHelper = RemoteStorageHelper.create();
bigquery = bigqueryHelper.getOptions().getService();
storage = storageHelper.getOptions().getService();
storage.create(BucketInfo.of(BUCKET));
storage.create(BlobInfo.newBuilder(BUCKET, LOAD_FILE).setContentType("text/plain").build(), CSV_CONTENT.getBytes(StandardCharsets.UTF_8));
storage.create(BlobInfo.newBuilder(BUCKET, JSON_LOAD_FILE).setContentType("application/json").build(), JSON_CONTENT.getBytes(StandardCharsets.UTF_8));
DatasetInfo info = DatasetInfo.newBuilder(DATASET).setDescription(DESCRIPTION).setLabels(LABELS).build();
bigquery.create(info);
LoadJobConfiguration configuration = LoadJobConfiguration.newBuilder(TABLE_ID, "gs://" + BUCKET + "/" + JSON_LOAD_FILE, FormatOptions.json()).setCreateDisposition(JobInfo.CreateDisposition.CREATE_IF_NEEDED).setSchema(TABLE_SCHEMA).build();
Job job = bigquery.create(JobInfo.of(configuration));
job = job.waitFor();
assertNull(job.getStatus().getError());
}
Aggregations