3636
3737import java .io .File ;
3838import java .io .FileNotFoundException ;
39+ import java .io .IOException ;
3940import java .io .InputStream ;
4041import java .util .Arrays ;
42+ import java .util .Collections ;
4143import java .util .HashSet ;
4244import java .util .List ;
4345import java .util .Set ;
@@ -57,11 +59,10 @@ public class VisualRecognitionIT extends WatsonServiceTest {
5759 private static final String VERSION = "2019-02-11" ;
5860 private static final String RESOURCE = "src/test/resources/visual_recognition/v4/" ;
5961
60- private static final String GIRAFFE_COLLECTION_ID = "d31d6534-3458-40c4-b6de-2185a5f3cbe4 " ;
62+ private static final String COLLECTION_ID = "684777e5-1f2d-40e3-987f-72d36557ef46 " ;
6163 private static final String GIRAFFE_CLASSNAME = "giraffe" ;
6264 private static final String SINGLE_GIRAFFE_IMAGE_PATH = RESOURCE + "giraffe_to_classify.jpg" ;
6365 private static final String GIRAFFE_POSITIVE_EXAMPLES_PATH = RESOURCE + "giraffe_positive_examples.zip" ;
64- private static final String TURTLE_COLLECTION_ID = "760c8625-a456-4b73-b71d-d1619a6daf84" ;
6566 private static final String SINGLE_TURTLE_IMAGE_PATH = RESOURCE + "turtle_to_classify.jpg" ;
6667 private static final String DOG_IMAGE_URL = "https://upload.wikimedia"
6768 + ".org/wikipedia/commons/thumb/4/47/American_Eskimo_Dog.jpg/1280px-American_Eskimo_Dog.jpg" ;
@@ -120,7 +121,7 @@ public void testAnalyzeWithFiles() throws FileNotFoundException {
120121 .contentType ("image/jpeg" )
121122 .build ();
122123 List <FileWithMetadata > filesToAnalyze = Arrays .asList (giraffeImage , turtleImage );
123- List <String > collectionIds = Arrays . asList ( GIRAFFE_COLLECTION_ID , TURTLE_COLLECTION_ID );
124+ List <String > collectionIds = Collections . singletonList ( COLLECTION_ID );
124125
125126 AnalyzeOptions options = new AnalyzeOptions .Builder ()
126127 .imagesFile (filesToAnalyze )
@@ -138,7 +139,7 @@ public void testAnalyzeWithFiles() throws FileNotFoundException {
138139 public void testAnalyzeWithUrl () throws FileNotFoundException {
139140 AnalyzeOptions options = new AnalyzeOptions .Builder ()
140141 .addImageUrl (DOG_IMAGE_URL )
141- .addCollectionIds (GIRAFFE_COLLECTION_ID )
142+ .addCollectionIds (COLLECTION_ID )
142143 .addFeatures (AnalyzeOptions .Features .OBJECTS )
143144 .build ();
144145 AnalyzeResponse response = service .analyze (options ).execute ().getResult ();
@@ -206,7 +207,7 @@ public void testCollectionOperations() {
206207 }
207208
208209 @ Test
209- public void testImageOperations () throws FileNotFoundException {
210+ public void testImageOperations () throws IOException {
210211 // create new collection so we don't run into duplicate image issues
211212 String testCollectionId = createTestCollection ();
212213
@@ -253,6 +254,7 @@ public void testImageOperations() throws FileNotFoundException {
253254 InputStream imageStream = service .getJpegImage (getJpegImageOptions ).execute ().getResult ();
254255
255256 assertNotNull (imageStream );
257+ imageStream .close ();
256258 } finally {
257259 // delete images
258260 for (String imageId : addedImageIds ) {
0 commit comments