Skip to content

Commit

Permalink
chore: removed try/catch & added exceptions at method signature (#456)
Browse files Browse the repository at this point in the history

Fixes #446  ☕️
  • Loading branch information
munkhuushmgl authored Apr 12, 2021
1 parent ed73474 commit 491e5e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient;
import com.google.cloud.videointelligence.v1p3beta1.VideoSegment;
import com.google.protobuf.ByteString;
import io.grpc.StatusRuntimeException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.concurrent.TimeoutException;

class StreamingShotChangeDetection {

// Perform streaming video detection for shot changes
static void streamingShotChangeDetection(String filePath) {
static void streamingShotChangeDetection(String filePath)
throws IOException, TimeoutException, StatusRuntimeException {
// String filePath = "path_to_your_video_file";

try (StreamingVideoIntelligenceServiceClient client =
Expand Down Expand Up @@ -92,8 +95,6 @@ static void streamingShotChangeDetection(String filePath) {
System.out.format("Shot: %fs to %fs\n", startTimeOffset, endTimeOffset);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@

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

import io.grpc.StatusRuntimeException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.concurrent.TimeoutException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Integration (system) tests for {@link StreamingShotChangeDetection}. */
/**
* Integration (system) tests for {@link StreamingShotChangeDetection}.
*/
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
public class StreamingShotChangeDetectionIT {

private ByteArrayOutputStream bout;
private PrintStream out;
private PrintStream originalPrintStream;
Expand All @@ -50,7 +56,8 @@ public void tearDown() {
}

@Test
public void testStreamingShotChangeDetection() {
public void testStreamingShotChangeDetection()
throws IOException, TimeoutException, StatusRuntimeException {
StreamingShotChangeDetection.streamingShotChangeDetection("resources/cat.mp4");
String got = bout.toString();

Expand Down

0 comments on commit 491e5e7

Please sign in to comment.