Search in sources :

Example 11 with GetClassifierOptions

use of com.ibm.watson.visual_recognition.v3.model.GetClassifierOptions in project java-sdk by watson-developer-cloud.

the class VisualRecognitionTest method testGetClassifierWOptions.

@Test
public void testGetClassifierWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"classifier_id\": \"classifierId\", \"name\": \"name\", \"owner\": \"owner\", \"status\": \"ready\", \"core_ml_enabled\": false, \"explanation\": \"explanation\", \"created\": \"2019-01-01T12:00:00.000Z\", \"classes\": [{\"class\": \"xClass\"}], \"retrained\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}";
    String getClassifierPath = "/v3/classifiers/testString";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the GetClassifierOptions model
    GetClassifierOptions getClassifierOptionsModel = new GetClassifierOptions.Builder().classifierId("testString").build();
    // Invoke operation with valid options model (positive test)
    Response<Classifier> response = visualRecognitionService.getClassifier(getClassifierOptionsModel).execute();
    assertNotNull(response);
    Classifier 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);
    assertNotNull(query);
    // Get query params
    assertEquals(query.get("version"), "testString");
    // Check request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, getClassifierPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) GetClassifierOptions(com.ibm.watson.visual_recognition.v3.model.GetClassifierOptions) Classifier(com.ibm.watson.visual_recognition.v3.model.Classifier) Test(org.testng.annotations.Test)

Aggregations

Test (org.junit.Test)8 Classifier (com.ibm.watson.visual_recognition.v3.model.Classifier)4 File (java.io.File)4 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)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 GetClassifierOptions (com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetClassifierOptions)3 GetClassifierOptions (com.ibm.watson.visual_recognition.v3.model.GetClassifierOptions)3 MockResponse (okhttp3.mockwebserver.MockResponse)3 Ignore (org.junit.Ignore)3 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)2 Classifier (com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classifier)2 GetClassifierOptions (com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.GetClassifierOptions)2 CreateClassifierOptions (com.ibm.watson.developer_cloud.visual_recognition.v3.model.CreateClassifierOptions)2 DeleteClassifierOptions (com.ibm.watson.developer_cloud.visual_recognition.v3.model.DeleteClassifierOptions)2 Classifier (com.ibm.watson.natural_language_classifier.v1.model.Classifier)2 GetClassifierOptions (com.ibm.watson.natural_language_classifier.v1.model.GetClassifierOptions)2 CreateClassifierOptions (com.ibm.watson.visual_recognition.v3.model.CreateClassifierOptions)2 DeleteClassifierOptions (com.ibm.watson.visual_recognition.v3.model.DeleteClassifierOptions)2