@@ -40,8 +40,9 @@ public class DetectIT {
40
40
private ByteArrayOutputStream bout ;
41
41
private PrintStream out ;
42
42
private static final String PROJECT_ID = System .getenv ("GOOGLE_CLOUD_PROJECT" );
43
- private static final String BUCKET = PROJECT_ID ;
44
- private static final String OUTPUT_PREFIX = "OCR_PDF_TEST_OUTPUT" ;
43
+ private static final String ASSET_BUCKET = "cloud-samples-data" ;
44
+ private static final String OUTPUT_BUCKET = PROJECT_ID ;
45
+ private static final String OUTPUT_PREFIX = "OCR_PDF_TEST_OUTPUT" ;
45
46
46
47
@ Before
47
48
public void setUp () throws IOException {
@@ -58,7 +59,7 @@ public void tearDown() {
58
59
@ Test
59
60
public void testFaces () throws Exception {
60
61
// Act
61
- String [] args = {"faces" , "./resources/face_no_surprise.jpg" };
62
+ String [] args = { "faces" , "./resources/face_no_surprise.jpg" };
62
63
Detect .argsHelper (args , out );
63
64
64
65
// Assert
@@ -71,7 +72,7 @@ public void testFaces() throws Exception {
71
72
@ Test
72
73
public void testFacesGcs () throws Exception {
73
74
// Act
74
- String [] args = {"faces" , "gs://" + BUCKET + "/vision/face_no_surprise.jpg" };
75
+ String [] args = { "faces" , "gs://" + ASSET_BUCKET + "/vision/face/ face_no_surprise.jpg" };
75
76
Detect .argsHelper (args , out );
76
77
77
78
// Assert
@@ -84,86 +85,85 @@ public void testFacesGcs() throws Exception {
84
85
@ Test
85
86
public void testLabels () throws Exception {
86
87
// Act
87
- String [] args = {"labels" , "./resources/wakeupcat.jpg" };
88
+ String [] args = { "labels" , "./resources/wakeupcat.jpg" };
88
89
Detect .argsHelper (args , out );
89
90
90
91
// Assert
91
- String got = bout .toString ();
92
+ String got = bout .toString (). toLowerCase () ;
92
93
assertThat (got ).contains ("whiskers" );
93
94
}
94
95
95
96
@ Test
96
97
public void testLabelsGcs () throws Exception {
97
98
// Act
98
- String [] args = {"labels" , "gs://" + BUCKET + "/vision/wakeupcat.jpg" };
99
+ String [] args = { "labels" , "gs://" + ASSET_BUCKET + "/vision/label/ wakeupcat.jpg" };
99
100
Detect .argsHelper (args , out );
100
101
101
102
// Assert
102
- String got = bout .toString ();
103
+ String got = bout .toString (). toLowerCase () ;
103
104
assertThat (got ).contains ("whiskers" );
104
105
}
105
106
106
107
@ Test
107
108
public void testLandmarks () throws Exception {
108
109
// Act
109
- String [] args = {"landmarks" , "./resources/landmark.jpg" };
110
+ String [] args = { "landmarks" , "./resources/landmark.jpg" };
110
111
Detect .argsHelper (args , out );
111
112
112
113
// Assert
113
- String got = bout .toString ();
114
- assertThat (got ).contains ("Palace of Fine Arts " );
114
+ String got = bout .toString (). toLowerCase () ;
115
+ assertThat (got ).contains ("palace of fine arts " );
115
116
}
116
117
117
118
@ Test
118
119
public void testLandmarksGcs () throws Exception {
119
120
// Act
120
- String [] args = {"landmarks" , "gs://" + BUCKET + "/vision/landmark.jpg" };
121
+ String [] args = { "landmarks" , "gs://" + ASSET_BUCKET + "/vision/landmark/pofa .jpg" };
121
122
Detect .argsHelper (args , out );
122
123
123
124
// Assert
124
- String got = bout .toString ();
125
- assertThat (got ).contains ("Palace of Fine Arts " );
125
+ String got = bout .toString (). toLowerCase () ;
126
+ assertThat (got ).contains ("palace of fine arts " );
126
127
}
127
128
128
129
@ Test
129
130
public void testLandmarksUrl () throws Exception {
130
131
// Act
131
- String uri = "https://storage-download.googleapis.com/"
132
- + BUCKET + "/vision/landmark.jpg" ;
133
- String [] args = {"landmarks" , uri };
132
+ String uri = "https://storage-download.googleapis.com/" + ASSET_BUCKET + "/vision/landmark/pofa.jpg" ;
133
+ String [] args = { "landmarks" , uri };
134
134
Detect .argsHelper (args , out );
135
135
136
136
// Assert
137
- String got = bout .toString ();
138
- assertThat (got ).contains ("Palace of Fine Arts " );
137
+ String got = bout .toString (). toLowerCase () ;
138
+ assertThat (got ).contains ("palace of fine arts " );
139
139
}
140
140
141
141
@ Test
142
142
public void testLogos () throws Exception {
143
143
// Act
144
- String [] args = {"logos" , "./resources/logos.png" };
144
+ String [] args = { "logos" , "./resources/logos.png" };
145
145
Detect .argsHelper (args , out );
146
146
147
147
// Assert
148
- String got = bout .toString ();
149
- assertThat (got ).contains ("Google " );
148
+ String got = bout .toString (). toLowerCase () ;
149
+ assertThat (got ).contains ("google " );
150
150
}
151
151
152
152
@ Test
153
153
public void testLogosGcs () throws Exception {
154
154
// Act
155
- String [] args = {"logos" , "gs://" + BUCKET + "/vision/logos .png" };
155
+ String [] args = { "logos" , "gs://" + ASSET_BUCKET + "/vision/logo/logo_google .png" };
156
156
Detect .argsHelper (args , out );
157
157
158
158
// Assert
159
- String got = bout .toString ();
160
- assertThat (got ).contains ("Google " );
159
+ String got = bout .toString (). toLowerCase () ;
160
+ assertThat (got ).contains ("google " );
161
161
}
162
162
163
163
@ Test
164
164
public void testText () throws Exception {
165
165
// Act
166
- String [] args = {"text" , "./resources/text.jpg" };
166
+ String [] args = { "text" , "./resources/text.jpg" };
167
167
Detect .argsHelper (args , out );
168
168
169
169
// Assert
@@ -174,7 +174,7 @@ public void testText() throws Exception {
174
174
@ Test
175
175
public void testTextGcs () throws Exception {
176
176
// Act
177
- String [] args = {"text" , "gs://" + BUCKET + "/vision/text.jpg" };
177
+ String [] args = { "text" , "gs://" + ASSET_BUCKET + "/vision/text/screen .jpg" };
178
178
Detect .argsHelper (args , out );
179
179
180
180
// Assert
@@ -185,7 +185,7 @@ public void testTextGcs() throws Exception {
185
185
@ Test
186
186
public void testSafeSearch () throws Exception {
187
187
// Act
188
- String [] args = {"safe-search" , "./resources/wakeupcat.jpg" };
188
+ String [] args = { "safe-search" , "./resources/wakeupcat.jpg" };
189
189
Detect .argsHelper (args , out );
190
190
191
191
// Assert
@@ -197,7 +197,7 @@ public void testSafeSearch() throws Exception {
197
197
@ Test
198
198
public void testSafeSearchGcs () throws Exception {
199
199
// Act
200
- String [] args = {"safe-search" , "gs://" + BUCKET + "/vision/wakeupcat.jpg" };
200
+ String [] args = { "safe-search" , "gs://" + ASSET_BUCKET + "/vision/label/ wakeupcat.jpg" };
201
201
Detect .argsHelper (args , out );
202
202
203
203
// Assert
@@ -209,7 +209,7 @@ public void testSafeSearchGcs() throws Exception {
209
209
@ Test
210
210
public void testProperties () throws Exception {
211
211
// Act
212
- String [] args = {"properties" , "./resources/landmark.jpg" };
212
+ String [] args = { "properties" , "./resources/landmark.jpg" };
213
213
Detect .argsHelper (args , out );
214
214
215
215
// Assert
@@ -223,7 +223,7 @@ public void testProperties() throws Exception {
223
223
@ Test
224
224
public void testPropertiesGcs () throws Exception {
225
225
// Act
226
- String [] args = {"properties" , "gs://" + BUCKET + "/vision/landmark.jpg" };
226
+ String [] args = { "properties" , "gs://" + ASSET_BUCKET + "/vision/landmark/pofa .jpg" };
227
227
Detect .argsHelper (args , out );
228
228
229
229
// Assert
@@ -237,74 +237,75 @@ public void testPropertiesGcs() throws Exception {
237
237
@ Test
238
238
public void detectWebAnnotations () throws Exception {
239
239
// Act
240
- String [] args = {"web" , "./resources/landmark.jpg" };
240
+ String [] args = { "web" , "./resources/landmark.jpg" };
241
241
Detect .argsHelper (args , out );
242
242
243
243
// Assert
244
- String got = bout .toString ();
245
- assertThat (got ).contains ("History " );
246
- assertThat (got ).contains ("Best guess label: palace of fine arts" );
244
+ String got = bout .toString (). toLowerCase () ;
245
+ assertThat (got ).contains ("history " );
246
+ assertThat (got ).contains ("best guess label: palace of fine arts" );
247
247
}
248
248
249
249
@ Test
250
250
public void detectWebAnnotationsGcs () throws Exception {
251
251
// Act
252
- String [] args = {"web" , "gs://" + BUCKET + "/vision/landmark.jpg" };
252
+ String [] args = { "web" , "gs://" + ASSET_BUCKET + "/vision/landmark/pofa .jpg" };
253
253
Detect .argsHelper (args , out );
254
254
255
255
// Assert
256
- String got = bout .toString ();
257
- assertThat (got ).contains ("History " );
258
- assertThat (got ).contains ("Best guess label: palace of fine arts" );
256
+ String got = bout .toString (). toLowerCase () ;
257
+ assertThat (got ).contains ("history " );
258
+ assertThat (got ).contains ("best guess label: palace of fine arts" );
259
259
}
260
260
261
261
@ Test
262
262
public void testDetectWebEntities () throws Exception {
263
263
// Act
264
- String [] args = {"web-entities" , "./resources/city.jpg" };
264
+ String [] args = { "web-entities" , "./resources/city.jpg" };
265
265
Detect .argsHelper (args , out );
266
266
267
267
// Assert
268
- String got = bout .toString ();
269
- assertThat (got ).doesNotContain ("Zepra " );
268
+ String got = bout .toString (). toLowerCase () ;
269
+ assertThat (got ).doesNotContain ("zepra " );
270
270
}
271
271
272
272
@ Test
273
273
public void testDetectWebEntitiesGcs () throws Exception {
274
274
// Act
275
- String [] args = {"web-entities" , "gs://" + BUCKET + "/vision/landmark.jpg" };
275
+ String [] args = { "web-entities" , "gs://" + ASSET_BUCKET + "/vision/landmark/pofa .jpg" };
276
276
Detect .argsHelper (args , out );
277
277
278
- String got = bout .toString ();
279
- assertThat (got ).contains ("Description " );
278
+ String got = bout .toString (). toLowerCase () ;
279
+ assertThat (got ).contains ("description " );
280
280
}
281
281
282
282
@ Test
283
283
public void testDetectWebEntitiesIncludeGeoResults () throws Exception {
284
284
// Act
285
- String [] args = {"web-entities-include-geo" , "./resources/city.jpg" };
285
+ String [] args = { "web-entities-include-geo" , "./resources/city.jpg" };
286
286
Detect .argsHelper (args , out );
287
287
288
288
// Assert
289
- String got = bout .toString ();
289
+ String got = bout .toString (). toLowerCase () ;
290
290
// Note: entities and labels can change over time.
291
- assertThat (got ).doesNotContain ("Error " );
291
+ assertThat (got ).doesNotContain ("error " );
292
292
}
293
293
294
294
@ Test
295
295
public void testDetectWebEntitiesIncludeGeoResultsGcs () throws Exception {
296
296
// Act
297
- String [] args = {"web-entities-include-geo" , "gs://" + BUCKET + "/vision/landmark.jpg" };
297
+ String [] args = { "web-entities-include-geo" ,
298
+ "gs://" + ASSET_BUCKET + "/vision/landmark/pofa.jpg" };
298
299
Detect .argsHelper (args , out );
299
300
300
- String got = bout .toString ();
301
- assertThat (got ).contains ("Description " );
301
+ String got = bout .toString (). toLowerCase () ;
302
+ assertThat (got ).contains ("description " );
302
303
}
303
304
304
305
@ Test
305
306
public void testCropHints () throws Exception {
306
307
// Act
307
- String [] args = {"crop" , "./resources/wakeupcat.jpg" };
308
+ String [] args = { "crop" , "./resources/wakeupcat.jpg" };
308
309
Detect .argsHelper (args , out );
309
310
310
311
// Assert
@@ -317,7 +318,7 @@ public void testCropHints() throws Exception {
317
318
@ Test
318
319
public void testCropHintsGcs () throws Exception {
319
320
// Act
320
- String [] args = {"crop" , "gs://" + BUCKET + "/vision/wakeupcat.jpg" };
321
+ String [] args = { "crop" , "gs://" + ASSET_BUCKET + "/vision/label/ wakeupcat.jpg" };
321
322
Detect .argsHelper (args , out );
322
323
323
324
// Assert
@@ -330,7 +331,7 @@ public void testCropHintsGcs() throws Exception {
330
331
@ Test
331
332
public void testDocumentText () throws Exception {
332
333
// Act
333
- String [] args = {"fulltext" , "./resources/text.jpg" };
334
+ String [] args = { "fulltext" , "./resources/text.jpg" };
334
335
Detect .argsHelper (args , out );
335
336
336
337
// Assert
@@ -343,7 +344,7 @@ public void testDocumentText() throws Exception {
343
344
@ Test
344
345
public void testDocumentTextGcs () throws Exception {
345
346
// Act
346
- String [] args = {"fulltext" , "gs://" + BUCKET + "/vision/text.jpg" };
347
+ String [] args = { "fulltext" , "gs://" + ASSET_BUCKET + "/vision/text/screen .jpg" };
347
348
Detect .argsHelper (args , out );
348
349
349
350
// Assert
@@ -356,17 +357,17 @@ public void testDocumentTextGcs() throws Exception {
356
357
@ Test
357
358
public void testDetectDocumentsGcs () throws Exception {
358
359
// Act
359
- String [] args = {"ocr" , "gs://" + BUCKET + "/vision/HodgeConj .pdf" ,
360
- "gs://" + BUCKET + "/" + OUTPUT_PREFIX + "/" };
360
+ String [] args = { "ocr" , "gs://" + ASSET_BUCKET + "/vision/document/custom_0773375000 .pdf" ,
361
+ "gs://" + OUTPUT_BUCKET + "/" + OUTPUT_PREFIX + "/" };
361
362
Detect .argsHelper (args , out );
362
363
363
364
// Assert
364
365
String got = bout .toString ();
365
- assertThat (got ).contains ("HODGE'S GENERAL CONJECTURE " );
366
+ assertThat (got ).contains ("OIL, GAS AND MINERAL LEASE " );
366
367
367
368
Storage storage = StorageOptions .getDefaultInstance ().getService ();
368
369
369
- Page <Blob > blobs = storage .list (BUCKET , BlobListOption .currentDirectory (),
370
+ Page <Blob > blobs = storage .list (OUTPUT_BUCKET , BlobListOption .currentDirectory (),
370
371
BlobListOption .prefix (OUTPUT_PREFIX + "/" ));
371
372
372
373
for (Blob blob : blobs .iterateAll ()) {
@@ -377,22 +378,23 @@ public void testDetectDocumentsGcs() throws Exception {
377
378
@ Test
378
379
public void testDetectLocalizedObjects () throws Exception {
379
380
// Act
380
- String [] args = {"object-localization" , "./resources/puppies.jpg" };
381
+ String [] args = { "object-localization" , "./resources/puppies.jpg" };
381
382
Detect .argsHelper (args , out );
382
383
383
384
// Assert
384
- String got = bout .toString ();
385
- assertThat (got ).contains ("Dog " );
385
+ String got = bout .toString (). toLowerCase () ;
386
+ assertThat (got ).contains ("dog " );
386
387
}
387
388
388
389
@ Test
389
390
public void testDetectLocalizedObjectsGcs () throws Exception {
390
391
// Act
391
- String [] args = {"object-localization" , "gs://cloud-samples-data/vision/puppies.jpg" };
392
+ String [] args = { "object-localization" ,
393
+ "gs://cloud-samples-data/vision/object_localization/puppies.jpg" };
392
394
Detect .argsHelper (args , out );
393
395
394
396
// Assert
395
- String got = bout .toString ();
396
- assertThat (got ).contains ("Dog " );
397
+ String got = bout .toString (). toLowerCase () ;
398
+ assertThat (got ).contains ("dog " );
397
399
}
398
- }
400
+ }
0 commit comments