Search in sources :

Example 6 with GetModelOptions

use of com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions in project java-sdk by watson-developer-cloud.

the class SpeechToTextTest method testGetModel.

/**
 * Test get model.
 *
 * @throws Exception the exception
 */
@Test
public void testGetModel() throws Exception {
    final MockResponse mockResponse = new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(speechModel));
    server.enqueue(mockResponse);
    GetModelOptions getOptionsString = new GetModelOptions.Builder().modelId("not-a-real-Model").build();
    SpeechModel model = service.getModel(getOptionsString).execute();
    RecordedRequest request = server.takeRequest();
    assertNotNull(model);
    assertEquals(model, speechModel);
    assertEquals(GET, request.getMethod());
    server.enqueue(mockResponse);
    GetModelOptions getOptionsGetter = new GetModelOptions.Builder().modelId("not-a-real-Model").build();
    model = service.getModel(getOptionsGetter).execute();
    request = server.takeRequest();
    assertNotNull(model);
    assertEquals(model, speechModel);
    assertEquals(GET, request.getMethod());
    TestUtils.assertNoExceptionsOnGetters(model);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) SpeechModel(com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModel) GetModelOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetModelOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)3 GetModelOptions (com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions)3 TranslationModel (com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel)3 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)2 GetModelOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetModelOptions)2 SpeechModel (com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModel)2 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1 MockResponse (okhttp3.mockwebserver.MockResponse)1