com.google.cloud.bigquery.testing.RemoteBigQueryHelper Java Examples

The following examples show how to use com.google.cloud.bigquery.testing.RemoteBigQueryHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractBigQueryIT.java    From nifi with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void beforeClass() throws IOException {
    final Map<PropertyDescriptor, String> propertiesMap = new HashMap<>();
    propertiesMap.put(CredentialPropertyDescriptors.SERVICE_ACCOUNT_JSON_FILE, SERVICE_ACCOUNT_JSON);
    Credentials credentials = credentialsProviderFactory.getGoogleCredentials(propertiesMap, new ProxyAwareTransportFactory(null));

    BigQueryOptions bigQueryOptions = BigQueryOptions.newBuilder()
            .setProjectId(PROJECT_ID)
            .setCredentials(credentials)
            .build();

    bigquery = bigQueryOptions.getService();

    DatasetInfo datasetInfo = DatasetInfo.newBuilder(RemoteBigQueryHelper.generateDatasetName()).build();
    dataset = bigquery.create(datasetInfo);
}
 
Example #2
Source File: BigQueryDataset.java    From gcp-ingestion with Mozilla Public License 2.0 5 votes vote down vote up
/** Find credentials in the environment and create a dataset in BigQuery. */
@Override
protected void starting(Description description) {
  RemoteBigQueryHelper bqHelper = RemoteBigQueryHelper.create();
  bigquery = bqHelper.getOptions().getService();
  project = bqHelper.getOptions().getProjectId();
  dataset = RemoteBigQueryHelper.generateDatasetName();
  bigquery.create(DatasetInfo.newBuilder(dataset).build());
}
 
Example #3
Source File: BigQueryIntegrationTest.java    From gcp-ingestion with Mozilla Public License 2.0 5 votes vote down vote up
/** Find credentials in the environment and create a dataset in BigQuery. */
@Before
public void createBigQueryDataset() {
  RemoteBigQueryHelper bqHelper = RemoteBigQueryHelper.create();
  bigquery = bqHelper.getOptions().getService();
  projectId = bqHelper.getOptions().getProjectId();
  dataset = RemoteBigQueryHelper.generateDatasetName();
}
 
Example #4
Source File: ITDatasetSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() {
  bigquery = RemoteBigQueryHelper.create().getOptions().getService();
  dataset = bigquery.create(DatasetInfo.newBuilder(DATASET).build());
  nonExistingDataset = bigquery.create(DatasetInfo.newBuilder(NON_EXISTING_DATASET).build());
  nonExistingDataset.delete(DatasetDeleteOption.deleteContents());
}
 
Example #5
Source File: ITDatasetSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testDelete() {
  String datasetName = RemoteBigQueryHelper.generateDatasetName();
  DatasetInfo dataset = DatasetInfo.newBuilder(datasetName).build();
  DatasetSnippets datasetSnippets = new DatasetSnippets(bigquery.create(dataset));
  assertTrue(datasetSnippets.deleteDataset());
}
 
Example #6
Source File: ITDatasetInfoSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() {
  bigquery = RemoteBigQueryHelper.create().getOptions().getService();
  datasetInfoSnippets = new DatasetInfoSnippets(bigquery);
  bigquery.create(DatasetInfo.newBuilder(DATASET).build());
  bout = new ByteArrayOutputStream();
  out = new PrintStream(bout);
  System.setOut(out);
}
 
Example #7
Source File: ITBigQuerySnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() {
  bigquery = RemoteBigQueryHelper.create().getOptions().getService();
  bigquerySnippets = new BigQuerySnippets(bigquery);
  bigquery.create(DatasetInfo.newBuilder(DATASET).build());
  bout = new ByteArrayOutputStream();
  out = new PrintStream(bout);
  System.setOut(out);
}
 
Example #8
Source File: ITTableSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() {
  bigquery = RemoteBigQueryHelper.create().getOptions().getService();
  bigquery.create(DatasetInfo.newBuilder(DATASET_NAME).build());
  bigquery.create(DatasetInfo.newBuilder(COPY_DATASET_NAME).build());
  storage = RemoteStorageHelper.create().getOptions().getService();
  storage.create(BucketInfo.of(BUCKET_NAME));
}
 
Example #9
Source File: ITCloudSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() {
  bigquery = RemoteBigQueryHelper.create().getOptions().getService();
  cloudSnippets = new CloudSnippets(bigquery);
  bigquery.create(DatasetInfo.newBuilder(DATASET).build());
  bout = new ByteArrayOutputStream();
  out = new PrintStream(bout);
  System.setOut(out);
}
 
Example #10
Source File: BigQueryDataset.java    From gcp-ingestion with Mozilla Public License 2.0 4 votes vote down vote up
/** Remove all resources we created in BigQuery. */
@Override
protected void finished(Description description) {
  RemoteBigQueryHelper.forceDelete(bigquery, dataset);
}
 
Example #11
Source File: BigQueryIntegrationTest.java    From gcp-ingestion with Mozilla Public License 2.0 4 votes vote down vote up
/** Remove all resources we created in BigQuery. */
@After
public void deleteBigQueryDataset() {
  RemoteBigQueryHelper.forceDelete(bigquery, dataset);
}
 
Example #12
Source File: ITTableSnippets.java    From google-cloud-java with Apache License 2.0 4 votes vote down vote up
@AfterClass
public static void afterClass() {
  RemoteBigQueryHelper.forceDelete(bigquery, DATASET_NAME);
  RemoteBigQueryHelper.forceDelete(bigquery, COPY_DATASET_NAME);
  RemoteStorageHelper.forceDelete(storage, BUCKET_NAME);
}
 
Example #13
Source File: ITJobSnippets.java    From google-cloud-java with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void beforeClass() {
  bigquery = RemoteBigQueryHelper.create().getOptions().getService();
}