Skip to content

Commit 491e5e7

Browse files
authored
chore: removed try/catch & added exceptions at method signature (#456)
Fixes #446 ☕️
1 parent ed73474 commit 491e5e7

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

video/src/main/java/beta/video/StreamingShotChangeDetection.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,19 @@
2828
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient;
2929
import com.google.cloud.videointelligence.v1p3beta1.VideoSegment;
3030
import com.google.protobuf.ByteString;
31+
import io.grpc.StatusRuntimeException;
3132
import java.io.IOException;
3233
import java.nio.file.Files;
3334
import java.nio.file.Path;
3435
import java.nio.file.Paths;
3536
import java.util.Arrays;
37+
import java.util.concurrent.TimeoutException;
3638

3739
class StreamingShotChangeDetection {
3840

3941
// Perform streaming video detection for shot changes
40-
static void streamingShotChangeDetection(String filePath) {
42+
static void streamingShotChangeDetection(String filePath)
43+
throws IOException, TimeoutException, StatusRuntimeException {
4144
// String filePath = "path_to_your_video_file";
4245

4346
try (StreamingVideoIntelligenceServiceClient client =
@@ -92,8 +95,6 @@ static void streamingShotChangeDetection(String filePath) {
9295
System.out.format("Shot: %fs to %fs\n", startTimeOffset, endTimeOffset);
9396
}
9497
}
95-
} catch (IOException e) {
96-
e.printStackTrace();
9798
}
9899
}
99100
}

video/src/test/java/beta/video/StreamingShotChangeDetectionIT.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,24 @@
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020

21+
import io.grpc.StatusRuntimeException;
2122
import java.io.ByteArrayOutputStream;
23+
import java.io.IOException;
2224
import java.io.PrintStream;
25+
import java.util.concurrent.TimeoutException;
2326
import org.junit.After;
2427
import org.junit.Before;
2528
import org.junit.Test;
2629
import org.junit.runner.RunWith;
2730
import org.junit.runners.JUnit4;
2831

29-
/** Integration (system) tests for {@link StreamingShotChangeDetection}. */
32+
/**
33+
* Integration (system) tests for {@link StreamingShotChangeDetection}.
34+
*/
3035
@RunWith(JUnit4.class)
3136
@SuppressWarnings("checkstyle:abbreviationaswordinname")
3237
public class StreamingShotChangeDetectionIT {
38+
3339
private ByteArrayOutputStream bout;
3440
private PrintStream out;
3541
private PrintStream originalPrintStream;
@@ -50,7 +56,8 @@ public void tearDown() {
5056
}
5157

5258
@Test
53-
public void testStreamingShotChangeDetection() {
59+
public void testStreamingShotChangeDetection()
60+
throws IOException, TimeoutException, StatusRuntimeException {
5461
StreamingShotChangeDetection.streamingShotChangeDetection("resources/cat.mp4");
5562
String got = bout.toString();
5663

0 commit comments

Comments
 (0)