NaturalLanguageClassifier extends BaseService { public ServiceCall<Classifier> createClassifier(CreateClassifierOptions createClassifierOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createClassifierOptions, "createClassifierOptions cannot be null"); String[] pathSegments = {"v1/classifiers"}; RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "createClassifier"); 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); okhttp3.RequestBody trainingMetadataBody = RequestUtils.inputStreamBody( createClassifierOptions.trainingMetadata(), "application/json"); multipartBuilder.addFormDataPart("training_metadata", "filename", trainingMetadataBody); okhttp3.RequestBody trainingDataBody = RequestUtils.inputStreamBody(createClassifierOptions.trainingData(), "text/csv"); multipartBuilder.addFormDataPart("training_data", "filename", trainingDataBody); builder.body(multipartBuilder.build()); ResponseConverter<Classifier> responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken<Classifier>() {}.getType()); return createServiceCall(builder.build(), responseConverter); } NaturalLanguageClassifier();  NaturalLanguageClassifier(Authenticator authenticator);  NaturalLanguageClassifier(String serviceName);  NaturalLanguageClassifier(String serviceName, Authenticator authenticator); ServiceCall<Classification> classify(ClassifyOptions classifyOptions); ServiceCall<ClassificationCollection> classifyCollection(
      ClassifyCollectionOptions classifyCollectionOptions); ServiceCall<Classifier> createClassifier(CreateClassifierOptions createClassifierOptions); ServiceCall<ClassifierList> listClassifiers(
      ListClassifiersOptions listClassifiersOptions); ServiceCall<ClassifierList> listClassifiers(); ServiceCall<Classifier> getClassifier(GetClassifierOptions getClassifierOptions); ServiceCall<Void> deleteClassifier(DeleteClassifierOptions deleteClassifierOptions);  }
@Test(expected = FileNotFoundException.class) public void testNullTrainingDataFile() throws FileNotFoundException { server.enqueue(jsonResponse(classifier)); File metadata = new File(RESOURCE + "metadata.json"); File trainingData = new File(RESOURCE + "notfound.txt"); CreateClassifierOptions createOptions = new CreateClassifierOptions.Builder() .trainingMetadata(metadata) .trainingData(trainingData) .build(); service.createClassifier(createOptions).execute(); }
@Test public void testCreateClassifier() throws InterruptedException, FileNotFoundException { server.enqueue(jsonResponse(classifier)); File metadata = new File(RESOURCE + "metadata.json"); File trainingData = new File(RESOURCE + "weather_data_train.csv"); CreateClassifierOptions createOptions = new CreateClassifierOptions.Builder() .trainingMetadata(metadata) .trainingData(trainingData) .build(); final Classifier response = service.createClassifier(createOptions).execute().getResult(); final RecordedRequest request = server.takeRequest(); assertEquals(CLASSIFIERS_PATH, request.getPath()); assertEquals(classifier, response); }