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

test: parametrize GCS Bucket for integration tests #49

Merged
merged 3 commits into from Jan 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -47,6 +47,17 @@
public class ITSystemTest {

private static LanguageServiceClient client;
private static final String GCS_BUCKET;
private static final String GCS_BUCKET_ENV_VAR = "GOOGLE_CLOUD_TESTS_LANGUAGE_BUCKET";

static {
if (System.getenv(GCS_BUCKET_ENV_VAR) != null) {
GCS_BUCKET = System.getenv(GCS_BUCKET_ENV_VAR);
} else {
GCS_BUCKET = "cloud-samples-data";
}
chingor13 marked this conversation as resolved.
Show resolved Hide resolved
}

private static final String ANALYZE_TEXT =
"Android is a mobile operating system developed by Google, based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablets.";

Expand All @@ -64,7 +75,7 @@ public void tearDown() {
public void analyzeEntitiesFileTest() {
Document doc =
Document.newBuilder()
.setGcsContentUri("gs://cloud-samples-data/language/android.txt")
.setGcsContentUri(String.format("gs://%s/language/android.txt", GCS_BUCKET))
.setType(Type.PLAIN_TEXT)
.build();
AnalyzeEntitiesRequest request = AnalyzeEntitiesRequest.newBuilder().setDocument(doc).build();
Expand Down Expand Up @@ -104,7 +115,7 @@ public void analyzeEntitiesTextTest() {
public void analyzeEntitySentimentFileTest() {
Document doc =
Document.newBuilder()
.setGcsContentUri("gs://cloud-samples-data/language/president.txt")
.setGcsContentUri(String.format("gs://%s/language/president.txt", GCS_BUCKET))
.setType(Type.PLAIN_TEXT)
.build();
AnalyzeEntitySentimentRequest request =
Expand Down Expand Up @@ -163,7 +174,7 @@ public void analyzeEntitySentimentTextWithEncodedExpectedResultTest() {
public void analyzeSentimentFileWithReturnPositiveTest() {
Document doc =
Document.newBuilder()
.setGcsContentUri("gs://cloud-samples-data/language/sentiment-positive.txt")
.setGcsContentUri(String.format("gs://%s/language/sentiment-positive.txt", GCS_BUCKET))
.setType(Type.PLAIN_TEXT)
.build();
AnalyzeSentimentResponse response = client.analyzeSentiment(doc);
Expand All @@ -188,7 +199,7 @@ public void analyzeSentimentTextWithReturnPositiveTest() {
public void analyzeSentimentFileWithReturnNegativeTest() {
Document doc =
Document.newBuilder()
.setGcsContentUri("gs://cloud-samples-data/language/sentiment-negative.txt")
.setGcsContentUri(String.format("gs://%s/language/sentiment-negative.txt", GCS_BUCKET))
.setType(Type.PLAIN_TEXT)
.build();
Sentiment sentiment = client.analyzeSentiment(doc).getDocumentSentiment();
Expand All @@ -212,7 +223,7 @@ public void analyzeSentimentTextWithReturnNegativeTest() {
public void analyzeSyntaxFileTest() {
Document doc =
Document.newBuilder()
.setGcsContentUri("gs://cloud-samples-data/language/syntax-sentence.txt")
.setGcsContentUri(String.format("gs://%s/language/syntax-sentence.txt", GCS_BUCKET))
.setType(Type.PLAIN_TEXT)
.build();
AnalyzeSyntaxRequest request =
Expand Down Expand Up @@ -255,7 +266,7 @@ public void analyzeSyntaxTextTest() {
public void classifyFileTest() {
Document doc =
Document.newBuilder()
.setGcsContentUri("gs://cloud-samples-data/language/android.txt")
.setGcsContentUri(String.format("gs://%s/language/android.txt", GCS_BUCKET))
.setType(Type.PLAIN_TEXT)
.build();
ClassifyTextRequest request = ClassifyTextRequest.newBuilder().setDocument(doc).build();
Expand Down