|
25 | 25 | import static org.junit.Assert.fail; |
26 | 26 |
|
27 | 27 | import com.google.cloud.Page; |
| 28 | +import com.google.cloud.WaitForOption; |
28 | 29 | import com.google.cloud.bigquery.BigQuery; |
29 | 30 | import com.google.cloud.bigquery.BigQuery.DatasetField; |
30 | 31 | import com.google.cloud.bigquery.BigQuery.DatasetOption; |
@@ -899,7 +900,7 @@ public void testListJobsWithSelectedFields() { |
899 | 900 | } |
900 | 901 |
|
901 | 902 | @Test |
902 | | - public void testCreateAndGetJob() { |
| 903 | + public void testCreateAndGetJob() throws InterruptedException, TimeoutException { |
903 | 904 | String sourceTableName = "test_create_and_get_job_source_table"; |
904 | 905 | String destinationTableName = "test_create_and_get_job_destination_table"; |
905 | 906 | TableId sourceTable = TableId.of(DATASET, sourceTableName); |
@@ -930,11 +931,18 @@ public void testCreateAndGetJob() { |
930 | 931 | assertEquals(createdJob.getSelfLink(), remoteJob.getSelfLink()); |
931 | 932 | assertEquals(createdJob.getUserEmail(), remoteJob.getUserEmail()); |
932 | 933 | assertTrue(createdTable.delete()); |
| 934 | + |
| 935 | + Job completedJob = |
| 936 | + remoteJob.waitFor( |
| 937 | + WaitForOption.checkEvery(1, TimeUnit.SECONDS), |
| 938 | + WaitForOption.timeout(1, TimeUnit.MINUTES)); |
| 939 | + assertNotNull(completedJob); |
| 940 | + assertNull(completedJob.getStatus().getError()); |
933 | 941 | assertTrue(bigquery.delete(DATASET, destinationTableName)); |
934 | 942 | } |
935 | 943 |
|
936 | 944 | @Test |
937 | | - public void testCreateAndGetJobWithSelectedFields() { |
| 945 | + public void testCreateAndGetJobWithSelectedFields() throws InterruptedException, TimeoutException { |
938 | 946 | String sourceTableName = "test_create_and_get_job_with_selected_fields_source_table"; |
939 | 947 | String destinationTableName = "test_create_and_get_job_with_selected_fields_destination_table"; |
940 | 948 | TableId sourceTable = TableId.of(DATASET, sourceTableName); |
@@ -972,6 +980,13 @@ public void testCreateAndGetJobWithSelectedFields() { |
972 | 980 | assertNull(remoteJob.getSelfLink()); |
973 | 981 | assertNull(remoteJob.getUserEmail()); |
974 | 982 | assertTrue(createdTable.delete()); |
| 983 | + |
| 984 | + Job completedJob = |
| 985 | + remoteJob.waitFor( |
| 986 | + WaitForOption.checkEvery(1, TimeUnit.SECONDS), |
| 987 | + WaitForOption.timeout(1, TimeUnit.MINUTES)); |
| 988 | + assertNotNull(completedJob); |
| 989 | + assertNull(completedJob.getStatus().getError()); |
975 | 990 | assertTrue(bigquery.delete(DATASET, destinationTableName)); |
976 | 991 | } |
977 | 992 |
|
|
0 commit comments