use of com.ibm.watson.text_to_speech.v1.model.DeleteCustomPromptOptions in project java-sdk by watson-developer-cloud.
the class TextToSpeechIT method testDeleteCustomPrompts.
/**
* Test deleteCustomPrompts.
*/
@Test
public void testDeleteCustomPrompts() {
try {
CreateCustomModelOptions createCustomModelOptions = new CreateCustomModelOptions.Builder().description("testdescription").name("testname").language(CreateCustomModelOptions.Language.EN_US).build();
CustomModel customModel = service.createCustomModel(createCustomModelOptions).execute().getResult();
customizationId = customModel.getCustomizationId();
PromptMetadata promptMetadata = new PromptMetadata.Builder().promptText("promptText").build();
File file = new File(RESOURCE + "numbers.wav");
AddCustomPromptOptions addCustomPromptOptions = new AddCustomPromptOptions.Builder().customizationId(customizationId).promptId("testId").metadata(promptMetadata).file(file).build();
Prompt prompt = service.addCustomPrompt(addCustomPromptOptions).execute().getResult();
assertNotNull(prompt.getStatus());
DeleteCustomPromptOptions deleteCustomPromptOptions = new DeleteCustomPromptOptions.Builder().customizationId(customizationId).promptId(prompt.getPromptId()).build();
service.deleteCustomPrompt(deleteCustomPromptOptions).execute().getResult();
} catch (Exception e) {
e.printStackTrace();
} finally {
DeleteCustomModelOptions deleteCustomModelOptions = new DeleteCustomModelOptions.Builder().customizationId(customizationId).build();
service.deleteCustomModel(deleteCustomModelOptions).execute().getResult();
}
}
use of com.ibm.watson.text_to_speech.v1.model.DeleteCustomPromptOptions in project java-sdk by watson-developer-cloud.
the class TextToSpeechTest method testDeleteCustomPromptWOptions.
// Test the deleteCustomPrompt operation with a valid options model parameter
@Test
public void testDeleteCustomPromptWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "";
String deleteCustomPromptPath = "/v1/customizations/testString/prompts/testString";
server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody));
// Construct an instance of the DeleteCustomPromptOptions model
DeleteCustomPromptOptions deleteCustomPromptOptionsModel = new DeleteCustomPromptOptions.Builder().customizationId("testString").promptId("testString").build();
// Invoke deleteCustomPrompt() with a valid options model and verify the result
Response<Void> response = textToSpeechService.deleteCustomPrompt(deleteCustomPromptOptionsModel).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(), "DELETE");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, deleteCustomPromptPath);
// Verify that there is no query string
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
}
Aggregations