Search in sources :

Example 1 with DeleteModelOptions

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

the class NaturalLanguageUnderstandingTest method testDeleteModel.

/**
 * Test delete model.
 *
 * @throws InterruptedException the interrupted exception
 */
@Test
public void testDeleteModel() throws InterruptedException {
    server.enqueue(jsonResponse(null));
    DeleteModelOptions deleteOptions = new DeleteModelOptions.Builder(modelId).build();
    final Void response = service.deleteModel(deleteOptions).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals(DELETE_PATH, request.getPath());
    assertEquals("DELETE", request.getMethod());
    assertEquals(null, response);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) DeleteModelOptions(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.DeleteModelOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 2 with DeleteModelOptions

use of com.ibm.watson.developer_cloud.language_translator.v2.model.DeleteModelOptions 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();
        }
    }
}
Also used : TranslationModel(com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) DeleteModelOptions(com.ibm.watson.developer_cloud.language_translator.v2.model.DeleteModelOptions) CreateModelOptions(com.ibm.watson.developer_cloud.language_translator.v2.model.CreateModelOptions) File(java.io.File) FileInputStream(java.io.FileInputStream) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 3 with DeleteModelOptions

use of com.ibm.watson.developer_cloud.language_translator.v2.model.DeleteModelOptions 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();
    }
}
Also used : TranslationModel(com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel) DeleteModelOptions(com.ibm.watson.developer_cloud.language_translator.v2.model.DeleteModelOptions) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)2 DeleteModelOptions (com.ibm.watson.developer_cloud.language_translator.v2.model.DeleteModelOptions)2 TranslationModel (com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 CreateModelOptions (com.ibm.watson.developer_cloud.language_translator.v2.model.CreateModelOptions)1 DeleteModelOptions (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.DeleteModelOptions)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 Ignore (org.junit.Ignore)1