Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

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 committed Apr 12, 2021
1 parent 230a208 commit fd87f06
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
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
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 fd87f06

Please sign in to comment.