Search in sources :

Example 1 with ListClassifiersOptions

use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ListClassifiersOptions in project java-sdk by watson-developer-cloud.

the class NaturalLanguageClassifierIT method cListClassifiers.

/**
 * Test list classifiers.
 */
@Test
public void cListClassifiers() {
    ListClassifiersOptions listOptions = new ListClassifiersOptions.Builder().build();
    final ClassifierList classifiers = service.listClassifiers(listOptions).execute();
    assertNotNull(classifiers);
    // #324: Classifiers may be empty, because of other tests interfering.
    // The build should not fail here, because this is out of our control.
    Assume.assumeFalse(classifiers.getClassifiers().isEmpty());
}
Also used : ClassifierList(com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifierList) ListClassifiersOptions(com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ListClassifiersOptions) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 2 with ListClassifiersOptions

use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ListClassifiersOptions in project java-sdk by watson-developer-cloud.

the class NaturalLanguageClassifier method listClassifiers.

/**
 * List classifiers.
 *
 * Returns an empty array if no classifiers are available.
 *
 * @param listClassifiersOptions the {@link ListClassifiersOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link ClassifierList}
 */
public ServiceCall<ClassifierList> listClassifiers(ListClassifiersOptions listClassifiersOptions) {
    String[] pathSegments = { "v1/classifiers" };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
    if (listClassifiersOptions != null) {
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ClassifierList.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) ClassifierList(com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifierList)

Example 3 with ListClassifiersOptions

use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ListClassifiersOptions in project java-sdk by watson-developer-cloud.

the class VisualRecognitionIT method testGetCoreMlModel.

/**
 * Test getting the Core ML file for a classifier.
 */
@Ignore
@Test
public void testGetCoreMlModel() {
    ListClassifiersOptions options = new ListClassifiersOptions.Builder().verbose(true).build();
    List<Classifier> classifiers = service.listClassifiers(options).execute().getClassifiers();
    for (Classifier classifier : classifiers) {
        if (classifier.isCoreMlEnabled()) {
            GetCoreMlModelOptions getCoreMlModelOptions = new GetCoreMlModelOptions.Builder().classifierId(classifier.getClassifierId()).build();
            InputStream coreMlFile = service.getCoreMlModel(getCoreMlModelOptions).execute();
            assertNotNull(coreMlFile);
            break;
        }
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ListClassifiersOptions(com.ibm.watson.developer_cloud.visual_recognition.v3.model.ListClassifiersOptions) Classifier(com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier) GetCoreMlModelOptions(com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetCoreMlModelOptions) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 4 with ListClassifiersOptions

use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ListClassifiersOptions in project java-sdk by watson-developer-cloud.

the class VisualRecognitionIT method testListClassifiers.

/**
 * Test list all the classifiers.
 */
@Ignore
@Test
public void testListClassifiers() {
    ListClassifiersOptions options = new ListClassifiersOptions.Builder().verbose(true).build();
    List<Classifier> classifiers = service.listClassifiers(options).execute().getClassifiers();
    assertNotNull(classifiers);
    assertTrue(!classifiers.isEmpty());
    Classifier classifier = classifiers.get(0);
    assertNotNull(classifier.getClassifierId());
    assertNotNull(classifier.getName());
    assertNotNull(classifier.getOwner());
    assertNotNull(classifier.getStatus());
    assertNotNull(classifier.getClasses());
    assertNotNull(classifier.getCreated());
}
Also used : ListClassifiersOptions(com.ibm.watson.developer_cloud.visual_recognition.v3.model.ListClassifiersOptions) Classifier(com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 5 with ListClassifiersOptions

use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ListClassifiersOptions in project java-sdk by watson-developer-cloud.

the class VisualRecognitionTest method testGetClassifiers.

/**
 * Test get classifiers.
 *
 * @throws InterruptedException the interrupted exception
 * @throws IOException Signals that an I/O exception has occurred.
 */
@Test
public void testGetClassifiers() throws InterruptedException, IOException {
    Classifier mockClassifier = loadFixture(FIXTURE_CLASSIFIER, Classifier.class);
    List<Classifier> classifiers = new ArrayList<Classifier>();
    classifiers.add(mockClassifier);
    classifiers.add(mockClassifier);
    classifiers.add(mockClassifier);
    JsonObject mockResponse = new JsonObject();
    mockResponse.add("classifiers", new Gson().toJsonTree(classifiers));
    server.enqueue(new MockResponse().setBody(mockResponse.toString()));
    ListClassifiersOptions options = new ListClassifiersOptions.Builder().verbose(true).build();
    List<Classifier> serviceResponse = service.listClassifiers(options).execute().getClassifiers();
    // first request
    RecordedRequest request = server.takeRequest();
    String path = PATH_CLASSIFIERS + "?" + VERSION_DATE + "=2016-05-20&verbose=true&api_key=" + API_KEY;
    assertEquals(path, request.getPath());
    assertEquals("GET", request.getMethod());
    assertEquals(serviceResponse, classifiers);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) ListClassifiersOptions(com.ibm.watson.developer_cloud.visual_recognition.v3.model.ListClassifiersOptions) Classifier(com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)3 Classifier (com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier)3 ListClassifiersOptions (com.ibm.watson.developer_cloud.visual_recognition.v3.model.ListClassifiersOptions)3 ClassifierList (com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifierList)2 Ignore (org.junit.Ignore)2 Gson (com.google.gson.Gson)1 JsonObject (com.google.gson.JsonObject)1 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1 ListClassifiersOptions (com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ListClassifiersOptions)1 GetCoreMlModelOptions (com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetCoreMlModelOptions)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1