use of com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel 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);
}
use of com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel 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.TranslationModel in project java-sdk by watson-developer-cloud.
the class LanguageTranslatorIT method testCreateAndDeleteModel.
/**
* Test create and delete model.
*/
@Test
public void testCreateAndDeleteModel() throws IOException {
String modelName = "integration-test";
String baseModelId = "en-es";
InputStream glossary = new FileInputStream(new File(RESOURCE + "glossary.tmx"));
CreateModelOptions options = new CreateModelOptions.Builder().name(modelName).baseModelId(baseModelId).forcedGlossary(glossary).forcedGlossaryFilename("test_glossary").build();
TranslationModel model = null;
try {
model = service.createModel(options).execute();
Thread.sleep(3000);
assertNotNull(model);
assertTrue(model.getModelId() != null && model.getModelId().length() > 0);
assertEquals(model.getName(), modelName);
assertEquals(model.getBaseModelId(), baseModelId);
assertEquals(model.isCustomizable(), false);
assertEquals(model.isDefaultModel(), false);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if (model != null) {
DeleteModelOptions deleteOptions = new DeleteModelOptions.Builder(model.getModelId()).build();
service.deleteModel(deleteOptions).execute();
}
}
}
use of com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel in project java-sdk by watson-developer-cloud.
the class LanguageTranslatorIT method testDeleteAllModels.
/**
* Test delete all models.
*/
@Test
@Ignore
public void testDeleteAllModels() {
List<TranslationModel> models = service.listModels(null).execute().getModels();
for (TranslationModel translationModel : models) {
DeleteModelOptions options = new DeleteModelOptions.Builder(translationModel.getModelId()).build();
service.deleteModel(options).execute();
}
}
use of com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel 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);
}
Aggregations