|
24 | 24 | import com.google.cloud.dlp.v2.DlpServiceClient; |
25 | 25 | import com.google.privacy.dlp.v2.CancelDlpJobRequest; |
26 | 26 | import java.io.ByteArrayOutputStream; |
27 | | -import java.io.IOException; |
28 | 27 | import java.io.PrintStream; |
29 | 28 | import java.util.Arrays; |
30 | | -import java.util.concurrent.ExecutionException; |
31 | 29 | import java.util.concurrent.TimeUnit; |
32 | 30 | import org.junit.After; |
33 | 31 | import org.junit.Before; |
@@ -158,60 +156,30 @@ public void testInspectImageFile() { |
158 | 156 | } |
159 | 157 |
|
160 | 158 | @Test |
161 | | - public void testInspectGcsFile() throws InterruptedException, ExecutionException, IOException { |
162 | | - |
| 159 | + public void testInspectGcsFile() throws Exception { |
163 | 160 | InspectGcsFile.inspectGcsFile(PROJECT_ID, GCS_PATH, TOPIC_ID, SUBSCRIPTION_ID); |
164 | | - // Await job creation |
165 | | - TimeUnit.SECONDS.sleep(3); |
166 | 161 |
|
167 | 162 | String output = bout.toString(); |
168 | | - assertThat(output, containsString("Job created: ")); |
169 | | - |
170 | | - // Cancelling the job early to conserve quota |
171 | | - String jobId = output.split("Job created: ")[1].split("\n")[0]; |
172 | | - CancelDlpJobRequest request = CancelDlpJobRequest.newBuilder().setName(jobId).build(); |
173 | | - try (DlpServiceClient client = DlpServiceClient.create()) { |
174 | | - client.cancelDlpJob(request); |
175 | | - } |
| 163 | + assertThat(output, containsString("Job status: DONE")); |
176 | 164 | } |
177 | 165 |
|
178 | 166 | @Test |
179 | | - public void testInspectDatastoreEntity() |
180 | | - throws InterruptedException, ExecutionException, IOException { |
| 167 | + public void testInspectDatastoreEntity() throws Exception { |
181 | 168 |
|
182 | 169 | InspectDatastoreEntity.insepctDatastoreEntity( |
183 | 170 | PROJECT_ID, datastoreNamespace, datastoreKind, TOPIC_ID, SUBSCRIPTION_ID); |
184 | | - // Await job creation |
185 | | - TimeUnit.SECONDS.sleep(3); |
186 | 171 |
|
187 | 172 | String output = bout.toString(); |
188 | | - assertThat(output, containsString("Job created: ")); |
189 | | - |
190 | | - // Cancelling the job early to conserve quota |
191 | | - String jobId = output.split("Job created: ")[1].split("\n")[0]; |
192 | | - CancelDlpJobRequest request = CancelDlpJobRequest.newBuilder().setName(jobId).build(); |
193 | | - try (DlpServiceClient client = DlpServiceClient.create()) { |
194 | | - client.cancelDlpJob(request); |
195 | | - } |
| 173 | + assertThat(output, containsString("Job status: DONE")); |
196 | 174 | } |
197 | 175 |
|
198 | 176 | @Test |
199 | | - public void testInspectBigQueryTable() |
200 | | - throws InterruptedException, ExecutionException, IOException { |
| 177 | + public void testInspectBigQueryTable() throws Exception { |
201 | 178 |
|
202 | | - InspectBigQueryTable.inspectBigQueryTable( |
203 | | - PROJECT_ID, DATASET_ID, TABLE_ID, TOPIC_ID, SUBSCRIPTION_ID); |
204 | | - // Await job creation |
205 | | - TimeUnit.SECONDS.sleep(3); |
| 179 | + InspectBigQueryTable |
| 180 | + .inspectBigQueryTable(PROJECT_ID, DATASET_ID, TABLE_ID, TOPIC_ID, SUBSCRIPTION_ID); |
206 | 181 |
|
207 | 182 | String output = bout.toString(); |
208 | | - assertThat(output, containsString("Job created: ")); |
209 | | - |
210 | | - // Cancelling the job early to conserve quota |
211 | | - String jobId = output.split("Job created: ")[1].split("\n")[0]; |
212 | | - CancelDlpJobRequest request = CancelDlpJobRequest.newBuilder().setName(jobId).build(); |
213 | | - try (DlpServiceClient client = DlpServiceClient.create()) { |
214 | | - client.cancelDlpJob(request); |
215 | | - } |
| 183 | + assertThat(output, containsString("Job status: DONE")); |
216 | 184 | } |
217 | 185 | } |
0 commit comments