use of com.ibm.watson.developer_cloud.language_translator.v2.model.ListModelsOptions in project java-sdk by watson-developer-cloud.
the class LanguageTranslatorIT method testListModelsWithOptions.
/**
* Test List Models with Options.
*/
@Test
public void testListModelsWithOptions() {
ListModelsOptions options = new ListModelsOptions.Builder().source("en").target("es").defaultModels(false).build();
final List<TranslationModel> models = service.listModels(options).execute().getModels();
assertNotNull(models);
assertFalse(models.isEmpty());
assertEquals(models.get(0).getSource(), options.source());
assertEquals(models.get(0).getTarget(), options.target());
}
use of com.ibm.watson.developer_cloud.language_translator.v2.model.ListModelsOptions in project java-sdk by watson-developer-cloud.
the class LanguageTranslator method listModels.
/**
* List models.
*
* Lists available translation models.
*
* @param listModelsOptions the {@link ListModelsOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link TranslationModels}
*/
public ServiceCall<TranslationModels> listModels(ListModelsOptions listModelsOptions) {
String[] pathSegments = { "v2/models" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
if (listModelsOptions != null) {
if (listModelsOptions.source() != null) {
builder.query("source", listModelsOptions.source());
}
if (listModelsOptions.target() != null) {
builder.query("target", listModelsOptions.target());
}
if (listModelsOptions.defaultModels() != null) {
builder.query("default", String.valueOf(listModelsOptions.defaultModels()));
}
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationModels.class));
}
use of com.ibm.watson.developer_cloud.language_translator.v2.model.ListModelsOptions in project java-sdk by watson-developer-cloud.
the class LanguageTranslatorTest method testListModels.
/**
* Test Get Models.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testListModels() throws InterruptedException {
server.enqueue(jsonResponse(models));
ListModelsOptions options = new ListModelsOptions.Builder().build();
final List<TranslationModel> modelList = service.listModels(options).execute().getModels();
final RecordedRequest request = server.takeRequest();
assertEquals(GET_MODELS_PATH, request.getPath());
assertEquals(GSON.toJson(models.getModels()), GSON.toJson(modelList));
}
Aggregations