NaturalLanguageClassifier extends BaseService { public ServiceCall<Classification> classify(ClassifyOptions classifyOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( classifyOptions, "classifyOptions cannot be null"); String[] pathSegments = {"v1/classifiers", "classify"}; String[] pathParameters = {classifyOptions.classifierId()}; RequestBuilder builder = RequestBuilder.post( RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "classify"); for (Entry<String, String> header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); contentJson.addProperty("text", classifyOptions.text()); builder.bodyJson(contentJson); ResponseConverter<Classification> responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken<Classification>() {}.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 = IllegalArgumentException.class) public void testNullClassifier() { ClassifyOptions classifyOptions = new ClassifyOptions.Builder().text("test").build(); service.classify(classifyOptions); }
@Test(expected = IllegalArgumentException.class) public void testNullText() { ClassifyOptions classifyOptions = new ClassifyOptions.Builder().classifierId(classifierId).build(); service.classify(classifyOptions); }
@Test public void testClassify() throws InterruptedException { final JsonObject contentJson = new JsonObject(); contentJson.addProperty(TEXT, classification.getText()); final String path = String.format(CLASSIFY_PATH, classifierId); server.enqueue(jsonResponse(classification)); ClassifyOptions classifyOptions = new ClassifyOptions.Builder() .classifierId(classifierId) .text(classification.getText()) .build(); final Classification result = service.classify(classifyOptions).execute().getResult(); final RecordedRequest request = server.takeRequest(); assertEquals(path, request.getPath()); assertEquals("POST", request.getMethod()); assertEquals(contentJson.toString(), request.getBody().readUtf8()); assertEquals(classification, result); }