Skip to content

Commit e898767

Browse files
Jerjou Chengchingor13
Jerjou Cheng
authored andcommitted
samples: Infer project from env
1 parent 10bc194 commit e898767

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

vision/snippets/src/test/java/com/example/vision/DetectIT.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public class DetectIT {
3535
private ByteArrayOutputStream bout;
3636
private PrintStream out;
3737
private Detect app;
38+
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
39+
private static final String BUCKET = PROJECT_ID;
3840

3941
@Before
4042
public void setUp() throws IOException {
@@ -65,7 +67,7 @@ public void testFaces() throws Exception {
6567
@Test
6668
public void testFacesGcs() throws Exception {
6769
// Act
68-
String[] args = {"faces", "gs://cloud-samples-tests/vision/face_no_surprise.jpg"};
70+
String[] args = {"faces", "gs://" + BUCKET + "/vision/face_no_surprise.jpg"};
6971
Detect.argsHelper(args, out);
7072

7173
// Assert
@@ -89,7 +91,7 @@ public void testLabels() throws Exception {
8991
@Test
9092
public void testLabelsGcs() throws Exception {
9193
// Act
92-
String[] args = {"labels", "gs://cloud-samples-tests/vision/wakeupcat.jpg"};
94+
String[] args = {"labels", "gs://" + BUCKET + "/vision/wakeupcat.jpg"};
9395
Detect.argsHelper(args, out);
9496

9597
// Assert
@@ -111,7 +113,7 @@ public void testLandmarks() throws Exception {
111113
@Test
112114
public void testLandmarksGcs() throws Exception {
113115
// Act
114-
String[] args = {"landmarks", "gs://cloud-samples-tests/vision/landmark.jpg"};
116+
String[] args = {"landmarks", "gs://" + BUCKET + "/vision/landmark.jpg"};
115117
Detect.argsHelper(args, out);
116118

117119
// Assert
@@ -144,7 +146,7 @@ public void testLogos() throws Exception {
144146
@Test
145147
public void testLogosGcs() throws Exception {
146148
// Act
147-
String[] args = {"logos", "gs://cloud-samples-tests/vision/logos.png"};
149+
String[] args = {"logos", "gs://" + BUCKET + "/vision/logos.png"};
148150
Detect.argsHelper(args, out);
149151

150152
// Assert
@@ -166,7 +168,7 @@ public void testText() throws Exception {
166168
@Test
167169
public void testTextGcs() throws Exception {
168170
// Act
169-
String[] args = {"text", "gs://cloud-samples-tests/vision/text.jpg"};
171+
String[] args = {"text", "gs://" + BUCKET + "/vision/text.jpg"};
170172
Detect.argsHelper(args, out);
171173

172174
// Assert
@@ -188,7 +190,7 @@ public void testSafeSearch() throws Exception {
188190
@Test
189191
public void testSafeSearchGcs() throws Exception {
190192
// Act
191-
String[] args = {"safe-search", "gs://cloud-samples-tests/vision/wakeupcat.jpg"};
193+
String[] args = {"safe-search", "gs://" + BUCKET + "/vision/wakeupcat.jpg"};
192194
Detect.argsHelper(args, out);
193195

194196
// Assert
@@ -213,7 +215,7 @@ public void testProperties() throws Exception {
213215
@Test
214216
public void testPropertiesGcs() throws Exception {
215217
// Act
216-
String[] args = {"properties", "gs://cloud-samples-tests/vision/landmark.jpg"};
218+
String[] args = {"properties", "gs://" + BUCKET + "/vision/landmark.jpg"};
217219
Detect.argsHelper(args, out);
218220

219221
// Assert
@@ -239,7 +241,7 @@ public void detectWebAnnotations() throws Exception {
239241
@Test
240242
public void detectWebAnnotationsGcs() throws Exception {
241243
// Act
242-
String[] args = {"web", "gs://cloud-samples-tests/vision/landmark.jpg"};
244+
String[] args = {"web", "gs://" + BUCKET + "/vision/landmark.jpg"};
243245
Detect.argsHelper(args, out);
244246

245247
// Assert
@@ -264,7 +266,7 @@ public void testCropHints() throws Exception {
264266
@Test
265267
public void testCropHintsGcs() throws Exception {
266268
// Act
267-
String[] args = {"crop", "gs://cloud-samples-tests/vision/wakeupcat.jpg"};
269+
String[] args = {"crop", "gs://" + BUCKET + "/vision/wakeupcat.jpg"};
268270
Detect.argsHelper(args, out);
269271

270272
// Assert
@@ -289,7 +291,7 @@ public void testDocumentText() throws Exception {
289291
@Test
290292
public void testDocumentTextGcs() throws Exception {
291293
// Act
292-
String[] args = {"fulltext", "gs://cloud-samples-tests/vision/text.jpg"};
294+
String[] args = {"fulltext", "gs://" + BUCKET + "/vision/text.jpg"};
293295
Detect.argsHelper(args, out);
294296

295297
// Assert

0 commit comments

Comments
 (0)