Search in sources :

Example 1 with ListClassifiersOptions

use of com.ibm.watson.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.natural_language_classifier.v1.model.ListClassifiersOptions in project java-sdk by watson-developer-cloud.

the class NaturalLanguageClassifierTest method testListClassifiersWOptions.

@Test
public void testListClassifiersWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"classifiers\": [{\"name\": \"name\", \"url\": \"url\", \"status\": \"Non Existent\", \"classifier_id\": \"classifierId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"status_description\": \"statusDescription\", \"language\": \"language\"}]}";
    String listClassifiersPath = "/v1/classifiers";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the ListClassifiersOptions model
    ListClassifiersOptions listClassifiersOptionsModel = new ListClassifiersOptions();
    // Invoke operation with valid options model (positive test)
    Response<ClassifierList> response = naturalLanguageClassifierService.listClassifiers(listClassifiersOptionsModel).execute();
    assertNotNull(response);
    ClassifierList responseObj = response.getResult();
    assertNotNull(responseObj);
    // Verify the contents of the request
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "GET");
    // Check query
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNull(query);
    // Check request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, listClassifiersPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) ClassifierList(com.ibm.watson.natural_language_classifier.v1.model.ClassifierList) ListClassifiersOptions(com.ibm.watson.natural_language_classifier.v1.model.ListClassifiersOptions) Test(org.testng.annotations.Test)

Example 3 with ListClassifiersOptions

use of com.ibm.watson.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();
    final ClassifierList classifiers = service.listClassifiers(listOptions).execute().getResult();
    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.natural_language_classifier.v1.model.ClassifierList) ListClassifiersOptions(com.ibm.watson.natural_language_classifier.v1.model.ListClassifiersOptions) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Example 4 with ListClassifiersOptions

use of com.ibm.watson.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().getResult().getClassifiers();
    for (Classifier classifier : classifiers) {
        if (classifier.isCoreMlEnabled()) {
            GetCoreMlModelOptions getCoreMlModelOptions = new GetCoreMlModelOptions.Builder().classifierId(classifier.getClassifierId()).build();
            InputStream coreMlFile = service.getCoreMlModel(getCoreMlModelOptions).execute().getResult();
            assertNotNull(coreMlFile);
            break;
        }
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ListClassifiersOptions(com.ibm.watson.visual_recognition.v3.model.ListClassifiersOptions) Classifier(com.ibm.watson.visual_recognition.v3.model.Classifier) GetCoreMlModelOptions(com.ibm.watson.visual_recognition.v3.model.GetCoreMlModelOptions) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Example 5 with ListClassifiersOptions

use of com.ibm.watson.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)

Aggregations

Test (org.junit.Test)7 Ignore (org.junit.Ignore)4 WatsonServiceTest (com.ibm.watson.common.WatsonServiceTest)3 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.natural_language_classifier.v1.model.ClassifierList)3 ListClassifiersOptions (com.ibm.watson.visual_recognition.v3.model.ListClassifiersOptions)3 MockResponse (okhttp3.mockwebserver.MockResponse)3 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)3 ListClassifiersOptions (com.ibm.watson.natural_language_classifier.v1.model.ListClassifiersOptions)2 Classifier (com.ibm.watson.visual_recognition.v3.model.Classifier)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 Test (org.testng.annotations.Test)2 Gson (com.google.gson.Gson)1 JsonObject (com.google.gson.JsonObject)1 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 ClassifierList (com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifierList)1