use of com.ibm.watson.speech_to_text.v1.model.Corpora in project java-sdk by watson-developer-cloud.
the class SpeechToTextTest method testGetCorpusWOptions.
// Test the getCorpus operation with a valid options model parameter
@Test
public void testGetCorpusWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"name\": \"name\", \"total_words\": 10, \"out_of_vocabulary_words\": 20, \"status\": \"analyzed\", \"error\": \"error\"}";
String getCorpusPath = "/v1/customizations/testString/corpora/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the GetCorpusOptions model
GetCorpusOptions getCorpusOptionsModel = new GetCorpusOptions.Builder().customizationId("testString").corpusName("testString").build();
// Invoke getCorpus() with a valid options model and verify the result
Response<Corpus> response = speechToTextService.getCorpus(getCorpusOptionsModel).execute();
assertNotNull(response);
Corpus 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, getCorpusPath);
// Verify that there is no query string
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
}
use of com.ibm.watson.speech_to_text.v1.model.Corpora 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);
}
use of com.ibm.watson.speech_to_text.v1.model.Corpora in project java-sdk by watson-developer-cloud.
the class SpeechToTextIT method testListCorpora.
/**
* Test list corpora.
*/
@Test
@Ignore
public void testListCorpora() {
ListCorporaOptions listOptions = new ListCorporaOptions.Builder().customizationId(customizationId).build();
Corpora result = service.listCorpora(listOptions).execute();
assertNotNull(result);
}
use of com.ibm.watson.speech_to_text.v1.model.Corpora in project java-sdk by watson-developer-cloud.
the class SpeechToTextTest method testListCorporaWOptions.
// Test the listCorpora operation with a valid options model parameter
@Test
public void testListCorporaWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"corpora\": [{\"name\": \"name\", \"total_words\": 10, \"out_of_vocabulary_words\": 20, \"status\": \"analyzed\", \"error\": \"error\"}]}";
String listCorporaPath = "/v1/customizations/testString/corpora";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ListCorporaOptions model
ListCorporaOptions listCorporaOptionsModel = new ListCorporaOptions.Builder().customizationId("testString").build();
// Invoke listCorpora() with a valid options model and verify the result
Response<Corpora> response = speechToTextService.listCorpora(listCorporaOptionsModel).execute();
assertNotNull(response);
Corpora 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, listCorporaPath);
// Verify that there is no query string
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
}
use of com.ibm.watson.speech_to_text.v1.model.Corpora in project java-sdk by watson-developer-cloud.
the class SpeechToTextTest method testAddCorpusWOptions.
// Test the addCorpus operation with a valid options model parameter
@Test
public void testAddCorpusWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "";
String addCorpusPath = "/v1/customizations/testString/corpora/testString";
server.enqueue(new MockResponse().setResponseCode(201).setBody(mockResponseBody));
// Construct an instance of the AddCorpusOptions model
AddCorpusOptions addCorpusOptionsModel = new AddCorpusOptions.Builder().customizationId("testString").corpusName("testString").corpusFile(TestUtilities.createMockStream("This is a mock file.")).allowOverwrite(false).build();
// Invoke addCorpus() with a valid options model and verify the result
Response<Void> response = speechToTextService.addCorpus(addCorpusOptionsModel).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, addCorpusPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(Boolean.valueOf(query.get("allow_overwrite")), Boolean.valueOf(false));
}
Aggregations