Search in sources :

Example 1 with DeleteCorpusOptions

use of com.ibm.watson.speech_to_text.v1.model.DeleteCorpusOptions in project java-sdk by watson-developer-cloud.

the class SpeechToTextTest method testDeleteCorpusWOptions.

// Test the deleteCorpus operation with a valid options model parameter
@Test
public void testDeleteCorpusWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "";
    String deleteCorpusPath = "/v1/customizations/testString/corpora/testString";
    server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody));
    // Construct an instance of the DeleteCorpusOptions model
    DeleteCorpusOptions deleteCorpusOptionsModel = new DeleteCorpusOptions.Builder().customizationId("testString").corpusName("testString").build();
    // Invoke deleteCorpus() with a valid options model and verify the result
    Response<Void> response = speechToTextService.deleteCorpus(deleteCorpusOptionsModel).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, deleteCorpusPath);
    // 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) DeleteCorpusOptions(com.ibm.watson.speech_to_text.v1.model.DeleteCorpusOptions) Test(org.testng.annotations.Test)

Example 2 with DeleteCorpusOptions

use of com.ibm.watson.speech_to_text.v1.model.DeleteCorpusOptions in project java-sdk by watson-developer-cloud.

the class SpeechToTextTest method testDeleteCorpus.

/**
 * Test delete corpus.
 *
 * @throws InterruptedException the interrupted exception
 * @throws FileNotFoundException the file not found exception
 */
@Test
public void testDeleteCorpus() throws InterruptedException, FileNotFoundException {
    String id = "foo";
    String corpus = "cName";
    server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}"));
    DeleteCorpusOptions deleteOptions = new DeleteCorpusOptions.Builder().customizationId(id).corpusName(corpus).build();
    service.deleteCorpus(deleteOptions).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals("DELETE", request.getMethod());
    assertEquals(String.format(PATH_CORPUS, id, corpus), request.getPath());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DeleteCorpusOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteCorpusOptions) ByteString(okio.ByteString) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Aggregations

MockResponse (okhttp3.mockwebserver.MockResponse)2 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 DeleteCorpusOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteCorpusOptions)1 DeleteCorpusOptions (com.ibm.watson.speech_to_text.v1.model.DeleteCorpusOptions)1 ByteString (okio.ByteString)1 Test (org.junit.Test)1 Test (org.testng.annotations.Test)1