Search in sources :

Example 1 with GetModelOptions

use of com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions in project java-sdk by watson-developer-cloud.

the class LanguageTranslatorIT method testGetModel.

/**
 * Test Get model by id.
 */
@Test
public void testGetModel() {
    GetModelOptions getOptions = new GetModelOptions.Builder(ENGLISH_TO_SPANISH).build();
    final TranslationModel model = service.getModel(getOptions).execute();
    assertNotNull(model);
}
Also used : TranslationModel(com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel) GetModelOptions(com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 2 with GetModelOptions

use of com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions in project java-sdk by watson-developer-cloud.

the class LanguageTranslatorTest method testGetModel.

/**
 * Test Get Model.
 *
 * @throws InterruptedException the interrupted exception
 */
@Test
public void testGetModel() throws InterruptedException {
    server.enqueue(jsonResponse(model));
    GetModelOptions getOptions = new GetModelOptions.Builder(model.getModelId()).build();
    final TranslationModel returnedModel = service.getModel(getOptions).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals(GET_MODELS_PATH + "/" + model.getModelId(), request.getPath());
    assertEquals(model, returnedModel);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) TranslationModel(com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel) GetModelOptions(com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 3 with GetModelOptions

use of com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions in project java-sdk by watson-developer-cloud.

the class LanguageTranslatorTest method testGetModelWithNull.

/**
 * Test get model with null.
 */
@Test(expected = IllegalArgumentException.class)
public void testGetModelWithNull() {
    final String modelId = null;
    GetModelOptions getOptions = new GetModelOptions.Builder(modelId).build();
    service.getModel(getOptions).execute();
}
Also used : GetModelOptions(com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 4 with GetModelOptions

use of com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions in project java-sdk by watson-developer-cloud.

the class LanguageTranslator method getModel.

/**
 * Get model details.
 *
 * Gets information about a translation model, including training status for custom models.
 *
 * @param getModelOptions the {@link GetModelOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link TranslationModel}
 */
public ServiceCall<TranslationModel> getModel(GetModelOptions getModelOptions) {
    Validator.notNull(getModelOptions, "getModelOptions cannot be null");
    String[] pathSegments = { "v2/models" };
    String[] pathParameters = { getModelOptions.modelId() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationModel.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) TranslationModel(com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel)

Example 5 with GetModelOptions

use of com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions in project java-sdk by watson-developer-cloud.

the class SpeechToTextIT method testGetModel.

/**
 * Test get model.
 */
@Test
public void testGetModel() {
    GetModelOptions getOptions = new GetModelOptions.Builder().modelId(EN_BROADBAND16K).build();
    SpeechModel model = service.getModel(getOptions).execute();
    assertNotNull(model);
    assertNotNull(model.getName());
    assertNotNull(model.getLanguage());
    assertNotNull(model.getRate());
    assertNotNull(model.getUrl());
    assertNotNull(model.getDescription());
    assertNotNull(model.getSessions());
    assertNotNull(model.getSupportedFeatures().isCustomLanguageModel());
    assertNotNull(model.getSupportedFeatures().isSpeakerLabels());
}
Also used : SpeechModel(com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModel) GetModelOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetModelOptions) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)3 GetModelOptions (com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions)3 TranslationModel (com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel)3 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)2 GetModelOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetModelOptions)2 SpeechModel (com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModel)2 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1 MockResponse (okhttp3.mockwebserver.MockResponse)1