diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java index dd5aeb618..b99690011 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java @@ -860,7 +860,7 @@ public void testListTablesWithRangePartitioning() { @Test public void testListPartitions() throws InterruptedException { - String tableName = "test_table_partitions"; + String tableName = "test_table_partitions_" + UUID.randomUUID().toString().substring(0, 8); Date date = Date.fromJavaUtilDate(new java.util.Date()); String partitionDate = date.toString().replaceAll("-", ""); TableId tableId = TableId.of(DATASET, tableName + "$" + partitionDate); @@ -873,18 +873,15 @@ public void testListPartitions() throws InterruptedException { Job job = bigquery.create(JobInfo.of(QueryJobConfiguration.newBuilder(query).build())); job.waitFor(); assertTrue(job.isDone()); - try { - Map row = new HashMap(); - row.put("StringField", "StringValue"); - InsertAllRequest request = InsertAllRequest.newBuilder(tableId).addRow(row).build(); - InsertAllResponse response = bigquery.insertAll(request); - assertFalse(response.hasErrors()); - assertEquals(0, response.getInsertErrors().size()); - List partitions = bigquery.listPartitions(TableId.of(DATASET, tableName)); - assertEquals(1, partitions.size()); - } finally { - bigquery.delete(tableId); - } + Map row = new HashMap<>(); + row.put("StringField", "StringValue"); + InsertAllRequest request = InsertAllRequest.newBuilder(tableId).addRow(row).build(); + InsertAllResponse response = bigquery.insertAll(request); + assertFalse(response.hasErrors()); + assertEquals(0, response.getInsertErrors().size()); + List partitions = bigquery.listPartitions(TableId.of(DATASET, tableName)); + assertEquals(1, partitions.size()); + bigquery.delete(tableId); } @Test