Skip to content

Commit 297d195

Browse files
committed
Add timeout for tests
1 parent 43ba4dd commit 297d195

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

video/beta/src/main/java/com/example/video/Detect.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceClient;
3636
import com.google.cloud.videointelligence.v1p1beta1.WordInfo;
3737
import java.io.IOException;
38+
import java.util.concurrent.TimeUnit;
3839

3940
public class Detect {
4041
/**
@@ -117,7 +118,8 @@ public static void analyzeFacesBoundingBoxes(String gcsUri) throws Exception {
117118
System.out.println("Waiting for operation to complete...");
118119
boolean faceFound = false;
119120
// Display the results
120-
for (VideoAnnotationResults results : response.get().getAnnotationResultsList()) {
121+
for (VideoAnnotationResults results : response.get(900, TimeUnit.SECONDS)
122+
.getAnnotationResultsList()) {
121123
int faceCount = 0;
122124
// Display the results for each face
123125
for (FaceDetectionAnnotation faceAnnotation : results.getFaceDetectionAnnotationsList()) {
@@ -194,7 +196,8 @@ public static void analyzeFaceEmotions(String gcsUri) throws Exception {
194196
System.out.println("Waiting for operation to complete...");
195197
boolean faceFound = false;
196198
// Display the results
197-
for (VideoAnnotationResults results : response.get().getAnnotationResultsList()) {
199+
for (VideoAnnotationResults results : response.get(600, TimeUnit.SECONDS)
200+
.getAnnotationResultsList()) {
198201
int faceCount = 0;
199202
// Display the results for each face
200203
for (FaceDetectionAnnotation faceAnnotation : results.getFaceDetectionAnnotationsList()) {
@@ -271,7 +274,8 @@ public static void speechTranscription(String gcsUri) throws Exception {
271274

272275
System.out.println("Waiting for operation to complete...");
273276
// Display the results
274-
for (VideoAnnotationResults results : response.get().getAnnotationResultsList()) {
277+
for (VideoAnnotationResults results : response.get(180, TimeUnit.SECONDS)
278+
.getAnnotationResultsList()) {
275279
for (SpeechTranscription speechTranscription : results.getSpeechTranscriptionsList()) {
276280
try {
277281
// Print the transcription

0 commit comments

Comments
 (0)