@Test
 public void testListBlobsSelectedFields() {
   String[] blobNames = {
     "test-list-blobs-selected-fields-blob1", "test-list-blobs-selected-fields-blob2"
   };
   ImmutableMap metadata = ImmutableMap.of("k", "v");
   BlobInfo blob1 =
       BlobInfo.builder(BUCKET, blobNames[0]).contentType(CONTENT_TYPE).metadata(metadata).build();
   BlobInfo blob2 =
       BlobInfo.builder(BUCKET, blobNames[1]).contentType(CONTENT_TYPE).metadata(metadata).build();
   assertNotNull(storage.create(blob1));
   assertNotNull(storage.create(blob2));
   Page<BlobInfo> page =
       storage.list(
           BUCKET,
           Storage.BlobListOption.prefix("test-list-blobs-selected-fields-blob"),
           Storage.BlobListOption.fields(BlobField.METADATA));
   int index = 0;
   for (BlobInfo remoteBlob : page.values()) {
     assertEquals(BUCKET, remoteBlob.bucket());
     assertEquals(blobNames[index++], remoteBlob.name());
     assertEquals(metadata, remoteBlob.metadata());
     assertNull(remoteBlob.contentType());
   }
   assertTrue(storage.delete(BUCKET, blobNames[0]));
   assertTrue(storage.delete(BUCKET, blobNames[1]));
 }
Esempio n. 2
0
 @Test
 public void testListJobsWithSelectedFields() {
   Page<Job> jobs = bigquery.listJobs(JobListOption.fields(JobField.USER_EMAIL));
   for (Job job : jobs.values()) {
     assertNotNull(job.jobId());
     assertNotNull(job.status());
     assertNotNull(job.userEmail());
     assertNull(job.statistics());
     assertNull(job.id());
   }
 }
Esempio n. 3
0
 @Test
 public void testListJobs() {
   Page<Job> jobs = bigquery.listJobs();
   for (Job job : jobs.values()) {
     assertNotNull(job.jobId());
     assertNotNull(job.statistics());
     assertNotNull(job.status());
     assertNotNull(job.userEmail());
     assertNotNull(job.id());
   }
 }
Esempio n. 4
0
 @Test
 public void testListTables() {
   String tableName = "test_list_tables";
   StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
   TableInfo tableInfo = TableInfo.of(TableId.of(DATASET, tableName), tableDefinition);
   Table createdTable = bigquery.create(tableInfo);
   assertNotNull(createdTable);
   Page<Table> tables = bigquery.listTables(DATASET);
   boolean found = false;
   Iterator<Table> tableIterator = tables.values().iterator();
   while (tableIterator.hasNext() && !found) {
     if (tableIterator.next().tableId().equals(createdTable.tableId())) {
       found = true;
     }
   }
   assertTrue(found);
   assertTrue(createdTable.delete());
 }