use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class CustomizationsIT method testGetWord.
/**
* Test get word.
*/
@Test
public void testGetWord() {
model = createVoiceModel();
final List<Word> expected = instantiateWords();
AddWordsOptions addOptions = new AddWordsOptions.Builder().customizationId(model.getCustomizationId()).words(expected).build();
service.addWords(addOptions).execute();
GetWordOptions getOptions = new GetWordOptions.Builder().customizationId(model.getCustomizationId()).word(expected.get(0).getWord()).build();
final Translation translation = service.getWord(getOptions).execute();
assertEquals(expected.get(0).getTranslation(), translation.getTranslation());
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class CustomizationsIT method testDeleteWord.
/**
* Test delete word with string.
*/
@Test
public void testDeleteWord() {
model = createVoiceModel();
final Word expected = instantiateWords().get(0);
AddWordOptions addOptions = new AddWordOptions.Builder().word(expected.getWord()).translation(expected.getTranslation()).customizationId(model.getCustomizationId()).build();
service.addWord(addOptions).execute();
DeleteWordOptions deleteOptions = new DeleteWordOptions.Builder().customizationId(model.getCustomizationId()).word(expected.getWord()).build();
service.deleteWord(deleteOptions).execute();
ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(model.getCustomizationId()).build();
final Words results = service.listWords(listOptions).execute();
assertEquals(0, results.getWords().size());
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class CustomizationsIT method instantiateWordsJapanese.
private List<Word> instantiateWordsJapanese() {
Word word1 = new Word();
word1.setWord("hodor");
word1.setTranslation("hold the door");
word1.setPartOfSpeech(Word.PartOfSpeech.JOSI);
Word word2 = new Word();
word2.setWord("clodor");
word2.setTranslation("close the door");
word2.setPartOfSpeech(Word.PartOfSpeech.HOKA);
return ImmutableList.of(word1, word2);
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class CustomizationsIT method testAddWord.
/**
* Test add word.
*/
@Test
public void testAddWord() {
model = createVoiceModel();
final Word expected = instantiateWords().get(0);
AddWordOptions addOptions = new AddWordOptions.Builder().word(expected.getWord()).translation(expected.getTranslation()).customizationId(model.getCustomizationId()).build();
service.addWord(addOptions).execute();
ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(model.getCustomizationId()).build();
final Words results = service.listWords(listOptions).execute();
assertEquals(1, results.getWords().size());
final Word result = results.getWords().get(0);
assertEquals(expected, result);
assertEquals(expected.getWord(), result.getWord());
assertEquals(expected.getTranslation(), result.getTranslation());
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class CustomizationsTest method testDeleteWord.
/**
* Test delete word.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testDeleteWord() throws InterruptedException {
final String expected = instantiateWords().get(0).getWord();
server.enqueue(new MockResponse().setResponseCode(204));
DeleteWordOptions deleteOptions = new DeleteWordOptions.Builder().customizationId(CUSTOMIZATION_ID).word(expected).build();
service.deleteWord(deleteOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID) + "/" + expected, request.getPath());
assertEquals("DELETE", request.getMethod());
}
Aggregations