use of com.ibm.watson.text_to_speech.v1.model.Translation in project java-sdk by watson-developer-cloud.
the class TextToSpeechTest method testListVoicesWOptions.
// Test the listVoices operation with a valid options model parameter
@Test
public void testListVoicesWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"voices\": [{\"url\": \"url\", \"gender\": \"gender\", \"name\": \"name\", \"language\": \"language\", \"description\": \"description\", \"customizable\": true, \"supported_features\": {\"custom_pronunciation\": false, \"voice_transformation\": false}, \"customization\": {\"customization_id\": \"customizationId\", \"name\": \"name\", \"language\": \"language\", \"owner\": \"owner\", \"created\": \"created\", \"last_modified\": \"lastModified\", \"description\": \"description\", \"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}], \"prompts\": [{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\", \"speaker_id\": \"speakerId\"}]}}]}";
String listVoicesPath = "/v1/voices";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ListVoicesOptions model
ListVoicesOptions listVoicesOptionsModel = new ListVoicesOptions();
// Invoke listVoices() with a valid options model and verify the result
Response<Voices> response = textToSpeechService.listVoices(listVoicesOptionsModel).execute();
assertNotNull(response);
Voices 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, listVoicesPath);
// Verify that there is no query string
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
}
use of com.ibm.watson.text_to_speech.v1.model.Translation in project java-sdk by watson-developer-cloud.
the class TextToSpeechTest method testCreateCustomModelWOptions.
// Test the createCustomModel operation with a valid options model parameter
@Test
public void testCreateCustomModelWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"customization_id\": \"customizationId\", \"name\": \"name\", \"language\": \"language\", \"owner\": \"owner\", \"created\": \"created\", \"last_modified\": \"lastModified\", \"description\": \"description\", \"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}], \"prompts\": [{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\", \"speaker_id\": \"speakerId\"}]}";
String createCustomModelPath = "/v1/customizations";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(201).setBody(mockResponseBody));
// Construct an instance of the CreateCustomModelOptions model
CreateCustomModelOptions createCustomModelOptionsModel = new CreateCustomModelOptions.Builder().name("testString").language("en-US").description("testString").build();
// Invoke createCustomModel() with a valid options model and verify the result
Response<CustomModel> response = textToSpeechService.createCustomModel(createCustomModelOptionsModel).execute();
assertNotNull(response);
CustomModel 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(), "POST");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, createCustomModelPath);
// Verify that there is no query string
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
}
use of com.ibm.watson.text_to_speech.v1.model.Translation in project java-sdk by watson-developer-cloud.
the class TextToSpeechTest method testUpdateCustomModelWOptions.
// Test the updateCustomModel operation with a valid options model parameter
@Test
public void testUpdateCustomModelWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "";
String updateCustomModelPath = "/v1/customizations/testString";
server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the Word model
Word wordModel = new Word.Builder().word("testString").translation("testString").partOfSpeech("Dosi").build();
// Construct an instance of the UpdateCustomModelOptions model
UpdateCustomModelOptions updateCustomModelOptionsModel = new UpdateCustomModelOptions.Builder().customizationId("testString").name("testString").description("testString").words(new java.util.ArrayList<Word>(java.util.Arrays.asList(wordModel))).build();
// Invoke updateCustomModel() with a valid options model and verify the result
Response<Void> response = textToSpeechService.updateCustomModel(updateCustomModelOptionsModel).execute();
assertNotNull(response);
Void responseObj = response.getResult();
assertNull(responseObj);
// Verify the contents of the request sent to the mock server
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "POST");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, updateCustomModelPath);
// Verify that there is no query string
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
}
use of com.ibm.watson.text_to_speech.v1.model.Translation 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