@@ -40,8 +40,9 @@ public class DetectIT {
4040 private ByteArrayOutputStream bout ;
4141 private PrintStream out ;
4242 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" ;
4546
4647 @ Before
4748 public void setUp () throws IOException {
@@ -58,7 +59,7 @@ public void tearDown() {
5859 @ Test
5960 public void testFaces () throws Exception {
6061 // Act
61- String [] args = {"faces" , "./resources/face_no_surprise.jpg" };
62+ String [] args = { "faces" , "./resources/face_no_surprise.jpg" };
6263 Detect .argsHelper (args , out );
6364
6465 // Assert
@@ -71,7 +72,7 @@ public void testFaces() throws Exception {
7172 @ Test
7273 public void testFacesGcs () throws Exception {
7374 // 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" };
7576 Detect .argsHelper (args , out );
7677
7778 // Assert
@@ -84,86 +85,85 @@ public void testFacesGcs() throws Exception {
8485 @ Test
8586 public void testLabels () throws Exception {
8687 // Act
87- String [] args = {"labels" , "./resources/wakeupcat.jpg" };
88+ String [] args = { "labels" , "./resources/wakeupcat.jpg" };
8889 Detect .argsHelper (args , out );
8990
9091 // Assert
91- String got = bout .toString ();
92+ String got = bout .toString (). toLowerCase () ;
9293 assertThat (got ).contains ("whiskers" );
9394 }
9495
9596 @ Test
9697 public void testLabelsGcs () throws Exception {
9798 // Act
98- String [] args = {"labels" , "gs://" + BUCKET + "/vision/wakeupcat.jpg" };
99+ String [] args = { "labels" , "gs://" + ASSET_BUCKET + "/vision/label/ wakeupcat.jpg" };
99100 Detect .argsHelper (args , out );
100101
101102 // Assert
102- String got = bout .toString ();
103+ String got = bout .toString (). toLowerCase () ;
103104 assertThat (got ).contains ("whiskers" );
104105 }
105106
106107 @ Test
107108 public void testLandmarks () throws Exception {
108109 // Act
109- String [] args = {"landmarks" , "./resources/landmark.jpg" };
110+ String [] args = { "landmarks" , "./resources/landmark.jpg" };
110111 Detect .argsHelper (args , out );
111112
112113 // 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 " );
115116 }
116117
117118 @ Test
118119 public void testLandmarksGcs () throws Exception {
119120 // Act
120- String [] args = {"landmarks" , "gs://" + BUCKET + "/vision/landmark.jpg" };
121+ String [] args = { "landmarks" , "gs://" + ASSET_BUCKET + "/vision/landmark/pofa .jpg" };
121122 Detect .argsHelper (args , out );
122123
123124 // 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 " );
126127 }
127128
128129 @ Test
129130 public void testLandmarksUrl () throws Exception {
130131 // 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 };
134134 Detect .argsHelper (args , out );
135135
136136 // 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 " );
139139 }
140140
141141 @ Test
142142 public void testLogos () throws Exception {
143143 // Act
144- String [] args = {"logos" , "./resources/logos.png" };
144+ String [] args = { "logos" , "./resources/logos.png" };
145145 Detect .argsHelper (args , out );
146146
147147 // Assert
148- String got = bout .toString ();
149- assertThat (got ).contains ("Google " );
148+ String got = bout .toString (). toLowerCase () ;
149+ assertThat (got ).contains ("google " );
150150 }
151151
152152 @ Test
153153 public void testLogosGcs () throws Exception {
154154 // Act
155- String [] args = {"logos" , "gs://" + BUCKET + "/vision/logos .png" };
155+ String [] args = { "logos" , "gs://" + ASSET_BUCKET + "/vision/logo/logo_google .png" };
156156 Detect .argsHelper (args , out );
157157
158158 // Assert
159- String got = bout .toString ();
160- assertThat (got ).contains ("Google " );
159+ String got = bout .toString (). toLowerCase () ;
160+ assertThat (got ).contains ("google " );
161161 }
162162
163163 @ Test
164164 public void testText () throws Exception {
165165 // Act
166- String [] args = {"text" , "./resources/text.jpg" };
166+ String [] args = { "text" , "./resources/text.jpg" };
167167 Detect .argsHelper (args , out );
168168
169169 // Assert
@@ -174,7 +174,7 @@ public void testText() throws Exception {
174174 @ Test
175175 public void testTextGcs () throws Exception {
176176 // Act
177- String [] args = {"text" , "gs://" + BUCKET + "/vision/text.jpg" };
177+ String [] args = { "text" , "gs://" + ASSET_BUCKET + "/vision/text/screen .jpg" };
178178 Detect .argsHelper (args , out );
179179
180180 // Assert
@@ -185,7 +185,7 @@ public void testTextGcs() throws Exception {
185185 @ Test
186186 public void testSafeSearch () throws Exception {
187187 // Act
188- String [] args = {"safe-search" , "./resources/wakeupcat.jpg" };
188+ String [] args = { "safe-search" , "./resources/wakeupcat.jpg" };
189189 Detect .argsHelper (args , out );
190190
191191 // Assert
@@ -197,7 +197,7 @@ public void testSafeSearch() throws Exception {
197197 @ Test
198198 public void testSafeSearchGcs () throws Exception {
199199 // Act
200- String [] args = {"safe-search" , "gs://" + BUCKET + "/vision/wakeupcat.jpg" };
200+ String [] args = { "safe-search" , "gs://" + ASSET_BUCKET + "/vision/label/ wakeupcat.jpg" };
201201 Detect .argsHelper (args , out );
202202
203203 // Assert
@@ -209,7 +209,7 @@ public void testSafeSearchGcs() throws Exception {
209209 @ Test
210210 public void testProperties () throws Exception {
211211 // Act
212- String [] args = {"properties" , "./resources/landmark.jpg" };
212+ String [] args = { "properties" , "./resources/landmark.jpg" };
213213 Detect .argsHelper (args , out );
214214
215215 // Assert
@@ -223,7 +223,7 @@ public void testProperties() throws Exception {
223223 @ Test
224224 public void testPropertiesGcs () throws Exception {
225225 // Act
226- String [] args = {"properties" , "gs://" + BUCKET + "/vision/landmark.jpg" };
226+ String [] args = { "properties" , "gs://" + ASSET_BUCKET + "/vision/landmark/pofa .jpg" };
227227 Detect .argsHelper (args , out );
228228
229229 // Assert
@@ -237,74 +237,75 @@ public void testPropertiesGcs() throws Exception {
237237 @ Test
238238 public void detectWebAnnotations () throws Exception {
239239 // Act
240- String [] args = {"web" , "./resources/landmark.jpg" };
240+ String [] args = { "web" , "./resources/landmark.jpg" };
241241 Detect .argsHelper (args , out );
242242
243243 // 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" );
247247 }
248248
249249 @ Test
250250 public void detectWebAnnotationsGcs () throws Exception {
251251 // Act
252- String [] args = {"web" , "gs://" + BUCKET + "/vision/landmark.jpg" };
252+ String [] args = { "web" , "gs://" + ASSET_BUCKET + "/vision/landmark/pofa .jpg" };
253253 Detect .argsHelper (args , out );
254254
255255 // 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" );
259259 }
260260
261261 @ Test
262262 public void testDetectWebEntities () throws Exception {
263263 // Act
264- String [] args = {"web-entities" , "./resources/city.jpg" };
264+ String [] args = { "web-entities" , "./resources/city.jpg" };
265265 Detect .argsHelper (args , out );
266266
267267 // Assert
268- String got = bout .toString ();
269- assertThat (got ).doesNotContain ("Zepra " );
268+ String got = bout .toString (). toLowerCase () ;
269+ assertThat (got ).doesNotContain ("zepra " );
270270 }
271271
272272 @ Test
273273 public void testDetectWebEntitiesGcs () throws Exception {
274274 // Act
275- String [] args = {"web-entities" , "gs://" + BUCKET + "/vision/landmark.jpg" };
275+ String [] args = { "web-entities" , "gs://" + ASSET_BUCKET + "/vision/landmark/pofa .jpg" };
276276 Detect .argsHelper (args , out );
277277
278- String got = bout .toString ();
279- assertThat (got ).contains ("Description " );
278+ String got = bout .toString (). toLowerCase () ;
279+ assertThat (got ).contains ("description " );
280280 }
281281
282282 @ Test
283283 public void testDetectWebEntitiesIncludeGeoResults () throws Exception {
284284 // Act
285- String [] args = {"web-entities-include-geo" , "./resources/city.jpg" };
285+ String [] args = { "web-entities-include-geo" , "./resources/city.jpg" };
286286 Detect .argsHelper (args , out );
287287
288288 // Assert
289- String got = bout .toString ();
289+ String got = bout .toString (). toLowerCase () ;
290290 // Note: entities and labels can change over time.
291- assertThat (got ).doesNotContain ("Error " );
291+ assertThat (got ).doesNotContain ("error " );
292292 }
293293
294294 @ Test
295295 public void testDetectWebEntitiesIncludeGeoResultsGcs () throws Exception {
296296 // 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" };
298299 Detect .argsHelper (args , out );
299300
300- String got = bout .toString ();
301- assertThat (got ).contains ("Description " );
301+ String got = bout .toString (). toLowerCase () ;
302+ assertThat (got ).contains ("description " );
302303 }
303304
304305 @ Test
305306 public void testCropHints () throws Exception {
306307 // Act
307- String [] args = {"crop" , "./resources/wakeupcat.jpg" };
308+ String [] args = { "crop" , "./resources/wakeupcat.jpg" };
308309 Detect .argsHelper (args , out );
309310
310311 // Assert
@@ -317,7 +318,7 @@ public void testCropHints() throws Exception {
317318 @ Test
318319 public void testCropHintsGcs () throws Exception {
319320 // Act
320- String [] args = {"crop" , "gs://" + BUCKET + "/vision/wakeupcat.jpg" };
321+ String [] args = { "crop" , "gs://" + ASSET_BUCKET + "/vision/label/ wakeupcat.jpg" };
321322 Detect .argsHelper (args , out );
322323
323324 // Assert
@@ -330,7 +331,7 @@ public void testCropHintsGcs() throws Exception {
330331 @ Test
331332 public void testDocumentText () throws Exception {
332333 // Act
333- String [] args = {"fulltext" , "./resources/text.jpg" };
334+ String [] args = { "fulltext" , "./resources/text.jpg" };
334335 Detect .argsHelper (args , out );
335336
336337 // Assert
@@ -343,7 +344,7 @@ public void testDocumentText() throws Exception {
343344 @ Test
344345 public void testDocumentTextGcs () throws Exception {
345346 // Act
346- String [] args = {"fulltext" , "gs://" + BUCKET + "/vision/text.jpg" };
347+ String [] args = { "fulltext" , "gs://" + ASSET_BUCKET + "/vision/text/screen .jpg" };
347348 Detect .argsHelper (args , out );
348349
349350 // Assert
@@ -356,17 +357,17 @@ public void testDocumentTextGcs() throws Exception {
356357 @ Test
357358 public void testDetectDocumentsGcs () throws Exception {
358359 // 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 + "/" };
361362 Detect .argsHelper (args , out );
362363
363364 // Assert
364365 String got = bout .toString ();
365- assertThat (got ).contains ("HODGE'S GENERAL CONJECTURE " );
366+ assertThat (got ).contains ("OIL, GAS AND MINERAL LEASE " );
366367
367368 Storage storage = StorageOptions .getDefaultInstance ().getService ();
368369
369- Page <Blob > blobs = storage .list (BUCKET , BlobListOption .currentDirectory (),
370+ Page <Blob > blobs = storage .list (OUTPUT_BUCKET , BlobListOption .currentDirectory (),
370371 BlobListOption .prefix (OUTPUT_PREFIX + "/" ));
371372
372373 for (Blob blob : blobs .iterateAll ()) {
@@ -377,22 +378,23 @@ public void testDetectDocumentsGcs() throws Exception {
377378 @ Test
378379 public void testDetectLocalizedObjects () throws Exception {
379380 // Act
380- String [] args = {"object-localization" , "./resources/puppies.jpg" };
381+ String [] args = { "object-localization" , "./resources/puppies.jpg" };
381382 Detect .argsHelper (args , out );
382383
383384 // Assert
384- String got = bout .toString ();
385- assertThat (got ).contains ("Dog " );
385+ String got = bout .toString (). toLowerCase () ;
386+ assertThat (got ).contains ("dog " );
386387 }
387388
388389 @ Test
389390 public void testDetectLocalizedObjectsGcs () throws Exception {
390391 // 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" };
392394 Detect .argsHelper (args , out );
393395
394396 // Assert
395- String got = bout .toString ();
396- assertThat (got ).contains ("Dog " );
397+ String got = bout .toString (). toLowerCase () ;
398+ assertThat (got ).contains ("dog " );
397399 }
398- }
400+ }
0 commit comments