VisualRecognition extends BaseService { public ServiceCall<ImageDetailsList> addImages(AddImagesOptions addImagesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( addImagesOptions, "addImagesOptions cannot be null"); com.ibm.cloud.sdk.core.util.Validator.isTrue( (addImagesOptions.imagesFile() != null) || (addImagesOptions.imageUrl() != null) || (addImagesOptions.trainingData() != null), "At least one of imagesFile, imageUrl, or trainingData must be supplied."); String[] pathSegments = {"v4/collections", "images"}; String[] pathParameters = {addImagesOptions.collectionId()}; RequestBuilder builder = RequestBuilder.post( RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); builder.query("version", versionDate); Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "addImages"); for (Entry<String, String> header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); if (addImagesOptions.imagesFile() != null) { for (FileWithMetadata item : addImagesOptions.imagesFile()) { okhttp3.RequestBody itemBody = RequestUtils.inputStreamBody(item.data(), item.contentType()); multipartBuilder.addFormDataPart("images_file", item.filename(), itemBody); } } if (addImagesOptions.imageUrl() != null) { for (String item : addImagesOptions.imageUrl()) { multipartBuilder.addFormDataPart("image_url", item); } } if (addImagesOptions.trainingData() != null) { multipartBuilder.addFormDataPart("training_data", addImagesOptions.trainingData()); } builder.body(multipartBuilder.build()); ResponseConverter<ImageDetailsList> responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken<ImageDetailsList>() {}.getType()); return createServiceCall(builder.build(), responseConverter); } VisualRecognition(String versionDate);  VisualRecognition(String versionDate, Authenticator authenticator);  VisualRecognition(String versionDate, String serviceName);  VisualRecognition(String versionDate, String serviceName, Authenticator authenticator); ServiceCall<AnalyzeResponse> analyze(AnalyzeOptions analyzeOptions); ServiceCall<Collection> createCollection(CreateCollectionOptions createCollectionOptions); ServiceCall<Collection> createCollection(); ServiceCall<CollectionsList> listCollections(
      ListCollectionsOptions listCollectionsOptions); ServiceCall<CollectionsList> listCollections(); ServiceCall<Collection> getCollection(GetCollectionOptions getCollectionOptions); ServiceCall<Collection> updateCollection(UpdateCollectionOptions updateCollectionOptions); ServiceCall<Void> deleteCollection(DeleteCollectionOptions deleteCollectionOptions); ServiceCall<InputStream> getModelFile(GetModelFileOptions getModelFileOptions); ServiceCall<ImageDetailsList> addImages(AddImagesOptions addImagesOptions); ServiceCall<ImageSummaryList> listImages(ListImagesOptions listImagesOptions); ServiceCall<ImageDetails> getImageDetails(GetImageDetailsOptions getImageDetailsOptions); ServiceCall<Void> deleteImage(DeleteImageOptions deleteImageOptions); ServiceCall<InputStream> getJpegImage(GetJpegImageOptions getJpegImageOptions); ServiceCall<ObjectMetadataList> listObjectMetadata(
      ListObjectMetadataOptions listObjectMetadataOptions); ServiceCall<UpdateObjectMetadata> updateObjectMetadata(
      UpdateObjectMetadataOptions updateObjectMetadataOptions); ServiceCall<ObjectMetadata> getObjectMetadata(
      GetObjectMetadataOptions getObjectMetadataOptions); ServiceCall<Void> deleteObject(DeleteObjectOptions deleteObjectOptions); ServiceCall<Collection> train(TrainOptions trainOptions); ServiceCall<TrainingDataObjects> addImageTrainingData(
      AddImageTrainingDataOptions addImageTrainingDataOptions); ServiceCall<TrainingEvents> getTrainingUsage(
      GetTrainingUsageOptions getTrainingUsageOptions); ServiceCall<TrainingEvents> getTrainingUsage(); ServiceCall<Void> deleteUserData(DeleteUserDataOptions deleteUserDataOptions);  }
@Test public void testAddImages() { server.enqueue(jsonResponse(imageDetailsList)); AddImagesOptions options = new AddImagesOptions.Builder() .addImagesFile(fileWithMetadata) .addImageUrl(IMAGE_URL) .collectionId(COLLECTION_ID) .trainingData(TRAINING_DATA) .build(); ImageDetailsList response = service.addImages(options).execute().getResult(); assertImageDetails(response.getImages().get(0)); assertEquals(CODE, response.getWarnings().get(0).getCode()); assertEquals(MESSAGE, response.getWarnings().get(0).getMessage()); assertEquals(MORE_INFO, response.getWarnings().get(0).getMoreInfo()); assertEquals(TRACE, response.getTrace()); }