Skip to content

Commit

Permalink
chore: removed all catch clauses which were causing error stack trace…
Browse files Browse the repository at this point in the history
… not appearing in the test result (#464)
  • Loading branch information
munkhuushmgl authored Apr 29, 2021
1 parent bb52e8a commit bc1427e
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 82 deletions.
7 changes: 7 additions & 0 deletions video/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,12 @@
<version>1.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-core</artifactId>
<version>1.94.0</version>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoConfig;
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient;
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;

public class StreamingAnnotationToStorage {

// Perform streaming video detection for explicit content
static void streamingAnnotationToStorage(String filePath, String gcsUri) {
static void streamingAnnotationToStorage(String filePath, String gcsUri)
throws IOException, TimeoutException, StatusRuntimeException {
// String filePath = "path_to_your_video_file";
// String gcsUri = "gs://BUCKET_ID";

Expand Down Expand Up @@ -89,8 +92,6 @@ static void streamingAnnotationToStorage(String filePath, String gcsUri) {
for (StreamingAnnotateVideoResponse response : call) {
System.out.format("Storage Uri: %s\n", response.getAnnotationResultsUri());
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.concurrent.TimeoutException;

class StreamingAutoMlClassification {

// Perform streaming video classification with an AutoML Model
static void streamingAutoMlClassification(String filePath, String projectId, String modelId)
throws StatusRuntimeException, IOException {
throws TimeoutException, StatusRuntimeException, IOException {
// String filePath = "path_to_your_video_file";
// String projectId = "YOUR_GCP_PROJECT_ID";
// String modelId = "YOUR_AUTO_ML_CLASSIFICATION_MODEL_ID";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoConfig;
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient;
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 StreamingExplicitContentDetection {

// Perform streaming video detection for explicit content
static void streamingExplicitContentDetection(String filePath) {
static void streamingExplicitContentDetection(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 streamingExplicitContentDetection(String filePath) {
System.out.format("\tPornography: %s", frame.getPornographyLikelihood());
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions video/src/main/java/beta/video/StreamingLabelDetection.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoConfig;
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient;
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 StreamingLabelDetection {

// Perform streaming video label detection
static void streamingLabelDetection(String filePath) {
static void streamingLabelDetection(String filePath)
throws IOException, TimeoutException, StatusRuntimeException {
// String filePath = "path_to_your_video_file";

try (StreamingVideoIntelligenceServiceClient client =
Expand Down Expand Up @@ -95,8 +98,6 @@ static void streamingLabelDetection(String filePath) {
System.out.format("%fs: %s (%f)\n", offset, entity, confidence);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions video/src/main/java/beta/video/StreamingObjectTracking.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoConfig;
import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient;
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 StreamingObjectTracking {

// Perform streaming video object tracking
static void streamingObjectTracking(String filePath) {
static void streamingObjectTracking(String filePath)
throws IOException, TimeoutException, StatusRuntimeException {
// String filePath = "path_to_your_video_file";

try (StreamingVideoIntelligenceServiceClient client =
Expand Down Expand Up @@ -104,8 +107,6 @@ static void streamingObjectTracking(String filePath) {
System.out.format("\tBottom: %f\n", frame.getNormalizedBoundingBox().getBottom());
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import com.google.cloud.storage.Storage.BlobListOption;
import com.google.cloud.storage.StorageOptions;
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;
Expand Down Expand Up @@ -58,7 +60,7 @@ public void tearDown() {
}

@Test
public void testStreamingAnnotationToStorage() {
public void testStreamingAnnotationToStorage() throws IOException, TimeoutException {
String gcsUri = String.format("gs://%s/%s", PROJECT_ID, OUTPUT_PREFIX);
StreamingAnnotationToStorage.streamingAnnotationToStorage("resources/cat.mp4", gcsUri);
String got = bout.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import static com.google.common.truth.Truth.assertThat;

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;
Expand Down Expand Up @@ -50,7 +52,7 @@ public void tearDown() {
}

@Test
public void testStreamingExplicitContent() {
public void testStreamingExplicitContent() throws IOException, TimeoutException {
StreamingExplicitContentDetection.streamingExplicitContentDetection("resources/cat.mp4");
String got = bout.toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import static com.google.common.truth.Truth.assertThat;

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;
Expand Down Expand Up @@ -50,7 +52,7 @@ public void tearDown() {
}

@Test
public void testStreamingLabelDetection() {
public void testStreamingLabelDetection() throws IOException, TimeoutException {
StreamingLabelDetection.streamingLabelDetection("resources/cat.mp4");
String got = bout.toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import static com.google.common.truth.Truth.assertThat;

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;
Expand Down Expand Up @@ -50,7 +52,7 @@ public void tearDown() {
}

@Test
public void testStreamingObjectTracking() {
public void testStreamingObjectTracking() throws IOException, TimeoutException {
StreamingObjectTracking.streamingObjectTracking("resources/cat.mp4");
String got = bout.toString();

Expand Down
4 changes: 3 additions & 1 deletion video/src/test/java/video/DetectTextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

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

import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import com.google.cloud.videointelligence.v1.TextAnnotation;
import com.google.cloud.videointelligence.v1.VideoAnnotationResults;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -46,7 +47,8 @@ public class DetectTextTest {
"METRO",
"RUE",
"CARLO");
@Rule public Retry retry = new Retry(3);
@Rule
public MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);
private ByteArrayOutputStream bout;
private PrintStream out;
private PrintStream originalPrintStream;
Expand Down
64 changes: 0 additions & 64 deletions video/src/test/java/video/Retry.java

This file was deleted.

0 comments on commit bc1427e

Please sign in to comment.