Search in sources :

Example 11 with GetWordOptions

use of com.ibm.watson.text_to_speech.v1.model.GetWordOptions in project java-sdk by watson-developer-cloud.

the class TextToSpeechTest method testGetWordWOptions.

// Test the getWord operation with a valid options model parameter
@Test
public void testGetWordWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "{\"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}";
    String getWordPath = "/v1/customizations/testString/words/testString";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    // Construct an instance of the GetWordOptions model
    GetWordOptions getWordOptionsModel = new GetWordOptions.Builder().customizationId("testString").word("testString").build();
    // Invoke getWord() with a valid options model and verify the result
    Response<Translation> response = textToSpeechService.getWord(getWordOptionsModel).execute();
    assertNotNull(response);
    Translation responseObj = response.getResult();
    assertNotNull(responseObj);
    // Verify the contents of the request sent to the mock server
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "GET");
    // Verify request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, getWordPath);
    // Verify that there is no query string
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNull(query);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) Translation(com.ibm.watson.text_to_speech.v1.model.Translation) GetWordOptions(com.ibm.watson.text_to_speech.v1.model.GetWordOptions) Test(org.testng.annotations.Test)

Aggregations

GetWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetWordOptions)4 Translation (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Translation)4 Word (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word)4 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)4 Test (org.junit.Test)4 AddWordsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordsOptions)3 Translation (com.ibm.watson.text_to_speech.v1.model.Translation)3 MockResponse (okhttp3.mockwebserver.MockResponse)3 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)2 GetWordOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetWordOptions)2 Word (com.ibm.watson.developer_cloud.speech_to_text.v1.model.Word)2 GetWordOptions (com.ibm.watson.speech_to_text.v1.model.GetWordOptions)2 Word (com.ibm.watson.speech_to_text.v1.model.Word)2 GetWordOptions (com.ibm.watson.text_to_speech.v1.model.GetWordOptions)2 File (java.io.File)2 InputStream (java.io.InputStream)2 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1