Search in sources :

Example 1 with RecognitionJobs

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

the class SpeechToText method checkJobs.

/**
 * Checks the status of all asynchronous jobs.
 *
 * Returns the ID and status of the latest 100 outstanding jobs associated with the service credentials with which it
 * is called. The method also returns the creation and update times of each job, and, if a job was created with a
 * callback URL and a user token, the user token for the job. To obtain the results for a job whose status is
 * `completed` or not one of the latest 100 outstanding jobs, use the `GET /v1/recognitions/{id}` method. A job and
 * its results remain available until you delete them with the `DELETE /v1/recognitions/{id}` method or until the
 * job's time to live expires, whichever comes first.
 *
 * @param checkJobsOptions the {@link CheckJobsOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link RecognitionJobs}
 */
public ServiceCall<RecognitionJobs> checkJobs(CheckJobsOptions checkJobsOptions) {
    String[] pathSegments = { "v1/recognitions" };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
    if (checkJobsOptions != null) {
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(RecognitionJobs.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) RecognitionJobs(com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognitionJobs)

Example 2 with RecognitionJobs

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

the class SpeechToTextIT method testCheckJobs.

/**
 * Test check jobs.
 */
@Test
public void testCheckJobs() {
    RecognitionJobs jobs = service.checkJobs().execute();
    assertNotNull(jobs);
}
Also used : RecognitionJobs(com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognitionJobs) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 3 with RecognitionJobs

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

the class SpeechToTextTest method testCheckJobs.

/**
 * Test check jobs.
 *
 * @throws InterruptedException the interrupted exception
 * @throws FileNotFoundException the file not found exception
 */
@Test
public void testCheckJobs() throws InterruptedException, FileNotFoundException {
    String jobsAsString = getStringFromInputStream(new FileInputStream("src/test/resources/speech_to_text/jobs.json"));
    JsonObject jobsAsJson = new JsonParser().parse(jobsAsString).getAsJsonObject();
    server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(jobsAsString));
    RecognitionJobs result = service.checkJobs().execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals("GET", request.getMethod());
    assertEquals(PATH_RECOGNITIONS, request.getPath());
    assertEquals(jobsAsJson.get("recognitions"), GSON.toJsonTree(result.getRecognitions()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) JsonObject(com.google.gson.JsonObject) ByteString(okio.ByteString) RecognitionJobs(com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognitionJobs) FileInputStream(java.io.FileInputStream) JsonParser(com.google.gson.JsonParser) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Aggregations

RecognitionJobs (com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognitionJobs)3 Test (org.junit.Test)2 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)1 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1 FileInputStream (java.io.FileInputStream)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 ByteString (okio.ByteString)1