Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ public Tuple<String, Iterable<Model>> listModels(
.setMaxResults(Option.MAX_RESULTS.getLong(options))
.setPageToken(Option.PAGE_TOKEN.getString(options))
.execute();
Iterable<Model> models = modelList.getModels();
Iterable<Model> models =
modelList.getModels() != null ? modelList.getModels() : ImmutableList.<Model>of();
return Tuple.of(modelList.getNextPageToken(), models);
} catch (IOException ex) {
throw translate(ex);
Expand Down Expand Up @@ -456,7 +457,10 @@ public Tuple<String, Iterable<Routine>> listRoutines(
.setMaxResults(Option.MAX_RESULTS.getLong(options))
.setPageToken(Option.PAGE_TOKEN.getString(options))
.execute();
Iterable<Routine> routines = routineList.getRoutines();
Iterable<Routine> routines =
routineList.getRoutines() != null
? routineList.getRoutines()
: ImmutableList.<Routine>of();
return Tuple.of(routineList.getNextPageToken(), routines);
} catch (IOException ex) {
throw translate(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public class ITBigQueryTest {
private static final String MODEL_DATASET = RemoteBigQueryHelper.generateDatasetName();
private static final String ROUTINE_DATASET = RemoteBigQueryHelper.generateDatasetName();
private static final String PROJECT_ID = ServiceOptions.getDefaultProjectId();
private static final String RANDOM_ID = UUID.randomUUID().toString().substring(0, 8);
private static final Map<String, String> LABELS =
ImmutableMap.of(
"example-label1", "example-value1",
Expand Down Expand Up @@ -1425,6 +1426,29 @@ public void testModelLifecycle() throws InterruptedException {
assertTrue(bigquery.delete(modelId));
}

@Test
public void testEmptyListModels() {
String datasetId = "test_empty_dataset_list_models_" + RANDOM_ID;
assertNotNull(bigquery.create(DatasetInfo.of(datasetId)));
Page<Model> models = bigquery.listModels(datasetId, BigQuery.ModelListOption.pageSize(100));
assertEquals(0, Iterables.size(models.getValues()));
assertFalse(models.hasNextPage());
assertNull(models.getNextPageToken());
assertTrue(bigquery.delete(datasetId));
}

@Test
public void testEmptyListRoutines() {
String datasetId = "test_empty_dataset_list_routines_" + RANDOM_ID;
assertNotNull(bigquery.create(DatasetInfo.of(datasetId)));
Page<Routine> routines =
bigquery.listRoutines(datasetId, BigQuery.RoutineListOption.pageSize(100));
assertEquals(0, Iterables.size(routines.getValues()));
assertFalse(routines.hasNextPage());
assertNull(routines.getNextPageToken());
assertTrue(bigquery.delete(datasetId));
}

@Test
public void testRoutineLifecycle() throws InterruptedException {

Expand Down