Search in sources :

Example 1 with DeleteCustomPromptOptions

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();
    }
}
Also used : CreateCustomModelOptions(com.ibm.watson.text_to_speech.v1.model.CreateCustomModelOptions) AddCustomPromptOptions(com.ibm.watson.text_to_speech.v1.model.AddCustomPromptOptions) DeleteCustomPromptOptions(com.ibm.watson.text_to_speech.v1.model.DeleteCustomPromptOptions) PromptMetadata(com.ibm.watson.text_to_speech.v1.model.PromptMetadata) Prompt(com.ibm.watson.text_to_speech.v1.model.Prompt) DeleteCustomModelOptions(com.ibm.watson.text_to_speech.v1.model.DeleteCustomModelOptions) File(java.io.File) CustomModel(com.ibm.watson.text_to_speech.v1.model.CustomModel) UnsupportedAudioFileException(javax.sound.sampled.UnsupportedAudioFileException) IOException(java.io.IOException) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Example 2 with DeleteCustomPromptOptions

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);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DeleteCustomPromptOptions(com.ibm.watson.text_to_speech.v1.model.DeleteCustomPromptOptions) Test(org.testng.annotations.Test)

Aggregations

DeleteCustomPromptOptions (com.ibm.watson.text_to_speech.v1.model.DeleteCustomPromptOptions)2 WatsonServiceTest (com.ibm.watson.common.WatsonServiceTest)1 AddCustomPromptOptions (com.ibm.watson.text_to_speech.v1.model.AddCustomPromptOptions)1 CreateCustomModelOptions (com.ibm.watson.text_to_speech.v1.model.CreateCustomModelOptions)1 CustomModel (com.ibm.watson.text_to_speech.v1.model.CustomModel)1 DeleteCustomModelOptions (com.ibm.watson.text_to_speech.v1.model.DeleteCustomModelOptions)1 Prompt (com.ibm.watson.text_to_speech.v1.model.Prompt)1 PromptMetadata (com.ibm.watson.text_to_speech.v1.model.PromptMetadata)1 File (java.io.File)1 IOException (java.io.IOException)1 UnsupportedAudioFileException (javax.sound.sampled.UnsupportedAudioFileException)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 Test (org.junit.Test)1 Test (org.testng.annotations.Test)1