1616
1717package com .google .cloud .examples .bigquery .snippets ;
1818
19+ import static org .junit .Assert .assertEquals ;
1920import static org .junit .Assert .assertTrue ;
2021
2122import com .google .cloud .bigquery .BigQuery ;
2223import com .google .cloud .bigquery .Job ;
2324import com .google .cloud .bigquery .JobConfiguration ;
2425import com .google .cloud .bigquery .JobInfo ;
26+ import com .google .cloud .bigquery .JobStatus ;
2527import com .google .cloud .bigquery .QueryJobConfiguration ;
2628import com .google .cloud .bigquery .testing .RemoteBigQueryHelper ;
2729
@@ -40,6 +42,16 @@ public static void beforeClass() {
4042 bigquery = RemoteBigQueryHelper .create ().options ().service ();
4143 }
4244
45+ @ Test
46+ public void testExists () throws Exception {
47+ JobConfiguration jobConfig = QueryJobConfiguration .builder (QUERY ).useLegacySql (false ).build ();
48+ JobInfo jobInfo = JobInfo .builder (jobConfig ).build ();
49+ Job job = bigquery .create (jobInfo );
50+ JobSnippets jobSnippets = new JobSnippets (job );
51+ boolean result = jobSnippets .exists ();
52+ assertTrue (result );
53+ }
54+
4355 @ Test
4456 public void testIsDone () throws Exception {
4557 JobConfiguration jobConfig = QueryJobConfiguration .builder (QUERY ).useLegacySql (false ).build ();
@@ -69,4 +81,34 @@ public void testWaitForWithOptions() throws Exception {
6981 boolean result = jobSnippets .waitForWithOptions ();
7082 assertTrue (result );
7183 }
84+
85+ @ Test
86+ public void testReload () throws Exception {
87+ JobConfiguration jobConfig = QueryJobConfiguration .builder (QUERY ).useLegacySql (false ).build ();
88+ JobInfo jobInfo = JobInfo .builder (jobConfig ).build ();
89+ Job job = bigquery .create (jobInfo );
90+ JobSnippets jobSnippets = new JobSnippets (job );
91+ JobStatus .State result = jobSnippets .reload ();
92+ assertEquals (JobStatus .State .DONE , result );
93+ }
94+
95+ @ Test
96+ public void testReloadStatus () throws Exception {
97+ JobConfiguration jobConfig = QueryJobConfiguration .builder (QUERY ).useLegacySql (false ).build ();
98+ JobInfo jobInfo = JobInfo .builder (jobConfig ).build ();
99+ Job job = bigquery .create (jobInfo );
100+ JobSnippets jobSnippets = new JobSnippets (job );
101+ JobStatus .State result = jobSnippets .reloadStatus ();
102+ assertEquals (JobStatus .State .DONE , result );
103+ }
104+
105+ @ Test
106+ public void testCancel () {
107+ JobConfiguration jobConfig = QueryJobConfiguration .builder (QUERY ).useLegacySql (false ).build ();
108+ JobInfo jobInfo = JobInfo .builder (jobConfig ).build ();
109+ Job job = bigquery .create (jobInfo );
110+ JobSnippets jobSnippets = new JobSnippets (job );
111+ boolean result = jobSnippets .cancel ();
112+ assertTrue (result );
113+ }
72114}
0 commit comments