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);
}
Aggregations